Skip to content

Latest commit

 

History

History
372 lines (295 loc) · 6.97 KB

api-documentation.md

File metadata and controls

372 lines (295 loc) · 6.97 KB

API Documentation

Configuration

config()

Configures the plugin.

config({
    description,
    inChannels,
    outChannels
}: {
    description: number;
    inChannels: number;
    outChannels: number;
}): void;

Example:

config({ description: 'volume', inChannels: 2, outChannels: 2 });

slider()

Registers a slider and its bound variable to be displayed in the plugin.

slider(
    sliderNumber: number,
    variable: number,
    initialValue: number,
    min: number,
    max: number,
    step: number,
    label: string
): void;

Example:

slider(1, volume, 0, -150, 18, 0.1, 'Volume [dB]');

selectBox()

Registers a select box and its bound variable to be displayed in the plugin.

selectBox(
    sliderNumber: number,
    variable: string,
    initialValue: string,
    values: { name: string; label: string }[],
    label: string
): void;

Example:

selectBox(
    3,
    algorithm,
    'sigmoid',
    [
        { name: 'sigmoid', label: 'Sigmoid' },
        { name: 'htan', label: 'Hyperbolic Tangent' },
        { name: 'hclip', label: 'Hard Clip' }
    ],
    'Algorithm'
);

Debugging

console

JS2EEL only supports the .log() method. console.log() creates a debug variable to print the value of a variable in the JSFX dev environment.

console: {
    log: (someVar: number | string) => void;
};

Example:

let myVal = 3;
console.log(myVal);

JSFX Computation Stages

These functions correspond to JSFX's @sample etc.

onInit()

Init variables and functions here.

onInit(callback: () => void): void;

onSlider()

What happens when a slider is moved.

onSlider(callback: () => void): void;

onSample()

Called for every single sample.

onSample(callback: () => void): void;

eachChannel()

Iterates over each channel and provides the current sample for manipulation.

eachChannel(callback: (sample: number, channel: number) => void): void;

Data Structures

EelBuffer

A fixed-size, multi-dimensional container for audio samples.

Access: buf[dimension][position]

Translates to EEL2s memory objects. Is not inlined in the EEL source, so only feasible for large data. For small data, use EelArray.

EelBuffer {
    constructor(dimensions: number, size: number);

    dimensions(): number;
    size(): number;
}

EelArray

A fixed-size, multi-dimensional container for numeric data.

Access: arr[dimension][position]

Is inlined in the EEL source, dimensions and size are restricted to 16 each. For large data, use EelBuffer.

EelArray {
    constructor(dimensions: number, size: number);

    dimensions(): number;
    size(): number;
}

Audio Constants

srate

The sample rate of your project

srate: number;

num_ch

Number of channels available

num_ch: number;

samplesblock

How many samples will come before the next onBlock() call

samplesblock: number;

tempo

The tempo of your project

tempo: number;

play_state

The current playback state of REAPER (0=stopped, <0=error, 1=playing, 2=paused, 5=recording, 6=record paused)

play_state: number;

play_position

The current playback position in REAPER (as of last @block), in seconds

play_position: number;

beat_position

Read-only. The current playback position (as of last @block) in REAPER, in beats (beats = quarternotes in /4 time signatures).

beat_position: number;

ts_num

Read-only. The current time signature numerator, i.e. 3.0 if using 3/4 time.

ts_num: number;

ts_denom

Read-only. The current time signature denominator, i.e. 4.0 if using 3/4 time.

ts_denom: number;

spl<1-64>

Channel 1 (L) sample variable

spl0: number;

Math Constants

$pi

Pi

$pi: number;

Math Functions

These functions correspond exactly to their equivalents in JSFX/EEL2.

sin()

Returns the Sine of the angle specified (specified in radians).

sin(angle: number): number;

cos()

Returns the Cosine of the angle specified (specified in radians).

cos(angle: number): number;

tan()

Returns the Tangent of the angle specified (specified in radians).

tan(angle: number): number;

asin()

Returns the Arc Sine of the value specified (return value is in radians).

asin(x: number): number;

acos()

Returns the Arc Cosine of the value specified (return value is in radians).

acos(x: number): number;

atan()

Returns the Arc Tangent of the value specified (return value is in radians).

atan(x: number): number;

atan2()

Returns the Arc Tangent of x divided by y (return value is in radians).

atan2(x: number, y: number): number;

sqr()

Returns the square of the parameter (similar to x*x, though only evaluating x once).

sqr(x: number): number;

sqrt()

Returns the square root of the parameter.

sqrt(x: number): number;

pow()

Returns the first parameter raised to the second parameter-th power. Identical in behavior and performance to the ^ operator.

pow(x: number, y: number): number;

exp()

Returns the number e (approx 2.718) raised to the parameter-th power. This function is significantly faster than pow() or the ^ operator.

exp(x: number): number;

log()

Returns the natural logarithm (base e) of the parameter.

log(x: number): number;

log10()

Returns the logarithm (base 10) of the parameter.

log10(x: number): number;

abs()

Returns the absolute value of the parameter.

abs(x: number): number;

min()

Returns the minimum value of the two parameters.

min(x: number, y: number): number;

max()

Returns the maximum value of the two parameters.

max(x: number, y: number): number;

sign()

Returns the sign of the parameter (-1, 0, or 1).

sign(x: number): number;

rand()

Returns a pseudo-random number between 0 and the parameter.

rand(x: number): number;

floor()

Rounds the value to the lowest integer possible (floor(3.9)==3, floor(-3.1)==-4).

floor(x: number): number;

ceil()

Rounds the value to the highest integer possible (ceil(3.1)==4, ceil(-3.9)==-3).

ceil(x: number): number;

invsqrt()

Returns a fast inverse square root (1/sqrt(x)) approximation of the parameter.

invsqrt(x: number): number;