aboutsummaryrefslogtreecommitdiff
path: root/audio/mididrv.h
diff options
context:
space:
mode:
authorMax Horn2011-03-23 13:04:46 +0100
committerMax Horn2011-03-23 15:25:47 +0100
commitc70c8864f131bfe42437b05d03f77ab198f59247 (patch)
tree233348b1fa140600952e9ee48184b047a0836985 /audio/mididrv.h
parenta539be098d3b5598422e52a65457c68b43042e4a (diff)
downloadscummvm-rg350-c70c8864f131bfe42437b05d03f77ab198f59247.tar.gz
scummvm-rg350-c70c8864f131bfe42437b05d03f77ab198f59247.tar.bz2
scummvm-rg350-c70c8864f131bfe42437b05d03f77ab198f59247.zip
AUDIO: Introduce a new MidiDriver_BASE base class.
The actual MidiDriver derives from it. MidiDriver_BASE only provides the minimal API necessary for transmitting MIDI data. The idea is that this is all MidiParser needs, thus allowing us to simplify the various MidiPlayer classes in our engines.
Diffstat (limited to 'audio/mididrv.h')
-rw-r--r--audio/mididrv.h77
1 files changed, 43 insertions, 34 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;