AUDIO: Let jumpToTick use processEvent too

This commit is contained in:
Willem Jan Palenstijn 2013-09-21 00:21:08 +02:00
parent 6c5a5cd8e9
commit da81c59308
2 changed files with 26 additions and 37 deletions

View file

@ -229,14 +229,16 @@ void MidiParser::onTimer() {
} }
} }
bool MidiParser::processEvent(const EventInfo &info) { bool MidiParser::processEvent(const EventInfo &info, bool fireEvents) {
if (info.event == 0xF0) { if (info.event == 0xF0) {
// SysEx event // SysEx event
// Check for trailing 0xF7 -- if present, remove it. // Check for trailing 0xF7 -- if present, remove it.
if (fireEvents) {
if (info.ext.data[info.length-1] == 0xF7) if (info.ext.data[info.length-1] == 0xF7)
_driver->sysEx(info.ext.data, (uint16)info.length-1); _driver->sysEx(info.ext.data, (uint16)info.length-1);
else else
_driver->sysEx(info.ext.data, (uint16)info.length); _driver->sysEx(info.ext.data, (uint16)info.length);
}
} else if (info.event == 0xFF) { } else if (info.event == 0xFF) {
// META event // META event
if (info.ext.type == 0x2F) { if (info.ext.type == 0x2F) {
@ -247,6 +249,7 @@ bool MidiParser::processEvent(const EventInfo &info) {
parseNextEvent(_nextEvent); parseNextEvent(_nextEvent);
} else { } else {
stopPlaying(); stopPlaying();
if (fireEvents)
_driver->metaEvent(info.ext.type, info.ext.data, (uint16)info.length); _driver->metaEvent(info.ext.type, info.ext.data, (uint16)info.length);
} }
return false; return false;
@ -255,8 +258,10 @@ bool MidiParser::processEvent(const EventInfo &info) {
setTempo(info.ext.data[0] << 16 | info.ext.data[1] << 8 | info.ext.data[2]); setTempo(info.ext.data[0] << 16 | info.ext.data[1] << 8 | info.ext.data[2]);
} }
} }
if (fireEvents)
_driver->metaEvent(info.ext.type, info.ext.data, (uint16)info.length); _driver->metaEvent(info.ext.type, info.ext.data, (uint16)info.length);
} else { } else {
if (fireEvents)
sendToDriver(info.event, info.basic.param1, info.basic.param2); sendToDriver(info.event, info.basic.param1, info.basic.param2);
} }
@ -399,34 +404,18 @@ bool MidiParser::jumpToTick(uint32 tick, bool fireEvents, bool stopNotes, bool d
_position._playTick = _position._lastEventTick; _position._playTick = _position._lastEventTick;
_position._playTime = _position._lastEventTime; _position._playTime = _position._lastEventTime;
if (info.event == 0xFF) { // Some special processing for the fast-forward case
if (info.ext.type == 0x2F) { // End of track if (info.command() == 0x9 && dontSendNoteOn) {
// Don't send note on; doing so creates a "warble" with
// some instruments on the MT-32. Refer to patch #3117577
} else if (info.event == 0xFF && info.ext.type == 0x2F) {
// End of track
// This means that we failed to find the right tick.
_position = currentPos; _position = currentPos;
_nextEvent = currentEvent; _nextEvent = currentEvent;
return false; return false;
} else { } else {
if (info.ext.type == 0x51 && info.length >= 3) // Tempo processEvent(info, fireEvents);
setTempo(info.ext.data[0] << 16 | info.ext.data[1] << 8 | info.ext.data[2]);
if (fireEvents)
_driver->metaEvent(info.ext.type, info.ext.data, (uint16) info.length);
}
} else if (fireEvents) {
if (info.event == 0xF0) {
if (info.ext.data[info.length-1] == 0xF7)
_driver->sysEx(info.ext.data, (uint16)info.length-1);
else
_driver->sysEx(info.ext.data, (uint16)info.length);
} else {
// The note on sending code is used by the SCUMM engine. Other engine using this code
// (such as SCI) have issues with this, as all the notes sent can be heard when a song
// is fast-forwarded. Thus, if the engine requests it, don't send note on events.
if (info.command() == 0x9 && dontSendNoteOn) {
// Don't send note on; doing so creates a "warble" with some instruments on the MT-32.
// Refer to patch #3117577
} else {
sendToDriver(info.event, info.basic.param1, info.basic.param2);
}
}
} }
parseNextEvent(_nextEvent); parseNextEvent(_nextEvent);

View file

@ -293,7 +293,7 @@ protected:
virtual void resetTracking(); virtual void resetTracking();
virtual void allNotesOff(); virtual void allNotesOff();
virtual void parseNextEvent(EventInfo &info) = 0; virtual void parseNextEvent(EventInfo &info) = 0;
virtual bool processEvent(const EventInfo &info); virtual bool processEvent(const EventInfo &info, bool fireEvents = true);
void activeNote(byte channel, byte note, bool active); void activeNote(byte channel, byte note, bool active);
void hangingNote(byte channel, byte note, uint32 ticksLeft, bool recycle = true); void hangingNote(byte channel, byte note, uint32 ticksLeft, bool recycle = true);