Detecting 1.0 from [phasor] in [gen~]
Hello all.
This is very simple...maybe silly question.
As far as I know, it's calculated by single sample in [gen~].
So is there anyway to retrieve 1.0(or any specific float number) from [phasor] in [gen~]?
Or maybe this is not possible in the first place?
Thank you in advanced
try this (use 0.99 instead of 1-- I don't think phasor is guaranteed to reach exactly 1)
detecting an exact number in gen is not going to be very precise because of the nature of floating point numbers. Floating point numbers can't exactly represent real numbers, so it's unlikely that the number you're trying to detect will occur, especially if it's the result of a series of operations. Instead, you can detect a number by looking for that number + a range around that number that is very small but not inconsequential. For example, if I'm looking for 1.0, I might try detecting with:
abs(in-1.0) < eps
where eps is the small range around the target number I'm looking for.
I think I'm correct in saying that phasor (or phasor~) will never truly reach 1. You can, however, either in gen~ or in MSP, use "delta" and "< 0" to look for the sample at which it wraps around toward 0, which is effectively the sample at which it "reaches 1". You can also use < or
OK..I see.
Thanks for all the tricks everyone.
One more question.
Before gen~ I used [delta~] - [
Christopher suggested same method but in [gen~].
Between MSP and gen version, which way is better or more precise?
Thank you.
I tired 3 different ways.
The results are almost same..
Yes, using [delta] and [< 0] is the recommended way to do it. Also [change] is available; it works like delta but returns 1, 0 or -1 to represent the direction of change only (not the amount).
Note that if the phasor frequency is negative you will get the boolean opposite (i.e. mostly 1's but a 0 when the phase wraps). If you want to support both positive and negative frequencies, you can try [phasor] -> [change] -> [change], though this will actually give two samples of click (one positive, one negative).
I see..
Thanks a lot