Gen~ and order of execution...

Peter McCulloch's icon

Cycling Folks,

Is there any way of predicting order of execution in gen~ when patching? I'd like to reset +=, then add an offset amount to it. I imagine codebox is the way to go, but I'd like to know if there is a different way (and so I can understand what happens when an object has multiple inlets that may be changing on the same sample)

Max Patch
Copy patch and select New From Clipboard in Max.

Thanks!

Wesley Smith's icon

Hi Peter. Everything in the gen domains is synchronous. If at a given sample, the second inlet of += has a non-zero value, the output for that sample will be the minimum count value (default 0). For all other cases, += will output the previous value + the left inlet increment.

Hopefully that answers your question. If not, please let us know.

Peter McCulloch's icon

So for that sample the left inlet isn't looked at? (it makes perfect sense when you're wanting to reset to the minimum, but it makes it tricky when you want to, say, reset to the maximum (in the case of reverse counting).

This is probably better handled in codebox (which I'm looking at).

Wesley Smith's icon

Exactly. For that sample, the left-inlet isn't used. If you're counting backward, couldn't you just invert the output of += with a [!- max_value]?

Peter McCulloch's icon

Yes, if I were doing it consistently, but I'm switching forwards and backwards at any given moment. (It's an analog step sequencer that you can drive automatically or with pulses; positive pulse = advance, negative = backwards)

Wesley Smith's icon

In that case, you can use the [?] operator to choose up or down depending on the pulse.

Peter McCulloch's icon

I'm not sure how I could generate things like this:

+1 -1 +1

1,2,3,4,5,6,7,6,5,4,3,2,1,0,15,14,13,12,13,14,15,0,1,2

Actually, now that I look at it, this is not a job for +=, but one for + (and use wrap/clip in the loop) (I have oneshot/loop modes)

Thanks, Wes!

Don't suppose you have any suggestions on the assignment question I just posted...