Audacity 2.0.3, Win 7 32-bit for now (occasionally use on MacOSX and Linux)

Hi,

I had an idea, and was going to try implementing it using stereo cross-channel convolution in foobar2000 foo_dsp_stereoconv, but discovered that its 1024-point FFT limits the delay I can apply when convolving. Nyquist sound like it might be capable of what I want and I’m very familiar with other aspects of Audacity.

I’m trying to get my head round Nyquist or SAL, mainly trying the Nyquist prompt, but I can’t seem to understand the syntax or the descriptions in the Nyquist reference well enough to make much beyond simple scaling work in the Nyquist prompt (e.g. Return s * 0.5) and can’t completely understand which bits refer to audio streams in some of the .ny files I’ve downloaded from here or found in the plugins folder.

I want to make a sort of repeated decaying echo effect with a short enough time (a few tens of milliseconds) that it ‘belongs’ to the same sound, like room-reflections (or reverb) rather than sounding like separate sounds (echo, hundreds of milliseconds). This so far sounds like a fairly simple delay and add a scaled version, and repeat until the added signal has decayed by, say, 90 dB.

However, I want to move some or all of the left source channel to the right channel at the first reflection and some or all of the right channel to the left channel too.

Rather than room modelling, I happen to be visualizing complex numbers representing both channels of each sample, where the sample value on the left channel is the REAL component, and that on the right channel is the IMAGINARY component, and I consider it as is on polar coordinates, so with each reflection, I multiply by the radius r by the attenuation factor to decay the reflection, and add x to the angle theta the pass that reflection on for a subsequent reflection), so the attenuation on the n’th reflectin is a^n, and the angle added to theta is x*n (that’s equivalent to raising the polar complex number to the n’th power.

The conversion from polar to real+imaginary parts returns us to the left and right channels.

I understand we need to think not of an array of samples, but of a sound and a modified sound (much like a circuit design), where the modification could be a delay of d milliseconds per reflection and we can apply simple scaling my multiplying by attenuation factor a where a = 10^(negative decibels/20), and for reflection n, the scale is a^n (a raised to the nth power)

DestinationLEFT = (a^n)*(sin(x*n)*SourceRIGHT_delayedBy(d*n) + cos(x*n) SourceLEFT_delayedBy(dn)) summed from n = 0 to Nmax
DestinationRIGHT = (a^n)*(cos(x

*n)*n)

*SourceRIGHT_delayedBy(d*n) - sin(x*SourceLEFT_delayedBy(d*n)) summed from n = 0 to Nmax

There’s also a special case, where x is 90°, and that means at each pass, either sin(x*n) or cos(x*n) is 0 so one channel can be left out of the calculation and a simple sequence of +1, 0, -1, 0 is repeated over and over, reducing the computation again.

For that case, I’d be happy just the swap channels and scale.

Computationally, I’m sure it’s most efficient to take input sample at time t and for each channel, map to the destination samples at time t + d, t+2d, t+3d and so on, each scaled by a from the previous version, but that might not suit Nyquist’s way of doing things.

I did try one or two examples some time ago by delaying and channel-mixing the waveforms as appropriate and using MixPaste in Cool Edit 96, and attenuation of about 12-18 dB per pass was fine, and 3 or 4 passes (with the 4th being 48 to 72 dB down) was enough to enough a bit of live-room effect. This is rather labour intensive, however, and I thought Nyquist could make it simple.

Can anyone point me at some code snippets that will do each step I require:

- Delay the audio and add a scaled-down echo version
- Swap or partially mix the channels of the added audio.

Once I understand that I can probably create input boxes such as those in the Delay plugin to make it configurable and could share the code here for review and clean-up and testing and possible refinement to suit boundary cases (e.g. awareness that the effect slightly lengthens the sample).

Thanks in advance.