aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--audio/mididrv.h77
-rw-r--r--audio/midiparser.h6
2 files changed, 46 insertions, 37 deletions
diff --git a/audio/mididrv.h b/audio/mididrv.h
index 8323553676..8d6f942455 100644
--- a/audio/mididrv.h
+++ b/audio/mididrv.h
@@ -90,11 +90,53 @@ enum MidiDriverFlags {
};
/**
+ * TODO: Document this, give it a better name.
+ */
+class MidiDriver_BASE {
+public:
+ virtual ~MidiDriver_BASE() { }
+
+ /**
+ * Output a packed midi command to the midi stream.
+ * The 'lowest' byte (i.e. b & 0xFF) is the status
+ * code, then come (if used) the first and second
+ * opcode.
+ */
+ virtual void send(uint32 b) = 0;
+
+ /**
+ * Output a midi command to the midi stream. Convenience wrapper
+ * around the usual 'packed' send method.
+ *
+ * Do NOT use this for sysEx transmission; instead, use the sysEx()
+ * method below.
+ */
+ void send(byte status, byte firstOp, byte secondOp) {
+ send(status | ((uint32)firstOp << 8) | ((uint32)secondOp << 16));
+ }
+
+ /**
+ * Transmit a sysEx to the midi device.
+ *
+ * The given msg MUST NOT contain the usual SysEx frame, i.e.
+ * do NOT include the leading 0xF0 and the trailing 0xF7.
+ *
+ * Furthermore, the maximal supported length of a SysEx
+ * is 264 bytes. Passing longer buffers can lead to
+ * undefined behavior (most likely, a crash).
+ */
+ virtual void sysEx(const byte *msg, uint16 length) { }
+
+ // TODO: Document this.
+ virtual void metaEvent(byte type, byte *data, uint16 length) { }
+};
+
+/**
* Abstract MIDI Driver Class
*
* @todo Rename MidiDriver to MusicDriver
*/
-class MidiDriver {
+class MidiDriver : public MidiDriver_BASE {
public:
/**
* The device handle.
@@ -173,25 +215,6 @@ public:
/** Close the midi driver. */
virtual void close() = 0;
- /**
- * Output a packed midi command to the midi stream.
- * The 'lowest' byte (i.e. b & 0xFF) is the status
- * code, then come (if used) the first and second
- * opcode.
- */
- virtual void send(uint32 b) = 0;
-
- /**
- * Output a midi command to the midi stream. Convenience wrapper
- * around the usual 'packed' send method.
- *
- * Do NOT use this for sysEx transmission; instead, use the sysEx()
- * method below.
- */
- void send(byte status, byte firstOp, byte secondOp) {
- send(status | ((uint32)firstOp << 8) | ((uint32)secondOp << 16));
- }
-
/** Get or set a property. */
virtual uint32 property(int prop, uint32 param) { return 0; }
@@ -218,22 +241,8 @@ public:
*/
void sendGMReset();
- /**
- * Transmit a sysEx to the midi device.
- *
- * The given msg MUST NOT contain the usual SysEx frame, i.e.
- * do NOT include the leading 0xF0 and the trailing 0xF7.
- *
- * Furthermore, the maximal supported length of a SysEx
- * is 264 bytes. Passing longer buffers can lead to
- * undefined behavior (most likely, a crash).
- */
- virtual void sysEx(const byte *msg, uint16 length) { }
-
virtual void sysEx_customInstrument(byte channel, uint32 type, const byte *instr) { }
- virtual void metaEvent(byte type, byte *data, uint16 length) { }
-
// Timing functions - MidiDriver now operates timers
virtual void setTimerCallback(void *timer_param, Common::TimerManager::TimerProc timer_proc) = 0;
diff --git a/audio/midiparser.h b/audio/midiparser.h
index 0b18a19a5b..eeeee981e4 100644
--- a/audio/midiparser.h
+++ b/audio/midiparser.h
@@ -32,7 +32,7 @@
#include "common/endian.h"
class MidiParser;
-class MidiDriver;
+class MidiDriver_BASE;
@@ -273,7 +273,7 @@ protected:
///< Used for "Smart Jump" and MIDI formats that do not include explicit Note Off events.
byte _hanging_notes_count; ///< Count of hanging notes, used to optimize expiration.
- MidiDriver *_driver; ///< The device to which all events will be transmitted.
+ MidiDriver_BASE *_driver; ///< The device to which all events will be transmitted.
uint32 _timer_rate; ///< The time in microseconds between onTimer() calls. Obtained from the MidiDriver.
uint32 _ppqn; ///< Pulses Per Quarter Note. (We refer to "pulses" as "ticks".)
uint32 _tempo; ///< Microseconds per quarter note.
@@ -380,7 +380,7 @@ public:
virtual void unloadMusic();
virtual void property(int prop, int value);
- void setMidiDriver(MidiDriver *driver) { _driver = driver; }
+ void setMidiDriver(MidiDriver_BASE *driver) { _driver = driver; }
void setTimerRate(uint32 rate) { _timer_rate = rate; }
void setTempo(uint32 tempo);
void onTimer();