[Scummvm-cvs-logs] CVS: scummvm/sky/music gmchannel.cpp,1.20,1.21 gmchannel.h,1.11,1.12 gmmusic.cpp,1.23,1.24 gmmusic.h,1.14,1.15 mt32music.cpp,1.23,1.24 mt32music.h,1.12,1.13

Jerome Fisher kingguppy at users.sourceforge.net
Sun Apr 3 15:02:12 CEST 2005


Update of /cvsroot/scummvm/scummvm/sky/music
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30995/sky/music

Modified Files:
	gmchannel.cpp gmchannel.h gmmusic.cpp gmmusic.h mt32music.cpp 
	mt32music.h 
Log Message:
Committed patch #1168149 (Shared GM/MT-32 mapping) by eriktorbjorn as-is. This does the following:
- Replaces multiple identical MT-32-to-General MIDI mapping tables with a common one in MidiDriver.
- Changes Sky's GmChannel class to allow NULL instrument and velocity mapping tables, giving a 1-to-1 mapping without creating a dummy table.


Index: gmchannel.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/music/gmchannel.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- gmchannel.cpp	1 Jan 2005 16:09:22 -0000	1.20
+++ gmchannel.cpp	3 Apr 2005 22:01:28 -0000	1.21
@@ -25,7 +25,7 @@
 
 namespace Sky {
 
-GmChannel::GmChannel(uint8 *pMusicData, uint16 startOfData, MidiDriver *pMidiDrv, byte *pInstMap, uint8 *veloTab) {
+GmChannel::GmChannel(uint8 *pMusicData, uint16 startOfData, MidiDriver *pMidiDrv, const byte *pInstMap, const byte *veloTab) {
 
 	_musicData = pMusicData;
 	_midiDrv = pMidiDrv;
@@ -34,7 +34,7 @@
 	_channelData.eventDataPtr = startOfData;
 	_channelData.channelActive = 1;
 	_channelData.nextEventTime = getNextEventTime();
-	_mt32_to_gm = pInstMap;
+	_instMap = pInstMap;
 	_veloTab = veloTab;
 
 	_musicVolume = 0x7F;
@@ -130,7 +130,9 @@
 			}
 		} else {
 			_channelData.note = opcode;
-			uint8 velocity = _veloTab[_musicData[_channelData.eventDataPtr]];
+			byte velocity = _musicData[_channelData.eventDataPtr];
+			if (_veloTab)
+				velocity = _veloTab[velocity];
 			_channelData.eventDataPtr++;
 			_midiDrv->send((0x90 | _channelData.midiChannelNumber) | (opcode << 8) | (velocity << 16));
 		}
@@ -155,8 +157,10 @@
 }
 
 void GmChannel::com90_setupInstrument(void) {
-
-	_midiDrv->send((0xC0 | _channelData.midiChannelNumber) | (_mt32_to_gm[_musicData[_channelData.eventDataPtr]] << 8));
+	byte instrument = _musicData[_channelData.eventDataPtr];
+	if (_instMap)
+		instrument = _instMap[instrument];
+	_midiDrv->send((0xC0 | _channelData.midiChannelNumber) | (instrument << 8));
 	_channelData.eventDataPtr++;
 }
 

Index: gmchannel.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/music/gmchannel.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- gmchannel.h	1 Jan 2005 16:09:22 -0000	1.11
+++ gmchannel.h	3 Apr 2005 22:01:36 -0000	1.12
@@ -39,14 +39,14 @@
 
 class GmChannel : public ChannelBase {
 public:
-	GmChannel(uint8 *pMusicData, uint16 startOfData, MidiDriver *pMidiDrv, byte *pInstMap, uint8 *veloTab);
+	GmChannel(uint8 *pMusicData, uint16 startOfData, MidiDriver *pMidiDrv, const byte *pInstMap, const byte *veloTab);
 	virtual void stopNote(void);
 	virtual uint8 process(uint16 aktTime);
 	virtual void updateVolume(uint16 pVolume);
 	virtual bool isActive(void);
 private:
-	byte *_mt32_to_gm;
-	uint8 *_veloTab;
+	const byte *_instMap;
+	const byte *_veloTab;
 	MidiDriver *_midiDrv;
 	uint8 *_musicData;
 	uint16 _musicVolume;

Index: gmmusic.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/music/gmmusic.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- gmmusic.cpp	12 Mar 2005 11:34:10 -0000	1.23
+++ gmmusic.cpp	3 Apr 2005 22:01:37 -0000	1.24
@@ -89,7 +89,7 @@
 	channelData++;
 	for (uint8 cnt = 0; cnt < _numberOfChannels; cnt++) {
 		uint16 chDataStart = ((channelData[(cnt << 1) | 1] << 8) | channelData[cnt << 1]) + _musicDataLoc;
-		_channels[cnt] = new GmChannel(_musicData, chDataStart, _midiDrv, _mt32_to_gm, _veloTab);
+		_channels[cnt] = new GmChannel(_musicData, chDataStart, _midiDrv, MidiDriver::_mt32ToGm, _veloTab);
 		_channels[cnt]->updateVolume(_musicVolume);
 	}
 }
