| 1 | /* $Id: MIDI.HPP,v 1.1 1999-05-24 20:20:05 ktk Exp $ */
|
|---|
| 2 |
|
|---|
| 3 | /*
|
|---|
| 4 | * RTMIDI code
|
|---|
| 5 | *
|
|---|
| 6 | * Copyright 1998 Joel Troster
|
|---|
| 7 | *
|
|---|
| 8 | *
|
|---|
| 9 | * Project Odin Software License can be found in LICENSE.TXT
|
|---|
| 10 | *
|
|---|
| 11 | */
|
|---|
| 12 | #ifndef _MIDI_HPP_
|
|---|
| 13 | #define _MIDI_HPP_
|
|---|
| 14 |
|
|---|
| 15 | #include "misc.h"
|
|---|
| 16 | #include "winmm.h"
|
|---|
| 17 | #include "irtmidi.hpp"
|
|---|
| 18 |
|
|---|
| 19 | // The Midi class represent a win32 midi device.
|
|---|
| 20 | class Midi
|
|---|
| 21 | {
|
|---|
| 22 | public:
|
|---|
| 23 | Midi( UINT uDeviceId );
|
|---|
| 24 | virtual ~Midi();
|
|---|
| 25 | UINT device() const
|
|---|
| 26 | { return iDeviceId; };
|
|---|
| 27 | void setCallback( DWORD dwCallback,
|
|---|
| 28 | DWORD dwCallbackInstance,
|
|---|
| 29 | DWORD dwflags );
|
|---|
| 30 | virtual MMRESULT open()=0;
|
|---|
| 31 | virtual MMRESULT close()=0;
|
|---|
| 32 | void callback( UINT msg, DWORD p1, DWORD p2);
|
|---|
| 33 |
|
|---|
| 34 | protected:
|
|---|
| 35 | UINT iDeviceId;
|
|---|
| 36 | IMidiInstance * iHwdInstance; // The Hardware Instance that this connected to
|
|---|
| 37 | IAppMidiInstance* iAppInstance;
|
|---|
| 38 |
|
|---|
| 39 | LPDRVCALLBACK iCallbackFunction;
|
|---|
| 40 | HWND iCallbackWindow;
|
|---|
| 41 | DWORD iCallbackInstance;
|
|---|
| 42 | };
|
|---|
| 43 |
|
|---|
| 44 | class MidiIn : public Midi
|
|---|
| 45 | {
|
|---|
| 46 | public:
|
|---|
| 47 | MidiIn( UINT uDeviceId );
|
|---|
| 48 | virtual ~MidiIn();
|
|---|
| 49 | virtual MMRESULT open();
|
|---|
| 50 | virtual MMRESULT start();
|
|---|
| 51 | virtual MMRESULT stop();
|
|---|
| 52 | virtual MMRESULT close();
|
|---|
| 53 | void getMessages();
|
|---|
| 54 | static MidiIn* find( HMIDIIN );
|
|---|
| 55 | static MidiIn* find( UINT uDeviceId );
|
|---|
| 56 | private:
|
|---|
| 57 | IAppMidiInstance* iAppInstance;
|
|---|
| 58 | unsigned long iStartTime;
|
|---|
| 59 | int iThreadId;
|
|---|
| 60 | BOOL iRunning;
|
|---|
| 61 | static MidiIn* iFirst; // First in linked list of MidiIn devices
|
|---|
| 62 | MidiIn* iNext; // Next in linked list of handles
|
|---|
| 63 | };
|
|---|
| 64 |
|
|---|
| 65 | class MidiOut : public Midi
|
|---|
| 66 | {
|
|---|
| 67 | public:
|
|---|
| 68 | MidiOut( UINT uDeviceId );
|
|---|
| 69 | virtual ~MidiOut();
|
|---|
| 70 | virtual MMRESULT open();
|
|---|
| 71 | virtual MMRESULT close();
|
|---|
| 72 | virtual MMRESULT sendMessage( DWORD msg ) const;
|
|---|
| 73 | virtual MMRESULT sendSysexMessage( BYTE* msg, ULONG msgLen ) const;
|
|---|
| 74 | virtual MMRESULT sendVolume( DWORD volume ) const;
|
|---|
| 75 | virtual DWORD getVolume() const;
|
|---|
| 76 | static MidiOut* find( HMIDIOUT );
|
|---|
| 77 | static MidiOut* find( UINT uDeviceId );
|
|---|
| 78 | protected:
|
|---|
| 79 | static MidiOut* iFirst; // First in linked list of MidiOut devices
|
|---|
| 80 | MidiOut* iNext; // Next in linked list of handles
|
|---|
| 81 | DWORD iVolume;
|
|---|
| 82 | };
|
|---|
| 83 |
|
|---|
| 84 | class MidiMapper : public MidiOut
|
|---|
| 85 | {
|
|---|
| 86 | public:
|
|---|
| 87 | MidiMapper();
|
|---|
| 88 | virtual ~MidiMapper();
|
|---|
| 89 | virtual MMRESULT open();
|
|---|
| 90 | virtual MMRESULT close();
|
|---|
| 91 | virtual MMRESULT sendMessage( DWORD msg ) const;
|
|---|
| 92 | virtual MMRESULT sendSysexMessage( BYTE* msg, ULONG msgLen ) const;
|
|---|
| 93 | private:
|
|---|
| 94 | };
|
|---|
| 95 |
|
|---|
| 96 | #endif
|
|---|