loadSoundFont
Description​
This function initiates a load of the soundfont using the given data. The supported data types is depending on the platform. AlphaTab only supports SoundFont2 and SoundFont3 (since 1.4.0) encoded soundfonts for loading. To load a soundfont the player must be enabled in advance.
Signatures​
Type | Values |
---|---|
function loadSoundFont(arraybuffer, append)JavaScript | Load the soundfont from the given raw bytes. |
function loadSoundFont(uint8array, append)JavaScript | Load the soundfont from the given raw bytes. |
function loadSoundFont(url, append)JavaScript | Load the soundfont from the given URL via AJAX. |
alphaTab('loadSoundFont', arraybuffer, append)JavaScript | Load the soundfont from the given raw bytes. |
alphaTab('loadSoundFont', uint8array, append)JavaScript | Load the soundfont from the given raw bytes. |
alphaTab('loadSoundFont', url, append)JavaScript | Load the soundfont from the given URL via AJAX. |
bool LoadSoundFont(byte[] raw, append).net | Load the soundfont from the given raw bytes. |
bool LoadSoundFont(Stream raw, append).net | Load the soundfont from the given stream. |
fun loadSoundFont(raw: ByteArray, append: Boolean = false): BooleanAndroid | Load the soundfont from the given raw bytes. |
fun loadSoundFont(raw: UByteArray, append: Boolean = false): BooleanAndroid | Load the soundfont from the given raw bytes. |
fun loadSoundFont(stream: java.io.InputStream, append: Boolean = false): BooleanAndroid | Load the soundfont from the given stream. |
Parameters​
Parameters | Type | Summary |
---|---|---|
arraybufferJavaScript & jQuery | ArrayBuffer | The arraybuffer containing the raw bytes of a SoundFont file |
uint8arrayJavaScript & jQuery | Uint8Array | The Uint8Array containing the raw bytes of a SoundFont file |
urlJavaScript & jQuery | string | A URL pointing to a SoundFont file that should be loaded via AJAX. |
raw.net | byte[] | The raw bytes containing a SoundFont file. |
raw.net | System.IO.Stream | The stream containing a SoundFont file. |
rawAndroid | ByteArray | The raw bytes containing a SoundFont file. |
rawAndroid | ByteArray | The raw bytes containing a SoundFont file. |
rawAndroid | UByteArray | The raw bytes containing a SoundFont file. |
streamAndroid | java.io.InputStream | The stream containing a SoundFont file. |
appendAll | boolean | Whether to append the presets of the new soundfont to the already loaded ones. Since: 1.1.0 |
Returns​
true
if the passed in object is a supported format and loading was initiated, otherwise false
.
Examples​
- JavaScript
- jQuery
- C#
- Android
const api = new alphaTab.AlphaTabApi(document.querySelector('#alphaTab'));
api.loadSoundFont('/assets/MyFile.sf2');
$('#alphaTab').alphaTab('loadSoundFont', '/assets/MyFile.sf2');
var api = new AlphaTabApi<MyControl>(...);
api.LoadSoundFont(System.IO.File.OpenRead("MyFile.sf2"));
val api = AlphaTabApi<MyControl>(...)
contentResolver.openInputStream(uri).use {
api.loadSoundFont(it)
}