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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1761 - (hide annotations) (download) (as text)
Fri Aug 29 15:42:06 2008 UTC (15 years, 7 months ago) by iliev
File MIME type: text/x-c++hdr
File size: 12682 byte(s)
* fixed a crash which occurs when removing a sampler channel waiting
  to start instrument loading after another channel

1 iliev 1130 /***************************************************************************
2     * *
3 schoenebeck 1686 * Copyright (C) 2007, 2008 Grigor Iliev *
4 iliev 1130 * *
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 schoenebeck 1686 // just symbol prototyping
30     class SamplerChannel;
31 schoenebeck 1695 class MidiInputDevice;
32     class MidiInputPort;
33 schoenebeck 1686
34 iliev 1130 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 schoenebeck 1686 virtual void ChannelAdded(SamplerChannel* pChannel) = 0;
96     virtual void ChannelToBeRemoved(SamplerChannel* pChannel) = 0;
97 iliev 1130 };
98    
99     /**
100 iliev 1761 * This class exists as convenience for creating listener objects.
101     * The methods in this class are empty.
102     */
103     class ChannelCountAdapter : public ChannelCountListener {
104     public:
105     virtual void ChannelCountChanged(int NewCount) { };
106     virtual void ChannelAdded(SamplerChannel* pChannel) { };
107     virtual void ChannelToBeRemoved(SamplerChannel* pChannel) { };
108     };
109    
110     /**
111 iliev 1130 * This class is used as a listener, which is notified
112     * when the number of audio output devices is changed.
113     */
114     class AudioDeviceCountListener {
115     public:
116     /**
117     * Invoked when the number of audio output devices has changed.
118     * @param NewCount The new number of audio output devices.
119     */
120     virtual void AudioDeviceCountChanged(int NewCount) = 0;
121     };
122    
123     /**
124     * This class is used as a listener, which is notified
125     * when the number of MIDI input devices is changed.
126     */
127     class MidiDeviceCountListener {
128     public:
129     /**
130     * Invoked when the number of MIDI input devices has changed.
131     * @param NewCount The new number of MIDI input devices.
132     */
133     virtual void MidiDeviceCountChanged(int NewCount) = 0;
134 schoenebeck 1695
135     /**
136     * Invoked right before the supplied MIDI input device is going
137     * to be destroyed.
138     * @param pDevice MidiInputDevice to be deleted
139     */
140     virtual void MidiDeviceToBeDestroyed(MidiInputDevice* pDevice) = 0;
141    
142     /**
143     * Invoked to inform that a new MidiInputDevice has just been
144     * created.
145     * @param pDevice newly created MidiInputDevice
146     */
147     virtual void MidiDeviceCreated(MidiInputDevice* pDevice) = 0;
148 iliev 1130 };
149    
150     /**
151 schoenebeck 1695 * This class is used as a listener, which is notified
152     * when the number of MIDI input ports is changed.
153     */
154     class MidiPortCountListener {
155     public:
156     /**
157     * Invoked when the number of MIDI input ports has changed.
158     * @param NewCount The new number of MIDI input ports.
159     */
160     virtual void MidiPortCountChanged(int NewCount) = 0;
161    
162     /**
163     * Invoked right before the supplied MIDI input port is going
164     * to be destroyed.
165     * @param pPort MidiInputPort to be deleted
166     */
167     virtual void MidiPortToBeRemoved(MidiInputPort* pPort) = 0;
168    
169     /**
170     * Invoked to inform that a new MidiInputPort has just been
171     * added.
172     * @param pPort newly created MidiInputPort
173     */
174     virtual void MidiPortAdded(MidiInputPort* pPort) = 0;
175     };
176    
177     /**
178 iliev 1130 * This class is used as a listener, which is notified when the number
179     * of MIDI instruments on a particular MIDI instrument map is changed.
180     */
181     class MidiInstrumentCountListener {
182     public:
183     /**
184     * Invoked when the number of MIDI instruments has changed.
185     * @param MapId The numerical ID of the MIDI instrument map.
186     * @param NewCount The new number of MIDI instruments.
187     */
188     virtual void MidiInstrumentCountChanged(int MapId, int NewCount) = 0;
189     };
190    
191     /**
192     * This class is used as a listener, which is notified
193     * when a MIDI instrument in a MIDI instrument map is changed.
194     */
195     class MidiInstrumentInfoListener {
196     public:
197     /**
198     * Invoked when a MIDI instrument in a MIDI instrument map is changed.
199     * @param MapId The numerical ID of the MIDI instrument map.
200     * @param Bank The index of the MIDI bank, containing the instrument.
201     * @param Program The MIDI program number of the instrument.
202     */
203     virtual void MidiInstrumentInfoChanged(int MapId, int Bank, int Program) = 0;
204     };
205    
206     /**
207     * This class is used as a listener, which is notified
208     * when the number of MIDI instrument maps is changed.
209     */
210     class MidiInstrumentMapCountListener {
211     public:
212     /**
213     * Invoked when the number of MIDI instrument maps has changed.
214     * @param NewCount The new number of MIDI instruments.
215     */
216     virtual void MidiInstrumentMapCountChanged(int NewCount) = 0;
217     };
218    
219     /**
220     * This class is used as a listener, which is notified
221     * when the settings of a MIDI instrument map are changed.
222     */
223     class MidiInstrumentMapInfoListener {
224     public:
225     /**
226     * Invoked when the settings of a MIDI instrument map are changed.
227     * @param MapId The numerical ID of the MIDI instrument map.
228     */
229     virtual void MidiInstrumentMapInfoChanged(int MapId) = 0;
230     };
231    
232     /**
233     * This class is used as a listener, which is notified when the number
234     * of effect sends on a particular sampler channel is changed.
235     */
236     class FxSendCountListener {
237     public:
238     /**
239     * Invoked when the number of effect sends
240     * on the specified sampler channel has changed.
241     * @param ChannelId The numerical ID of the sampler channel.
242     * @param NewCount The new number of effect sends.
243     */
244     virtual void FxSendCountChanged(int ChannelId, int NewCount) = 0;
245     };
246    
247     /**
248     * This class is used as a listener, which is notified when the number
249     * of active voices in a particular sampler channel is changed.
250     */
251     class VoiceCountListener {
252     public:
253     /**
254     * Invoked when the number of active voices
255     * on the specified sampler channel has changed.
256     * @param ChannelId The numerical ID of the sampler channel.
257     * @param NewCount The new number of active voices.
258     */
259     virtual void VoiceCountChanged(int ChannelId, int NewCount) = 0;
260     };
261    
262     /**
263     * This class is used as a listener, which is notified when the number
264     * of active disk streams in a particular sampler channel is changed.
265     */
266     class StreamCountListener {
267     public:
268     /**
269     * Invoked when the number of active disk streams
270     * on the specified sampler channel has changed.
271     * @param ChannelId The numerical ID of the sampler channel.
272     * @param NewCount The new number of active disk streams.
273     */
274     virtual void StreamCountChanged(int ChannelId, int NewCount) = 0;
275     };
276    
277     /**
278     * This class is used as a listener, which is notified when the fill state
279     * of the disk stream buffers on a particular sampler channel is changed.
280     */
281     class BufferFillListener {
282     public:
283     /**
284     * Invoked when the fill state of the disk stream
285     * buffers on the specified sampler channel is changed.
286     * @param ChannelId The numerical ID of the sampler channel.
287     * @param FillData The buffer fill data for the specified sampler channel.
288     */
289     virtual void BufferFillChanged(int ChannelId, String FillData) = 0;
290     };
291    
292     /**
293     * This class is used as a listener, which is notified
294 iliev 1541 * when the total number of active streams is changed.
295     */
296     class TotalStreamCountListener {
297     public:
298     /**
299     * Invoked when the total number of active streams is changed.
300     * @param NewCount The new number of active streams.
301     */
302     virtual void TotalStreamCountChanged(int NewCount) = 0;
303     };
304    
305     /**
306     * This class is used as a listener, which is notified
307 iliev 1130 * when the total number of active voices is changed.
308     */
309     class TotalVoiceCountListener {
310     public:
311     /**
312     * Invoked when the total number of active voices is changed.
313     * @param NewCount The new number of active voices.
314     */
315     virtual void TotalVoiceCountChanged(int NewCount) = 0;
316     };
317    
318     /**
319     * This class is used as a listener, which is notified
320     * when the engine type of a particular sampler channel is changed.
321     */
322     class EngineChangeListener {
323     public:
324     /**
325 schoenebeck 1686 * Invoked when the engine type of the specified sampler channel
326     * is going to be changed soon.
327     * @param ChannelId The numerical ID of the sampler channel
328     */
329     virtual void EngineToBeChanged(int ChannelId) = 0;
330    
331     /**
332 iliev 1130 * Invoked when the engine type of the
333 schoenebeck 1686 * specified sampler channel was changed.
334 iliev 1130 * @param ChannelId The numerical ID of the sampler
335     * channel, which engine type has been changed.
336     */
337     virtual void EngineChanged(int ChannelId) = 0;
338     };
339     }
340     #endif

  ViewVC Help
Powered by ViewVC