The complete protocol of the DSP object — the thing that actually makes sound — together with the parameter classes that describe what can be changed inside it.

1. What a DSP is

DSP is an opaque handle on a compiled FAUST program. It is not a Pharo object in the ordinary sense — it wraps memory owned by the FAUST engine, reached over uFFI. That has two practical consequences: it must be initialised before it can do anything, and it must be destroyed to release its memory.

Everything else on this page is a message you can send to that handle. A UGen chain is the description of a sound; the DSP is the running instance of it.

2. Creating a DSP

2.1 From a UGen

The usual route — send one of these to any UGen:

MessageProduces
asDspA mono DSP
asDspWithName:A named DSP — useful when several run at once
asDspMIDIA MIDI-enabled DSP
asDspMIDIWithName:A named MIDI-enabled DSP

Send stereo to the UGen first for two-channel output.

2.2 From FAUST source

A DSP can also be built from a FAUST program as a string, bypassing the UGen layer entirely:

Class-side messageEffect
DSP create: aStringCompile a FAUST program
DSP create: aString withName: aNameThe same, named
DSP defaultNameThe name used when none is given
x1 := DSP create: 'import("stdfaust.lib"); process = os.osc(400);'.
x1 init.
x1 start.

See Raw FAUST & the Box API for when this is worth doing.

2.3 The registry

Phausto keeps track of the DSPs it has created, which is how you find one you have lost the variable for:

Class-side messageReturns
DSP initializedDSPsEvery DSP currently initialised
DSP initializedDSPThe most recently initialised DSP
DSP register: aDspAdd a DSP to the registry
DSP unregister: aDspRemove one
DSP rendererTypeThe audio renderer in use on this platform
Stopping a runaway patch If sound is coming from a DSP you no longer have a reference to, DSP initializedDSPs do: [ :d | d stop ] will silence everything.

3. Lifecycle

MessageEffect
initCompile to native code and allocate buffers. Required once before start
startBegin audio output on the audio thread
stopHalt output; the DSP stays initialised and can be restarted
destroyRelease native memory and unregister
playConvenience: init then start
playFor: aDurationStart, wait, then stop
isInitializedWhether init has run
name / name:The DSP's name
source / source:The UGen this DSP was built from
isMIDI / isMIDI:Whether MIDI support was compiled in
Destroy is not optional Undestroyed DSPs keep their native memory and keep consuming CPU. When iterating on a patch, stop then destroy before rebuilding. See First Sounds §2.2.

4. Parameter access

4.1 Setting

MessageEffect
setValue: aNumber parameter: aStringSet a parameter by name
setValue: aNumber parameterIndex: anIntegerSet by index — skips the name lookup
sweepToValue: aTarget parameter: aString in: secondsMove gradually to a value
sweepToMfValue: aTarget parameter: aString in: secondsThe same, for multiplication-factor parameters

4.2 Reading and discovery

MessageReturns
traceAllParamsPrints every parameter and value to the Transcript
allParametersAll parameters as objects
parametersThe parameter collection
parameterStoreThe DSPParameterStore — see §8
getParamCountHow many parameters exist
getParamValue: aStringCurrent value, by name
getParamValueIndex: anIntegerCurrent value, by index
getParamAddress: anIntegerThe name at a given index
getParamIndex: aStringThe index of a given name
includesParameter: aStringWhether a name exists
Names are addresses A FAUST parameter name is really a path. Nested groups produce names like 'Freeverb/0x00/RoomSize'. Copy them verbatim from traceAllParams rather than reconstructing them.

5. Triggering and performance

MessageEffect
trig: aStringFire a named trigger
trig: aString for: secondsHold a gate open for a duration, then release
playNote: aMidiNN prefix: aString dur: secondsPlay a MIDI note on a prefixed instrument
syncTrigResetReset synchronised triggers to a common origin
startSubBeatStart the sub-beat clock

