[Scummvm-cvs-logs] SF.net SVN: scummvm:[52184] scummvm/trunk/engines/sci/sound/drivers/midi. cpp
thebluegr at users.sourceforge.net
thebluegr at users.sourceforge.net
Wed Aug 18 13:03:12 CEST 2010
Revision: 52184
http://scummvm.svn.sourceforge.net/scummvm/?rev=52184&view=rev
Author: thebluegr
Date: 2010-08-18 11:03:12 +0000 (Wed, 18 Aug 2010)
Log Message:
-----------
SCI MIDI: adding some asserts as well as proper initialization for _velocityMap
Modified Paths:
--------------
scummvm/trunk/engines/sci/sound/drivers/midi.cpp
Modified: scummvm/trunk/engines/sci/sound/drivers/midi.cpp
===================================================================
--- scummvm/trunk/engines/sci/sound/drivers/midi.cpp 2010-08-18 07:58:38 UTC (rev 52183)
+++ scummvm/trunk/engines/sci/sound/drivers/midi.cpp 2010-08-18 11:03:12 UTC (rev 52184)
@@ -139,6 +139,10 @@
void MidiPlayer_Midi::noteOn(int channel, int note, int velocity) {
uint8 patch = _channels[channel].mappedPatch;
+ assert(channel <= 15);
+ assert(note <= 127);
+ assert(velocity <= 127);
+
if (channel == MIDI_RHYTHM_CHANNEL) {
if (_percussionMap[note] == MIDI_UNMAPPED) {
debugC(kDebugLevelSound, "[Midi] Percussion instrument %i is unmapped", note);
@@ -175,6 +179,7 @@
// We assume that velocity 0 maps to 0 (for note off)
int mapIndex = _channels[channel].velocityMapIdx;
+ assert(velocity <= 127);
velocity = _velocityMap[mapIndex][velocity];
}
@@ -183,6 +188,8 @@
}
void MidiPlayer_Midi::controlChange(int channel, int control, int value) {
+ assert(channel <= 15);
+
switch (control) {
case 0x07:
_channels[channel].volume = value;
@@ -232,6 +239,8 @@
void MidiPlayer_Midi::setPatch(int channel, int patch) {
bool resetVol = false;
+ assert(channel <= 15);
+
if ((channel == MIDI_RHYTHM_CHANNEL) || (_channels[channel].patch == patch))
return;
@@ -772,6 +781,9 @@
_percussionMap[i] = i;
_patchMap[i] = i;
_velocityMap[0][i] = i;
+ _velocityMap[1][i] = i;
+ _velocityMap[2][i] = i;
+ _velocityMap[3][i] = i;
_keyShift[i] = 0;
_volAdjust[i] = 0;
_velocityMapIdx[i] = 0;
@@ -817,8 +829,12 @@
warning("Game has no native support for General MIDI, applying auto-mapping");
// Modify velocity map to make low velocity notes a little louder
- for (uint i = 1; i < 0x40; i++)
+ for (uint i = 1; i < 0x40; i++) {
_velocityMap[0][i] = 0x20 + (i - 1) / 2;
+ _velocityMap[1][i] = 0x20 + (i - 1) / 2;
+ _velocityMap[2][i] = 0x20 + (i - 1) / 2;
+ _velocityMap[3][i] = 0x20 + (i - 1) / 2;
+ }
res = resMan->findResource(ResourceId(kResourceTypePatch, 1), 0);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list