SAOL / SASL Quick Reference
This quick-reference document is intended to provide an overview of the syntax of the MPEG-4 structured audio languages. No attempt has been made to cover all of the complexities of the SAOL language, such as the rate and width semantics governing evaluation of expressions and control structures. For a full description of MPEG-4 SA please consult ISO/IEC 14496-3 sec5 available from the MPEG-4 structured audio home page: http://sound.media.mit.edu/mpeg4/Top-level constructs
// global block:instr | name( [ pname1[, pname2 ...] ] )[ preset int [int ...] ]{ | |
[variable declarations] | ||
[instrument statements] } |
opcoderate | name( [ prate p0name[, prate p1name ...] ] ){ | |
[variable declarations] | ||
[opcode statements] } | ||
// opcoderate is one of: aopcode, kopcode, iopcode, opcode | ||
// prate is one of: asig, ksig, ivar, xsig | ||
// formal params can be arrays and can also be table references. |
template | < name[, name ...] > [ preset maplist ]( [ pname1[, pname2 ...] ] ) | |
map{ ident[, ident ...] }with{ maplist }{ | ||
[variable declarations] | ||
[opcode statements] } |
instr | startup( ... ){ ... } |
// if defined, the startup instrument is run at i-rate after global | |
// variables have been initialised to 0 but before global tables are | |
// instansiated. |
Global statements
// global parameters:srate int; | // default 32000 Hz |
krate int; | // default 100 Hz |
inchannels int; | // defaults to number of input sources or 0 |
outchannels int; | // default 1 |
interp int; | // 0==low, 1==hi. default low |
route(bus, instr1[, instr2 ...]); | // routes outputs of instrs onto bus |
send(instr; [instrParams]; bus1[, bus2...]); | // create instr to process busses |
sequence(instr1[, instr2 ...]); | // define evaluation order for instruments |
Instrument variable declarations
[sharingtag] ivar name[, name ...]; // sharingtag: imports, exports, imports exports// ivar, ksig and asig names can be single valued or arrays: | |
name[ int ] | // int can be a literal or inchannels or outchannels |
table name(genroutine, size [, genparams ...]); | //local wavetable |
sharingtag table name[, name ...]; | // wavetable placeholder |
oparray opname[int]; | |
tablemap name(table1[, table2 ...]); |
Instrument statements
// control structures:lvalue = expr; | // evaluate expr and assign its value to lvalue |
expr; | // evaluate expression (execute opcodes etc) |
Arithmetic and logical operators (in order of precedence)
! | // logical negation (not) |
- | // arithmetic negation (unary minus) |
*, / | // multiplication, division |
+, - | // addition, subtraction |
<, >, <=, >= | // relational |
==, != | // equality, inequality |
&& | // logical and |
|| | // logical or |
expr ? expr : expr | // switch |
Miscellaneous expressions
( expr ) | // expression grouping |
name[expr] | // array or tablemap access |
opcodename(expr[, expr]) | // opcode call |
opcodename[expr]( expr[, expr]) | // oparray call |
Standard names
k_rate | // control rate in Hz |
s_rate | // sampling rate in Hz |
inchan | // number of channels of input to current instrument |
outchan | // number of channels of output by current instrument (see DCOR2.10) |
time | // instantiation time of current note |
dur | // duration of note or -1 if unknown |
itime | // elapsed time of note in seconds |
MIDIctrl[128] | // MIDI controllers for current instrument channel |
MIDItouch | // polyphonic aftertouch for current note |
MIDIbend | // pitch bend for current instrument channel |
channel | // extended MIDI channel of current note |
preset | // preset of current note |
input[inchannels] | // input signal(s) provided by the send instruction |
inGroup[inchannels] | // grouping of input signals to current note |
released | // 1 if note is about to be destroyed, otherwise 0 |
cpuload | // approximate cpu usage of current note |
position[3] | // BIFS scene graph node position |
direction[3] | // BIFS scene graph node direction |
listenerPosition[3] | // BIFS scene graph listener position |
listenerDirection[3] | // BIFS scene graph listener direction |
minFront, maxFront | // radiation pattern of soundNode see ISO/IEC 14496-1 c9 |
minBack, maxBack | // radiation pattern of soundNode see ISO/IEC 14496-1 c9 |
params[128] | // params of BIFS AudioFX node |
Mathematical Functions
opcode int(xsig x)Pitch Converters
opcode gettune()Tempo Functions
opcode gettempo([xsig dummy])Noise generators
iopcode irand(ivar p)Table operations
opcode ftlen(table t)Table based generators
aopcode oscil(table t, sig freq[, ivar loops])Signal generators
kopcode kline(ivar x1, ivar dur1, ivar x2[, ivar dur2, ivar x3, ...])Filters
kopcode port(ksig ctrl, ksig htime)Spectral analysis
specialop fft(asig input, table re, table im[, ivar len, ivar shift, ivar size, table win])Gain control
specialop rms(asig x[, ivar length])Sample conversion
specialop decimate(asig input)Delays
aopcode delay(asig x, ivar t)Effects
aopcode reverb(asig x, ivar f0[, ivar r0, ivar f1, ivar r1, ivar ...])Core wavetable generators
table name(sample, size, which[, skip])SASL syntax
// note that the optional * at the beginning of a score line indicates that the