startOrchestra

Built-ins

Canonical ID: music.startOrchestra. Nederlands: startOrkest.

Starts up to 16 synchronized musical parts on one named track without blocking the program.

Signature

startOrchestra(track, parts, tempo = 120, loop = false, tempoChanges = [])

Each part is a list [instrument, score] or [instrument, score, volume]. Volume defaults to 100 and ranges from 0 to 100. The parts value may be a literal, variable or computed list.

Example

# language: en
let parts = [
    ["gm.acoustic-grand-piano", "C4+E4+G4:2 F4+A4+C5:2", 75],
    ["gm.cello", "C3:2 F2:2", 60],
    ["drums", "C2:1 D2:1 C2:1 D2:1", 35]
]
startOrchestra("song", parts, 120, false, [[2, 90]])
wait(3)

The first two beats use 120 BPM, then all parts change to 90 BPM. The four-beat arrangement lasts about 2.33 seconds.

Parts, volume and looping

All parts share one start time. The longest score sets the common length; shorter parts rest until that boundary. When loop is true, the whole arrangement repeats together.

The orchestra uses one named track. setTrackVolume(track, percentage), stopTrack(track) and replacement affect every part. Part, track and master volume multiply. Starting another orchestra on the same name replaces its audio and preserves that track’s volume.

Choose an exact gm. instrument ID, drums, or chip, bell, pluck, flute. The block/composer instrument picker contains all 128 GM programs. Scores accept single notes, rests and chords such as C4+E4+G4:2. For drums, B1–A5 select the 47 percussion sounds.

Tempo changes and bounds

tempoChanges is a list of up to 256 [beat, BPM] pairs. Beat positions start at zero, increase strictly and fall before the longest score ends. BPM must be 20–400. A marker at zero overrides tempo; markers repeat each loop. Notes crossing a marker remain held.

There must be 1–16 parts and at most 4096 score events across them. Each score lasts at most 4096 beats, with event durations of 1/64–64 beats and up to eight distinct pitches per chord. Playback shares the host’s limit of 32 simultaneous sounding notes. There are at most 16 named tracks. Invalid arguments leave existing playback unchanged.

Keep looping playback alive with events, a game loop or a positive wait. Normal completion stops loops; Stop/Reset stop playback. Synthesized audio works in the IDE, playground and supported native Windows/Linux/Raspberry Pi exports. The text-only CLI and phone preview do not play it.

Composer and MIDI input · startMelody · setTrackVolume