MCPcopy Create free account
hub / github.com/CoderLine/alphaTab / loadSoundFont

Method loadSoundFont

packages/alphatab/src/synth/AlphaSynth.ts:421–443  ·  view source on GitHub ↗
(data: Uint8Array, append: boolean)

Source from the content-addressed store, hash-verified

419 private _loadedSoundFonts: Hydra[] = [];
420
421 public loadSoundFont(data: Uint8Array, append: boolean): void {
422 this.pause();
423
424 const input: ByteBuffer = ByteBuffer.fromBuffer(data);
425 try {
426 Logger.debug('AlphaSynth', 'Loading soundfont from bytes');
427 const soundFont: Hydra = new Hydra();
428 soundFont.load(input);
429 if (!append) {
430 this._loadedSoundFonts = [];
431 }
432 this._loadedSoundFonts.push(soundFont);
433
434 this.isSoundFontLoaded = true;
435 (this.soundFontLoaded as EventEmitter).trigger();
436
437 Logger.debug('AlphaSynth', 'soundFont successfully loaded');
438 this._checkReadyForPlayback();
439 } catch (e) {
440 Logger.error('AlphaSynth', `Could not load soundfont from bytes ${e}`);
441 (this.soundFontLoadFailed as EventEmitterOfT<Error>).trigger(e as Error);
442 }
443 }
444
445 private _checkReadyForPlayback(): void {
446 if (this.isReadyForPlayback) {

Callers

nothing calls this directly

Calls 8

pauseMethod · 0.95
loadMethod · 0.95
fromBufferMethod · 0.80
debugMethod · 0.65
errorMethod · 0.65
pushMethod · 0.45
triggerMethod · 0.45

Tested by

no test coverage detected