diff options
Diffstat (limited to 'audio/mididrv.h')
-rw-r--r-- | audio/mididrv.h | 77 |
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; |