[Scummvm-cvs-logs] CVS: scummvm/simon midi.cpp,1.43,1.44 midi.h,1.17,1.18
Jamieson Christian
jamieson630 at users.sourceforge.net
Fri May 23 20:58:04 CEST 2003
Update of /cvsroot/scummvm/scummvm/simon
In directory sc8-pr-cvs1:/tmp/cvs-serv6069/scummvm/simon
Modified Files:
midi.cpp midi.h
Log Message:
Fixed MIDI channel conflict between music and MIDI sound effects in simon1dos.
Also added notes about the GMF header for posterity's sake.
Index: midi.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/midi.cpp,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- midi.cpp 24 May 2003 03:10:14 -0000 1.43
+++ midi.cpp 24 May 2003 03:55:37 -0000 1.44
@@ -88,19 +88,18 @@
volume = (byte) ((b >> 16) & 0xFF) * _masterVolume / 255;
_volumeTable [b & 0xF] = volume;
b = (b & 0xFF00FFFF) | (volume << 16);
- } else if ((b & 0xF0) == 0xC0) {
- int chan = b & 0x0F;
- if (!_current->in_use [chan])
- _driver->send (0x007BB0 | chan); // All Notes Off
- _current->in_use [chan] = true;
} else if ((b & 0xFFF0) == 0x007BB0) {
// Only respond to an All Notes Off if this channel
// has already been marked "in use" by this parser.
- if (!_current->in_use [b & 0x0F])
+ if (!_current->channel [b & 0x0F])
return;
}
- _driver->send (b);
+ byte channel = (byte) (b & 0x0F);
+ if (!_current->channel [channel])
+ _current->channel[channel] = (channel == 9) ? _driver->getPercussionChannel() : _driver->allocateChannel();
+ if (_current->channel [channel])
+ _driver->send ((b & ~0x0F) | _current->channel[channel]->getNumber());
}
void MidiPlayer::metaEvent (byte type, byte *data, uint16 length) {
@@ -269,8 +268,10 @@
delete info.parser;
if (_driver) {
for (i = 0; i < 16; ++i) {
- if (info.in_use[i])
- _driver->send (0x007BB0 | i); // All Notes Off
+ if (info.channel[i]) {
+ _driver->send (0x007BB0 | info.channel[i]->getNumber()); // All Notes Off
+ info.channel[i]->release();
+ }
}
}
info.clear();
@@ -299,6 +300,13 @@
in->read (p->data, size);
if (!memcmp (p->data, "GMF\x1", 4)) {
+ // BTW, here's what we know about the GMF header,
+ // the 7 bytes preceding the actual MIDI events.
+ // 3 BYTES: 'GMF'
+ // 1 BYTE : Always seems to be 0x01
+ // 1 BYTE : Always seems to be 0x00
+ // 1 BYTE : Ranges from 0x02 to 0x08 (always 0x02 for SFX, though)
+ // 1 BYTE : Loop control. 0 = no loop, 1 = loop
if (!sfx)
setLoop (p->data[6] != 0);
Index: midi.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/midi.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- midi.h 24 May 2003 01:26:05 -0000 1.17
+++ midi.h 24 May 2003 03:55:37 -0000 1.18
@@ -31,17 +31,17 @@
struct MusicInfo {
MidiParser *parser;
byte * data;
- byte num_songs; // For Type 1 SMF resources
- byte * songs[16]; // For Type 1 SMF resources
- uint32 song_sizes[16]; // For Type 1 SMF resources
- bool in_use[16]; // Tracks which resource is using which MIDI channels
+ byte num_songs; // For Type 1 SMF resources
+ byte * songs[16]; // For Type 1 SMF resources
+ uint32 song_sizes[16]; // For Type 1 SMF resources
+ MidiChannel *channel[16]; // Dynamic remapping of channels to resolve conflicts
MusicInfo() { clear(); }
void clear() {
parser = 0; data = 0; num_songs = 0;
memset (songs, 0, sizeof (songs));
memset (song_sizes, 0, sizeof (song_sizes));
- memset (in_use, 0, sizeof (in_use));
+ memset (channel, 0, sizeof (channel));
}
};
More information about the Scummvm-git-logs
mailing list