Prompt Basics
This page explains how to use the Audacity Nyquist Prompt to test-run Nyquist code snippets.
Last updated
This page explains how to use the Audacity Nyquist Prompt to test-run Nyquist code snippets.
Last updated
The Audacity Nyquist prompt appears in Audacity's "Tools" menu.
For testing generate-type commands in Nyquist, you can use the Generate Prompt plugin instead.
Sound files are imported into Audacity via: File > Import > Audio or the shortcut CTRL + SHIFT + I
.
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.
Select the track(s) and click Tools > Nyquist Prompt.
The Nyquist Prompt appears like this:
Simply enter the code below and press Apply to receive a "hello world" prompt:
The programming language used above is Lisp. The Nyquist prompt automatically assumes you're using Lisp if the first character is an (
. If it isn't, the prompt assumes you are writing SAL, which is more similar to C-like syntax. If you prefer SAL, a "hello world" program looks like this:
The prompt also comes with a debug button. It shows you various warnings and non-fatal errors after the program finished. For example, if you forget the quotation marks around "
hello world
"
, just hitting apply will just do nothing, whereas hitting debug will tell you where you went wrong:
The current Nyquist manual is here: Nyquist Reference Manual.
A useful index of Nyquist commands is here: Nyquist Language reference
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").
Note: Prior to version 4 syntax, the vaiable S
was used instead of *TRACK*
. You may encounter this in some old plugins or old documentation. The old syntax is obsolete and should not be used in new code
Note: These examples are focused upon using Audacity to manipulate digital signals (clearly Audacity is better suited to audio, but features such as Nyquist can open many other uses). For those interested, the signal used is an infra red (IR) sample from a remote control.
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.
To multiply a signal with a generated carrier signal, you can use the following commands:
The (hzosc 19000) produces 19kHz sine wave carrier.
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.
Note: Unfortunately, this isn't the end of the road for this sample; it is near, but the curved "head/tail" of the signal causes a problem for the digital signal being produced [and it was also upside-down, too...]. This will hopefully form the basis of some more complex examples, since I shall need to use Nyquist to:
Find the zero crossing points
Then only apply the carrier frequency to those regions above zero. Or find another suitable command...