Example cookbook
The repository contains complete, compilable patches ranging from a sine wave to convolution, polyphony, feedback matrices, and WebAssembly hosting. Select an Onda example below to open it directly in the browser playground, then edit and run it there. Start small and follow the path that matches what you want to build.
All paths below are relative to the repository root. Run audio examples with:
onda run examples/foundations/sine.onda
Or render one without opening an audio device:
onda run render examples/foundations/sine.onda --output sine.wav --dur 3
Foundations
| Example | What it teaches |
|---|---|
sine.onda |
Params, persistent phase, block and sample rates |
sines.onda |
Combining multiple oscillators |
saw_blep.onda |
Band-limited waveform generation |
dual_osc_oversampled_8x.onda |
Oversampled sample code |
simple_events.onda |
Host-triggered events and persistent state |
Read these after the first-patch guide. They introduce the core execution model without a large abstraction layer.
Processors and graphs
Onda processors package state and behavior into reusable DSP units. Graphs connect those processors declaratively and let the compiler check shapes, rates, and cycles.
saw_filter_saturator.onda combines standard-library oscillator and resonant-filter processors with a custom oversampled drive processor and helper function. It is also the example shown on the project homepage.
| Imperative version | Graph version | Focus |
|---|---|---|
proc_gain.onda |
proc_gain_graph.onda |
A minimal reusable processor |
proc_split.onda |
proc_split_graph.onda |
Multiple outputs and routing |
proc_array_stereo_sine.onda |
proc_array_stereo_sine_graph.onda |
Proc arrays and stereo composition |
reverb_sample.onda |
reverb_graph.onda |
A larger effect in both styles |
Use --dump-graph to inspect the compiler’s resolved graph:
onda compile examples/processors-and-graphs/proc_gain_graph.onda --dump-graph
Standard library
The std modules provide oscillators, filters, envelopes, delay, FFT, convolution, mixing, noise, pitch, smoothing, math, data helpers, and more.
std_osc_shapes.onda— oscillator shapes.std_filter_modes.onda— filter modes.std_env_adsr.onda— an ADSR envelope.std_noise.onda— noise generators.std_smoothing.onda— parameter smoothing.std_mix_gain_pitch.onda— utilities composed together.
Buffers, FFT, and convolution
These examples are more host- and data-oriented:
buffer_looper_read.ondareads a host-bound buffer.sample_player.ondaplays a host-bound clip under event, speed, and audio-rate amplitude control.fft_bin_shift.ondatransforms frequency bins.convolution_impulse.ondaperforms convolution with generated impulse data.convolution_wav_impulse.ondauses a WAV impulse response.
Larger patches
Once the smaller examples feel familiar, explore:
polyphonic_saw.ondafor event-driven polyphony.neural_synth.ondafor a more unusual synthesis design.schroeder_reverb_impulse.ondafor a classic reverberator structure.matrix_feedback_blipblop.ondaand itslushandchaosvariants for complex feedback systems.cybernetic_feedback_graph.ondafor a graph-heavy generative patch.