Canorus  0.7
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
mididevice.h
Go to the documentation of this file.
1 
8 #ifndef MIDIDEVICE_H_
9 #define MIDIDEVICE_H_
10 
11 #include <QStringList>
12 #include <QVector>
13 #include <QMap>
14 #include <QString>
15 #include <QObject>
16 
17 #include "core/diatonicpitch.h"
18 
19 class CASheet;
20 class CADiatonicKey;
21 
22 class CAMidiDevice : public QObject {
23 #ifndef SWIG
24  Q_OBJECT
25 #endif
26 
27  friend void rtMidiInCallback( double deltatime, std::vector< unsigned char > *message, void *userData );
28 public:
32  };
33 
34  CAMidiDevice();
35 
36  enum midiCommands {
37  Meta_Text = 0x01,
41  Meta_Lyric = 0x05,
42  Meta_Marker = 0x06,
43  Meta_CuePoint = 0x07,
44  Meta_Tempo = 0x51, // len=03 tt tt tt microseconds per midi quarter note
45  Meta_SMPTEOffs = 0x54, // len=05 hr mn se fr ff SMPTE Offset
46  Meta_Timesig = 0x58,
47  Meta_Keysig = 0x59,
49 
52  Midi_Ctl_Pan = 0x0a,
56  // Events with midi channel on the low nibble:
57  Midi_Note_Off = 0x80, // 3 byte
58  Midi_Note_On = 0x90,
59  Midi_Prog_Change = 0xc0, // 2 byte
60  Midi_Control_Chg = 0xb0 // 3 byte
61  };
62 
63 
64  QStringList GM_INSTRUMENTS;
65  static unsigned char freeMidiChannel( CASheet* );
66 
67  virtual ~CAMidiDevice() {};
68 
70 
71  bool isRealTime() { return _realTime; }
72  virtual QMap<int, QString> getOutputPorts() = 0;
73  virtual QMap<int, QString> getInputPorts() = 0;
74 
75  virtual bool openOutputPort(int port) = 0; // return true on success, false otherwise
76  virtual bool openInputPort(int port) = 0; // return true on success, false otherwise
77  virtual void closeOutputPort() = 0;
78  virtual void closeInputPort() = 0;
79  virtual void send(QVector<unsigned char> message, int mSeconds=0) = 0; // message and absolute time of the message in miliseconds
80 
81 #ifndef SWIG
82 signals:
83  void midiInEvent( QVector< unsigned char > message );
84 #endif
85 
86 public:
90 
91 protected:
92  void setRealTime( bool r ) { _realTime = r; }
95  bool _realTime; // is the device
96 };
97 
98 #endif /* MIDIDEVICE_H_ */