back to main JSFX reference page


JSFX Programming Reference - Special Variables
  • Special Variables


    top  Special Variables

    Basic Functionality: Audio and transport state:
    • srate
      Context: available everywhere
      Usage: read-only
      The srate variable is set by the system to whatever the current sampling frequency is set to (usually 44100 to 192000). Generally speaking your @init code section will be called when this changes, though it's probably a good idea not to depend too much on that.

    • num_ch
      Context: most contexts (see comments)
      Usage: read-only
      Specifies the number of channels available (usually 2). Note however splXX are still available even if this count is less, their inputs/outputs are just ignored. You can change the channel count available via in_pin:/out_pin: lines.

    • samplesblock
      Context: most contexts (see comments)
      Usage: read-only
      The samplesblock variable can be used within @block code to see how many samples will come before the next @block call. It may also be valid in other contexts (though your code should handle invalid values in other contexts with grace).

    • tempo
      Context: @block, @sample
      Usage: read-only
      The current project tempo, in "bpm". An example value would be 120.0.

    • play_state
      Context: @block, @sample
      Usage: read-only
      The current playback state of REAPER (0=stopped, <0=error, 1=playing, 2=paused, 5=recording, 6=record paused).

    • play_position
      Context: @block, @sample
      Usage: read-only
      The current playback position in REAPER (as of last @block), in seconds.

    • beat_position
      Context: @block, @sample
      Usage: read-only The current playback position (as of last @block) in REAPER, in beats (beats = quarternotes in /4 time signatures).

    • ts_num
      Context: @block, @sample
      Usage: read-only The current time signature numerator, i.e. 3.0 if using 3/4 time.

    • ts_denom
      Context: @block, @sample
      Usage: read-only The current time signature denominator, i.e. 4.0 if using 3/4 time.

    Extended Functionality:
    • ext_noinit
      Context: @init only
      Set this variable to 1.0 in your @init section if you do not wish for @init to be called (and variables/RAM to be possibly cleared) on every transport start.

    • ext_nodenorm
      Context: @init only
      Set this variable to 1.0 in your @init section if you do not wish to have anti-denormal noise added to input.

    • reg00-reg99
      Context: available everywhere
      Usage: read/write
      The 100 variables reg00, reg01, reg02, .. reg99 are shared across all effects and can be used for inter-effect communication. Their use should be documented in the effect descriptions to avoid collisions with other effects. regXX aliases to _global.regXX.

    • _global.* -- -- REAPER 4.5+
      Context: available everywhere
      Usage: read/write
      Like regXX, _global.* are variables shared between all instances of all effects.
    Delay Compensation (PDC):
    • pdc_delay
      Context: @block, @slider
      Usage: read-write
      The current delay added by the plug-in, in samples. Note that you shouldnt change this too often. This specifies the amount of the delay that should be compensated, however you need to set the pdc_bot_ch and pdc_top_ch below to tell JS which channels should be compensated.

    • pdc_bot_ch, pdc_top_ch
      Context: @block, @slider
      Usage: read-write
      The channels that are delayed by pdc_delay. For example:
       
          pdc_bot_ch=0; pdc_top_ch=2; // delays the first two channels (spl0/spl1).
          pdc_bot_ch=2; pdc_top_ch=5; // delays channels spl2,spl3, and spl4.
          
      (this is provided so that channels you dont delay can be properly synchronized by the host).

    • pdc_midi
      Context: @block, @slider
      Usage: read-write
      If set to 1.0, this will delay compensate MIDI as well as any specified audio channels.

    Graphics and Mouse:
    • gfx_* and mouse_* are also defined for use in @gfx code.

    MIDI Bus Support:
    • There are also variables defined for accessing MIDI Buses.






  •   Home
        Company
        Reviews
        Radio
      About
        Technical
        Old Versions
        Language Packs
        ReaPlugs
        Distribution
      Developer
        Theme Development
        Custom Cursors
        JSFX Programming
        ReaScript
        Extensions SDK
        Extensions to VST SDK
        OSC
        Language Pack Template
      Resources
        User Guide
        Videos
        Stash
        Forum