From 893a79b01dd02ebc7475b7cdd0f5ec154229f51c Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 30 Nov 2008 01:53:32 +0000 Subject: Initial version of proper MIDI support for KYRA. svn-id: r35174 --- sound/midiparser.cpp | 14 ++++++++++++-- sound/midiparser.h | 7 ++++--- 2 files changed, 16 insertions(+), 5 deletions(-) (limited to 'sound') diff --git a/sound/midiparser.cpp b/sound/midiparser.cpp index b2897dadfa..389de58ea4 100644 --- a/sound/midiparser.cpp +++ b/sound/midiparser.cpp @@ -209,8 +209,7 @@ void MidiParser::onTimer() { jumpToTick(0); parseNextEvent(_next_event); } else { - allNotesOff(); - resetTracking(); + stopPlaying(); _driver->metaEvent(info.ext.type, info.ext.data, (uint16)info.length); } return; @@ -302,6 +301,17 @@ bool MidiParser::setTrack(int track) { return true; } +void MidiParser::stopPlaying() { + if (_smartJump) + hangAllActiveNotes(); + else + allNotesOff(); + resetTracking(); + + _active_track = _num_tracks+1; + memset(_active_notes, 0, sizeof(_active_notes)); +} + void MidiParser::hangAllActiveNotes() { // Search for note off events until we have // accounted for every active note. diff --git a/sound/midiparser.h b/sound/midiparser.h index 304a9d9f82..0c0b9cdb8d 100644 --- a/sound/midiparser.h +++ b/sound/midiparser.h @@ -283,9 +283,7 @@ protected: bool _smartJump; //!< Support smart expiration of hanging notes when jumping bool _centerPitchWheelOnUnload; //!< Center the pitch wheels when unloading a song - // FIXME: Was 32 here, Kyra tracks use 120(!!!) which seems wrong. this is a hacky - // workaround until situation is investigated. - byte * _tracks[120]; //!< Multi-track MIDI formats are supported, up to 120 tracks. + byte *_tracks[120]; //!< Multi-track MIDI formats are supported, up to 120 tracks. byte _num_tracks; //!< Count of total tracks for multi-track MIDI formats. 1 for single-track formats. byte _active_track; //!< Keeps track of the currently active track, in multi-track formats. @@ -366,6 +364,9 @@ public: void setTempo(uint32 tempo); void onTimer(); + bool isPlaying() const { return (_position._play_pos != 0); } + void stopPlaying(); + bool setTrack(int track); bool jumpToTick(uint32 tick, bool fireEvents = false); -- cgit v1.2.3