Controls
const orchestre = new Orchestre(120);
await orchestre.addPlayers([
{name: 'bass', url: './assets/bass.ogg', length: 16, position: 'absolute'},
{name: 'melody', url: './assets/melody.ogg', length: 8, position: 'relative'},
// etc...
])
orchestre.start();
Play
Activate and deactivate your players to make them play in sync.
There are two kinds of players: absolute and relative. Play around with them to hear the difference!
Absolute
Will always stay on the same beats
Relative
Will play on the first beat when activated
orchestre.play('bass');
orchestre.stop('bass');
// alternate between play and stop
orchestre.toggle('bass');
Options
Orchestre-JS comes with several options to trigger audio layers in different ways.
Play or stop immediately with a fade in and fade out
Play only once
Schedule player on next 2 bars
(Scheduled…)
Stop loop but let the track end
orchestre.toggle('synth', {
now: true,
fade: 1.2
});
orchestre.play('jingle', {
once: true
});
orchestre.schedule("shamisen", 8, "play", {
absolute: true,
});
orchestre.stop("shamisen", {
keep: true,
});
Events
Subscribe to events to trigger actions on beat.
EIGHT!
Called every two beats
await orchestre.wait(8);
let listenerId = orchestre.addListener( () => playAnimation(), 2 );
orchestre.removeListener(listenerId);