-
Notifications
You must be signed in to change notification settings - Fork 4
/
midiapplication.h
115 lines (89 loc) · 3.23 KB
/
midiapplication.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/****************************************************************************
**
** Copyright (C) 2018 Robert Vetter.
**
** This file is part of the MagicstompFrenzy - an editor for Yamaha Magicstomp
** effect processor
**
** THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
** ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
** IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
** PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
**
** GNU General Public License Usage
** This file may be used under the terms of the GNU
** General Public License version 2.0 or (at your option) the GNU General
** Public license version 3 or any later version . The licenses are
** as published by the Free Software Foundation and appearing in the file LICENSE
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
** https://www.gnu.org/licenses/gpl-3.0.html.
**/
#ifndef MIDIAPPLICATION_H
#define MIDIAPPLICATION_H
#include <QApplication>
#include <QSet>
#ifdef Q_OS_LINUX
typedef struct _snd_seq snd_seq_t;
typedef snd_seq_t* MidiClientHandle;
#include "midiportidalsa.h"
Q_DECLARE_METATYPE(MidiPortIdAlsa)
class MidiInThread;
class MidiSender;
#endif
#ifdef Q_OS_MACOS
typedef quint32 MidiClientHandle;
typedef quint32 MidiClientPortId;
class MIDINotification;
class MIDIPacketList;
class MIDISysexSendRequest;
#endif
#ifdef Q_OS_WIN
typedef quint32 MidiClientHandle;
typedef quint32 MidiClientPortId;
#endif
class MidiPortModel;
class MidiEvent;
class MidiApplication : public QApplication
{
Q_OBJECT
public:
MidiApplication(int &argc, char **argv);
MidiPortModel *ReadablePortsModel() { return readablePortsModel;}
MidiPortModel *WritablePortsModel() { return writablePortsModel;}
bool event(QEvent *) override;
signals:
void midiEventReceived(MidiEvent *);
public slots:
bool changeReadableMidiPortStatus( MidiClientPortId mcpId, bool connect );
bool changeWritebleMidiPortStatus( MidiClientPortId mcpId, bool connect );
bool changeReadableMidiPortStatus( const QString &portName, bool connect );
bool changeWritebleMidiPortStatus( const QString &portName, bool connect );
bool sendMidiEvent(MidiEvent *ev);
private slots:
void onPortConnectionStatusChanged(MidiClientPortId srcId, MidiClientPortId destId, bool isConnected);
void onPortClientPortStatusChanged(MidiClientPortId mpId, bool isExisting);
void isQuitting();
private:
#ifdef Q_OS_LINUX
MidiInThread *midiInThread;
QThread *midiOutThread;
MidiSender *midiSender;
#endif
#ifdef Q_OS_MACOS
static void MIDIEngineNotifyProc(const MIDINotification *message, void *refCon);
static void MIDIEngineReadProc(const MIDIPacketList *pktlist, void *arg, void *connRefCon);
static void sysexCompletionProc(MIDISysexSendRequest *req);
#endif
//#ifdef Q_OS_WIN
// static void CALLBACK MidiInProc(HMIDIIN hMidiIn, UINT wMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2);
//#endif
MidiPortModel *readablePortsModel;
MidiPortModel *writablePortsModel;
MidiClientHandle handle;
void midiSystemInit();
MidiClientPortId thisInPort;
MidiClientPortId thisOutPort;
};
#endif // MIDIAPPLICATION_H