I am trying to create a PWM effect such that a square-wave is modulated with PWM to approximate the input selection in Audacity. One could use this to hear what their favorite music would sound like in PC (or Apple ][) Squeaker Fidelity LOL :-) after applying a suitable filter effect.
My original thought was to create a saw oscillator and use it as reference for the comparitor step of PWM
the hard part is keeping track of the square wave flips based on the comparitor results
In C++ I'd just do it per sample using > and change the sign of the currently generating square sample as appropriate but this is audacity in windows (unlike linux where C/C++ compiler comes stock) so I've only got the Nyquist prompt to try to do this with
---assume mono sample input for simplicity---
using (> s (osc-saw 44100)) as comparison doesn't work
so I'm not sure where to go from here since the sample looping stuff in nyquist is very scary and evil
audacity doesn't have a plugin to do this effect... it only has a PWM tone generator
PS: I could use some examples of how to do the per-sample stuff in Nyquist.