1 |
/*************************************************************************** |
2 |
* * |
3 |
* Copyright (C) 2007 Grigor Iliev * |
4 |
* * |
5 |
* This program is free software; you can redistribute it and/or modify * |
6 |
* it under the terms of the GNU General Public License as published by * |
7 |
* the Free Software Foundation; either version 2 of the License, or * |
8 |
* (at your option) any later version. * |
9 |
* * |
10 |
* This program is distributed in the hope that it will be useful, * |
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
13 |
* GNU General Public License for more details. * |
14 |
* * |
15 |
* You should have received a copy of the GNU General Public License * |
16 |
* along with this program; if not, write to the Free Software * |
17 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, * |
18 |
* MA 02110-1301 USA * |
19 |
***************************************************************************/ |
20 |
|
21 |
#ifndef __LS_EVENTLISTENERS_H__ |
22 |
#define __LS_EVENTLISTENERS_H__ |
23 |
|
24 |
#include <vector> |
25 |
#include "common/global.h" |
26 |
|
27 |
namespace LinuxSampler { |
28 |
|
29 |
template<class L> |
30 |
class ListenerList { |
31 |
public: |
32 |
/** |
33 |
* Registers the specified listener for receiving event messages. |
34 |
*/ |
35 |
void AddListener(L l) { |
36 |
vListenerList.push_back(l); |
37 |
} |
38 |
|
39 |
/** |
40 |
* Removes the specified listener. |
41 |
*/ |
42 |
void RemoveListener(L l) { |
43 |
typename std::vector<L>::iterator it; |
44 |
it = vListenerList.begin(); |
45 |
for (; it != vListenerList.end(); it++) { |
46 |
if (*it == l) { |
47 |
vListenerList.erase(it); |
48 |
return; |
49 |
} |
50 |
} |
51 |
} |
52 |
|
53 |
/** |
54 |
* Removes all listeners. |
55 |
*/ |
56 |
void RemoveAllListeners() { |
57 |
vListenerList.clear(); |
58 |
} |
59 |
|
60 |
/** |
61 |
* Gets the number of the registered listeners. |
62 |
*/ |
63 |
int GetListenerCount() { |
64 |
return vListenerList.size(); |
65 |
} |
66 |
|
67 |
/** |
68 |
* Gets the listener at the specified position. |
69 |
* @param index The position of the listener to return. |
70 |
*/ |
71 |
L GetListener(int index) { |
72 |
return vListenerList.at(index); |
73 |
} |
74 |
|
75 |
private: |
76 |
std::vector<L> vListenerList; |
77 |
}; |
78 |
|
79 |
/** |
80 |
* This class is used as a listener, which is notified |
81 |
* when the number of sampler channels is changed. |
82 |
*/ |
83 |
class ChannelCountListener { |
84 |
public: |
85 |
/** |
86 |
* Invoked when the number of sampler channels has changed. |
87 |
* @param NewCount The new number of sampler channels. |
88 |
*/ |
89 |
virtual void ChannelCountChanged(int NewCount) = 0; |
90 |
}; |
91 |
|
92 |
/** |
93 |
* This class is used as a listener, which is notified |
94 |
* when the number of audio output devices is changed. |
95 |
*/ |
96 |
class AudioDeviceCountListener { |
97 |
public: |
98 |
/** |
99 |
* Invoked when the number of audio output devices has changed. |
100 |
* @param NewCount The new number of audio output devices. |
101 |
*/ |
102 |
virtual void AudioDeviceCountChanged(int NewCount) = 0; |
103 |
}; |
104 |
|
105 |
/** |
106 |
* This class is used as a listener, which is notified |
107 |
* when the number of MIDI input devices is changed. |
108 |
*/ |
109 |
class MidiDeviceCountListener { |
110 |
public: |
111 |
/** |
112 |
* Invoked when the number of MIDI input devices has changed. |
113 |
* @param NewCount The new number of MIDI input devices. |
114 |
*/ |
115 |
virtual void MidiDeviceCountChanged(int NewCount) = 0; |
116 |
}; |
117 |
|
118 |
/** |
119 |
* This class is used as a listener, which is notified when the number |
120 |
* of MIDI instruments on a particular MIDI instrument map is changed. |
121 |
*/ |
122 |
class MidiInstrumentCountListener { |
123 |
public: |
124 |
/** |
125 |
* Invoked when the number of MIDI instruments has changed. |
126 |
* @param MapId The numerical ID of the MIDI instrument map. |
127 |
* @param NewCount The new number of MIDI instruments. |
128 |
*/ |
129 |
virtual void MidiInstrumentCountChanged(int MapId, int NewCount) = 0; |
130 |
}; |
131 |
|
132 |
/** |
133 |
* This class is used as a listener, which is notified |
134 |
* when a MIDI instrument in a MIDI instrument map is changed. |
135 |
*/ |
136 |
class MidiInstrumentInfoListener { |
137 |
public: |
138 |
/** |
139 |
* Invoked when a MIDI instrument in a MIDI instrument map is changed. |
140 |
* @param MapId The numerical ID of the MIDI instrument map. |
141 |
* @param Bank The index of the MIDI bank, containing the instrument. |
142 |
* @param Program The MIDI program number of the instrument. |
143 |
*/ |
144 |
virtual void MidiInstrumentInfoChanged(int MapId, int Bank, int Program) = 0; |
145 |
}; |
146 |
|
147 |
/** |
148 |
* This class is used as a listener, which is notified |
149 |
* when the number of MIDI instrument maps is changed. |
150 |
*/ |
151 |
class MidiInstrumentMapCountListener { |
152 |
public: |
153 |
/** |
154 |
* Invoked when the number of MIDI instrument maps has changed. |
155 |
* @param NewCount The new number of MIDI instruments. |
156 |
*/ |
157 |
virtual void MidiInstrumentMapCountChanged(int NewCount) = 0; |
158 |
}; |
159 |
|
160 |
/** |
161 |
* This class is used as a listener, which is notified |
162 |
* when the settings of a MIDI instrument map are changed. |
163 |
*/ |
164 |
class MidiInstrumentMapInfoListener { |
165 |
public: |
166 |
/** |
167 |
* Invoked when the settings of a MIDI instrument map are changed. |
168 |
* @param MapId The numerical ID of the MIDI instrument map. |
169 |
*/ |
170 |
virtual void MidiInstrumentMapInfoChanged(int MapId) = 0; |
171 |
}; |
172 |
|
173 |
/** |
174 |
* This class is used as a listener, which is notified when the number |
175 |
* of effect sends on a particular sampler channel is changed. |
176 |
*/ |
177 |
class FxSendCountListener { |
178 |
public: |
179 |
/** |
180 |
* Invoked when the number of effect sends |
181 |
* on the specified sampler channel has changed. |
182 |
* @param ChannelId The numerical ID of the sampler channel. |
183 |
* @param NewCount The new number of effect sends. |
184 |
*/ |
185 |
virtual void FxSendCountChanged(int ChannelId, int NewCount) = 0; |
186 |
}; |
187 |
|
188 |
/** |
189 |
* This class is used as a listener, which is notified when the number |
190 |
* of active voices in a particular sampler channel is changed. |
191 |
*/ |
192 |
class VoiceCountListener { |
193 |
public: |
194 |
/** |
195 |
* Invoked when the number of active voices |
196 |
* on the specified sampler channel has changed. |
197 |
* @param ChannelId The numerical ID of the sampler channel. |
198 |
* @param NewCount The new number of active voices. |
199 |
*/ |
200 |
virtual void VoiceCountChanged(int ChannelId, int NewCount) = 0; |
201 |
}; |
202 |
|
203 |
/** |
204 |
* This class is used as a listener, which is notified when the number |
205 |
* of active disk streams in a particular sampler channel is changed. |
206 |
*/ |
207 |
class StreamCountListener { |
208 |
public: |
209 |
/** |
210 |
* Invoked when the number of active disk streams |
211 |
* on the specified sampler channel has changed. |
212 |
* @param ChannelId The numerical ID of the sampler channel. |
213 |
* @param NewCount The new number of active disk streams. |
214 |
*/ |
215 |
virtual void StreamCountChanged(int ChannelId, int NewCount) = 0; |
216 |
}; |
217 |
|
218 |
/** |
219 |
* This class is used as a listener, which is notified when the fill state |
220 |
* of the disk stream buffers on a particular sampler channel is changed. |
221 |
*/ |
222 |
class BufferFillListener { |
223 |
public: |
224 |
/** |
225 |
* Invoked when the fill state of the disk stream |
226 |
* buffers on the specified sampler channel is changed. |
227 |
* @param ChannelId The numerical ID of the sampler channel. |
228 |
* @param FillData The buffer fill data for the specified sampler channel. |
229 |
*/ |
230 |
virtual void BufferFillChanged(int ChannelId, String FillData) = 0; |
231 |
}; |
232 |
|
233 |
/** |
234 |
* This class is used as a listener, which is notified |
235 |
* when the total number of active voices is changed. |
236 |
*/ |
237 |
class TotalVoiceCountListener { |
238 |
public: |
239 |
/** |
240 |
* Invoked when the total number of active voices is changed. |
241 |
* @param NewCount The new number of active voices. |
242 |
*/ |
243 |
virtual void TotalVoiceCountChanged(int NewCount) = 0; |
244 |
}; |
245 |
|
246 |
/** |
247 |
* This class is used as a listener, which is notified |
248 |
* when the engine type of a particular sampler channel is changed. |
249 |
*/ |
250 |
class EngineChangeListener { |
251 |
public: |
252 |
/** |
253 |
* Invoked when the engine type of the |
254 |
* specified sampler channel is changed. |
255 |
* @param ChannelId The numerical ID of the sampler |
256 |
* channel, which engine type has been changed. |
257 |
*/ |
258 |
virtual void EngineChanged(int ChannelId) = 0; |
259 |
}; |
260 |
} |
261 |
#endif |