Skip to content

Samples

Playback of authored audio: teacher uploads, story narration, arcade voice lines, ambience beds. The engine names these sounds because the engine owns the content; SuperCollider loads and plays them. Game feedback — the chime when a hold is hit — is NOT a sample the engine asks for: SuperCollider chooses it from the mode’s own messages.

/sample/load

engine → sc state since 0.2.0

Load an audio file into memory under a key.

s key
s path
ss
key s string
The name everything else will use for this sound, e.g. "savanna/giraffe". Letters, digits, dashes and slashes. Loading a key that is already loaded replaces it.
path s string
File path relative to the /sys/assets root. WAV, AIFF or FLAC; mono or stereo.

Acknowledged by /sample/loaded.

packet /sample/load savanna/giraffe stories/savanna/giraffe.wav
SuperCollider NetAddr("127.0.0.1", 57120).sendMsg('/sample/load', "savanna/giraffe", "stories/savanna/giraffe.wav");
engine (C#) osc.Send(Osc.SampleLoad, "savanna/giraffe", "stories/savanna/giraffe.wav");

Load everything a mode will name before /mode/load, then wait for every /sample/loaded. Loading reads from disk and is not instant; a sample played before it has loaded is silence.

Marked `rate: state` on purpose: the set of loaded samples is state, and after a SuperCollider restart the engine re-sends every /sample/load as part of /sys/sync.

/sample/loaded

sc → engine event since 0.2.0

A sample has finished loading, or failed to.

s key
i ok
f duration
s detail
sifs
key s string
The key from /sample/load.
ok i int32 0 | 1
1 on success, 0 on failure.
duration f float32 seconds
Length of the file. 0.0 on failure.
detail s string
Empty on success; the reason on failure, e.g. "file not found".
packet /sample/loaded savanna/giraffe 1 2.4
SuperCollider ~osc[\sampleLoaded].value("savanna/giraffe", 1, 2.4, "");
engine (C#) // handler for Osc.SampleLoaded

/sample/free

engine → sc event since 0.2.0

Release a sample's memory.

s key
s
key s string
The key to free. Freeing an unknown key is a no-op.
packet /sample/free savanna/giraffe
SuperCollider NetAddr("127.0.0.1", 57120).sendMsg('/sample/free', "savanna/giraffe");
engine (C#) osc.Send(Osc.SampleFree, "savanna/giraffe");

Stops any instance still playing first. Free a story's samples when leaving the mode; a day of uploads adds up.

/sample/play

engine → sc event since 0.2.0

Play a loaded sample.

s key
s bus
f gain
f pan
i loop
ssffi
key s string
A key that has been loaded. Unknown keys are logged and ignored.
bus s string "voice" | "music" | "ambience" | "sfx" | "content"
Which mix bus it plays on — see /audio/bus/volume.
gain f float32 0.0 – 1.0normalizeddefault 1.0
Level for this instance, before the bus level.
pan f float32 -1.0 – 1.0default 0.0
Horizontal position across the wall, -1.0 left edge to 1.0 right edge. Narration stays at 0.0.
loop i int32 0 | 1default 0
1 loops until /sample/stop — for ambience beds.
packet /sample/play savanna/narration-01 voice 1.0 0.0 0
SuperCollider NetAddr("127.0.0.1", 57120).sendMsg('/sample/play', "savanna/narration-01", "voice", 1.0, 0.0, 0);
engine (C#) osc.Send(Osc.SamplePlay, "savanna/narration-01", "voice", 1.0f, 0.0f, 0);

Playing a key that is already playing starts a second instance. A non-looping instance reports /sample/ended when it finishes.

/sample/stop

engine → sc event since 0.2.0

Stop every playing instance of a sample.

s key
f fade
sf
key s string
The key to stop.
fade f float32 0.0 – 10.0secondsdefault 0.1
Fade-out time. 0.0 cuts instantly, which will click.
packet /sample/stop savanna/ambience 2.0
SuperCollider NetAddr("127.0.0.1", 57120).sendMsg('/sample/stop', "savanna/ambience", 2.0);
engine (C#) osc.Send(Osc.SampleStop, "savanna/ambience", 2.0f);

/sample/ended

sc → engine event since 0.2.0

A sample instance has stopped playing.

s key
i completed
si
key s string
The key that stopped.
completed i int32 0 | 1
1 if it played to the end, 0 if it was stopped or cut off.
packet /sample/ended savanna/narration-01 1
SuperCollider ~osc[\sampleEnded].value("savanna/narration-01", 1);
engine (C#) // handler for Osc.SampleEnded

This is how the engine sequences narration against lights: play a line, wait for its /sample/ended, light the next hold. SuperCollider knows exactly when audio finishes; the engine can only guess from the duration, and the guess drifts.

Looping instances report only when stopped.