Nyquist Basics: The Audacity Nyquist Prompt
|This page explains how to use the Audacity Nyquist Prompt to test-run Nyquist code snippets.
- Peter 21Jul19: Done - by trimming off the TCPs (to aid future generalization against future TCP changes). And added the indentations that Connie likes.
The Audacity Nyquist prompt appears in Audacity's "Tools" menu.
Load a Sound File
Sound files are imported into Audacity via:
CTRL + SHIFT + Ior the shortcut
If you have no pre-existing sound files to work with, you can create your own mono or stereo tracks via the Audacity "Generate" menu.
Create a Mono Track
1. Click. An empty mono track will appear in the Audacity window:
2. Click. Leave everything as-is and just click . The mono tracks will become filled with the generated sound.
Create a Stereo Track
1. Create an empty stereo track.
- click .
An empty stereo track will appear in the Audacity window.
2. Now click. Leave everything as-is and just click "OK". The stereo tracks will become filled with the generated sound.
The Nyquist Prompt
|Recent versions of Audacity have an option to "Use legacy (version 3) syntax" in the Nyquist Prompt. Ensure that option is NOT enabled for these examples.|
Select the track(s) and click.
The Nyquist Prompt appears like this:
The Nyquist Interpreter
In the Nyquist Prompt window, type (print "hello") into the text field with the parentheses and quotes, as follows:
When you click OK, you should get a message box displaying the word hello:
The message box disappears when you click OK.
This, as you have learned, is how you can send messages to the user.
The Nyquist Debugger
Go back to, and this time, type (print hello) with the parentheses but without the quotes:
Important: This time, click instead of .
A "debug window" appears, displaying the error messages that Nyquist returned:
Basic Nyquist Commands
The Nyquist manual entirely using LISP syntax is here: Nyquist Reference Manual.
The current Nyquist manual introducing SAL syntax is here: Nyquist 3.02 Reference Manual.
Audacity uses the *TRACK* variable to reference the current audio file/selection. Thus, you can use basic commands such as mult or sum with *track* and the Nyquist prompt will replace the file/selection with the result (or as Audacity calls it, "returned audio").
Applying a DC offset to a signal
Original Signal before command.
Type the following into the Nyquist Prompt (using LISP syntax):
|(sum *track* 1)|
Or type the following equivalent SAL command:
|return *track* + 1|
The whole signal has now moved up to above zero.
Modulating with a carrier frequency
To multiply a signal with a generated carrier signal, you can use the following commands:
|(mult *track* (hzosc 19000))|
Or the SAL equivalent:
|return *track* * hzosc(19000)|
The (hzosc 19000) produces 19kHz sine wave carrier.
|(mult *track* (osc-pulse 19000 0))|
Or the SAL equivalent:
|return *track* * osc-pulse(19000, 0)|
The (osc-pulse 19000 0) produces 19kHz square wave carrier (note the 0 is the bias or 50/50 duty cycle, -1 to 1 = 0%-100% pulse-width ). Applying the 19kHz square wave carrier obtains this result.
The top and bottoms of the signal can then be clipped using the Hard Limiter option from the effects menu (0dB limit and Wet level 1) if required.
The above examples show how you can use the many Nyquist commands to perform basic signal processing without using scripts.
- Find the zero crossing points
- Then only apply the carrier frequency to those regions above zero.
Thanks to Forum moderators stevethefiddle & kozikowski for their help with Audacity & Nyquist.