This is a reference guide to programming audio-oriented effects for REAPER using JS. JS is a scripting language which is compiled on
the fly and allows you to modify and/or generate audio and MIDI, as well as draw custom vector based UI and analysis displays.
JS effects are simple text files, which when loaded in REAPER become full featured plug-ins. You can try loading existing JS effects
and since they are distributed in source form, you can also edit existing effects to suit your needs (we recommend if editing an existing effect you save it as something with a new name--if you do not you may lose your changes when upgrading REAPER).
This guide will offer an outline of the structure of the text file used by JS, the syntax for writing code, as well as a list of
all functions and special variables available for use.
JS File Structure
JS Effects are text files that are composed of some description lines followed by one or more code sections.
The description lines that can be specified are:
- desc:Effect Description
This line should be specified once and only once, and defines the name of the effect which will be displayed to the user.
Ideally this line should be the first line of the file, so that it can be quickly identified as a JS file.
- slider1:5<0,10,1>slider description
You can specify multiple of these lines (from 1-16 currently) to specify parameters that the user can control using standard
UI controls (typically a fader and text input, but this can vary, see below). These parameters are also automatable from REAPER.
In the above example, the first 1 specifies the first parameter, 5 is the default value of the parameter, 0 is
the minimum value, 10 is the maximum value, and 1 is the change increment. slider description
is what is displayed to the user.
There are additional extended slider syntaxes. One is:
slider1:0<0,5,1{zerolabel,onelabel,twolabel,threelabel,fourlabel,fivelabel}>some setting
This will show this parameter with a list of options from "zerolabel" to "fivelabel". Note that these parameters should be set to
start at 0 and have a change increment of 1, as shown above.
Another extended syntax is:
slider1:/some_path:default_value:slider description
In the above example, the /some_path specifies a subdirectory of the REAPER\Data path, which will be scanned for .wav, .txt, .ogg, or .raw files. default_value defines a default filename. If this is used, the script will generally use file_open(slider1) in the @serialize code section to read the contents of the selected file.
- filename:0,filename.wav
These lines can be used to specify filenames which can be used by code later.
These definitions include 0 (the index) and a filename. The indices must be listed in order without gaps -- i.e. the first should always be 0, the second (if any) always should be 1, and so on.
To use for generic data files, the files should be located in the REAPER\Data directory, and these can be opened with file_open(), passing the filename index.
You may also specify a PNG file. If you specify a file ending in .png, it will be opened from the same directory as the effect, and you can use the filename index as a parameter to gfx_blit(). -- REAPER 2.018+