| 1 |
/* |
| 2 |
* midisnoop - MIDI monitor and prober |
| 3 |
* Copyright (C) 2012 Devin Anderson |
| 4 |
* |
| 5 |
* This program is free software; you can redistribute it and/or modify it |
| 6 |
* under the terms of the GNU General Public License as published by the Free |
| 7 |
* Software Foundation; either version 2 of the License, or (at your option) |
| 8 |
* any later version. |
| 9 |
* |
| 10 |
* This program is distributed in the hope that it will be useful, but WITHOUT |
| 11 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 12 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 13 |
* more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU General Public License along with |
| 16 |
* this program; if not, write to the Free Software Foundation, Inc., 675 Mass |
| 17 |
* Ave, Cambridge, MA 02139, USA. |
| 18 |
*/ |
| 19 |
|
| 20 |
#ifndef __ENGINE_H__ |
| 21 |
#define __ENGINE_H__ |
| 22 |
|
| 23 |
#include <QtCore/QByteArray> |
| •24 |
#include <QtCore/QObject> |
| 25 |
#include <QtCore/QStringList> |
| 26 |
#include <QtCore/QVector> |
| 27 |
|
| 28 |
#include <RtMidi.h> |
| 29 |
|
| 30 |
class Engine: public QObject { |
| 31 |
|
| 32 |
Q_OBJECT |
| 33 |
|
| 34 |
public: |
| 35 |
|
| 36 |
explicit |
| 37 |
Engine(QObject *parent=0); |
| 38 |
|
| 39 |
~Engine(); |
| 40 |
|
| 41 |
int |
| 42 |
getDriver() const; |
| 43 |
|
| 44 |
int |
| 45 |
getDriverCount() const; |
| 46 |
|
| 47 |
QString |
| 48 |
getDriverName(int index) const; |
| 49 |
|
| 50 |
bool |
| 51 |
getIgnoreActiveSensingEvents() const; |
| 52 |
|
| 53 |
bool |
| 54 |
getIgnoreSystemExclusiveEvents() const; |
| 55 |
|
| 56 |
bool |
| 57 |
getIgnoreTimeEvents() const; |
| 58 |
|
| 59 |
int |
| 60 |
getInputPort() const; |
| 61 |
|
| 62 |
int |
| 63 |
getInputPortCount() const; |
| 64 |
|
| 65 |
QString |
| 66 |
getInputPortName(int index) const; |
| 67 |
|
| 68 |
int |
| 69 |
getOutputPort() const; |
| 70 |
|
| 71 |
int |
| 72 |
getOutputPortCount() const; |
| 73 |
|
| 74 |
QString |
| 75 |
getOutputPortName(int index) const; |
| 76 |
|
| 77 |
public slots: |
| 78 |
|
| 79 |
quint64 |
| 80 |
sendMessage(const QByteArray &message); |
| 81 |
|
| 82 |
void |
| 83 |
setDriver(int index); |
| 84 |
|
| 85 |
void |
| 86 |
setIgnoreActiveSensingEvents(bool ignore); |
| 87 |
|
| 88 |
void |
| 89 |
setIgnoreSystemExclusiveEvents(bool ignore); |
| 90 |
|
| 91 |
void |
| 92 |
setIgnoreTimeEvents(bool ignore); |
| 93 |
|
| 94 |
void |
| 95 |
setInputPort(int index); |
| 96 |
|
| 97 |
void |
| 98 |
setOutputPort(int index); |
| 99 |
|
| 100 |
signals: |
| 101 |
|
| 102 |
void |
| 103 |
driverChanged(int index); |
| 104 |
|
| 105 |
void |
| 106 |
ignoreActiveSensingEventsChanged(bool ignore); |
| 107 |
|
| 108 |
void |
| 109 |
ignoreSystemExclusiveEventsChanged(bool ignore); |
| 110 |
|
| 111 |
void |
| 112 |
ignoreTimeEventsChanged(bool ignore); |
| 113 |
|
| 114 |
void |
| 115 |
inputPortAdded(int index, const QString &name); |
| 116 |
|
| 117 |
void |
| 118 |
inputPortChanged(int index); |
| 119 |
|
| 120 |
void |
| 121 |
inputPortRemoved(int index); |
| 122 |
|
| 123 |
void |
| 124 |
messageReceived(quint64 timeStamp, const QByteArray &message); |
| 125 |
|
| 126 |
void |
| 127 |
outputPortAdded(int index, const QString &name); |
| 128 |
|
| 129 |
void |
| 130 |
outputPortChanged(int index); |
| 131 |
|
| 132 |
void |
| 133 |
outputPortRemoved(int index); |
| 134 |
|
| 135 |
private: |
| 136 |
|
| 137 |
static void |
| 138 |
handleMidiInput(double timeStamp, std::vector<unsigned char> *message, |
| 139 |
void *engine); |
| 140 |
|
| 141 |
quint64 |
| 142 |
getCurrentTimestamp() const; |
| 143 |
|
| 144 |
void |
| 145 |
handleMidiInput(double timeStamp, |
| 146 |
const std::vector<unsigned char> &message); |
| 147 |
|
| 148 |
void |
| 149 |
removePorts(); |
| 150 |
|
| 151 |
void |
| 152 |
updateEventFilter(); |
| 153 |
|
| 154 |
int driver; |
| 155 |
QList<RtMidi::Api> driverAPIs; |
| 156 |
QStringList driverNames; |
| 157 |
bool ignoreActiveSensingEvents; |
| 158 |
bool ignoreSystemExclusiveEvents; |
| 159 |
bool ignoreTimeEvents; |
| 160 |
RtMidiIn *input; |
| 161 |
int inputPort; |
| 162 |
QStringList inputPortNames; |
| 163 |
RtMidiOut *output; |
| 164 |
int outputPort; |
| 165 |
QStringList outputPortNames; |
| 166 |
bool virtualPortsAdded; |
| 167 |
|
| 168 |
}; |
| 169 |
|
| 170 |
#endif |