Gen == comparing question

Luca Schwarz's icon

Hey there! Just a quick one: Comparing a phasor ramp with a static value between 0 and 1 should give out a single sample trig in theory right? Any ideas how to implement such in gen? I tried this and it did not work out.

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

👽'tW∆s ∆lienz👽's icon

Comparing a phasor ramp with a static value between 0 and 1 should give out a single sample trig in theory right?

no, the values in a phasor are often different each cycle, so going for an exact value like '0.2' will never be reliable(sometimes the '0.2' you're looking for, within a digitally-sampled calculation of a phasor~ will be something like "0.2224915982103598203895" and it will be different during the next cycle of the phasor~ because the math is making an estimation of the value at that particular digitally-sampled time(unless you're able to sync up your phasor~ frequency to an exact multiple of your sample-rate, digitally sampling that phasor~ at any given time, will cause the phasor~ calculation to be different each cycle)).

instead, you can track for boundary-crossings/slope-changes something like this:

a bit early morning for me, so i might not be thinking of the most clearcut way... perhaps others might have a better way so you don't need the '< 0.' after the 'delta' but basically, for tracking a boundary-crossing/slope-change, 'delta' is your friend.

Luca Schwarz's icon

awwww thx matey! exactly what i was looking for <3

Graham Wakefield's icon

Here's a more robust "did the phasor just pass this value" patch, which will handle inputs between 0 and 1 and including 0 and 1 (which a phasor's sample output hardly ever actually touches, even though conceptually the phasor goes through them), as well as handling zero and negative frequency phasors, etc:

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

Roman Thilenius's icon

what about adding an offset to the phase and then check for 1 to 0 transitions?