See Parameters & Control §5 and MIDI & Playing Notes.

6. Interface

MessageOpens
displayUIThe complete generated interface
sliderFor: aStringA slider presenter for one parameter
buttonFor: aStringA button presenter for one trigger
openSliderFor: aStringBuild and open a slider in one step
openButtonFor: aStringBuild and open a button in one step
keyBoardFor: aSynthNameA piano keyboard bound to an instrument
requirePianoKeyboardEnsure the keyboard component is loaded
s := dsp sliderFor: 'SineOscFreq'.
s openInWindow.

7. Introspection

The FAUST engine can describe its own interface, which is how displayUI is built and how the exporters know what controls to generate:

MessageReturns
getJSONThe full FAUST UI description as JSON
getUIfromJSONThe parsed UI structure
getUIItemsEvery UI item
getUIItemsLabeledDictionaryUI items keyed by label
getUIButtonsJust the buttons
getUIKnobsJust the continuous controls
getNumInputNumber of audio inputs
getNumOutputNumber of audio outputs
generatedCodeThe FAUST source that was compiled
soundfilesSound files referenced by the DSP
Reading the generated code dsp generatedCode returns the FAUST program Phausto built from your UGen chain. It is the single best way to understand what an operator actually compiled to — and useful when a patch does not behave as expected.

8. DSPParameter and DSPParameterStore

Beyond raw name-and-value access, Phausto models parameters as objects. This is the layer presets, automation and plugin exports are built on.

class DSPParameter

Represents a single adjustable value: its current value and its valid range. It knows nothing about the UI, the DSP code, or presets — only what the parameter is.

AccessorMeaning
label / label:Display label
shortName / shortName:Abbreviated name
address / address:Full FAUST path
initValue / initValue:Default value
minValue / minValue:Lower bound
maxValue / maxValue:Upper bound
stepValue / stepValue:Increment
type / type:Widget type — slider, button, entry
DSPParameter fromDictionary:Build one from a parsed JSON description
class DSPParameterStore

Holds all parameters of a DSP in one place. UI, presets, automation and the DSP itself read from the store, but the store depends on none of them.

MessageEffect
DSPParameterStore from: aDSPBuild a store for a DSP
parametersThe stored parameters
dsp / dsp:The DSP it belongs to
Separation of concerns The split between DSPParameter (what a parameter is) and DSPParameterStore (where values live) is deliberate. It is what makes it possible to export a patch as a JUCE plugin with a full parameter tree — see Exporting.

9. Exceptions

ExceptionRaised when
DSP uninitializedExceptionA DSP is used before init
DSP invalidExceptionThe DSP could not be compiled or is otherwise unusable
DSP paramExceptionA parameter operation failed
PhBox nullBoxExceptionA box expression produced nothing — usually a connection error

getLastError on PhaustoDynamicEngine returns the FAUST compiler's own message, which is usually more specific than the Pharo-side exception. See Architecture & Internals.

10. Where to go next

DocumentWhat it covers
Parameters & ControlThese messages in the context of actually performing.
Architecture & InternalsWhat sits beneath the DSP handle.
ExportingThe export half of the DSP protocol.
Raw FAUST & the Box APICreating a DSP without UGens.

11. Troubleshooting

An exception says the DSP is not initialised

init must run once before start or any parameter access — §3.

Sound is playing and I have lost the reference

DSP initializedDSPs do: [ :d | d stop ] — §2.3.

getParamValue: returns nothing useful

The name does not exist. Check with includesParameter: first, or list them with traceAllParams — §4.2.

The patch compiles but sounds wrong, and I cannot see why

Read dsp generatedCode. The FAUST source shows exactly what the operators produced — §7.

A null box exception when building the DSP

A connection failed, usually a channel-count mismatch. See Connecting §7, and check PhaustoDynamicEngine getLastError — §9.

The image slows down the longer I work

DSPs are accumulating. Destroy them — §3.