-
Notifications
You must be signed in to change notification settings - Fork 1
/
events.h
executable file
·181 lines (158 loc) · 6.93 KB
/
events.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
/////////////////////////////////////////////////////////////////////////////////////////////////////
// PROGRAM: MidyAX 2 - MIDI communications orchestrator - MIDI controllers to AXE-FX //
// AIM: Provide enhanced usability of the AXE-FX by making it possible to set the //
// AXE-FX parameters with a hardware interface (knobs/switches of a MIDI controller //
// like : BCR2000 /BCF2000, XTouch Mini, BeatStep, Guitar Wing ... ) //
// CREATOR: Eric FEUILLEAUBOIS //
// PROG ENV: Qt v5.6 or above, RTMIDI library (https://github.com/thestk/rtmidi) //
// HARDWARE: Tested on RPi / PC / MAC / Linux Box / Pipo X8 //
// LICENSE: GNU GPL v3 - That means OPEN SOFWARE, COPYLEFT and hope it's useful to you //
/////////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef EVENTS_H
#define EVENTS_H
#include "mididefs.h"
#include <QEvent>
const QEvent::Type ControlChangeEventType = QEvent::Type( QEvent::registerEventType( QEvent::User + STATUS_CTLCHG ) );
const QEvent::Type ProgramChangeEventType = QEvent::Type( QEvent::registerEventType( QEvent::User + STATUS_PROGRAM ) );
const QEvent::Type ChannelKeyPressEventType = QEvent::Type( QEvent::registerEventType( QEvent::User + STATUS_CHANAFT ) );
const QEvent::Type PitchWheelEventType = QEvent::Type( QEvent::registerEventType( QEvent::User + STATUS_BENDER) );
const QEvent::Type SysExEventType = QEvent::Type( QEvent::registerEventType( QEvent::User + STATUS_SYSEX) );
const QEvent::Type LogSentSysExEventType = QEvent::Type( QEvent::registerEventType( QEvent::User + LOG_SYSEX) );
const QEvent::Type MIDIContDialSetValEventType = QEvent::Type( QEvent::registerEventType( QEvent::User + 1/*MIDI_CONT_SET_VAL*/) );
const QEvent::Type MIDIContDialPageChangeEventType = QEvent::Type( QEvent::registerEventType( QEvent::User + 2) );
const QEvent::Type AXEFXMIDIChannelEventType = QEvent::Type( QEvent::registerEventType( QEvent::User + 3) );
const QEvent::Type IHMSetValEventType = QEvent::Type( QEvent::registerEventType( QEvent::User + 40 ) );
const QEvent::Type BlownUpStartEventType = QEvent::Type( QEvent::registerEventType( QEvent::User + BLOWNUP_START) );
const QEvent::Type BlownUpStopEventType = QEvent::Type( QEvent::registerEventType( QEvent::User + BLOWNUP_STOP) );
class AXEFXMIDIChannelEvent : public QEvent
{
public:
AXEFXMIDIChannelEvent( quint8 AXEFX_Channel) : QEvent(AXEFXMIDIChannelEventType), m_AXEFXChannel(AXEFX_Channel) { }
int getAXEFXChannel() const { return m_AXEFXChannel; }
protected:
quint8 m_AXEFXChannel;
};
class MIDIContDialSetValEvent : public QEvent
{
public:
MIDIContDialSetValEvent( int MIDIContNumb, int pageNumb, int elemNumb, double dispValue )
: QEvent(MIDIContDialSetValEventType), m_MIDIContNumb(MIDIContNumb), m_pageNumb( pageNumb), m_elemNumb(elemNumb), m_dispValue(dispValue) { }
int getMIDIContNumb() const { return m_MIDIContNumb; }
int getPageNumb() const { return m_pageNumb; }
int getElemNumb() const { return m_elemNumb; }
double getDispValue() const { return m_dispValue; }
protected:
int m_MIDIContNumb;
int m_pageNumb;
int m_elemNumb;
double m_dispValue;
};
class IHMSetValEvent : public QEvent
{
public:
IHMSetValEvent( int pageNumb, int elemNumb, double dispValue )
: QEvent(IHMSetValEventType), m_pageNumb( pageNumb), m_elemNumb(elemNumb), m_dispValue(dispValue) { }
int getPageNumb() const { return m_pageNumb; }
int getElemNumb() const { return m_elemNumb; }
double getDispValue() const { return m_dispValue; }
protected:
int m_pageNumb;
int m_elemNumb;
double m_dispValue;
};
class BlownUpStartEvent : public QEvent
{
public:
BlownUpStartEvent() : QEvent(BlownUpStartEventType), m_state(true) { }
protected:
bool m_state;
};
class BlownUpStopEvent : public QEvent
{
public:
BlownUpStopEvent() : QEvent(BlownUpStopEventType), m_state(false) { }
protected:
bool m_state;
};
class MIDIContDialPageChangeEvent : public QEvent
{
public:
MIDIContDialPageChangeEvent( int MIDIContNumb, int receivedCC, int receivedVal )
: QEvent(MIDIContDialPageChangeEventType), m_MIDIContNumb(MIDIContNumb), m_receivedCC( receivedCC), m_receivedVal(receivedVal) { }
int getMIDIContNumb() const { return m_MIDIContNumb; }
int getReceivedCC() const { return m_receivedCC; }
int getReceivedVal() const { return m_receivedVal; }
protected:
int m_MIDIContNumb;
int m_receivedCC;
int m_receivedVal;
};
class ControlChangeEvent : public QEvent
{
public:
ControlChangeEvent(int device, unsigned char channel,unsigned char ctl, unsigned char value, unsigned char direction)
: QEvent(ControlChangeEventType), m_device(device), m_channel(channel), m_ctl(ctl), m_value(value), m_direction(direction) { }
int getDevice() const { return m_device; }
unsigned char getChannel() const { return m_channel; }
unsigned char getController() const { return m_ctl; }
unsigned char getValue() const { return m_value; }
unsigned char getDirection() const { return m_direction; }
private:
int m_device;
unsigned char m_channel;
unsigned char m_ctl;
unsigned char m_value;
unsigned char m_direction;
};
class ValueEvent : public QEvent
{
public:
ValueEvent(int value, QEvent::Type type)
: QEvent(type), m_value(value) { }
int getValue() const { return m_value; }
private:
int m_value;
};
class ProgramChangeEvent : public ValueEvent
{
public:
ProgramChangeEvent(unsigned char value)
: ValueEvent(value, ProgramChangeEventType) { }
};
class ChannelKeyPressEvent : public ValueEvent
{
public:
ChannelKeyPressEvent(unsigned char value)
: ValueEvent(value, ChannelKeyPressEventType) { }
};
class PitchWheelEvent : public ValueEvent
{
public:
PitchWheelEvent(int value)
: ValueEvent(value, PitchWheelEventType) { }
};
class SysExEvent : public QEvent
{
// Event used to process SYSEX message received from MIDI device
public:
SysExEvent(int device, std::vector<unsigned char> sysex_vector)
: QEvent(SysExEventType), m_device(device), m_sysex_vector(sysex_vector) { }
int getDevice() { return m_device; }
std::vector<unsigned char> * getSysEx() { return &m_sysex_vector; }
private :
int m_device;
std::vector<unsigned char> m_sysex_vector;
};
class LogSentSysExEvent : public QEvent
{
// Event used to log SYSEX message send to MIDI device
public:
LogSentSysExEvent(int device, std::vector<unsigned char> sysex_vector)
: QEvent(LogSentSysExEventType), m_device(device), m_sysex_vector(sysex_vector) { }
int getDevice() { return m_device; }
std::vector<unsigned char> * getSysEx() { return &m_sysex_vector; }
private :
int m_device;
std::vector<unsigned char> m_sysex_vector;
};
#endif /* EVENTS_H */