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

Method loadMidiFile

packages/alphatab/src/synth/AlphaSynth.ts:463–487  ·  view source on GitHub ↗

* Loads the given midi file for playback. * @param midi The midi file to load

(midi: MidiFile)

Source from the content-addressed store, hash-verified

461 * @param midi The midi file to load
462 */
463 public loadMidiFile(midi: MidiFile): void {
464 this.stop();
465
466 try {
467 Logger.debug('AlphaSynth', 'Loading midi from model');
468 this.sequencer.loadMidi(midi);
469 this._isMidiLoaded = true;
470 this._loadedMidiInfo = new PositionChangedEventArgs(
471 0,
472 this.sequencer.currentEndTime,
473 0,
474 this.sequencer.currentEndTick,
475 false,
476 this.sequencer.currentTempo,
477 this.sequencer.modifiedTempo
478 );
479 (this.midiLoaded as EventEmitterOfT<PositionChangedEventArgs>).trigger(this._loadedMidiInfo);
480 Logger.debug('AlphaSynth', 'Midi successfully loaded');
481 this._checkReadyForPlayback();
482 this.tickPosition = 0;
483 } catch (e) {
484 Logger.error('AlphaSynth', `Could not load midi from model ${e}`);
485 (this.midiLoadFailed as EventEmitterOfT<Error>).trigger(e as Error);
486 }
487 }
488
489 public applyTranspositionPitches(transpositionPitches: Map<number, number>): void {
490 this.synthesizer.applyTranspositionPitches(transpositionPitches);

Callers

nothing calls this directly

Calls 6

stopMethod · 0.95
loadMidiMethod · 0.80
debugMethod · 0.65
errorMethod · 0.65
triggerMethod · 0.45

Tested by

no test coverage detected