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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1686 - (show annotations) (download) (as text)
Thu Feb 14 14:58:50 2008 UTC (16 years, 2 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 10719 byte(s)
* added new LSCP event "CHANNEL_MIDI" which can be used by frontends to
  react on MIDI data arriving on certain sampler channels (so far only
  Note-On and Note-Off events are sent via this LSCP event)
* bumped LSCP compliance version to 1.4
* bumped LS version to 0.5.1.3cvs

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

  ViewVC Help
Powered by ViewVC