Hybrid synth + sampler + tracker audio plugin for Clayground. One coherent
engine, two wrappers for pre-existing assets (Sound, Music), and a
small instrument/sequencer layer on top (SynthInstrument,
SampleInstrument, SongPlayer, ChipMood/MoodPlayer). Offline render
is first-class and deterministic.
See docs/docs/manual/dojo.md for how to hot-reload song files without
resetting the playhead (.dojoignore).
Getting Started
import Clayground.Sound
Components
Sound
For short sound effects (fire-and-forget). Supports overlapping playback with
instance pooling for efficiency.
Sound {
id: jumpSound
source: "sounds/jump.wav"
volume: 0.8
lazyLoading: false // preload by default
}
// Usage
onJumped: jumpSound.play()
onReset: jumpSound.stop() // stops all playing instances
WASM: full support — the same QAudioSink-driven engine as desktop,
through Qt Multimedia's emscripten backend. See "What Music cannot do
on WASM" below.
Desktop/Mobile: Full support — all types above work end-to-end.
What Music cannot do on WASM
Qt's WebAssembly media backend plays a Music source through an HTML
element and reports almost nothing back, so on the web
(and only there):
status and loaded stay at their initial values until the track ends
duration and position stay 0
loop has no effect — the track plays once
A background loop on the web therefore needs a Sound re-triggered by a
Timer at the clip length, the way Music was worked around before it
played at all (see #216).
Technical Notes
Audio is fully preloaded before playback (no streaming)
WASM: Web Audio API requires user gesture to start AudioContext
WASM: Remote URLs must be CORS-enabled
Desktop: Uses QAudioSink for all in-engine types, QMediaPlayer for Music
Hot-reload: SongPlayer watches its source file; drop a .dojoignore
(songs/ or *.song.json) next to your Sandbox.qml to prevent the
dojo from reloading the whole scene on song edits