-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathController.h
137 lines (97 loc) · 4.52 KB
/
Controller.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
#ifndef CONTROLLER_H
#define CONTROLLER_H
#include <Thread.h>
#include <Lock.h>
#include <SoundModel.h>
#include <queue>
#include <string>
#include <iostream>
namespace SYNTHPI {
namespace audio{
class Controller: public Thread{
protected:
/*!An item on the noteQueue.*/
class QueueItem{
public:
bool noteOff;
int note;
/*! Creates a new item and initialises its variables.*/
QueueItem(bool noteOff, int note){
this->noteOff = noteOff;
this->note = note;
}
};
/*!Lock for signalling of changes in keyboard or pedal input.*/
Lock outputLock;
/*!SoundModel the controller attaches to.*/
SoundModel *playout;
/*!Variable for storing the current status of playout.*/
bool isPlaying;
/*!Stores whether or not the pedal has triggered a broadcast.*/
bool pedalTriggered;
/*!Buffers notes sent by keyboard. Notes are stored in instantiations of type QueueItem.*/
std::queue<QueueItem> noteQueue;
/*!Lock for accessing the noteQueue. */
Lock queueLock;
/*! float to pass the volume from the midi CC to SoundModelPoly
float volume;
/*! float to pass the volume from the midi CC to SoundModelPoly
float wavemix_val;
/*! float to pass the volume from the midi CC to SoundModelPoly
float attack_time;
/*! float to pass the volume from the midi CC to SoundModelPoly
float decay_time;
/*! float to pass the volume from the midi CC to SoundModelPoly
float sustain_level;
/*! float to pass the volume from the midi CC to SoundModelPoly
float release_time;
/*! float to pass the volume from the midi CC to SoundModelPoly
int bank_number;*/
public:
/*! Creates a new controller object
\param playout Soundmodel to which controller passes signals.*/
Controller(SoundModel *playout);
/*! Called when a controller object is destroyed.*/
~Controller();
/*! Called by keyboard interface whenever a key event happens.
Stores notes in the noteQueue while waiting for processor time.
\param noteOff is a boolean which is true if the event is turning a note off.
\param note indicates which note to turn off.*/
void keyEvent(bool noteOff, int note);
/*! Called by keyboard interface when it receives a value from the CC associated to the volume control
\param parameter the midi value which represents volume */
void updateVolume(unsigned int parameter);
/*! Called by keyboard interface when it receives a value from the CC associated to the wavemix control
\param parameter the midi value which represents wavemix */
void updateWavemix(unsigned int parameter);
/*! Called by keyboard interface when it receives a value from the CC associated to the attack time control
\param parameter the midi value which represents the attack time */
void updateAttack(unsigned int parameter);
/*! Called by keyboard interface when it receives a value from the CC associated to the decay time control
\param parameter the midi value which represents the decay time */
void updateDecay(unsigned int parameter);
/*! Called by keyboard interface when it receives a value from the CC associated to the sustain level control
\param parameter the midi value which represents the sustain level */
void updateSustain(unsigned int parameter);
/*! Called by keyboard interface when it receives a value from the CC associated to the release time control
\param parameter the midi value which represents the release time */
void updateRelease(unsigned int parameter);
/*! Called by keyboard interface when it receives a value from the CC associated to the bank select control
\param parameter the value which represents the bank to play from */
void updateBank(int parameter);
/*! Called by keyboard interface when it receives a value from the CC associated to the filter cutoff frequency
control
\param parameter the midi value which represents the filter cutoff frequency */
void updateCutoff(unsigned int parameter);
/*! Called by keyboard interface when it receives a value from the CC associated to the filter resonance control
\param parameter the midi value which represents the amount of resonance to the filter*/
void updateRes(unsigned int parameter);
/*! Called by keyboard interface when it receives a value from the CC associated to the slope select control
\param parameter the midi value which select the filter slope (12or24dB/octave) */
void updateSlope(unsigned int parameter);
/*! Starts the running of playout*/
virtual void run();
};
} //close audio namespace
} //close SYNTHPI namespace
#endif /* CONTROLLER_H */