I'm looking for a phasor that would play on trigger just one period (one ramp then stay at 0 or stay at "maximum").
I haven't found such an object, so I'm looking for pointers on how to detect the "wrapping around" of the phasor.
I'd like to detect when the addition of a phase-increment makes the phasor reach the "top" or when "the next phase-increment addition will wrap around and go back to zero-ish".
Thanks for any pointer/suggestion of object to study!
Triggered phasor playing just one period?
Make phazorFm play only one cycle
A linear-slope AD envelope with 0 attack and whatever you want for decay sounds like what you need.
a|x
Thanks for the idea. It could work in some cases, but I need that in S-Rate, with a strict progression and a vertical edge. If I use a K-rate envelope followed by interpolation, the vertical edge is smoothed over 16 samples. That's why I'm looking at a phasor-like implementation.
Ah, good point. What you need then, is an S-Rate AD envelope. Not sure if that exists, but it shouldn't be hard to convert the K-Rate object to work at S-Rate (with 16x the CPU overhead, of course). I might give that a go myself, if I have a free moment this evening.
a|x
Not that easy, since K-Rate envelopes use int32_t type and when it goes "<0".
A S-rate phasor code is super efficient, just a repeated addition on a frac32.buffer.positive type. For this reason, we can't detect "<0", nor "==0" (==0 depends on the exact phase increment).
Still wondering how to "stop" or "suspend" such a phasor at the right time. Will keep working on it...
I think rbrt/old/1shot does what you're looking for. The only thing is that frequency is calculated as a range inside a given table, because has a very specific use. Maybe you can modify it to suit your needs...
Check if the current value is lower than the current decrement value (assuming the value is being decremented from the 1>>27 to 0) and decrement if not.
a|x
@valmir Thanks for the pointer, I'll look at that.
@toneburst Yes, that sounds like a great idea, will try!
I should say, if current value is less than decrement value, set to 0, else decrement.
a|x
Here is what I came up with. Thanks all for the help.
one-period-phasor-trig.axp (2.4 KB)