[Scummvm-cvs-logs] CVS: scummvm/sound mididrv.h,1.3,1.4 mididrv.cpp,1.13,1.14
Jamieson Christian
jamieson630 at users.sourceforge.net
Mon Oct 21 02:33:03 CEST 2002
Update of /cvsroot/scummvm/scummvm/sound
In directory usw-pr-cvs1:/tmp/cvs-serv22828/scummvm/sound
Modified Files:
mididrv.h mididrv.cpp
Log Message:
Pitch bend fixes for QTMA
Index: mididrv.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/mididrv.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- mididrv.h 2 Oct 2002 23:31:40 -0000 1.3
+++ mididrv.h 21 Oct 2002 09:32:38 -0000 1.4
@@ -97,6 +97,9 @@
/* retrieve a string representation of an error code */
static const char *get_error_name(int error_code);
+
+ // HIGH-LEVEL SEMANTIC METHODS
+ virtual void setPitchBendRange (uint range) = 0;
};
Index: mididrv.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/mididrv.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- mididrv.cpp 14 Oct 2002 16:19:19 -0000 1.13
+++ mididrv.cpp 21 Oct 2002 09:32:38 -0000 1.14
@@ -45,6 +45,7 @@
void send(uint32 b);
void pause(bool pause);
void set_stream_callback(void *param, StreamCallback *sc);
+ void setPitchBendRange (uint range) { }
private:
struct MyMidiHdr {
@@ -304,6 +305,7 @@
void send(uint32 b);
void pause(bool pause);
void set_stream_callback(void *param, StreamCallback *sc);
+ void setPitchBendRange (uint range) { }
private:
enum {
@@ -515,6 +517,7 @@
void send(uint32 b);
void pause(bool pause);
void set_stream_callback(void *param, StreamCallback *sc);
+ void setPitchBendRange (uint range) { }
private:
StreamCallback *_stream_proc;
@@ -650,8 +653,9 @@
int open(int mode);
void close();
void send(uint32 b);
- void pause(bool pause);
+ void pause(bool pause) { }
void set_stream_callback(void *param, StreamCallback *sc);
+ void setPitchBendRange (uint range);
private:
NoteAllocator qtNoteAllocator;
@@ -661,6 +665,11 @@
StreamCallback *_stream_proc;
void *_stream_param;
int _mode;
+
+ // Pitch bend tracking. Necessary since QTMA handles
+ // pitch bending so differently from MPU401.
+ uint16 _pitchbend [16];
+ byte _pitchbend_range [16];
};
void MidiDriver_QT::set_stream_callback(void *param, StreamCallback *sc)
@@ -808,8 +817,9 @@
// multiply it by a factor. If all was right, the factor would be 3/8, but for
// mysterious reasons the actual factor we have to use is more like 1/32 or 3/64.
// Maybe the QT docs are right, and
- long theBend = (long)midiCmd[1] | (long)(midiCmd[2] << 7);
- theBend = (theBend - 0x2000) * 2 / 64;
+ long theBend = ((long)midiCmd[1] | (long)(midiCmd[2] << 7));
+ _pitchbend[chanID] = theBend;
+ theBend = (theBend - 0x2000) * _pitchbend_range[channel] / 32;
NASetController(qtNoteAllocator, qtNoteChannel[chanID], kControllerPitchBend, theBend);
}
@@ -822,8 +832,15 @@
}
}
-void MidiDriver_QT::pause(bool)
+void MidiDriver_QT::setPitchBendRange (channel, range)
{
+ if (_pitchbend_range[channel] == range)
+ return;
+ _pitchbend_range[channel] = range;
+
+ long theBend = _pitchbend[channel];
+ theBend = (theBend - 0x2000) * range / 32;
+ NASetController(qtNoteAllocator, qtNoteChannel[channel], kControllerPitchBend, theBend);
}
MidiDriver *MidiDriver_QT_create()
@@ -848,6 +865,7 @@
void send(uint32 b);
void pause(bool pause);
void set_stream_callback(void *param, StreamCallback *sc);
+ void setPitchBendRange (uint range) { }
private:
AudioUnit au_MusicDevice;
@@ -966,10 +984,11 @@
class MidiDriver_NULL:public MidiDriver {
public:
int open(int mode);
- void close();
- void send(uint32 b);
- void pause(bool pause);
- void set_stream_callback(void *param, StreamCallback *sc);
+ void close() { }
+ void send(uint32 b) { }
+ void pause(bool pause) { }
+ void set_stream_callback(void *param, StreamCallback *sc) { }
+ void setPitchBendRange (uint range) { }
private:
};
@@ -978,18 +997,6 @@
warning("Music not enabled - MIDI support selected with no MIDI driver available. Try Adlib");
return 0;
}
-void MidiDriver_NULL::close()
-{
-}
-void MidiDriver_NULL::send(uint32 b)
-{
-}
-void MidiDriver_NULL::pause(bool pause)
-{
-}
-void MidiDriver_NULL::set_stream_callback(void *param, StreamCallback *sc)
-{
-}
MidiDriver *MidiDriver_NULL_create()
{
@@ -1054,6 +1061,7 @@
void send(uint32 b);
void pause(bool pause);
void set_stream_callback(void *param, StreamCallback *sc);
+ void setPitchBendRange (uint range) { }
private:
void send_event(int do_flush);
@@ -1205,7 +1213,7 @@
break;
case 0xE0:{
- long theBend = ((((long)midiCmd[1] + (long)(midiCmd[2] << 8))) - 0x4000) / 4;
+ long theBend = ((((long)midiCmd[1] + (long)(midiCmd[2] << 7))) - 0x2000) / 4;
snd_seq_ev_set_pitchbend(&ev, chanID, theBend);
send_event(1);
}
More information about the Scummvm-git-logs
mailing list