Custom Instruments (load)

Handel allows custom instruments to be loaded into Handel Programs.

Instruments can be created and added to a run of a Handel program as follows:

let myinst = Handel.MakeInstrument({
A1: 'https://tonejs.github.io/audio/casio/A1.mp3',
A2: 'https://tonejs.github.io/audio/casio/A2.mp3'
})
let config = {}
config.instruments = {funkyinst: myinst}
Handel.RunHandel(`
start
load funkyinst as funky
chunk example
play E4 for 4b
endchunk
run example with sound funky
finish
`, config)

The MakeInstrument function wraps Tone.js's sampler constructor. It takes a urls object as its argument. This urls object, maps note names matched to their location (locally or not). One or more mappings can be used.

After making an instrument above, we add it to our config object and run the Handel program with that config.

Within the Handel program we load the instrument as follows: load configInstrumentName as nameOfInstrumentWithinHandel

Note: this feature makes your Handel program less portable but gives you the freedom of using arbitrary instruments in your Handel program.