Mercurial > hg > svcore
annotate data/midi/MIDIInput.h @ 1677:f97d64b8674f single-point
Make XmlExportables store their export IDs and always obtain a new one, avoiding reuse when an object is allocated at the same heap location as a previous one. This makes the ID system stable enough to be used in the export tests.
author | Chris Cannam |
---|---|
date | Thu, 28 Mar 2019 11:55:02 +0000 |
parents | ad5f892c0c4d |
children |
rev | line source |
---|---|
Chris@559 | 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ |
Chris@559 | 2 |
Chris@559 | 3 /* |
Chris@559 | 4 Sonic Visualiser |
Chris@559 | 5 An audio file viewer and annotation editor. |
Chris@559 | 6 Centre for Digital Music, Queen Mary, University of London. |
Chris@559 | 7 This file copyright 2006-2009 Chris Cannam and QMUL. |
Chris@559 | 8 |
Chris@559 | 9 This program is free software; you can redistribute it and/or |
Chris@559 | 10 modify it under the terms of the GNU General Public License as |
Chris@559 | 11 published by the Free Software Foundation; either version 2 of the |
Chris@559 | 12 License, or (at your option) any later version. See the file |
Chris@559 | 13 COPYING included with this distribution for more information. |
Chris@559 | 14 */ |
Chris@559 | 15 |
Chris@1581 | 16 #ifndef SV_MIDI_INPUT_H |
Chris@1581 | 17 #define SV_MIDI_INPUT_H |
Chris@559 | 18 |
Chris@559 | 19 #include <QObject> |
Chris@559 | 20 #include "MIDIEvent.h" |
Chris@559 | 21 |
Chris@560 | 22 #include <vector> |
Chris@560 | 23 #include "base/RingBuffer.h" |
Chris@567 | 24 #include "base/FrameTimer.h" |
Chris@560 | 25 |
Chris@561 | 26 class RtMidiIn; |
Chris@559 | 27 |
Chris@559 | 28 class MIDIInput : public QObject |
Chris@559 | 29 { |
Chris@559 | 30 Q_OBJECT |
Chris@559 | 31 |
Chris@559 | 32 public: |
Chris@567 | 33 MIDIInput(QString name, FrameTimer *timer); |
Chris@559 | 34 virtual ~MIDIInput(); |
Chris@559 | 35 |
Chris@561 | 36 bool isOK() const { return m_rtmidi != 0; } |
Chris@559 | 37 |
Chris@559 | 38 bool isEmpty() const { return getEventsAvailable() == 0; } |
Chris@929 | 39 int getEventsAvailable() const { return m_buffer.getReadSpace(); } |
Chris@559 | 40 MIDIEvent readEvent(); |
Chris@559 | 41 |
Chris@559 | 42 signals: |
Chris@559 | 43 void eventsAvailable(); |
Chris@559 | 44 |
Chris@559 | 45 protected: |
Chris@561 | 46 RtMidiIn *m_rtmidi; |
Chris@567 | 47 FrameTimer *m_frameTimer; |
Chris@559 | 48 |
Chris@561 | 49 static void staticCallback(double, std::vector<unsigned char> *, void *); |
Chris@559 | 50 void callback(double, std::vector<unsigned char> *); |
Chris@559 | 51 |
Chris@559 | 52 void postEvent(MIDIEvent); |
Chris@559 | 53 RingBuffer<MIDIEvent *> m_buffer; |
Chris@559 | 54 }; |
Chris@559 | 55 |
Chris@559 | 56 #endif |
Chris@559 | 57 |