aboutsummaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorJohannes Schickel2008-11-30 01:53:32 +0000
committerJohannes Schickel2008-11-30 01:53:32 +0000
commit893a79b01dd02ebc7475b7cdd0f5ec154229f51c (patch)
tree4e5888179f175d8660eab8c9828c25703affb2e2 /sound
parentfead4f304f2034de410564e113cef20563018d26 (diff)
downloadscummvm-rg350-893a79b01dd02ebc7475b7cdd0f5ec154229f51c.tar.gz
scummvm-rg350-893a79b01dd02ebc7475b7cdd0f5ec154229f51c.tar.bz2
scummvm-rg350-893a79b01dd02ebc7475b7cdd0f5ec154229f51c.zip
Initial version of proper MIDI support for KYRA.
svn-id: r35174
Diffstat (limited to 'sound')
-rw-r--r--sound/midiparser.cpp14
-rw-r--r--sound/midiparser.h7
2 files changed, 16 insertions, 5 deletions
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);