Sine Wave Frequency Sweep with Audacity

Thoughts from the team
By    | November 5, 2008 | Tutorials

I was recently trying to create a sine wave frequency sweep audio sample file to test out a digital signal processing (DSP) filter I was trying to write.  Using Audacity, you can create plug-ins to achieve all sorts of cool effects.  After a little experimentation I came up with the following code:

;nyquist plug-in
;version 1
;type generate
;name "Frequency Sweep"
;action "Producing frequency sweep..."
;info "by Adam Pope"

;control startf "Start Frequency (Hz)" real "" 1 0 20000
;control endf "End Frequency (Hz)" real "" 10000 0 30000
;control duration "Duration (secs)" real "" 20 1 300
;control type "Sweep scale [1=Linear, 2=Exponential]" int "" 1 1 2
;control other "I dont know what this does" real "" 5 0 100

(if (= type 2)
(fmosc startf (pwe duration endf other))
(fmosc startf (pwl duration endf other)) )

Copy this code into a frequencysweep.ny file and place it in your Audacity plug-ins directory.  You’ll need to restart audactity for it to register the new plug-in.  Once you’re back in, click on ‘Generate’ on the menu bar and select ‘Frequency Sweep’ from the list of options.  You will then be presented with a dialog containing sliders to play with the parameters of your sweep.  If any of the limits are too restricitve for you, simply change the values in the plug-in file!

If anybody can explain what the 3rd parameter of pwe and pwl does, I’d love to know!

Update: Many thanks to Paul Schimmel who sent me this updated version which removes the unknown parameter and also adds output level control.

;nyquist plug-in
;version 1
;type generate
;name "Frequency Sweep..."
;action "Producing frequency sweep..."
;info "by Adam Pope and Paul Schimmel"

;control startf "Start Frequency (Hz)" real "" 20 20 20000
;control endf "End Frequency (Hz)" real "" 20000 20 20000
;control duration "Duration (secs)" real "" 30 1 300
;control level "Level (dBFS)" real " " 0 -40 0
;control type "Sweep scale [1=Linear, 2=Exponential]" int "" 2 1 2

(if (= type 2)
(scale-db level (fmosc 0 (pwev startf duration endf))) (scale-db level (fmosc 0 (pwlv startf duration endf))) )

More like this