@@ -102,19 +102,7 @@
 	// skip all sysEx as it can't be handled anyways.
 }
 
-byte GmMusic::_mt32_to_gm[128] = {
-//    0    1    2    3    4    5    6    7    8    9    A    B    C    D    E    F
-	  0,   1,   0,   2,   4,   4,   5,   3,  16,  17,  18,  16,  16,  19,  20,  21, // 0x
-	  6,   6,   6,   7,   7,   7,   8, 112,  62,  62,  63,  63,  38,  38,  39,  39, // 1x
-	 88,  95,  52,  98,  97,  99,  14,  54, 102,  96,  53, 102,  81, 100,  14,  80, // 2x
-	 48,  48,  49,  45,  41,  40,  42,  42,  43,  46,  45,  24,  25,  28,  27, 104, // 3x
-	 32,  32,  34,  33,  36,  37,  35,  35,  79,  73,  72,  72,  74,  75,  64,  65, // 4x
-	 66,  67,  71,  71,  68,  69,  70,  22,  56,  59,  57,  57,  60,  60,  58,  61, // 5x
-	 61,  11,  11,  98,  14,   9,  14,  13,  12, 107, 107,  77,  78,  78,  76,  76, // 6x
-	 47, 117, 127, 118, 118, 116, 115, 119, 115, 112,  55, 124, 123,   0,  14, 117, // 7x
-};
-
-uint8 GmMusic::_veloTab[128] = {
+const byte GmMusic::_veloTab[128] = {
 	0x00, 0x40, 0x41, 0x41, 0x42, 0x42, 0x43, 0x43, 0x44, 0x44,
 	0x45, 0x45, 0x46, 0x46, 0x47, 0x47, 0x48, 0x48, 0x49, 0x49,
 	0x4A, 0x4A, 0x4B, 0x4B, 0x4C, 0x4C, 0x4D, 0x4D, 0x4E, 0x4E,

Index: gmmusic.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/music/gmmusic.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- gmmusic.h	28 Jan 2005 22:05:48 -0000	1.14
+++ gmmusic.h	3 Apr 2005 22:01:37 -0000	1.15
@@ -40,8 +40,7 @@
 	uint32 _timerCount;
 	uint8 *_sysExSequence;
 	MidiDriver *_midiDrv;
-	static byte _mt32_to_gm[128];
-	static uint8 _veloTab[128];
+	static const byte _veloTab[128];
 
 	virtual void setupPointers(void);
 	virtual void setupChannels(uint8 *channelData);

Index: mt32music.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/music/mt32music.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- mt32music.cpp	28 Jan 2005 22:05:48 -0000	1.23
+++ mt32music.cpp	3 Apr 2005 22:01:37 -0000	1.24
@@ -40,8 +40,6 @@
 	int midiRes = _midiDrv->open();
 	if (midiRes != 0)
 		error("Can't open midi device. Errorcode: %d",midiRes);
-	for (uint8 cnt = 0; cnt < 128; cnt++)
-		_dummyMap[cnt] = cnt;
 	_timerCount = 0;
 	_midiDrv->setTimerCallback(this, passTimerFunc);
 }
@@ -86,7 +84,7 @@
 	channelData++;
 	for (uint8 cnt = 0; cnt < _numberOfChannels; cnt++) {
 		uint16 chDataStart = ((channelData[(cnt << 1) | 1] << 8) | channelData[cnt << 1]) + _musicDataLoc;
-		_channels[cnt] = new GmChannel(_musicData, chDataStart, _midiDrv, _dummyMap, _dummyMap);
+		_channels[cnt] = new GmChannel(_musicData, chDataStart, _midiDrv, NULL, NULL);
 		_channels[cnt]->updateVolume(_musicVolume);
 	}
 }

Index: mt32music.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/music/mt32music.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- mt32music.h	28 Jan 2005 22:05:48 -0000	1.12
+++ mt32music.h	3 Apr 2005 22:01:37 -0000	1.13
@@ -41,7 +41,6 @@
 	uint32 _timerCount;
 	uint8 *_sysExSequence;
 	MidiDriver *_midiDrv;
-	uint8 _dummyMap[128];
 
 	virtual void setupPointers(void);
 	virtual void setupChannels(uint8 *channelData);





More information about the Scummvm-git-logs mailing list