[audacity4blind] Updated plug-in: LFO panning 2

  • From: "David R. Sky" <davidsky@xxxxxxxxxxxxxx>
  • To: audacity4blind@xxxxxxxxxxxxx
  • Date: Fri, 7 Sep 2007 17:55:32 -0700 (PDT)

* panlfo2.ny: LFO Panning 2
attached to this post

Pans your stereo audio selection in Audacity using an LFO [low-
frequency oscillator], which is a waveform 20 cycles per second or

Much improved over previous version of LFO Panning: with LFO
waveform choice, and ability to set leftmost and rightmost pan

For Audacity 1.3.3 beta and later, panlfo2a.ny [with improved screen display] is available from


which contains panlfo2a.ny and the help file panlfo2a.txt.

Copy panlfo2.ny into your Audacity plug-ins folder. Start Audacity.
Load or create a stereo track.
Select some or all of this audio.
Open effects menu.
click on 'Panning [LFO] 2'.
Set edit fields as desired.
Click on 'okay' button.

Explanation of edit fields

1. LFO frequency [hz]

default 0.1 hz

Frequency of the LFO which pans your stereo audio.

If you set the LFO frequency to 1 hz and LFO waveform to 0 sine
wave, it will take 1 second to smoothly pan your audio from the
starting pan position, to one extreme pan position, to the other
extreme pan position, then back to  the starting pan position. And
it will repeat this pattern for the duration of your selected

2. LFO waveform 0=sine 1=triangle 2=saw 3=inverted saw 4=pulse

default 0 sine wave

Sine wave pans your audio back and forth smoothly between leftmost
and rightmost pan positions.
Triangle wave pans your audio back and forth in 'straighter' lines
than with sine wave.
Sawtooth wave pans your audio in a straight line from leftmost pan
position to rightmost pan position, then immediately to leftmost
pan position.
Inverted sawtooth wave pans your audio in a straight line from
rightmost pan position to leftmost pan position, then immediately
to rightmost pan position.
Pulse waveform pans your audio first to one pan position, then
immediately to the other pan position, then back, with no smooth
transition between these two pan positions.

3. pulse waveform duty cycle [percent]

Used only when pulse waveform is selected. default 50 percent
range 1 to 99 percent

A square wave is a pulse wave with 50 percent duty - half the time
the level is higher than the lower level.

A pulse wave with 90 percent duty is higher 90 percent of the time
than the lower level.

The higher the duty cycle, the more of the time your audio is
panned to the rightmost pan position.

4. LFO starting phase [degrees]

default 0 degrees
range from negative 180 to plus 180 degrees

Depending on the starting phase, you willl hear the start of your
audio panned to a slightly different location, in the LFO panning

5 and 6. Leftmost [or rightmost] pan positions [percent]

default 5 and 95 percent, respectively

The lower either of these values, the further left your audio will
be panned during the LFO sweep.

Conversely, the higher either of these values, the further to the
right your audio will be panned.


1. For proper panning effect, panlfo2.ny combines the two channels
of your audio selection into a mono-sounding stereo track before
panning it.

2. Due to this mixing of left and right channels, you may hear a
drop in volume of your panned audio.

Reason: When both channels contain audio at maximum volume and
these channels are mixed, when the mixed audio is panned anywhere
left or right of center, the signal will become clipped. So the
mixed audio is reduced in amplitude by one-half.

Compensatory code has been added to amplify the panned signal
depending on the setting of the leftmost and rightmost pan

3. You will get an error message:

a. If you select mono audio for LFO panning; or,

b. if you set identical leftmost and rightmost pan positions.

Written by David R. Sky September 7, 2007
Released under terms of the GNU General Public License version 2

David R. Sky
;nyquist plug-in

;version 2

;type process

;name "Panning [LFO] 2..."

;action "Panning your audio using a low-frequency oscillator..."

;info "panlfo2.ny by David R. Sky www.shellworld.net/~davidsky/ \nFor panning, 
your selected audio needs to be stereo. \nPans your stereo audio using an LFO 
[low-frequency oscillator]. \nFor left-most and right-most pan positions: 
0%=left channel, 50%=center, 100%=right channel \nReleased under terms of the 
GNU General Public License version 2"

;control rate "LFO frequency [hz]" real "" 0.1 0.02 20 

;control waveform "LFO waveform" choice "sine,triangle,saw,inverted saw,pulse" 0

;control duty "pulse waveform duty cycle [percent]" int "" 50 1 99

;control phase "LFO starting phase [degrees]" int "" 0 -180 180

;control left "Leftmost pan position [percent]" int "" 5 0 100

;control right "Rightmost pan position [percent]" int "" 95 0 100

; LFO Panning by David R. Sky

; simplified December 29, 2005

; improved [with multiple LFO waveform choice] panlfo2.ny September 7, 2007


; check if selected audio is stereo

((not (arrayp s))

(format nil

"Error - your selected audio is mono,

it needs to be stereo to be panned.

LFO Panning effect has not been applied. ~%"))

; check if left and right pan values are equal

((= left right)

(format nil 

"Error - you have set identical leftmost and rightmost pan positions: ~a ~a

these values need to be different.

LFO panning effect has not been applied. ~%" left right))

; has passed error-checking, apply LFO panning


; function to pan stereo audio

; by Dominic Mazzoni

; 'where' can be a number or signal, from 0 to +1, inclusive

; 0 left channel, 0.5 center pan position, 1.0 right channel

(defun pan2 (sound where)

   (vector (mult (aref sound 0) (sum 1 (mult -1 where)))

       (mult (aref sound 1) where)))

; duty is for pulse waveform only -

; 50% first half of waveform is higher [right-most pan position],

; and last half of waveform is lower value [left-most pan position]

; 1% duty means first 1% is higher, last 99% is lower


; first convert duty percent to a linear value

; duty is anywhere between 1 and 99 inclusive

(setf duty (* duty 0.01))

; calculate duration of selected audio

(setf dur (/ len *sound-srate*))

; create pulse waveform using pwl function

(setq *pulse-table* (list 

(pwl 0 1 (/ duty dur) 1 (/ duty dur) -1 (/ dur)  -1 (/ dur)) 

(hz-to-step 1) t))

; setting chosen Nyquist waveform

(setq *waveform* 


((= waveform 0) *sine-table*)

((= waveform 1) *tri-table*)

((or (= waveform 2) (= waveform 3)) *saw-table*)

(t *pulse-table*)))

; if inverted saw is chosen, set sign value to -1

(setf sign (if (= waveform 3) -1.0 1.0))

; calculate range - how far LFO sweeps

(setf range (* 0.01 (abs (- left right))))

; offset - how far right of the left channel

; the LFO sweep takes place

; for default values of 20% and 80%, range is 60%

; and offset becomes 20%

(setf offset (* 0.01 (min left right)))

; determine scaling factor to use after audio has been panned

; this is because left and right channels may have had maximum amplitude

; before panning, so closer to middle pan position after panning,

; volume will sound reduced

(setf scale-factor (* 2 (- 1.0 

(* 0.01 (max (abs (- 50 left))

(abs (- 50 right)))) )))

; function to return LFO waveform for panning

(defun get-lfo 

(offset sign range rate *waveform* phase)

(sum offset (mult range (sum 0.5 (mult sign 0.5 

(lfo rate 1.0 *waveform* phase))))))

; applying LFO  panning


; following lines convert stereo audio into mono-sounding audio 

; for proper panning effect

(mult 0.5 scale-factor 

(vector (sum (aref s 0) (aref s 1)) (sum (aref s 1) (aref s 0))))

(get-lfo offset sign range rate *waveform* phase))

)) ; end cond

Other related posts:

  • » [audacity4blind] Updated plug-in: LFO panning 2