Audio — spectrum, beats & synth
Sound is part of the graph, not bolted on. ONDA covers three things: playing an audio clip on the timeline, reacting to music (beats and spectrum, frame-accurate), and synthesising audio from a declarative graph.
<Audio> — a clip on the timeline
Section titled “<Audio> — a clip on the timeline”A non-visual node that plays during preview and is muxed into the MP4 on export (GIF has no audio track).
import { Audio, Sequence } from 'onda-engine/react'
<Sequence from={30}> <Audio src="/score.mp3" start={1} startAt={0.5} volume={0.8} /></Sequence>src— path, URL, ordata:URI.start— composition time (seconds) at which it begins. Default0.startAt— seconds into the source to begin from (trim the head). Default0.volume— linear gain0..1. Default1.
@onda-engine/components wraps this with a fade envelope as <AudioClip>.
Audio-reactive motion — cut to the music
Section titled “Audio-reactive motion — cut to the music”@onda-engine/components analyses a clip into a frame-unit beat grid that is deterministic and identical in preview and export. Drive motion straight from it.
import { useAudioBeats, beatPulse, isBeat } from 'onda-engine/components'
function Kick({ src }) { const frame = useCurrentFrame() const b = useAudioBeats(src) // { tempo, beats, onsets, onsetEnv } const pulse = beatPulse(frame, b?.beats ?? []) // 1 → 0 punch on each beat return <Rect scaleX={1 + 0.3 * pulse} scaleY={1 + 0.3 * pulse} /* … */ />}useAudioBeats(src)→{ tempo, beats, onsets, onsetEnv }, all in frame units.beatPulse(frame, beats, decay?)— a1 → 0punch on each beat (hit an element on the kick).isBeat(frame, beats)— boolean, for hard cuts on the beat.onsetEnv[frame](0..1) — transient energy, for glows and shakes.useAudioData(src)→ the lower-levelAudioAnalyzer(spectrogram bands) behind a spectrum<AudioVisualizer>.
Analysis runs through @onda-engine/wasm-audio (symphonia + rustfft), so the browser and native export compute identical spectra and beat grids.
Synthesis — a declarative AudioGraph
Section titled “Synthesis — a declarative AudioGraph”ONDA generates sound too. audio-rs defines a declarative AudioGraph (the audio analogue of the scene graph): voices summed through an optional reverb, each voice an oscillator/chord/noise source shaped by an envelope and optional biquad filter and tremolo. Pure Rust, deterministic, wasm-ready.
- Sources —
Osc { wave },Chord,Noise. - Envelopes —
Adsr { a, d, s, r },ExpDecay { attack, tau }. - Per-voice — biquad
Filter,Tremolo. - Bus — a
Reverbsend.
Good for beds, risers, impacts, stabs and SFX (not real vocals or foley). The synth_json example CLI takes an AudioGraph JSON and writes a WAV — the same path the Studio audio_synth tool drives.
cargo run -p onda-cli --example synth_json -- graph.json out.wavWhat runs where
Section titled “What runs where”| Capability | Browser preview | Native export |
|---|---|---|
<Audio> playback | ✅ plays | ✅ muxed to AAC in MP4 |
beats / spectrum (@onda-engine/wasm-audio) | ✅ | ✅ (identical) |
AudioGraph synthesis | ✅ (wasm) | ✅ |
See also
Section titled “See also”- Effects & finishing — grade the visuals you cut to the beat.
- Composing — complete reference —
useAudioBeatsrecipes.