November 13, 2020
Helpful SuperCollider plugin macros
This is a transcription of Dan Stowell’s very helpful table in the SuperCollider Book (MIT), slightly edited and transcribed for the “new” c++ style for writing plugins. It contains some of the macros available when writing UGens/Plugins in c++ in SuperCollider.
This repo contains example code for writing plugins in both the “old” and “new” style which I found helpful in understanding this subject.
Also check out this cookiecutter template for generating plugins and the Server Plugin API.
Macros
Macro | Description |
---|---|
in(index) | a float* pointer to input number index |
out(index) | a float* pointer to output number index |
in0(index) | a single (control-rate) value from input number index |
out0(index) | a single (control-rate) value at output number index |
inRate(index) | The rate of input index, an integer value corresponding to 1 of the following constants: calc_ScalarRate (scalar-rate), calc_BufRate (control-rate), calc_FullRate (audio-rate), calc_DemandRate (demand-rate) |
set_calc_function<ClassName, &ClassName::next>() | Set the calculation function for ugen ClassName to next |
sampleRate() | Samplerate of the ugen as a double. Note: For control-rate UGens this is not the full audio rate but audio rate/blocksize |
sampleDur() | Reciprocal of sampleRate() (seconds per sample) |
bufferSize() | Equal to the block size if the unit is audio rate and 1 if the unit is control rate |
ClearUnitOutputs(unit, inNumSamples) | Print text to the SuperCollider post window; arguments are just like those for the C function printf |
Print(text) | Print text to the SuperCollider post window; arguments are just like those for the C function printf |
RTAlloc(world, numBytes) | Allocate memory from the real-time pool – analogous to malloc(numBytes) |
RTRealloc(world, pointer, numBytes) | Reallocate memory from the real-time pool – analogous to realloc(pointer, numBytes) |
RTFree(world, pointer) | Free allocated memory back to the real-time pool – analogous to free(pointer) |
fullSampleRate() | The full audio sample rate of the server (irrespective of the rate of the UGen) as a double |
fullBufferSize() | The integer number of samples in an audio-rate input (irrespective of the rate of the UGen) |