-
-
Notifications
You must be signed in to change notification settings - Fork 17
SoundFont Manager
The soundfont manager allows for handling multiple soundfonts with a single synthesizer instance.
It is accessible via the synth.soundfontManager
property.
Every operation sends a new presetlist
event.
synth.soundfontManager.soundfontList;
Which is a list of objects defined as follows:
- id -
string
- the unique soundfont identifier. - bankOffset -
number
- the bank offset for the soundfont.
The list is ordered from the most important soundfont to the least (e.g., first soundfont is used as a base and other soundfonts get added on top (not override))
Important
When first creating the synthesizer,
soundfontList contains one soundfont with the identifier main
and bank offset of 0.
The behavior is defined as follows:
- The program looks for the first soundfont that has the requested program:bank combo and uses it.
- If not found, the program looks for the first soundfont that has the requested program number and uses it.
- If not found, the program uses the first preset of the first soundfont.
This function adds a new soundfont at the top of the soundfont stack.
await synth.soundfontManager.addNewSoundFont(soundfontBuffer, id, bankOffset = 0);
- soundfontBuffer -
ArrayBuffer
- the soundfont binary data. - id -
string
- unique ID for the soundfont. Any string as long as it's unique. - bankOffset -
number
, optional - the bank offset for the soundfont.
Important
This function is asynchronous.
This function removes a specified soundfont.
synth.soundfontManager.deleteSoundFont(id);
- id -
string
- unique ID for the soundfont to delete.
This function reorders the soundfonts.
synth.soundfontManager.rearrangeSoundFonts(newOrderedList);
- newOrderedList - array of
string
- The new list of the soundfont identifiers, in the desired order.
This function removes all soundfonts and adds a new one with id main
and bank offset of 0.
await synth.soundfontManager.reloadManager(soundfontBuffer);
- soundfontBuffer -
ArrayBuffer
- the new soundfont to reload the synth with.
Important
This function is asynchronous.
Tip
If you encounter any errors in this documentation, please open an issue!
Warning
Make sure you always update worklet_processor.min.js
along with the npm package!