* Loads the given midi file for playback. * @param midi The midi file to load
(midi: MidiFile)
| 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); |