finding the next 1 in the list when counting through the list …

Mar 11, 2011 at 12:04pm

finding the next 1 in the list when counting through the list …

Hi,

Here’s challenge that seems to bug me:

I have a sequencer that counts through the numbers in a list:

1 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0

then I would like to know how many positions there are to the next number one,
if the counter for example is at 2 (this would be 4 positions from 2 etc.)

Is there a nifty way of making this happen in max?

Kaspar

#55462
Mar 11, 2011 at 12:29pm

I have some of the idea working, however, it is a very complicated way of doing it, and I would like to ask, if there is an easier way?

– Pasted Max Patch, click to expand. –
#199576
Mar 11, 2011 at 1:26pm

and now the problem is solved in the below patch, however:

it is incredible how many max objects it took :-(
- hmm, I still need a more nifty way of doing it …

– Pasted Max Patch, click to expand. –
#199577
Mar 11, 2011 at 6:55pm

I’m sure there is a nifty way… maybe zl lookup and zl stream to gather groups of 0′s?

The patch below is kind of useless, didn’t get it very far, but maybe an idea or two in there.

– Pasted Max Patch, click to expand. –
#199578
Mar 11, 2011 at 7:51pm

probably not any more nifty than what has been said, but might give you some ideas

Attachments:
  1. MRlistIt.zip
#199579
Mar 12, 2011 at 10:59pm
– Pasted Max Patch, click to expand. –
#199580
Mar 12, 2011 at 11:07pm

Kaspar did you know that you can create a patcher inside a patch? To place all your objects inside? It can really dramatically save CPU resources. (patcher) with (inlet) and (outlet) inside, you can name the patcher too like (patcher kaspars-counter) : )

In other words, you create your own object from your counter patch, name it and use it inside other patches whilst reducing cpu load. type (patcher) and see the help file.

#199581
Mar 13, 2011 at 5:45am

great solution Luke :)

makes perfect sense…just didn’t see it!

#199582

You must be logged in to reply to this topic.