The following are the types of the Sema intermediate representation
This is the top level node of the tree, and contains an array of branches
{ "@lang" : [branches]}
Execute a branch of a tree
{ "@spawn":<branch>}
{"@num":{value:val}}
{"@string":val}
Set a variable.
{"@setvar": {"@varname":<string>,"@varvalue":value}};
Get a variable
{"@getvar":<string>}
@sigp represents a signal processor or signal generation. It looks like this:
{"@sigp": {"@params":[params], "@func":<string>}}
It needs a function name, and an array of parameters. You can use any of the options below:
Get a signal from the system default input Parameters:
- Gain
Output a signal to the system default audio interface
Parameters:
- Signal
- (optional) Channel number (starting from 0)
If parameter 2 is to given, then the signal is copied to all the outputs
A saw oscillator Parameters:
- Frequency (Hz)
- Initial Phase (0 - 1)
A sinewave oscillator Parameters:
- Frequency (Hz)
- Initial Phase (0 - 1)
A triangle wave oscillator Parameters:
- Frequency (Hz)
- Initial Phase (0 - 1)
A square wave oscillator Parameters:
- Frequency (Hz)
- Initial Phase (0 - 1)
A phasor, rising from 0 to 1 Parameters:
- Frequency (Hz)
- Initial Phase (0 - 1)
A phasor with configurable start and end levels Parameters:
- Frequency (Hz)
- Start level
- End level
- Initial Phase (0 - 1)
A pulse oscillator with modulatable phase width Parameters:
- Frequency (Hz)
- Phase width (0-1)
- Initial Phase (0 - 1)
An impulse generator Parameters:
- Frequency (Hz)
- Initial Phase (0 - 1)
An band limited saw wave oscillator Parameters:
- Frequency (Hz)
- Initial Phase (0 - 1)
An white noise generator Parameters:
- Amplitude
Creates a sampler with a signal input, the sample plays when the input has a positive zero crossing
- Input signal
- Sample name
Creates a sampler that plays in a continuous loop
- Speed
- Sample name
Slice up a sample
- Trigger, on which to set the sample position
- The sample position to set when a trigger is received (0-1)
- The sample name
Sample and hold
- Input signal
- Hold time (ms)
Outputs 1 if
- A
- B
Outputs 1 if
- A
- B
A modulo B Parameters:
- A
- B
- A
- B
- A
- B
- A
- B
- A
- B
- A
- B
The absolute value of A Parameters:
- A
Sums all parameters
Product of all parameters
Mean of all parameters
ADSR envelope generator Parameters:
- Trigger
- Attack (ms)
- Decay (ms)
- Sustain (0-1)
- Release (ms)
Triggered line generator Parameters:
- Trigger
- Time (ms) to rise from 0 to 1
Map input into a linear range, assuming bipolar source (between -1 and 1) Parameters:
- Input signal
- Lower bound of destination range
- Upper bound of destination range
Map input into an exponential range, assuming bipolar source (between -1 and 1) Parameters:
- Input signal
- Lower bound of destination range
- Upper bound of destination range
Map input into a linear range, assuming unipolar source (between 0 and 1) Parameters:
- Input signal
- Lower bound of destination range
- Upper bound of destination range
Map input into an exponential range, assuming unipolar source (between 0 and 1) Parameters:
- Input signal
- Lower bound of destination range
- Upper bound of destination range
Map input into a linear range, specifying the range of the source Parameters:
- Input signal
- Lower bound of source range
- Upper bound of source range
- Lower bound of destination range
- Upper bound of destination range
Map input into an exponential range, specifying the range of the source Parameters:
- Input signal
- Lower bound of source range
- Upper bound of source range
- Lower bound of destination range
- Upper bound of destination range
Tanh distortion
- Input signal
- Distortion level (0 upwards)
Asymmetric wave shaping
- Input signal
- The curve shape for values below zero (e.g. 2 = squared, 3 = cubed, 0.5 = square root)
- The curve shape for values above zero
Delay
- Input signal
- Delay time (in samples)
- Feedback
Flanger
- Input signal
- Delay (ms)
- Feedback (0-1)
- Speed (Hz)
- Depth (0-1)
Flanger
- Input signal
- Delay (ms)
- Feedback (0-1)
- Speed (Hz)
- Depth (0-1)
Reverb Arguments:
- Input signal
- Room size (0-1)
- Absorption (0-1)
One pole lowpass filter
- Input signal
- Filter amount (0-1)
One pole highpass filter
- Input signal
- Filter amount (0-1)
Resonant lowpass filter
- Input signal
- Filter frequency (Hz)
- Resonance
Resonant lowpass filter
- Input signal
- Filter frequency (Hz)
- Resonance
State variable filter
- Input signal
- Cutoff frequency (Hz)
- Resonance
- Low pass filter amount (0-1)
- Band pass filter amount (0-1)
- High pass filter amount (0-1)
- Notch filter amount (0-1)
Creates a transducer for sending a signal to a javascript model
- A trigger, on which to send data
- The channel number
- Data value (this can be a list or a number)
- The block size of the data
Creates a transducer for receiving a signal from a javascript model
- Channel (a number)
- A trigger, indicating when to read from the channel. A zero here indicates that the channel will be read whenever data is available.
These functions are paired with 'input' and 'output' in the machine learning window
Choose when to bring in new code changes
- 1 = at the start of the next bar, 0 = immeadiately
Phasor derived from constantly running clock phasor
- Number of cycles per bar
- Phase offset (0-1)
Trigger derived from constantly running clock phasor
- Number of triggers per bar
- Phase offset (0-1)
Set the clock
- Beats per minute
- The number of beats in a bar
Create a trigger on a zero crossing
- A signal
Create a trigger when a change occurs in the input signal
- A signal
- Tolerance (a trigger will be generated if the change is more than +/- this value)
Counts up when receiving a trigger
- Input trigger
- Reset trigger
Index into a list
- Trigger input - output a value when triggered
- The index of the value to be output when a trigger is received (normalised to between 0 and 1)
- A list of values
Mouse X coordinate in the sema client window, normalised to between 0 and 1
Mouse Y coordinate in the sema client window, normalised to between 0 and 1
Some simple helper functions are available within the scope of the grammar scripts to aid in putting together trees in a more readable way:
// create the tree structure for a number
function num(val) {
return { "@num": { value: val } };
}
// create the tree structure for a string - useful for naming samples
function str(val) {
return { "@string": val };
}
// create the tree structure for a DSP function
function synth(functionName, params) {
let branch = {
"@sigp": { "@params": params, "@func": { value: functionName } }
};
return branch;
}
// create the tree structure for setting a variable
function setvar(name, value) {
return { "@setvar": { "@varname": name, "@varvalue": value } };
}
// create the tree structure for reading a variable
function getvar(name) {
return { "@getvar": name };
}
You can create your own helper functions in the first portion of the grammar between @{%
and %}
.