annotate data/midi/MIDIInput.h @ 565:3086876472dc

* rtmidi & activity updates
author Chris Cannam
date Tue, 24 Feb 2009 17:25:55 +0000
parents ecce042cc374
children e6d35670e1df
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@559 16 #ifndef _MIDI_INPUT_H_
Chris@559 17 #define _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@560 24
Chris@561 25 class RtMidiIn;
Chris@559 26
Chris@559 27 class MIDIInput : public QObject
Chris@559 28 {
Chris@559 29 Q_OBJECT
Chris@559 30
Chris@559 31 public:
Chris@562 32 MIDIInput(QString name);
Chris@559 33 virtual ~MIDIInput();
Chris@559 34
Chris@561 35 bool isOK() const { return m_rtmidi != 0; }
Chris@559 36
Chris@559 37 bool isEmpty() const { return getEventsAvailable() == 0; }
Chris@561 38 size_t getEventsAvailable() const { return m_buffer.getReadSpace(); }
Chris@559 39 MIDIEvent readEvent();
Chris@559 40
Chris@559 41 signals:
Chris@559 42 void eventsAvailable();
Chris@559 43
Chris@559 44 protected:
Chris@561 45 RtMidiIn *m_rtmidi;
Chris@559 46
Chris@561 47 static void staticCallback(double, std::vector<unsigned char> *, void *);
Chris@559 48 void callback(double, std::vector<unsigned char> *);
Chris@559 49
Chris@559 50 void postEvent(MIDIEvent);
Chris@559 51 RingBuffer<MIDIEvent *> m_buffer;
Chris@559 52 };
Chris@559 53
Chris@559 54 #endif
Chris@559 55