SoundFont
constructor.
Path to the SoundFont directory.
Loads SoundFont configuration from a soundfont.json
file in the base URL
directory. Does not load any of the samples.
Load samples necessary to play a set of notes. This must be called before any notes can be played.
Array of program/isDrum/pitch/velocity for notes that will be loaded.
Play a note using one of the sampled instruments.
Pitch of the note.
Velocity of the note.
Time at which to start playing the note.
Length of the note in seconds.
Program number to use for instrument lookup.
Drum status to use for instrument lookup.
Output AudioNode
.
Strikes a note down using one of the sampled instruments. If you call this twice without calling playNoteUp() in between, it will implicitly release the note before striking it the second time.
Pitch of the note.
Velocity of the note.
Program number to use for instrument lookup.
Drum status to use for instrument lookup.
Output AudioNode
.
Releases a note using one of the sampled instruments. If you call this twice without calling playNoteDown() in between, it will not implicitly call playNoteDown() for you, and the second call will have no noticeable effect.
Pitch of the note.
Velocity of the note.
Program number to use for instrument lookup.
Drum status to use for instrument lookup.
Output AudioNode
.
Generated using TypeDoc
Multi-instrument SoundFont. Must be initialized and samples must be pre-loaded using the
loadSamples
method before any notes can be played.If you want to use your own SoundFont samples, your SoundFont directory must have this structure:
└─your_local_soundfont |-- soundfont.json |-- instrument_name (for each of the instruments listed in soundfont.json) |-- instrument.json |-- p1_v1.mp3 |-- p1_v2.mp3 |-- ... |-- p${PITCH}_v${VELOCITY}.mp3, for all the pitches and velocities you want to support
The soundfont.json file contains the name of the SoundFont, as well as all the available instruments. The sgm_plus/soundfont.json for example looks like: { "name": "sgm_plus", "instruments": { "0": "acoustic_grand_piano", "1": "bright_acoustic_piano", "2": "electric_grand_piano", ... }
For each of the instruments listed in the soundfont.json file, the instrument.json contains an InstrumentSpec. For example, the sgm_plus/acoustic_grand_piano/instrument.json:
{ "name": "acoustic_grand_piano", "minPitch": 21, "maxPitch": 108, "durationSeconds": 3.0, "releaseSeconds": 1.0, "percussive": false, "velocities": [15, 31, 47, 63, 79, 95, 111, 127] }