Proposal Nyquist process effects in Chains

Proposed Feature
To enable support for Nyquist Effects in Chains.

Developer/QA Backing

 * Steve
 * Edgar
 * Leland
 * Gale
 * Martyn

Motivation / Use Cases
Chains allows multiple effects to be run automatically in sequence and are the only mechanism available in Audacity for batch processing. Currently only the built-in effects shipped with Audacity (at the top of the Effect menu) can be used in Chains. The ten currently shipped Nyquist process effects can't be used in Chains.

Optional Nyquist effects added by the user further complement the built-in effects by providing functionality in Audacity that is otherwise missing. Excluding Nyquist support in Chains thus severely restricts their usefulness. It is not uncommon for Audacity users to be driven to use other software because of this restriction.

The highest rated feature request in the Automation section is "Include features dependent on selecting regions (e.g. trim, fades) (43 votes)". This becomes possible when Nyquist effects are supported by Chains.

Example User Cases
The range of user cases is too broad to list in full, but here are some actual user example cases to illustrate the versatility of this feature:


 * 1) Chain to trim off first 25 seconds
 * I have spent days trying to figure out how to create a simple chain to cut off 25 seconds of the start of an mp3 file. In the "Select Command" I see no effect choice of edit or trim, and I see no means to add those effects to the "Select Command" drop down menu! It would be great to add or remove commands from "Select Command" drop down! Then it would be nice to run the chain through a directory of files!
 * 1) * This could be accomplished using the Extract Audio plug-in in a Chain.
 * 2) Automatic segmentation/Remove silent sections
 * I need to simultaneously split a file into multiple files with silent sections removed. I have tried the Truncate Silence tool, but it only removes silence on a single track; it does not segment the file into multiple files. I would also like to perform this in batch, so that I could take a folder of audio files and split each one into multiple files, with the split files in one folder for each original file.
 * 1) * This could be accomplished by modifying Sound Finder to write the detected sounds to files, then using the modified effect to a Chain.
 * 2) Decode Morse
 * I'm trying to to encode and decode text into Morse (-code & audio). So far, the text conversion and code -> audio conversions have been completed, but I'm stuck at the audio -> code part. After trying SoX's .dat output, their "stat" function, as well as ffmpeg's "silencedetect", I found out about audacity's "Sound finder" function (Though I've been using audacity for years). compared to SoX and ffmpeg's output, audacity's is a lot more accurate, not to mention easier to parse. The only problem is that I'd have to open audacity for each file, manually. So, for that reason, I'd like to request command line support / output for the various analysing functions in audacity.
 * 1) * This could be accomplished by modifying Sound Finder to export the duration of sounds and silences to a text file, or with a little mor modification could entirely decode Morse code to text.
 * 2) Batch Clipping Detection
 * Have been trying to think creatively of a way to use a chain to evaluate a series of files to see whether the peak level exceeds 0db. Is this at all possible?
 * 1) * While it is the case that integer format audio files never exceed 0 dB it would be simple to construct a Nyquist effect to scan files and output a list of peak levels.
 * 2) Changing the length of silence
 * I need a chain for batch processing, that changes the length of the initial silence of a file to 500 ms, and the final silence to 1000. Is it possible, and how?
 * 1) * Run a slightly modified version of the Extract Audio plug-in in a Chain.
 * 2) Equal loudness normalising of files
 * There is an experimental plug-in for Equal Loudness Normalizing
 * "I presume that as it is a plugin that one can't use batch processing"
 * 1) * The usefulness of this plug-in would be substantially increased by batch processing.
 * 2) Automating operations in Audacity
 * I have hundreds of old (~1890s through 1920s) mono recordings as mp3 files. I want to process them to reduce noise, pops and clicks, improve dynamic range, simulate a bit of stereo and so on.
 * 1) * Currently Noise Reduction, Click Removal and the Compressor can be used in batch processing with Chains, but the other major feature requested was simulating stereo. There is an excellent Pseudo-stereo Nyquist plug-in effect available.
 * 2) Batch create waveforms
 * 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
 * 1) * Any of the Nyquist Generator plug-ins could be applied to a batch of "dummy" files to create a large number of tones. The *scratch* variable could possibly be used to step through a sequence of data, or the data could be read from a simple text file.
 * 2) Trimming almost-silence from the beginning and end of a file
 * I have a bunch (over 100) of very short audio files, many of which have a second or two of almost empty space at the beginning and end of the file. I'm wondering if there's any way to set something up to automatically remove those portions, while leaving alone anything in the middle (eg. pauses between words), thereby shortening the length of the audio file while leaving the core unchanged.
 * 1) * One of the most common potential jobs for a Nyquist plug-in in a Chain.
 * 2) Replace one channel of a stereo track with a copy of the other channel
 * Is there any way to edit these files en mass to delete the right ear channel and essentially make it mono but using only the left ear channel? I know how to do this one file at a time, but I don't feel like going through over 24h of files one at a time...
 * 1) * This could be accomplished using the Channel Mixer plug-in in a Chain.

Related Use Cases outside this proposal

 * Extend Chains support to arbitrary VST and LADSPA effect plug-ins added by the user.
 * Extend explicit Chains support to built-in items in the Audacity Generate and Analyze menus and to similar plug-ins in Nyquist and VAMP formats.
 * These are more suitable for running Chains on the current project than on files, but would be useful even if limited to the current project. Built-in Generate menu items would ideally need support for region selection.

Current status
Comitted in revision 11752.

Testing and committing
Above was all OK. The only issue I really had is that running a Nyquist effect in a chain resets the parameters of the effect when run from the menu (if those were different). That's worse behaviour than with some of the built-in effects, but some do likewise, as per bug 73.
 * Steve: Initial testing on svn head Jul 25 2011 has been successful.
 * Retested on Linux with Audacity r11238 21st/22nd Aug 2011. Still good
 * Martyn: Testing here on 20th August 2011 HEAD also looks good
 * Martyn: I also tested the new patch on Win, Linux and Mac and it works for me.  Previous one doesn't as it does not call SetXlispPath at an appropriate time.
 * Gale: Testing with build from HEAD 1 Aug 2011 (wx 2.8.12) seemed good but shows excessive width between the columns of commands in the "Select Command" window (that window is now resizeable as at 26 Aug 2011).
 * Martyn: Is it resizable on Linux? It isn't for me, and is frustrating me trying to fix it.
 * Gale: Yes in HEAD on Ubuntu 10.10 (built with Widgets 2.8.12) the "Select Command" window is resizable on all four edges and all four corners.
 * Martyn: But column widths work for me on *nix (appropriate to content) but not win (all the same width as widest col).
 * Gale: Tested [[Media:Nyqchains1.txt|Nyqchains1 patch]] 13 Sep 11 on Win 7. Tested:
 * mix of Nyquist and non-Nyquist effects in chain
 * two commands in chain for the same Nyquist effect with different parameters
 * valid text-entered parameters in Nyquist effect that were outside slider range.

Credits
Many thanks to Edgar for providing the initial proof of concept and to Leland and Martyn for developing the current patch.