Automatically cycle a number box to count up and down

alring's icon

Hi folks...

Seems simple but I've tried a bunch of avenues and am just stuck.

I want a number box to continuously count from 0 to 1 (steps of hundredths) and back down to zero. This is going to control jit.xfade so that it crossfades between to video sources back and forth.

Here is my latest idea...but I can only make it work by manually triggering the switch object. What (probably) obvious solution am I missing??

Thanks for any suggestions!
Alex

crossfader.maxpat
Max Patch

tmhglnd's icon

I like to use line/line~/bline for these kind of fade-in/out functions.

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

alring's icon

That's the ticket! Perfect :)

Thanks so much!!

Alex

Gabriele Strada's icon

How would you suggest to have it loop with line objects but to also be able to change the speed of the ramp without retriggering the whole ramp? I'm using $1 for the time of the ramp, but all the times I change it the ramp restarts. I would like a smoother effect that just increases the current and future ramps.

Source Audio's icon

use metro & counter instead of line.

tmhglnd's icon

If you want a looping ramp with variable speed I'd suggest using [phasor~], you can adjust the frequency while it is running without resetting the ramp. You can use eg.[snapshot~ 5] to convert to a float. Combine with [triangle~] to create a ramp that goes up and down.

Roman Thilenius's icon

one of the many issues when using signals is that you hardly reach the min and max values exactly at a frame.

speaking of frames, why 1/100th steps? 100 (or actually 101 steps) do not fit into the 8 bit resolution of the color values in the sources. so that will quantize the modulation. if you use 128 instead of 101 steps, the results will be more linear. (well, or float.)

Source Audio's icon

this cycles in 1/1000 steps reliably at 0.1 ms metro speed , can be reduced to 1/100 or whatever

Roman Thilenius's icon

exactly. just made the same.

both, min and max value, as well as the time they occur can be set accurately, and it can be restarted or phaseshifted easily.

those who do not trust [counter 2 n n] or need other than palindrome mode can also use [t 1] - [accum] - and then any kind of math function or a [pong].