linuxsampler 2.3.1
EventListeners.h
Go to the documentation of this file.
1/***************************************************************************
2 * *
3 * Copyright (C) 2007 - 2009 Grigor Iliev *
4 * Copyright (C) 2016 Christian Schoenebeck *
5 * *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
19 * MA 02110-1301 USA *
20 ***************************************************************************/
21
22#ifndef __LS_EVENTLISTENERS_H__
23#define __LS_EVENTLISTENERS_H__
24
25#include <vector>
26#include "common/global.h"
27
28namespace LinuxSampler {
29
30 // just symbol prototyping
31 class SamplerChannel;
32 class MidiInputDevice;
33 class MidiInputPort;
34
35 template<class L>
37 public:
41 void AddListener(L l) {
42 vListenerList.push_back(l);
43 }
44
49 typename std::vector<L>::iterator it;
50 it = vListenerList.begin();
51 for (; it != vListenerList.end(); it++) {
52 if (*it == l) {
53 vListenerList.erase(it);
54 return;
55 }
56 }
57 }
58
63 vListenerList.clear();
64 }
65
70 return (int) vListenerList.size();
71 }
72
78 return vListenerList.at(index);
79 }
80
81 private:
82 std::vector<L> vListenerList;
83 };
84
85#define REGISTER_FIRE_EVENT_METHOD(method) virtual void method() \
86 { for(int i = 0; i < GetListenerCount(); i++) GetListener(i)->method(); }
87
88#define REGISTER_FIRE_EVENT_METHOD_ARG1(method, T1) virtual void method(T1 _evt_arg1_) \
89 { for(int i = 0; i < GetListenerCount(); i++) GetListener(i)->method(_evt_arg1_); }
90
91#define REGISTER_FIRE_EVENT_METHOD_ARG2(method, T1, T2) virtual void method(T1 _evt_arg1_, T2 _evt_arg2_) \
92 { for(int i = 0; i < GetListenerCount(); i++) GetListener(i)->method(_evt_arg1_, _evt_arg2_); }
93
99 public:
104 virtual void ChannelCountChanged(int NewCount) = 0;
107 };
108
114 public:
115 virtual void ChannelCountChanged(int NewCount) { };
118 };
119
125 public:
130 virtual void AudioDeviceCountChanged(int NewCount) = 0;
131 };
132
138 public:
143 virtual void MidiDeviceCountChanged(int NewCount) = 0;
144
150 virtual void MidiDeviceToBeDestroyed(MidiInputDevice* pDevice) = 0;
151
157 virtual void MidiDeviceCreated(MidiInputDevice* pDevice) = 0;
158 };
159
165 public:
170 virtual void MidiPortCountChanged(int NewCount) = 0;
171
177 virtual void MidiPortToBeRemoved(MidiInputPort* pPort) = 0;
178
184 virtual void MidiPortAdded(MidiInputPort* pPort) = 0;
185 };
186
192 public:
198 virtual void MidiInstrumentCountChanged(int MapId, int NewCount) = 0;
199 };
200
206 public:
213 virtual void MidiInstrumentInfoChanged(int MapId, int Bank, int Program) = 0;
214 };
215
221 public:
227 };
228
234 public:
239 virtual void MidiInstrumentMapInfoChanged(int MapId) = 0;
240 };
241
247 public:
254 virtual void FxSendCountChanged(int ChannelId, int NewCount) = 0;
255 };
256
262 public:
269 virtual void VoiceCountChanged(int ChannelId, int NewCount) = 0;
270 };
271
277 public:
284 virtual void StreamCountChanged(int ChannelId, int NewCount) = 0;
285 };
286
292 public:
300 };
301
307 public:
312 virtual void TotalStreamCountChanged(int NewCount) = 0;
313 };
314
320 public:
325 virtual void TotalVoiceCountChanged(int NewCount) = 0;
326 };
327
333 public:
339 virtual void EngineToBeChanged(int ChannelId) = 0;
340
347 virtual void EngineChanged(int ChannelId) = 0;
348 };
349}
350#endif
This class is used as a listener, which is notified when the number of audio output devices is change...
virtual void AudioDeviceCountChanged(int NewCount)=0
Invoked when the number of audio output devices has changed.
This class is used as a listener, which is notified when the fill state of the disk stream buffers on...
virtual void BufferFillChanged(int ChannelId, String FillData)=0
Invoked when the fill state of the disk stream buffers on the specified sampler channel is changed.
This class exists as convenience for creating listener objects.
virtual void ChannelToBeRemoved(SamplerChannel *pChannel)
virtual void ChannelCountChanged(int NewCount)
Invoked when the number of sampler channels has changed.
virtual void ChannelAdded(SamplerChannel *pChannel)
This class is used as a listener, which is notified when the number of sampler channels is changed.
virtual void ChannelCountChanged(int NewCount)=0
Invoked when the number of sampler channels has changed.
virtual void ChannelAdded(SamplerChannel *pChannel)=0
virtual void ChannelToBeRemoved(SamplerChannel *pChannel)=0
This class is used as a listener, which is notified when the engine type of a particular sampler chan...
virtual void EngineToBeChanged(int ChannelId)=0
Invoked when the engine type of the specified sampler channel is going to be changed soon.
virtual void EngineChanged(int ChannelId)=0
Invoked when the engine type of the specified sampler channel was changed.
This class is used as a listener, which is notified when the number of effect sends on a particular s...
virtual void FxSendCountChanged(int ChannelId, int NewCount)=0
Invoked when the number of effect sends on the specified sampler channel has changed.
void RemoveAllListeners()
Removes all listeners.
int GetListenerCount()
Gets the number of the registered listeners.
void RemoveListener(L l)
Removes the specified listener.
L GetListener(int index)
Gets the listener at the specified position.
void AddListener(L l)
Registers the specified listener for receiving event messages.
This class is used as a listener, which is notified when the number of MIDI input devices is changed.
virtual void MidiDeviceCreated(MidiInputDevice *pDevice)=0
Invoked to inform that a new MidiInputDevice has just been created.
virtual void MidiDeviceToBeDestroyed(MidiInputDevice *pDevice)=0
Invoked right before the supplied MIDI input device is going to be destroyed.
virtual void MidiDeviceCountChanged(int NewCount)=0
Invoked when the number of MIDI input devices has changed.
Abstract base class for MIDI input drivers in LinuxSampler.
This class is used as a listener, which is notified when the number of MIDI instruments on a particul...
virtual void MidiInstrumentCountChanged(int MapId, int NewCount)=0
Invoked when the number of MIDI instruments has changed.
This class is used as a listener, which is notified when a MIDI instrument in a MIDI instrument map i...
virtual void MidiInstrumentInfoChanged(int MapId, int Bank, int Program)=0
Invoked when a MIDI instrument in a MIDI instrument map is changed.
This class is used as a listener, which is notified when the number of MIDI instrument maps is change...
virtual void MidiInstrumentMapCountChanged(int NewCount)=0
Invoked when the number of MIDI instrument maps has changed.
This class is used as a listener, which is notified when the settings of a MIDI instrument map are ch...
virtual void MidiInstrumentMapInfoChanged(int MapId)=0
Invoked when the settings of a MIDI instrument map are changed.
This class is used as a listener, which is notified when the number of MIDI input ports is changed.
virtual void MidiPortCountChanged(int NewCount)=0
Invoked when the number of MIDI input ports has changed.
virtual void MidiPortAdded(MidiInputPort *pPort)=0
Invoked to inform that a new MidiInputPort has just been added.
virtual void MidiPortToBeRemoved(MidiInputPort *pPort)=0
Invoked right before the supplied MIDI input port is going to be destroyed.
LinuxSampler sampler channel (a.k.a.
Definition Sampler.h:49
This class is used as a listener, which is notified when the number of active disk streams in a parti...
virtual void StreamCountChanged(int ChannelId, int NewCount)=0
Invoked when the number of active disk streams on the specified sampler channel has changed.
Wraps as a kind of pointer class some data object shared with other threads, to protect / synchronize...
This class is used as a listener, which is notified when the total number of active streams is change...
virtual void TotalStreamCountChanged(int NewCount)=0
Invoked when the total number of active streams is changed.
This class is used as a listener, which is notified when the total number of active voices is changed...
virtual void TotalVoiceCountChanged(int NewCount)=0
Invoked when the total number of active voices is changed.
This class is used as a listener, which is notified when the number of active voices in a particular ...
virtual void VoiceCountChanged(int ChannelId, int NewCount)=0
Invoked when the number of active voices on the specified sampler channel has changed.
std::string String
Definition global.h:44