fold within jit.gen broken?

Deliverer's icon

Hi,

In jit.gen, I just can't make the fold operator work as expected: it acts as a clamp operator instead. Is that a bug? Or am I missing something?

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

TFL's icon

Interesting!

To me, fold in jit.gen works as expected:

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

The problem comes from the feedback loop and the way you increment the Y value.

When the value reaches 1. after the [fold 0 1], the actual jit.gen output will be 1.01 (because of your [+ 0.01]). At the next bang, your 1.01 goes through [fold 0 1], so it gets back to 0.99, but then you [+ 0.01] again so the output is 1. again. And so on and so forth.

The only way I can think of is to increment a value outside of the matrix itself and pass it as a parameter:

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

...or to use [jit.time.tri @scale 0.5 @offset 0.5] but then you get a time-based increment rather than frame-based.

Deliverer's icon

waoh! that just makes sense! thank you for this clear explanation.

Deliverer's icon

I managed to make it work by splitting the jit.gen output in two different parts: One outlet for incremental feedback, and another with the fold operator for the rendering.

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