| 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/QStringList> |
| 25 |
#include <QtCore/QVector> |
| 26 |
|
| 27 |
#include <RtMidi.h> |
| 28 |
|
| 29 |
class Engine: public QObject { |
| 30 |
|
| 31 |
Q_OBJECT |
| 32 |
|
| 33 |
public: |
| 34 |
|
| 35 |
explicit |
| 36 |
Engine(QObject *parent=0); |
| 37 |
|
| 38 |
~Engine(); |
| 39 |
|
| 40 |
int |
| 41 |
getDriver() const; |
| 42 |
|
| 43 |
int |
| 44 |
getDriverCount() const; |
| 45 |
|
| 46 |
QString |
| 47 |
getDriverName(int index) const; |
| 48 |
|
| 49 |
bool |
| 50 |
getIgnoreActiveSensingEvents() const; |
| 51 |
|
| 52 |
bool |
| 53 |
getIgnoreSystemExclusiveEvents() const; |
| 54 |
|
| 55 |
bool |
| 56 |
getIgnoreTimeEvents() const; |
| 57 |
|
| 58 |
int |
| 59 |
getInputPort() const; |
| 60 |
|
| 61 |
int |
| 62 |
getInputPortCount() const; |
| 63 |
|
| 64 |
QString |
| 65 |
getInputPortName(int index) const; |
| 66 |
|
| 67 |
int |
| 68 |
getOutputPort() const; |
| 69 |
|
| 70 |
int |
| 71 |
getOutputPortCount() const; |
| 72 |
|
| 73 |
QString |
| 74 |
getOutputPortName(int index) const; |
| 75 |
|
| 76 |
public slots: |
| 77 |
|
| 78 |
quint64 |
| 79 |
sendMessage(const QByteArray &message); |
| 80 |
|
| 81 |
void |
| 82 |
setDriver(int index); |
| 83 |
|
| 84 |
void |
| 85 |
setIgnoreActiveSensingEvents(bool ignore); |
| 86 |
|
| 87 |
void |
| 88 |
setIgnoreSystemExclusiveEvents(bool ignore); |
| 89 |
|
| 90 |
void |
| 91 |
setIgnoreTimeEvents(bool ignore); |
| 92 |
|
| 93 |
void |
| 94 |
setInputPort(int index); |
| 95 |
|
| 96 |
void |
| 97 |
setOutputPort(int index); |
| 98 |
|
| 99 |
signals: |
| 100 |
|
| 101 |
void |
| 102 |
driverChanged(int index); |
| 103 |
|
| 104 |
void |
| 105 |
ignoreActiveSensingEventsChanged(bool ignore); |
| 106 |
|
| 107 |
void |
| 108 |
ignoreSystemExclusiveEventsChanged(bool ignore); |
| 109 |
|
| 110 |
void |
| 111 |
ignoreTimeEventsChanged(bool ignore); |
| 112 |
|
| 113 |
void |
| 114 |
inputPortAdded(int index, const QString &name); |
| 115 |
|
| 116 |
void |
| 117 |
inputPortChanged(int index); |
| 118 |
|
| 119 |
void |
| 120 |
inputPortRemoved(int index); |
| 121 |
|
| 122 |
void |
| 123 |
messageReceived(quint64 timeStamp, const QByteArray &message); |
| 124 |
|
| 125 |
void |
| 126 |
outputPortAdded(int index, const QString &name); |
| 127 |
|
| 128 |
void |
| 129 |
outputPortChanged(int index); |
| 130 |
|
| 131 |
void |
| 132 |
outputPortRemoved(int index); |
| 133 |
|
| 134 |
private: |
| 135 |
|
| 136 |
static void |
| 137 |
handleMidiInput(double timeStamp, std::vector<unsigned char> *message, |
| 138 |
void *engine); |
| 139 |
|
| 140 |
quint64 |
| 141 |
getCurrentTimestamp() const; |
| 142 |
|
| 143 |
void |
| 144 |
handleMidiInput(double timeStamp, |
| 145 |
const std::vector<unsigned char> &message); |
| 146 |
|
| 147 |
void |
| 148 |
removePorts(); |
| 149 |
|
| 150 |
void |
| 151 |
updateEventFilter(); |
| 152 |
|
| 153 |
int driver; |
| 154 |
QList<RtMidi::Api> driverAPIs; |
| 155 |
QStringList driverNames; |
| 156 |
bool ignoreActiveSensingEvents; |
| 157 |
bool ignoreSystemExclusiveEvents; |
| 158 |
bool ignoreTimeEvents; |
| 159 |
RtMidiIn *input; |
| 160 |
int inputPort; |
| 161 |
QStringList inputPortNames; |
| 162 |
RtMidiOut *output; |
| 163 |
int outputPort; |
| 164 |
QStringList outputPortNames; |
| 165 |
bool virtualPortsAdded; |
| 166 |
|
| 167 |
}; |
| 168 |
|
| 169 |
#endif |