Mercurial > hg > svcore
comparison data/midi/MIDIInput.h @ 561:863ad4b1f841
* a few more midi bits, attempt to fix vertical-black-bar-misplacement-on-mac
author | Chris Cannam |
---|---|
date | Mon, 23 Feb 2009 14:40:17 +0000 |
parents | 2e50d95cf621 |
children | ecce042cc374 |
comparison
equal
deleted
inserted
replaced
560:2e50d95cf621 | 561:863ad4b1f841 |
---|---|
20 #include "MIDIEvent.h" | 20 #include "MIDIEvent.h" |
21 | 21 |
22 #include <vector> | 22 #include <vector> |
23 #include "base/RingBuffer.h" | 23 #include "base/RingBuffer.h" |
24 | 24 |
25 class RtMidi; | 25 class RtMidiIn; |
26 | 26 |
27 class MIDIInput : public QObject | 27 class MIDIInput : public QObject |
28 { | 28 { |
29 Q_OBJECT | 29 Q_OBJECT |
30 | 30 |
31 public: | 31 public: |
32 MIDIInput(); | 32 MIDIInput(); |
33 virtual ~MIDIInput(); | 33 virtual ~MIDIInput(); |
34 | 34 |
35 bool isOK() const; | 35 bool isOK() const { return m_rtmidi != 0; } |
36 | 36 |
37 bool isEmpty() const { return getEventsAvailable() == 0; } | 37 bool isEmpty() const { return getEventsAvailable() == 0; } |
38 size_t getEventsAvailable() const; | 38 size_t getEventsAvailable() const { return m_buffer.getReadSpace(); } |
39 MIDIEvent readEvent(); | 39 MIDIEvent readEvent(); |
40 | 40 |
41 signals: | 41 signals: |
42 void eventsAvailable(); | 42 void eventsAvailable(); |
43 | 43 |
44 protected: | 44 protected: |
45 RtMidi *m_rtmidi; | 45 RtMidiIn *m_rtmidi; |
46 | 46 |
47 static void callback(double, std::vector<unsigned char> *, void *); | 47 static void staticCallback(double, std::vector<unsigned char> *, void *); |
48 void callback(double, std::vector<unsigned char> *); | 48 void callback(double, std::vector<unsigned char> *); |
49 | 49 |
50 void postEvent(MIDIEvent); | 50 void postEvent(MIDIEvent); |
51 RingBuffer<MIDIEvent *> m_buffer; | 51 RingBuffer<MIDIEvent *> m_buffer; |
52 }; | 52 }; |