aboutsummaryrefslogtreecommitdiff
path: root/audio
diff options
context:
space:
mode:
authorMatthew Hoops2012-09-08 11:05:47 -0400
committerMatthew Hoops2012-09-08 11:05:47 -0400
commit2cb301337a32b09449fe64d43fa1031af3d09454 (patch)
tree27d324d0d3ecea2d76f557c1b6d996cffaec5247 /audio
parent8259d3cd9e68288dc622302fe84a924d6f94b00c (diff)
downloadscummvm-rg350-2cb301337a32b09449fe64d43fa1031af3d09454.tar.gz
scummvm-rg350-2cb301337a32b09449fe64d43fa1031af3d09454.tar.bz2
scummvm-rg350-2cb301337a32b09449fe64d43fa1031af3d09454.zip
AUDIO: Fix QuickTime MIDI pitch bend
Diffstat (limited to 'audio')
-rw-r--r--audio/midiparser_qt.cpp28
1 files changed, 25 insertions, 3 deletions
diff --git a/audio/midiparser_qt.cpp b/audio/midiparser_qt.cpp
index 2b8a02ba5e..e16c73bfec 100644
--- a/audio/midiparser_qt.cpp
+++ b/audio/midiparser_qt.cpp
@@ -149,9 +149,31 @@ uint32 MidiParser_QT::readNextEvent(EventInfo &info) {
case 0x4:
case 0x5:
// Controller
- info.event = 0xB0 | ((control >> 24) & 0x1F);
- info.basic.param1 = (control >> 16) & 0xFF;
- info.basic.param2 = (control >> 8) & 0xFF;
+ if (((control >> 16) & 0xFF) == 32) {
+ // Pitch bend
+ info.event = 0xE0 | ((control >> 24) & 0x1F);
+
+ // Actually an 8.8 fixed point number
+ int16 value = (int16)(control & 0xFFFF);
+
+ if (value < -0x200 || value > 0x1FF) {
+ warning("QuickTime MIDI pitch bend value (%d) out of range, clipping", value);
+ value = CLIP<int16>(value, -0x200, 0x1FF);
+ }
+
+ // Now convert the value to 'normal' MIDI values
+ value += 0x200;
+ value *= 16;
+
+ // param1 holds the low 7 bits, param2 holds the high 7 bits
+ info.basic.param1 = value & 0x7F;
+ info.basic.param2 = value >> 7;
+ } else {
+ // Regular controller
+ info.event = 0xB0 | ((control >> 24) & 0x1F);
+ info.basic.param1 = (control >> 16) & 0xFF;
+ info.basic.param2 = (control >> 8) & 0xFF;
+ }
break;
case 0x6:
case 0x7: