Hello Phausto

Lesson 1 The minimal Phausto program. A sine wave oscillator at 440 Hz (A4), wrapped in a DSP object and started.

In Phausto, every sound is built from Unit Generators (UGens). To hear a UGen, you must wrap it in a DSP object, initialise it, and start it. Evaluate these lines one at a time in a Playground:

step by step Hello Phausto
"Create a new SineWave Oscillator — default frequency is 440 Hz (A4)"
sine := SineOsc new.

"Wrap it in a DSP object"
dsp := sine asDsp.

"Initialise the DSP (compiles the FAUST code to native audio)"
dsp init.

"Start playback — you should now hear the tone"
dsp start.

"Stop the sound"
dsp stop.

The DSP Lifecycle

Every Phausto patch follows the same four-step lifecycle:

Create — build a UGen chain (or a single UGen), then call asDsp to get a DSP object.
Initdsp init compiles the FAUST DSP to native code and allocates audio buffers.
Startdsp start begins audio output. The DSP runs on a separate audio thread.
Stop / Destroydsp stop halts audio. Call dsp destroy to free native resources when done.
MessageEffect
asDspWrap UGen chain in a DSP object (mono)
stereo asDspWrap with stereo output
dsp initCompile and allocate
dsp startBegin audio playback
dsp stopHalt audio output
dsp destroyFree native resources

Hello Stereo

Lesson 2 Most instruments need a stereo output. Add stereo before asDsp to duplicate the signal to both channels.

"Create a Sawtooth oscillator"
saw := SawOsc new.

"Create a STEREO DSP — notice 'stereo' before 'asDsp'"
dsp := saw stereo asDsp.

dsp init.
dsp start.
dsp stop.
Tip
Always use stereo for instruments you plan to run through effects chains. Effects like GreyHole and Freeverb expect stereo input.

Unit Generators 101

Lesson 3 Unit Generators are the atoms of synthesis in Phausto — oscillators, noise generators, envelopes, filters, effects, physical models. All UGens share a common interface.

"White noise is the simplest signal source"
noise := Noise new.
dsp := noise stereo asDsp.
dsp init.
dsp start.

"All UGens have a 'uLevel' parameter — linear volume control"
"Open its UI to see the knob"
dsp displayUI.

dsp stop.

UGen categories

CategoryExamples
OscillatorsSineOsc, SawOsc, TriOsc, SquareOsc, PulseOsc
NoiseNoise
EnvelopesADSREnv
FiltersMoogVcf, PhSvfLp, PhModeFilter
EffectsGreyHole, Freeverb
Physical ModelsDjembe, Marimba, ElecGuitar
LFOsLFOTriPos, LFORandomPos
Pulse generatorsPulse, Pulsen
FM operatorsDx7Op
Common parameter
Every UGen has a uLevel: setter for linear amplitude. Human loudness perception is logarithmic, so small uLevel changes sound more dramatic at lower values.

At the Controls

Lesson 4 Change UGen parameters in real time with setValue:parameter:, or inspect what parameters are available with traceAllParams.

"PulseOsc is a square oscillator with a variable duty cycle"
pulse := PulseOsc new.
dsp := pulse asDsp.
dsp init.
dsp start.

"Change the duty cycle while running"
dsp setValue: 0.2 parameter: 'PulseOscDuty'.

"Change the frequency"
dsp setValue: 120 parameter: 'PulseOscFreq'.

"See all available parameters for this DSP"
dsp traceAllParams.

dsp stop.
method setValue: aNumber parameter: aString
"Set a named DSP parameter in real time.
aNumber — the new value.
aString — exact FAUST parameter label (check traceAllParams or class comments)."
dsp setValue: 440 parameter: 'SineOscFreq'.
method traceAllParams
"Print all parameter labels and current values to the Transcript."
dsp traceAllParams.
Tip
Parameter labels are derived from FAUST slider/button labels. You can also find them in each UGen's class comment, or by calling dsp traceAllParams after init.

Display the UI

Lesson 5 FAUST generates a UI automatically from the slider and button definitions in each module. Call displayUI to open it as a Pharo window.

"Djembe — a physical model of the West African goblet drum"
perc := Djembe new.
dsp := perc asDsp.
dsp init.
dsp start.

"Open the auto-generated UI — press DjembeTrigger to trigger the drum"
dsp displayUI.

"Try substituting Djembe with Marimba for a different timbral character"
dsp stop.

UI parameter types

FAUST elementPhausto classUse
hsliderPhHSliderHorizontal slider (range + step)
nentryPhNumEntryNumerical entry (integer or float)
buttonauto-generatedTrigger (pulse on click)
knobauto-generatedRotary control
Note
Only UI parameters (declared as FAUST sliders/knobs/buttons) can be changed in real time. Internal computed values cannot be modified while the DSP is running.