/[svn]/linuxsampler/trunk/src/EventListeners.h
ViewVC logotype

Contents of /linuxsampler/trunk/src/EventListeners.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1695 - (show annotations) (download) (as text)
Sat Feb 16 01:09:33 2008 UTC (16 years, 1 month ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 12257 byte(s)
* added new LSCP event "DEVICE_MIDI" which can be used by frontends to
  react on MIDI data arriving on certain MIDI input devices (so far only
  Note-On and Note-Off events are sent via this LSCP event)
* bumped version to 0.5.1.4cvs

1 /***************************************************************************
2 * *
3 * Copyright (C) 2007, 2008 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 // just symbol prototyping
30 class SamplerChannel;
31 class MidiInputDevice;
32 class MidiInputPort;
33
34 template<class L>
35 class ListenerList {
36 public:
37 /**
38 * Registers the specified listener for receiving event messages.
39 */
40 void AddListener(L l) {
41 vListenerList.push_back(l);
42 }
43
44 /**
45 * Removes the specified listener.
46 */
47 void RemoveListener(L l) {
48 typename std::vector<L>::iterator it;
49 it = vListenerList.begin();
50 for (; it != vListenerList.end(); it++) {
51 if (*it == l) {
52 vListenerList.erase(it);
53 return;
54 }
55 }
56 }
57
58 /**
59 * Removes all listeners.
60 */
61 void RemoveAllListeners() {
62 vListenerList.clear();
63 }
64
65 /**
66 * Gets the number of the registered listeners.
67 */
68 int GetListenerCount() {
69 return vListenerList.size();
70 }
71
72 /**
73 * Gets the listener at the specified position.
74 * @param index The position of the listener to return.
75 */
76 L GetListener(int index) {
77 return vListenerList.at(index);
78 }
79
80 private:
81 std::vector<L> vListenerList;
82 };
83
84 /**
85 * This class is used as a listener, which is notified
86 * when the number of sampler channels is changed.
87 */
88 class ChannelCountListener {
89 public:
90 /**
91 * Invoked when the number of sampler channels has changed.
92 * @param NewCount The new number of sampler channels.
93 */
94 virtual void ChannelCountChanged(int NewCount) = 0;
95 virtual void ChannelAdded(SamplerChannel* pChannel) = 0;
96 virtual void ChannelToBeRemoved(SamplerChannel* pChannel) = 0;
97 };
98
99 /**
100 * This class is used as a listener, which is notified
101 * when the number of audio output devices is changed.
102 */
103 class AudioDeviceCountListener {
104 public:
105 /**
106 * Invoked when the number of audio output devices has changed.
107 * @param NewCount The new number of audio output devices.
108 */
109 virtual void AudioDeviceCountChanged(int NewCount) = 0;
110 };
111
112 /**
113 * This class is used as a listener, which is notified
114 * when the number of MIDI input devices is changed.
115 */
116 class MidiDeviceCountListener {
117 public:
118 /**
119 * Invoked when the number of MIDI input devices has changed.
120 * @param NewCount The new number of MIDI input devices.
121 */
122 virtual void MidiDeviceCountChanged(int NewCount) = 0;
123
124 /**
125 * Invoked right before the supplied MIDI input device is going
126 * to be destroyed.
127 * @param pDevice MidiInputDevice to be deleted
128 */
129 virtual void MidiDeviceToBeDestroyed(MidiInputDevice* pDevice) = 0;
130
131 /**
132 * Invoked to inform that a new MidiInputDevice has just been
133 * created.
134 * @param pDevice newly created MidiInputDevice
135 */
136 virtual void MidiDeviceCreated(MidiInputDevice* pDevice) = 0;
137 };
138
139 /**
140 * This class is used as a listener, which is notified
141 * when the number of MIDI input ports is changed.
142 */
143 class MidiPortCountListener {
144 public:
145 /**
146 * Invoked when the number of MIDI input ports has changed.
147 * @param NewCount The new number of MIDI input ports.
148 */
149 virtual void MidiPortCountChanged(int NewCount) = 0;
150
151 /**
152 * Invoked right before the supplied MIDI input port is going
153 * to be destroyed.
154 * @param pPort MidiInputPort to be deleted
155 */
156 virtual void MidiPortToBeRemoved(MidiInputPort* pPort) = 0;
157
158 /**
159 * Invoked to inform that a new MidiInputPort has just been
160 * added.
161 * @param pPort newly created MidiInputPort
162 */
163 virtual void MidiPortAdded(MidiInputPort* pPort) = 0;
164 };
165
166 /**
167 * This class is used as a listener, which is notified when the number
168 * of MIDI instruments on a particular MIDI instrument map is changed.
169 */
170 class MidiInstrumentCountListener {
171 public:
172 /**
173 * Invoked when the number of MIDI instruments has changed.
174 * @param MapId The numerical ID of the MIDI instrument map.
175 * @param NewCount The new number of MIDI instruments.
176 */
177 virtual void MidiInstrumentCountChanged(int MapId, int NewCount) = 0;
178 };
179
180 /**
181 * This class is used as a listener, which is notified
182 * when a MIDI instrument in a MIDI instrument map is changed.
183 */
184 class MidiInstrumentInfoListener {
185 public:
186 /**
187 * Invoked when a MIDI instrument in a MIDI instrument map is changed.
188 * @param MapId The numerical ID of the MIDI instrument map.
189 * @param Bank The index of the MIDI bank, containing the instrument.
190 * @param Program The MIDI program number of the instrument.
191 */
192 virtual void MidiInstrumentInfoChanged(int MapId, int Bank, int Program) = 0;
193 };
194
195 /**
196 * This class is used as a listener, which is notified
197 * when the number of MIDI instrument maps is changed.
198 */
199 class MidiInstrumentMapCountListener {
200 public:
201 /**
202 * Invoked when the number of MIDI instrument maps has changed.
203 * @param NewCount The new number of MIDI instruments.
204 */
205 virtual void MidiInstrumentMapCountChanged(int NewCount) = 0;
206 };
207
208 /**
209 * This class is used as a listener, which is notified
210 * when the settings of a MIDI instrument map are changed.
211 */
212 class MidiInstrumentMapInfoListener {
213 public:
214 /**
215 * Invoked when the settings of a MIDI instrument map are changed.
216 * @param MapId The numerical ID of the MIDI instrument map.
217 */
218 virtual void MidiInstrumentMapInfoChanged(int MapId) = 0;
219 };
220
221 /**
222 * This class is used as a listener, which is notified when the number
223 * of effect sends on a particular sampler channel is changed.
224 */
225 class FxSendCountListener {
226 public:
227 /**
228 * Invoked when the number of effect sends
229 * on the specified sampler channel has changed.
230 * @param ChannelId The numerical ID of the sampler channel.
231 * @param NewCount The new number of effect sends.
232 */
233 virtual void FxSendCountChanged(int ChannelId, int NewCount) = 0;
234 };
235
236 /**
237 * This class is used as a listener, which is notified when the number
238 * of active voices in a particular sampler channel is changed.
239 */
240 class VoiceCountListener {
241 public:
242 /**
243 * Invoked when the number of active voices
244 * on the specified sampler channel has changed.
245 * @param ChannelId The numerical ID of the sampler channel.
246 * @param NewCount The new number of active voices.
247 */
248 virtual void VoiceCountChanged(int ChannelId, int NewCount) = 0;
249 };
250
251 /**
252 * This class is used as a listener, which is notified when the number
253 * of active disk streams in a particular sampler channel is changed.
254 */
255 class StreamCountListener {
256 public:
257 /**
258 * Invoked when the number of active disk streams
259 * on the specified sampler channel has changed.
260 * @param ChannelId The numerical ID of the sampler channel.
261 * @param NewCount The new number of active disk streams.
262 */
263 virtual void StreamCountChanged(int ChannelId, int NewCount) = 0;
264 };
265
266 /**
267 * This class is used as a listener, which is notified when the fill state
268 * of the disk stream buffers on a particular sampler channel is changed.
269 */
270 class BufferFillListener {
271 public:
272 /**
273 * Invoked when the fill state of the disk stream
274 * buffers on the specified sampler channel is changed.
275 * @param ChannelId The numerical ID of the sampler channel.
276 * @param FillData The buffer fill data for the specified sampler channel.
277 */
278 virtual void BufferFillChanged(int ChannelId, String FillData) = 0;
279 };
280
281 /**
282 * This class is used as a listener, which is notified
283 * when the total number of active streams is changed.
284 */
285 class TotalStreamCountListener {
286 public:
287 /**
288 * Invoked when the total number of active streams is changed.
289 * @param NewCount The new number of active streams.
290 */
291 virtual void TotalStreamCountChanged(int NewCount) = 0;
292 };
293
294 /**
295 * This class is used as a listener, which is notified
296 * when the total number of active voices is changed.
297 */
298 class TotalVoiceCountListener {
299 public:
300 /**
301 * Invoked when the total number of active voices is changed.
302 * @param NewCount The new number of active voices.
303 */
304 virtual void TotalVoiceCountChanged(int NewCount) = 0;
305 };
306
307 /**
308 * This class is used as a listener, which is notified
309 * when the engine type of a particular sampler channel is changed.
310 */
311 class EngineChangeListener {
312 public:
313 /**
314 * Invoked when the engine type of the specified sampler channel
315 * is going to be changed soon.
316 * @param ChannelId The numerical ID of the sampler channel
317 */
318 virtual void EngineToBeChanged(int ChannelId) = 0;
319
320 /**
321 * Invoked when the engine type of the
322 * specified sampler channel was changed.
323 * @param ChannelId The numerical ID of the sampler
324 * channel, which engine type has been changed.
325 */
326 virtual void EngineChanged(int ChannelId) = 0;
327 };
328 }
329 #endif

  ViewVC Help
Powered by ViewVC