*SCRATCH* – the variable that lasts

*Scratch* is a very useful Nyquist variable (in Audacity). It has the unique property that it survives from one call of Nyquist to the next. This allows, for example, a plug-in to perform sequential operations on a series of tracks, or for one plug-in to analyse a track and then another plug-in to process the track according to the analysis.

*Scratch* is described in the manual  as:

  • a global symbol, which is not deleted in-between plug-in runs.
  • a way for information to survive from one invocation of a plug-in to the next.

The manual also warns that you should not rely on the “value” of *SCRATCH* beyond a single invocation of a plug-in as it could be overwritten by another plug-in.

Cleaning up after use

Rather than leaving data hanging around in memory, it is good practice to free up memory and avoid possible conflicts with other plug-ins by “un-setting” *scratch* after use.

Here is a utility function that unbinds the *scratch* symbol (removes its “value”) and clears any/all of its property lists:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.