SoundFont Manager - spessasus/spessasynth_lib GitHub Wiki
The 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.
Accessing the list of soundfonts
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.
Adding a new 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.
[!TIP] Using an existing ID will replace the existing bank in-place.
Removing a Soundfont
This function removes a specified soundfont.
synth.soundfontManager.deleteSoundFont(id);
- id -
string
- unique ID for the soundfont to delete.
Changing the order of Soundfonts
This function reorders the soundfonts.
synth.soundfontManager.rearrangeSoundFonts(newOrderedList);
- newOrderedList - array of
string
- The new list of the soundfont identifiers, in the desired order.
Clearing the Soundfonts
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.