(data: Uint8Array, append: boolean)
| 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) { |
nothing calls this directly
no test coverage detected