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.
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+
All memory and variables are zero on load, and if no @serialize code section is defined, then all memory and variables will be re-zeroed before calling @init (on samplerate change, playback start/stop/etc).
Note when saving the state of variables or memory, they are stored in a more compact 32 bit representation, so a slight precision loss is possible. Note also that you should not clear any variables saved/loaded by @serialize in @init, as sometimes @init will be called following @serialize.
The @gfx section has two optional parameters, which can specify the desired width/height of the graphics area. Set either of these to 0 (or omit them) to specify that the code doesn't care what size it gets. Note that these are simply
hints to request this size -- you may not always get the specified size. Your code in this section should use the gfx_w, gfx_h variables to actually determine drawing dimensions.