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.

Buffers, FFT, and convolution

These examples are more host- and data-oriented:

Larger patches

Once the smaller examples feel familiar, explore: