Hey all -
I'm trying to figure out how to use the audio library to "hard-sync" two oscillators. To me, this means that the phase of one oscillator will be programmatically reset to 0 with the period of the other. Many of the "synth" objects have a phase field, but I am struggling to determine a good way to utilize it in this context. For those familiar with Pure Data, having some sort of "bang" occur to reset the phase to 0 once per cycle would be ideal; perhaps I'm too locked into this way of thinking to find another solution.
Things I've thought of so far:
With explicit knowledge of the two oscillator frequencies, I have thought of using some sort of counter to reset the phase once the specified period has elapsed, but this seems kludgy at best, and all the counters I know of only have 1ms resolution, which means this solution is unworkable for frequencies above 1kHz.
I considered using the PWM waveform as well. It also seems ill-advised, but an idea that crossed my mind was to set the duty cycle to be extremely uneven (let's say 1 sample high and the rest low) and use peak-detection to trigger the phase-reset when the high value comes along once per cycle. This seems more workable than my first solution, but I'm craving a way to more directly link the phase-reset to a known period.
Thanks in advance for your input!!
- Jz
I'm trying to figure out how to use the audio library to "hard-sync" two oscillators. To me, this means that the phase of one oscillator will be programmatically reset to 0 with the period of the other. Many of the "synth" objects have a phase field, but I am struggling to determine a good way to utilize it in this context. For those familiar with Pure Data, having some sort of "bang" occur to reset the phase to 0 once per cycle would be ideal; perhaps I'm too locked into this way of thinking to find another solution.
Things I've thought of so far:
With explicit knowledge of the two oscillator frequencies, I have thought of using some sort of counter to reset the phase once the specified period has elapsed, but this seems kludgy at best, and all the counters I know of only have 1ms resolution, which means this solution is unworkable for frequencies above 1kHz.
I considered using the PWM waveform as well. It also seems ill-advised, but an idea that crossed my mind was to set the duty cycle to be extremely uneven (let's say 1 sample high and the rest low) and use peak-detection to trigger the phase-reset when the high value comes along once per cycle. This seems more workable than my first solution, but I'm craving a way to more directly link the phase-reset to a known period.
Thanks in advance for your input!!
- Jz