I wish to use the Nyquist Prompt plugin in Audacity to construct a piece-wise linear waveform of 2048 samples in length. For example, I can generate a square pulse wave by starting with 2048 silent (zero) samples, selecting all, and then invoking the Nyquist Prompt with:
(sum s (pwl
0 1
0.5 1
0.5))
This uses the piece-wise linear (pwl) function to create a waveform that starts at time 0, level 1.0, then linearly interpolates to time 0.5 (half-way across the selection), level 1.0, then immediately jump down to level 0.0, and continue at 0.0 until time 1.0.
This works, however the resulting waveform does not have a sharp one-sample transition (step) at time 0.5, instead it has a linear ramp between 1.0 and 0.0 over ~40 samples. This is not acceptable in this situation.
The conversion here suggests that within Audacity the Nyquist plugin actually runs at a control rate much less than the audio rate, hence the resulting ramp.
I actually wish to create a much more complicated waveform than a square wave, so once this issue is resolved I can continue to construct the full waveform.
My questions are:
- is it possible to adjust the control rate to match the audio sampling rate, so that I can have sample-accurate control of the pwl function, and
- how would this be incorporated into a Nyquist Lisp expression that also calls 'pwl' - I'm not very familiar with Lisp at all and don't understand how to execute two statements sequentially. My guess is there's a function to do it...
I would be happy to use Nyquist outside of Audacity if that makes more sense.