|
Canorus
0.7
|
00001 00008 #ifndef MIDIDEVICE_H_ 00009 #define MIDIDEVICE_H_ 00010 00011 #include <QStringList> 00012 #include <QVector> 00013 #include <QMap> 00014 #include <QString> 00015 #include <QObject> 00016 00017 #include "core/diatonicpitch.h" 00018 00019 class CASheet; 00020 class CADiatonicKey; 00021 00022 class CAMidiDevice : public QObject { 00023 #ifndef SWIG 00024 Q_OBJECT 00025 #endif 00026 00027 friend void rtMidiInCallback( double deltatime, std::vector< unsigned char > *message, void *userData ); 00028 public: 00029 enum CAMidiDeviceType { 00030 RtMidiDevice, 00031 MidiExportDevice 00032 }; 00033 00034 CAMidiDevice(); 00035 00036 enum midiCommands { 00037 Meta_Text = 0x01, 00038 Meta_Copyright = 0x02, 00039 Meta_SeqTrkName = 0x03, 00040 Meta_InstrName = 0x04, 00041 Meta_Lyric = 0x05, 00042 Meta_Marker = 0x06, 00043 Meta_CuePoint = 0x07, 00044 Meta_Tempo = 0x51, // len=03 tt tt tt microseconds per midi quarter note 00045 Meta_SMPTEOffs = 0x54, // len=05 hr mn se fr ff SMPTE Offset 00046 Meta_Timesig = 0x58, 00047 Meta_Keysig = 0x59, 00048 Meta_Track_End = 0x2f, 00049 00050 Midi_Ctl_Reverb = 0x5b, 00051 Midi_Ctl_Chorus = 0x5d, 00052 Midi_Ctl_Pan = 0x0a, 00053 Midi_Ctl_Volume = 0x07, 00054 Midi_Ctl_Sustain = 0x40, 00055 Midi_Ctl_Event = 0xff, 00056 // Events with midi channel on the low nibble: 00057 Midi_Note_Off = 0x80, // 3 byte 00058 Midi_Note_On = 0x90, 00059 Midi_Prog_Change = 0xc0, // 2 byte 00060 Midi_Control_Chg = 0xb0 // 3 byte 00061 }; 00062 00063 00064 QStringList GM_INSTRUMENTS; 00065 static unsigned char freeMidiChannel( CASheet* ); 00066 00067 virtual ~CAMidiDevice() {}; 00068 00069 inline CAMidiDeviceType midiDeviceType() { return _midiDeviceType; }; 00070 00071 bool isRealTime() { return _realTime; } 00072 virtual QMap<int, QString> getOutputPorts() = 0; 00073 virtual QMap<int, QString> getInputPorts() = 0; 00074 00075 virtual bool openOutputPort(int port) = 0; // return true on success, false otherwise 00076 virtual bool openInputPort(int port) = 0; // return true on success, false otherwise 00077 virtual void closeOutputPort() = 0; 00078 virtual void closeInputPort() = 0; 00079 virtual void send(QVector<unsigned char> message, int mSeconds=0) = 0; // message and absolute time of the message in miliseconds 00080 00081 #ifndef SWIG 00082 signals: 00083 void midiInEvent( QVector< unsigned char > message ); 00084 #endif 00085 00086 public: 00087 static int diatonicPitchToMidiPitch( CADiatonicPitch ); 00088 static CADiatonicPitch midiPitchToDiatonicPitch( int ); 00089 static CADiatonicPitch midiPitchToDiatonicPitch( int, CADiatonicKey k ); 00090 00091 protected: 00092 void setRealTime( bool r ) { _realTime = r; } 00093 inline void setMidiDeviceType( CAMidiDeviceType t ) { _midiDeviceType = t; } 00094 CAMidiDeviceType _midiDeviceType; 00095 bool _realTime; // is the device 00096 }; 00097 00098 #endif /* MIDIDEVICE_H_ */
1.8.0