I would like to use Audacity’s tone generating capabilities to the utmost. Rather than manually entering information for each sine wave that I’d like to make, I would love to be able to “batch create” hundreds of tracks in a single project that each have waveforms of different frequencies, with those frequencies determined by a CSV document. Basically, I would like to click on an option in the “Generate” menu that would ask me for the CSV document path and then proceed to create a new track for each waveform at each frequency listed. This sounds like it should be simple, but I am out of my depth scripting-wise in terms of how to make it a reality. I would be extremely grateful to any and all who might be able to help by making it, or even just by pointing me in the right direction.
The standard tone generator in Audacity is a built-in effect, not a Nyquist effect and it cannot be controlled by Nyquist. However, Nyquist has its own generate functions for creating a variety of waveforms including sine waves, sawtooth, triangle, square and white noise. A very simple example is the function “hzosc” which is a simple sine wave oscillator in which the frequency is defined in Hz. For example, if you select part of a track, select the “Nyquist Prompt” effect from the Effect menu, and enter this text into the text box:
it will generate a sine tone, amplitude 1, frequency 440 Hz.
To create a tone at a lower amplitude you can add a scaling function like this:
(scale 0.5 (hzosc 440))
which will produce a 440 Hz sine tone with an amplitude of 0.5.
Text and file handling in Nyquist is possible but tricky as Nyquist is primarily designed for handling sound rather than text.
Producing a robust cross-platform compatible file reader is quite tricky, but fortunately there is a much more simple way to input the data which is to copy and paste the data directly into a text box in the plug-in interface.
One more problem exists which is that Nyquist generators can only create one track and are not currently supported by the Chain (batch) feature in Audacity. You can create a series of tones on one track which could then be split into separate tracks or files, but it is not possible to create multiple tracks. What you can do is to manually create multiple tracks then select all of the tracks and use the scratch variable to pass the csv data to each track in turn. If you have hundreds of tracks in a single Audacity project it is likely that your computer will be unable to handle the load and will probably freeze.
So the short answer is that if you can put up with some workarounds then it sounds mostly possible.
Thank you, steve. That at least gets me somewhere…
Probably a good place to start would be to try creating a few really simple plug-ins such as simple filters. Have a look at the code for the notch filter that is shipped with Audacity 1.3.13 for an example. It is a file called “notch.ny” and will be in the plug-ins folder if you have Audacity 1.3.13 installed. The file can be opened in Microsoft NotePad or just about any other plain text editor.
If you are on Windows I’d recommend Notepad++ for editing as it has parentheses matching which is almost essential when writing or editing LISP based code (when the cursor is next to one bracket, the matching bracket is automatically highlighted). I think it also supports syntax highlighting for LISP which is useful as Nyquist is based on LISP.
There’s quite a lot of documentation available for Nyquist and a good starting point is here: http://wiki.audacityteam.org/wiki/Nyquist_Plug-ins_Reference
Once you’ve got the hang of how to make a plug-in you can start looking at the actual code that you need to use for the project. For example you could move on to making a simple sine wave generator plug-in.
Feel free to ask if you have questions or get stuck.