aboutsummaryrefslogtreecommitdiff
path: root/sky/music
diff options
context:
space:
mode:
authorJerome Fisher2005-04-03 22:01:38 +0000
committerJerome Fisher2005-04-03 22:01:38 +0000
commiteda317924ec0573d5c2a8407feaa8dafb6d4a9bc (patch)
tree7613d4f6e4af714ffd33af7cee8feba5533d2168 /sky/music
parente62d6773ef629e11f966e4b4c3086db8cea58a0b (diff)
downloadscummvm-rg350-eda317924ec0573d5c2a8407feaa8dafb6d4a9bc.tar.gz
scummvm-rg350-eda317924ec0573d5c2a8407feaa8dafb6d4a9bc.tar.bz2
scummvm-rg350-eda317924ec0573d5c2a8407feaa8dafb6d4a9bc.zip
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. svn-id: r17361
Diffstat (limited to 'sky/music')
-rw-r--r--sky/music/gmchannel.cpp14
-rw-r--r--sky/music/gmchannel.h6
-rw-r--r--sky/music/gmmusic.cpp16
-rw-r--r--sky/music/gmmusic.h3
-rw-r--r--sky/music/mt32music.cpp4
-rw-r--r--sky/music/mt32music.h1
6 files changed, 16 insertions, 28 deletions
diff --git a/sky/music/gmchannel.cpp b/sky/music/gmchannel.cpp
index 82b118eb9e..ec50a160e3 100644
--- a/sky/music/gmchannel.cpp
+++ b/sky/music/gmchannel.cpp
@@ -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 @@ GmChannel::GmChannel(uint8 *pMusicData, uint16 startOfData, MidiDriver *pMidiDrv
_channelData.eventDataPtr = startOfData;
_channelData.channelActive = 1;
_channelData.nextEventTime = getNextEventTime();
- _mt32_to_gm = pInstMap;
+ _instMap = pInstMap;
_veloTab = veloTab;
_musicVolume = 0x7F;
@@ -130,7 +130,9 @@ uint8 GmChannel::process(uint16 aktTime) {
}
} 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_stopChannel(void) {
}
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++;
}
diff --git a/sky/music/gmchannel.h b/sky/music/gmchannel.h
index deb6681b82..68c99fe43c 100644
--- a/sky/music/gmchannel.h
+++ b/sky/music/gmchannel.h
@@ -39,14 +39,14 @@ typedef struct {
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;
diff --git a/sky/music/gmmusic.cpp b/sky/music/gmmusic.cpp
index 8863dbc5e1..daa2071289 100644
--- a/sky/music/gmmusic.cpp
+++ b/sky/music/gmmusic.cpp
@@ -89,7 +89,7 @@ void GmMusic::setupChannels(uint8 *channelData) {
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 @@ void GmMusic::startDriver(void) {
// 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,
diff --git a/sky/music/gmmusic.h b/sky/music/gmmusic.h
index 90e9ec68db..b618303500 100644
--- a/sky/music/gmmusic.h
+++ b/sky/music/gmmusic.h
@@ -40,8 +40,7 @@ private:
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);
diff --git a/sky/music/mt32music.cpp b/sky/music/mt32music.cpp
index 0b176fe44c..caabb21ec7 100644
--- a/sky/music/mt32music.cpp
+++ b/sky/music/mt32music.cpp
@@ -40,8 +40,6 @@ MT32Music::MT32Music(MidiDriver *pMidiDrv, Disk *pDisk)
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 @@ void MT32Music::setupChannels(uint8 *channelData) {
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);
}
}
diff --git a/sky/music/mt32music.h b/sky/music/mt32music.h
index bf56f161da..e63fb1ad76 100644
--- a/sky/music/mt32music.h
+++ b/sky/music/mt32music.h
@@ -41,7 +41,6 @@ private:
uint32 _timerCount;
uint8 *_sysExSequence;
MidiDriver *_midiDrv;
- uint8 _dummyMap[128];
virtual void setupPointers(void);
virtual void setupChannels(uint8 *channelData);