Audacity Plugins
Audacityteam.orgAudacity Support
  • Audacity Plugins
  • Installing plugins
  • FFMPEG & LAME
  • realtime effects
    • Plugin Suites
    • Pitch and Tempo
    • Delay and Reverb
    • Distortion
    • Dynamics Processing
    • Filters
    • Equalizers
    • Modulation
    • Noise Removal and Repair
  • AI plugins
    • AI plugins
  • Nyquist Plugins
    • Generator Plugins
      • Tone Generators
      • Noise Generators
      • Special Effect Generators
      • Instrument Sound Generators
      • Sequence Generators
      • Generator Utilities
    • Effect Plugins
      • Amplify, Mix and Pan Effects
      • Delay and Reverb
      • Distortion Effects
      • Dynamics Processing
      • Filters and EQ
      • Modulation Effects
      • Sequencer Effects
      • Time, Pitch and Tempo
  • Analyzers
    • Analysis plugins
    • Loudness compliance checks
  • Contributing
    • Adding plugins to this site
    • Developing your own plugins and scripts
      • Creating your own Nyquist Plugins
        • Nyquist Reference Manual
        • Plugin Reference
        • Headers Reference
        • Widgets Reference
        • Basics
          • Volume Basics
          • Independent Stereo Volume Basics
          • Delay Basics
          • Prompt Basics
        • Tutorials
          • The *SCRATCH* Symbol Tutorial
          • Property List Tutorial
          • Stereo Tracks Tutorial
          • Macro Tutorial
          • File Button Tutorial
        • 💬Nyquist Forum
      • Scripting reference
  • Additional resources
    • Audacity custom themes
    • EQ curves
      • EQ XML to TXT converter
      • Weighted curves
      • Playback equalization for 78 rpm shellacs and early 33â…“ LPs
    • External scripts
    • Audacity Support
Powered by GitBook
On this page

Was this helpful?

Edit on GitHub
Export as PDF
  1. Contributing
  2. Developing your own plugins and scripts
  3. Creating your own Nyquist Plugins
  4. Tutorials

The *SCRATCH* Symbol Tutorial

This page provides a brief introduction to using the *SCRATCH* symbol in Nyquist programming.

*SCRATCH* is a global symbol, specific to Nyquist in Audacity, which is not deleted in-between plugin runs. It provides a way for information to survive from one invocation of a plugin to the next. However, you should not rely on the "value" of *SCRATCH* beyond a single invocation of a plugin as it could be overwritten by another plugin. It is better to use property lists of *SCRATCH*. That way, you get a whole name space rather than a single variable name, and with careful naming of the property keys, name collisions can be avoided.

To pass data from plugin "effectX-partA" to "effectX-partB":

1. Assign a property name based on the effect name, e.g.: 'EFFECTX [or in SAL, which does not support the single-quote notation of LISP, write QUOTE(EFFECTX). ]

2. "effectX-partA" should delete any old property value:

exec remprop(quote(*SCRATCH*), quote(effectx)) ;; in SAL
(remprop '*SCRATCH* 'effectx) ;; in LISP

3. "effectX-partA" should compute a new property value v and save it:

 exec putprop(quote(*SCRATCH*), v, quote(effectx)) ;; in SAL
 (putprop '*SCRATCH* v 'effectx) ;; in LISP

4. "effectX-partB" should access the property using:

 set v = get(quote(*SCRATCH*), quote(effectx)) ;; in SAL
 (get '*SCRATCH* 'effectx) ;; in LISP

5. When "effectX-partB" finishes, it should remove the property:

 exec remprop(quote(*SCRATCH*), quote(effectx)) ;; in SAL
 (remprop '*SCRATCH* 'effectx) ;; in LISP

But there may be cases where you do some analysis and want to use the analysis data multiple times. You might even have multiple analysis plugins operating on different inputs to collect data to feed into a plugin with multiple inputs. In this case, which might be quite common, you should not call REMPROP(), but this has the problem of leaving data on the *SCRATCH* property list indefinitely.

In cases where *SCRATCH* data is not deleted immediately after use, and where there is the potential to leave large amounts of memory there, there should be another effect, e.g. "effectX-partCleanup", that simply calls:

 exec remprop(quote(*SCRATCH*), quote(effectx)) ;; in SAL
 (remprop '*SCRATCH* 'effectx) ;; in LISP

allowing the user to explicitly free up any data stored on the 'EFFECTX property. It would be reasonable to omit the "effectX-partCleanup" effect if the data stored on the property list has a maximum size of, say, 10KB. The problem we want to avoid is properties with unbounded size getting left in the heap until Audacity is restarted.

PreviousTutorialsNextProperty List Tutorial

Last updated 2 years ago

Was this helpful?