3 |
* LinuxSampler - modular, streaming capable sampler * |
* LinuxSampler - modular, streaming capable sampler * |
4 |
* * |
* * |
5 |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
6 |
|
* Copyright (C) 2005 - 2008 Christian Schoenebeck * |
7 |
* * |
* * |
8 |
* This program is free software; you can redistribute it and/or modify * |
* This program is free software; you can redistribute it and/or modify * |
9 |
* it under the terms of the GNU General Public License as published by * |
* it under the terms of the GNU General Public License as published by * |
26 |
|
|
27 |
#include <vector> |
#include <vector> |
28 |
#include <map> |
#include <map> |
29 |
|
#include "EventListeners.h" |
30 |
#include "common/global.h" |
#include "common/global.h" |
31 |
#include "common/LinuxSamplerException.h" |
#include "common/Exception.h" |
32 |
#include "engines/common/Engine.h" |
#include "engines/EngineChannel.h" |
33 |
#include "mididriver/MidiInputDevice.h" |
#include "drivers/midi/MidiInputDevice.h" |
34 |
#include "audiodriver/AudioOutputDevice.h" |
#include "drivers/audio/AudioOutputDevice.h" |
35 |
|
|
36 |
namespace LinuxSampler { |
namespace LinuxSampler { |
37 |
|
|
38 |
// just symbol prototyping |
// just symbol prototyping |
39 |
class Sampler; |
class Sampler; |
40 |
|
|
41 |
/** LinuxSampler sampler channel |
/** @brief LinuxSampler sampler channel |
42 |
* |
* |
43 |
* Encapsulates one sampler engine, one connection to a MIDI input |
* Encapsulates a channel of a specific sampler engine type, one |
44 |
* device and one connection to an audio output device. You cannot |
* connection to a MIDI input device and one connection to an audio |
45 |
* create an instance of this class on your own, you have to use the |
* output device. You cannot create an instance of this class on your |
46 |
* AddSamplerChannel() method of the Sampler object to create a new |
* own, you have to use the AddSamplerChannel() method of the Sampler |
47 |
* sampler channel. |
* object to create a new sampler channel. |
48 |
*/ |
*/ |
49 |
class SamplerChannel { |
class SamplerChannel { |
50 |
public: |
public: |
51 |
/** |
/** |
52 |
* Deploy a sampler engine of the given type for this sampler |
* Assign a sampler engine type to this sampler channel. |
|
* channnel. If there was already a sampler engine deployed on |
|
|
* this sampler channel, then the old engine will automatically |
|
|
* be destroyed. |
|
53 |
* |
* |
54 |
* @param EngineType - type of the engine to deploy |
* @param EngineType - type of the engine to use |
55 |
|
* @throws Exception - if \a EngineType is invalid |
56 |
|
* @see Sampler::AvailableEngineTypes() |
57 |
*/ |
*/ |
58 |
void LoadEngine(Engine::type_t EngineType); // TODO: to be changed to 'void LoadEngine(String EngineType) throws (LinuxSamplerException);' |
void SetEngineType(String EngineType) throw (Exception); |
59 |
|
|
60 |
/** |
/** |
61 |
* Connect this sampler channel to an audio output device, that |
* Connect this sampler channel to an audio output device, that |
68 |
void SetAudioOutputDevice(AudioOutputDevice* pDevice); |
void SetAudioOutputDevice(AudioOutputDevice* pDevice); |
69 |
|
|
70 |
/** |
/** |
71 |
* Connect this sampler channel to and MIDI input device (that |
* Connect this sampler channel to a MIDI input device. |
|
* is MIDI input driver) of the given type. If the MIDI input |
|
|
* driver for the desired MIDI input system is not yet created, |
|
|
* then it will be created automatically, but with default |
|
|
* settings though. If this sampler channel was already |
|
|
* connected to a MIDI input device, then the old connection |
|
|
* will automatically be removed before. |
|
72 |
* |
* |
73 |
* @param MidiType - MIDI input system to connect to |
* @param pDevice - MIDI input device to connect to |
74 |
|
*/ |
75 |
|
void SetMidiInputDevice(MidiInputDevice *pDevice); |
76 |
|
|
77 |
|
/** |
78 |
|
* Connect this sampler channel to a MIDI input port. |
79 |
|
* |
80 |
|
* @param MidiPort - MIDI port to connect to |
81 |
|
*/ |
82 |
|
void SetMidiInputPort(int MidiPort); |
83 |
|
|
84 |
|
/** |
85 |
|
* Define on which MIDI channel(s) this sampler channel should |
86 |
|
* listen to. By default, that is after creation of a new |
87 |
|
* sampler channel, the sampler channel will listen to all MIDI |
88 |
|
* channels. |
89 |
|
* |
90 |
|
* @param MidiChannel - MIDI channel to listen |
91 |
|
*/ |
92 |
|
void SetMidiInputChannel(midi_chan_t MidiChannel); |
93 |
|
|
94 |
|
/** |
95 |
|
* Connect this sampler channel to a MIDI input triplet. |
96 |
|
* |
97 |
|
* @param pDevice - MIDI input device to connect to |
98 |
|
* @param iMidiPort - MIDI port to connect to |
99 |
* @param MidiChannel - optional: MIDI channel on which the |
* @param MidiChannel - optional: MIDI channel on which the |
100 |
* sampler channel should listen to |
* sampler channel should listen to |
101 |
* (default: listen on all MIDI channels) |
* (default: listen on all MIDI channels) |
102 |
*/ |
*/ |
103 |
void SetMidiInputDevice(MidiInputDevice::type_t MidiType, MidiInputDevice::midi_chan_t MidiChannel = MidiInputDevice::midi_chan_all); // TODO: 'MidiType' type to be changed to 'MidiInputDevice*' |
void SetMidiInput(MidiInputDevice* pDevice, int iMidiPort, midi_chan_t MidiChannel = midi_chan_all); |
104 |
|
|
105 |
/** |
/** |
106 |
* Returns the engine that was deployed on this sampler channel. |
* Returns the EngineChannel object that was deployed on this |
107 |
|
* sampler channel appropriate to the given sampler engine type. |
108 |
* |
* |
109 |
* @returns pointer to engine or NULL if no engine deployed |
* @returns pointer to engine or NULL if no engine deployed |
110 |
*/ |
*/ |
111 |
Engine* GetEngine(); |
EngineChannel* GetEngineChannel(); |
112 |
|
|
113 |
/** |
/** |
114 |
* Returns the MIDI input device to which this sampler channel |
* Returns the MIDI input channel to which this sampler |
115 |
* is currently connected to. |
* channel is currently connected to. |
116 |
* |
* |
117 |
* @returns pointer to MIDI input device or NULL if not |
* @returns The MIDI input channel on which the sampler |
118 |
* connected |
* channel is listening to. |
119 |
*/ |
*/ |
120 |
MidiInputDevice* GetMidiInputDevice(); |
midi_chan_t GetMidiInputChannel(); |
121 |
|
|
122 |
|
/** |
123 |
|
* Returns the MIDI input port number to which this sampler |
124 |
|
* channel is currently connected to. |
125 |
|
* |
126 |
|
* @returns MIDI input port number or -1 if not connected |
127 |
|
*/ |
128 |
|
int GetMidiInputPort(); |
129 |
|
|
130 |
/** |
/** |
131 |
* Returns the audio output device to which this sampler channel |
* Returns the audio output device to which this sampler channel |
137 |
AudioOutputDevice* GetAudioOutputDevice(); |
AudioOutputDevice* GetAudioOutputDevice(); |
138 |
|
|
139 |
/** |
/** |
140 |
|
* Returns the MIDI input device to which this sampler channel |
141 |
|
* is currently connected to. |
142 |
|
* |
143 |
|
* @returns pointer to MIDI input device or NULL if not |
144 |
|
* connected |
145 |
|
*/ |
146 |
|
MidiInputDevice* GetMidiInputDevice(); |
147 |
|
|
148 |
|
/** |
149 |
* Returns the index number of this sampler channel within the |
* Returns the index number of this sampler channel within the |
150 |
* Sampler instance. |
* Sampler instance. |
151 |
*/ |
*/ |
152 |
uint Index(); |
uint Index(); |
153 |
|
|
154 |
|
/** |
155 |
|
* Registers the specified listener to be notified |
156 |
|
* when the engine type of this sampler channel is changed. |
157 |
|
*/ |
158 |
|
void AddEngineChangeListener(EngineChangeListener* l); |
159 |
|
|
160 |
|
/** |
161 |
|
* Removes the specified listener. |
162 |
|
*/ |
163 |
|
void RemoveEngineChangeListener(EngineChangeListener* l); |
164 |
|
|
165 |
|
/** |
166 |
|
* Removes the specified listener. |
167 |
|
*/ |
168 |
|
void RemoveAllEngineChangeListeners(); |
169 |
|
|
170 |
|
/** |
171 |
|
* Notifies listeners that the engine type of this sampler |
172 |
|
* channel is going to be changed soon. |
173 |
|
*/ |
174 |
|
void fireEngineToBeChanged(); |
175 |
|
|
176 |
|
/** |
177 |
|
* Notifies listeners that the engine |
178 |
|
* type of this sampler channel is changed. |
179 |
|
*/ |
180 |
|
void fireEngineChanged(); |
181 |
|
|
182 |
|
|
183 |
protected: |
protected: |
184 |
SamplerChannel(Sampler* pS); |
SamplerChannel(Sampler* pS); |
185 |
~SamplerChannel(); |
virtual ~SamplerChannel(); |
186 |
|
|
187 |
|
/** Getting MIDI input device port given its index number. */ |
188 |
|
MidiInputPort* __GetMidiInputDevicePort(int iMidiPort); |
189 |
|
|
190 |
Sampler* pSampler; |
Sampler* pSampler; |
191 |
Engine* pEngine; |
EngineChannel* pEngineChannel; |
|
MidiInputDevice* pMidiInputDevice; |
|
192 |
AudioOutputDevice* pAudioOutputDevice; |
AudioOutputDevice* pAudioOutputDevice; |
193 |
|
MidiInputDevice* pMidiInputDevice; |
194 |
int iIndex; |
int iIndex; |
195 |
|
|
196 |
friend class Sampler; |
friend class Sampler; |
197 |
|
private: |
198 |
|
int iMidiPort; ///< Don't access directly, read GetMidiInputPort() instead ! |
199 |
|
midi_chan_t midiChannel; ///< Don't access directly, read GetMidiInputChannel() instead ! |
200 |
|
ListenerList<EngineChangeListener*> llEngineChangeListeners; |
201 |
}; |
}; |
202 |
|
|
203 |
/** LinuxSampler main class |
/** @brief LinuxSampler main class |
204 |
* |
* |
205 |
* This is the toplevel class for a LinuxSampler instance. |
* This is the toplevel class for a LinuxSampler instance. |
206 |
* |
* |
208 |
* sampler channel can individually be deployed with it's own sampler |
* sampler channel can individually be deployed with it's own sampler |
209 |
* engine, connected to an arbitrary MIDI input device and connected to |
* engine, connected to an arbitrary MIDI input device and connected to |
210 |
* an arbitrary audio output device. Here an example setup: |
* an arbitrary audio output device. Here an example setup: |
211 |
|
* @code |
212 |
|
* S.Channel MIDI in S.Engine Audio out |
213 |
|
* ------------------------------------------------------------------- |
214 |
|
* 0 Alsa -> gig::Engine -> Jack |
215 |
|
* 1 VSTi -> Akai::Engine -> VSTi |
216 |
|
* 2 Jack -> DLS::Engine -> Jack |
217 |
|
* 3 Jack -> SF::Engine -> Alsa |
218 |
* |
* |
219 |
* S.Channel. MIDI in S.Engine Audio out |
* ... (and so on) ... |
220 |
* ------------------------------------------------------------------- |
* @endcode |
|
* 0 Alsa -> gig::Engine -> Jack |
|
|
* 1 VSTi -> Akai::Engine -> VSTi |
|
|
* 2 Jack -> DLS::Engine -> Jack |
|
|
* 3 Jack -> SF::Engine -> Alsa |
|
|
* |
|
|
* ... (and so on) ... |
|
221 |
* |
* |
222 |
* Note that not all audio and MIDI backends and sampler engines listed |
* Note that not all audio and MIDI backends and sampler engines listed |
223 |
* in the example above are already implemented! |
* in the example above might already been implemented! |
224 |
* |
* |
225 |
* As you can see in the example setup, LinuxSampler is capable to use |
* As you can see in the example setup, LinuxSampler is capable to use |
226 |
* several, different audio output and MIDI input systems |
* several, different audio output and MIDI input systems |
227 |
* simultaniously at the same time. Here the example setup shown in the |
* simultaniously at the same time. Here the example setup shown in the |
228 |
* ascpect of MIDI input and audio output devices / drivers: |
* aspect of MIDI input and audio output devices / drivers: |
229 |
* |
* @code |
230 |
* ######################### ######################### |
* ######################### ######################### |
231 |
* # AudioOutputDeviceJack # # AudioOutputDeviceVSTi # |
* # AudioOutputDeviceJack # # AudioOutputDeviceVSTi # |
232 |
* ######################### ######################### |
* ######################### ######################### |
233 |
* ^ ^ ^ |
* ^ ^ ^ |
234 |
* /------------>|Sampler Channel 0|-----/ | | |
* /------------>|Sampler Channel 0|-----/ | | |
235 |
* | /--------->|Sampler Channel 1|---------------------/ |
* | /--------->|Sampler Channel 1|---------------------/ |
236 |
* | | /---->|Sampler Channel 2|---------/ |
* | | /------>|Sampler Channel 2|---------/ |
237 |
* | | | /->|Sampler Channel 3|------------>######################### |
* | | | /--->|Sampler Channel 3|------------>######################### |
238 |
* | | | | ... (and so on) ... # AudioOutputDeviceAlsa # |
* | | | | ... (and so on) ... # AudioOutputDeviceAlsa # |
239 |
* | | | | ######################### |
* | | | | ######################### |
240 |
* | | | \----------------------------------------------------\ |
* | | | \-----------------------------------------------------\ |
241 |
* | | \-------------------------------------------\ | |
* | | \--------------------------------------------\ | |
242 |
* | \--------------------\ | | |
* | \--------------------\ | | |
243 |
* | | | | |
* | | | | |
244 |
* ####################### ####################### ####################### |
* ####################### ####################### ####################### |
245 |
* # MidiInputDeviceAlsa # # MidiInputDeviceVSTi # # MidiInputDeviceJack # |
* # MidiInputDeviceAlsa # # MidiInputDeviceVSTi # # MidiInputDeviceJack # |
246 |
* ####################### ####################### ####################### |
* ####################### ####################### ####################### |
247 |
|
* @endcode |
248 |
* |
* |
249 |
* As you can see in this example setup, one device (that is midi input |
* As you can see in this example setup, one device (that is midi input |
250 |
* driver / audio output driver) can be connected multiple times to |
* driver / audio output driver) can be connected multiple times to |
251 |
* different sampler channels. |
* different sampler channels. |
252 |
|
* |
253 |
|
* It's even possible to create multiple instances of the same driver, for |
254 |
|
* example multiple instances of the Alsa output driver to use multiple |
255 |
|
* sound cards at the same time, or multiple instances of the JACK audio |
256 |
|
* output driver to leverage SMP systems or boxes with several hard discs. |
257 |
*/ |
*/ |
258 |
class Sampler { |
class Sampler { |
259 |
public: |
public: |
265 |
/** |
/** |
266 |
* Destructor. |
* Destructor. |
267 |
*/ |
*/ |
268 |
~Sampler(); |
virtual ~Sampler(); |
269 |
|
|
270 |
/** |
/** |
271 |
* Returns the number of sampler channels currently allocated. |
* Returns the number of sampler channels currently allocated. |
273 |
uint SamplerChannels(); |
uint SamplerChannels(); |
274 |
|
|
275 |
/** |
/** |
276 |
* Create and add a new sampler channel to this Sampler instance. |
* Create and add a new sampler channel to this Sampler |
277 |
|
* instance. For race condition reasons the new channel will use |
278 |
|
* an index past the last already existing sampler channel |
279 |
|
* index (in case the index limit was not reached yet, otherwise |
280 |
|
* a free index starting from 0 is searched). |
281 |
* |
* |
282 |
* @returns pointer to new sampler channel |
* @returns pointer to new sampler channel |
283 |
*/ |
*/ |
292 |
SamplerChannel* GetSamplerChannel(uint uiSamplerChannel); |
SamplerChannel* GetSamplerChannel(uint uiSamplerChannel); |
293 |
|
|
294 |
/** |
/** |
295 |
|
* Returns all created sampler channels. |
296 |
|
*/ |
297 |
|
std::map<uint, SamplerChannel*> GetSamplerChannels(); |
298 |
|
|
299 |
|
/** |
300 |
* Destroy and remove the given sampler channel from this |
* Destroy and remove the given sampler channel from this |
301 |
* Sampler instance. |
* Sampler instance. |
302 |
* |
* |
313 |
*/ |
*/ |
314 |
void RemoveSamplerChannel(uint uiSamplerChannel); |
void RemoveSamplerChannel(uint uiSamplerChannel); |
315 |
|
|
316 |
|
/** |
317 |
|
* Registers the specified listener to be notified |
318 |
|
* when the number of sampler chanels is changed. |
319 |
|
*/ |
320 |
|
void AddChannelCountListener(ChannelCountListener* l); |
321 |
|
|
322 |
|
/** |
323 |
|
* Removes the specified listener. |
324 |
|
*/ |
325 |
|
void RemoveChannelCountListener(ChannelCountListener* l); |
326 |
|
|
327 |
|
/** |
328 |
|
* Registers the specified listener to be notified |
329 |
|
* when the number of audio output devices is changed. |
330 |
|
*/ |
331 |
|
void AddAudioDeviceCountListener(AudioDeviceCountListener* l); |
332 |
|
|
333 |
|
/** |
334 |
|
* Removes the specified listener. |
335 |
|
*/ |
336 |
|
void RemoveAudioDeviceCountListener(AudioDeviceCountListener* l); |
337 |
|
|
338 |
|
|
339 |
|
/** |
340 |
|
* Registers the specified listener to be notified |
341 |
|
* when the number of MIDI input devices is changed. |
342 |
|
*/ |
343 |
|
void AddMidiDeviceCountListener(MidiDeviceCountListener* l); |
344 |
|
|
345 |
|
/** |
346 |
|
* Removes the specified listener. |
347 |
|
*/ |
348 |
|
void RemoveMidiDeviceCountListener(MidiDeviceCountListener* l); |
349 |
|
|
350 |
|
/** |
351 |
|
* Registers the specified listener to be notified when the number |
352 |
|
* of active voices in a particular sampler channel is changed. |
353 |
|
*/ |
354 |
|
void AddVoiceCountListener(VoiceCountListener* l); |
355 |
|
|
356 |
|
/** |
357 |
|
* Removes the specified listener. |
358 |
|
*/ |
359 |
|
void RemoveVoiceCountListener(VoiceCountListener* l); |
360 |
|
|
361 |
|
/** |
362 |
|
* Notifies listeners that the number of active voices |
363 |
|
* on the specified sampler channel is changed. |
364 |
|
* @param ChannelId The numerical ID of the sampler channel. |
365 |
|
* @param NewCount The new number of active voices. |
366 |
|
*/ |
367 |
|
void fireVoiceCountChanged(int ChannelId, int NewCount); |
368 |
|
|
369 |
|
/** |
370 |
|
* Registers the specified listener to be notified when the number |
371 |
|
* of active disk streams in a particular sampler channel is changed. |
372 |
|
*/ |
373 |
|
void AddStreamCountListener(StreamCountListener* l); |
374 |
|
|
375 |
|
/** |
376 |
|
* Removes the specified listener. |
377 |
|
*/ |
378 |
|
void RemoveStreamCountListener(StreamCountListener* l); |
379 |
|
|
380 |
|
/** |
381 |
|
* Notifies listeners that the number of active disk streams |
382 |
|
* on the specified sampler channel is changed. |
383 |
|
* @param ChannelId The numerical ID of the sampler channel. |
384 |
|
* @param NewCount The new number of active disk streams. |
385 |
|
*/ |
386 |
|
void fireStreamCountChanged(int ChannelId, int NewCount); |
387 |
|
|
388 |
|
/** |
389 |
|
* Registers the specified listener to be |
390 |
|
* notified when the fill state of the disk stream |
391 |
|
* buffers on a specific sampler channel is changed. |
392 |
|
*/ |
393 |
|
void AddBufferFillListener(BufferFillListener* l); |
394 |
|
|
395 |
|
/** |
396 |
|
* Removes the specified listener. |
397 |
|
*/ |
398 |
|
void RemoveBufferFillListener(BufferFillListener* l); |
399 |
|
|
400 |
|
/** |
401 |
|
* Notifies listeners that the fill state of the disk stream |
402 |
|
* buffers on the specified sampler channel is changed. |
403 |
|
* @param ChannelId The numerical ID of the sampler channel. |
404 |
|
* @param FillData The buffer fill data for the specified sampler channel. |
405 |
|
*/ |
406 |
|
void fireBufferFillChanged(int ChannelId, String FillData); |
407 |
|
|
408 |
|
/** |
409 |
|
* Registers the specified listener to be notified |
410 |
|
* when total number of active voices is changed. |
411 |
|
*/ |
412 |
|
void AddTotalVoiceCountListener(TotalVoiceCountListener* l); |
413 |
|
|
414 |
|
/** |
415 |
|
* Removes the specified listener. |
416 |
|
*/ |
417 |
|
void RemoveTotalVoiceCountListener(TotalVoiceCountListener* l); |
418 |
|
|
419 |
|
/** |
420 |
|
* Notifies listeners that the total number of active voices is changed. |
421 |
|
* @param NewCount The new number of active voices. |
422 |
|
*/ |
423 |
|
void fireTotalVoiceCountChanged(int NewCount); |
424 |
|
|
425 |
|
void AddTotalStreamCountListener(TotalStreamCountListener* l); |
426 |
|
void RemoveTotalStreamCountListener(TotalStreamCountListener* l); |
427 |
|
void fireTotalStreamCountChanged(int NewCount); |
428 |
|
|
429 |
|
/** |
430 |
|
* Registers the specified listener to be notified when the number |
431 |
|
* of effect sends on a particular sampler channel is changed. |
432 |
|
*/ |
433 |
|
void AddFxSendCountListener(FxSendCountListener* l); |
434 |
|
|
435 |
|
/** |
436 |
|
* Removes the specified listener. |
437 |
|
*/ |
438 |
|
void RemoveFxSendCountListener(FxSendCountListener* l); |
439 |
|
|
440 |
|
/** |
441 |
|
* Returns the names of all available audio output drivers. |
442 |
|
*/ |
443 |
std::vector<String> AvailableAudioOutputDrivers(); |
std::vector<String> AvailableAudioOutputDrivers(); |
444 |
|
|
445 |
/** |
/** |
446 |
* Create an audio output device of the given type. |
* Returns the names of all available MIDI input drivers. |
447 |
|
*/ |
448 |
|
std::vector<String> AvailableMidiInputDrivers(); |
449 |
|
|
450 |
|
/** |
451 |
|
* Returns the names of all available sampler engine types. |
452 |
|
* @see SamplerChannel::SetEngineType() |
453 |
|
*/ |
454 |
|
std::vector<String> AvailableEngineTypes(); |
455 |
|
|
456 |
|
/** |
457 |
|
* Create an audio output device. |
458 |
* |
* |
459 |
* @param AudioDriver - name of the audio driver |
* @param AudioDriver - name of the audio driver |
460 |
* @param Parameters - eventually needed driver parameters to |
* @param Parameters - eventually needed driver parameters to |
461 |
* create the device |
* create the device |
462 |
* @returns pointer to created audio output device |
* @returns pointer to created audio output device |
463 |
* @throws LinuxSamplerException if device could not be created |
* @throws Exception if device could not be created |
464 |
|
*/ |
465 |
|
AudioOutputDevice* CreateAudioOutputDevice(String AudioDriver, std::map<String,String> Parameters) throw (Exception); |
466 |
|
|
467 |
|
/** |
468 |
|
* Create a midi input device. |
469 |
|
* |
470 |
|
* @param MidiDriver - name of the midi driver |
471 |
|
* @param Parameters - eventually needed driver parameters to |
472 |
|
* create the device |
473 |
|
* @returns pointer to created midi input device |
474 |
|
* @throws Exception if device could not be created |
475 |
*/ |
*/ |
476 |
AudioOutputDevice* CreateAudioOutputDevice(String AudioDriver, std::map<String,String> Parameters) throw (LinuxSamplerException); |
MidiInputDevice* CreateMidiInputDevice(String MidiDriver, std::map<String,String> Parameters) throw (Exception); |
477 |
|
|
478 |
|
/** |
479 |
|
* Returns the number of all created audio output devices. |
480 |
|
*/ |
481 |
uint AudioOutputDevices(); |
uint AudioOutputDevices(); |
482 |
|
|
483 |
|
/** |
484 |
|
* Returns the number of all created MIDI input devices. |
485 |
|
*/ |
486 |
|
uint MidiInputDevices(); |
487 |
|
|
488 |
|
/** |
489 |
|
* Returns all created audio output devices. |
490 |
|
*/ |
491 |
std::map<uint, AudioOutputDevice*> GetAudioOutputDevices(); |
std::map<uint, AudioOutputDevice*> GetAudioOutputDevices(); |
492 |
|
|
493 |
void DestroyAudioOutputDevice(AudioOutputDevice* pDevice) throw (LinuxSamplerException); |
/** |
494 |
|
* Returns all created MIDI input devices. |
495 |
|
*/ |
496 |
|
std::map<uint, MidiInputDevice*> GetMidiInputDevices(); |
497 |
|
|
498 |
/** |
/** |
499 |
* Create a MIDI input device of the given type. |
* Destroy the given audio output device and takes care if there |
500 |
|
* are still sampler angines connected to this device, etc. |
501 |
* |
* |
502 |
* @param MidiType - desired MIDI input system to use |
* @throws Exception if sampler channels are still |
503 |
* @returns pointer to created MIDI input device |
* connected to the device |
504 |
*/ |
*/ |
505 |
MidiInputDevice* CreateMidiInputDevice(MidiInputDevice::type_t MidiType); //TODO: to be changed to 'MidiInputDevice* CreateMidiInputDevice(String MidiDriver, std::map<String,String> Parameters) throw (LinuxSamplerException);' |
void DestroyAudioOutputDevice(AudioOutputDevice* pDevice) throw (Exception); |
506 |
|
|
507 |
/** |
/** |
508 |
* Returns the MIDI input device of the given type. |
* Destroy the given MIDI input device and takes care if there |
509 |
|
* are still sampler angines connected to this device, etc. |
510 |
* |
* |
511 |
* @param MidiType - desired MIDI input system to use |
* @throws Exception if sampler channels are still |
512 |
* @returns pointer to MIDI input device or NULL if device of |
* connected to the device |
513 |
* desired type is not yet created |
*/ |
514 |
|
void DestroyMidiInputDevice(MidiInputDevice* pDevice) throw (Exception); |
515 |
|
|
516 |
|
/** |
517 |
|
* Gets the current number of all active streams. |
518 |
|
* @returns The current number of all active streams. |
519 |
*/ |
*/ |
520 |
MidiInputDevice* GetMidiInputDevice(MidiInputDevice::type_t MidiType); |
int GetDiskStreamCount(); |
521 |
|
|
522 |
|
/** |
523 |
|
* Gets the current number of all active voices. |
524 |
|
* @returns The current number of all active voices. |
525 |
|
*/ |
526 |
|
int GetVoiceCount(); |
527 |
|
|
528 |
|
/** |
529 |
|
* Reset the whole sampler. Destroy all engines, sampler |
530 |
|
* channels, MIDI input devices and audio output devices. |
531 |
|
*/ |
532 |
|
void Reset(); |
533 |
|
|
534 |
protected: |
protected: |
535 |
|
/** |
536 |
|
* Notifies listeners that the number of sampler channels has been changed. |
537 |
|
* @param NewCount The new number of sampler channels. |
538 |
|
*/ |
539 |
|
void fireChannelCountChanged(int NewCount); |
540 |
|
|
541 |
|
/** |
542 |
|
* Notifies listeners that the specified sampler channel has just |
543 |
|
* been added. |
544 |
|
* @param pChannel The new sampler channel. |
545 |
|
*/ |
546 |
|
void fireChannelAdded(SamplerChannel* pChannel); |
547 |
|
|
548 |
|
/** |
549 |
|
* Notifies listeners that the specified sampler channel is |
550 |
|
* going to be removed soon. |
551 |
|
* @param pChannel sampler channel to be removed. |
552 |
|
*/ |
553 |
|
void fireChannelToBeRemoved(SamplerChannel* pChannel); |
554 |
|
|
555 |
|
/** |
556 |
|
* Notifies listeners that the number of audio output devices has been changed. |
557 |
|
* @param NewCount The new number of audio output devices. |
558 |
|
*/ |
559 |
|
void fireAudioDeviceCountChanged(int NewCount); |
560 |
|
|
561 |
|
/** |
562 |
|
* Notifies listeners that the number of MIDI input devices has been changed. |
563 |
|
* @param NewCount The new number of MIDI input devices. |
564 |
|
*/ |
565 |
|
void fireMidiDeviceCountChanged(int NewCount); |
566 |
|
|
567 |
|
/** |
568 |
|
* Notifies listeners that the supplied MIDI input device is |
569 |
|
* going to be destroyed soon. |
570 |
|
* @param pDevice MIDI input device to be destroyed |
571 |
|
*/ |
572 |
|
void fireMidiDeviceToBeDestroyed(MidiInputDevice* pDevice); |
573 |
|
|
574 |
|
/** |
575 |
|
* Notifies listeners that the supplied MIDI input device was |
576 |
|
* just created. |
577 |
|
* @param pDevice new MIDI input device |
578 |
|
*/ |
579 |
|
void fireMidiDeviceCreated(MidiInputDevice* pDevice); |
580 |
|
|
581 |
|
/** |
582 |
|
* Notifies listeners that the number of effect sends |
583 |
|
* on a particular sampler channel is changed. |
584 |
|
* @param ChannelId The numerical ID of the sampler channel. |
585 |
|
* @param NewCount The new number of sampler channels. |
586 |
|
*/ |
587 |
|
void fireFxSendCountChanged(int ChannelId, int NewCount); |
588 |
|
|
589 |
typedef std::map<uint, AudioOutputDevice*> AudioOutputDeviceMap; |
typedef std::map<uint, AudioOutputDevice*> AudioOutputDeviceMap; |
590 |
typedef std::map<MidiInputDevice::type_t, MidiInputDevice*> MidiInputDeviceMap; |
typedef std::map<uint, MidiInputDevice*> MidiInputDeviceMap; |
591 |
|
typedef std::map<uint, SamplerChannel*> SamplerChannelMap; |
592 |
|
|
593 |
std::vector<SamplerChannel*> vSamplerChannels; ///< contains all created sampler channels |
SamplerChannelMap mSamplerChannels; ///< contains all created sampler channels |
594 |
AudioOutputDeviceMap mAudioOutputDevices; ///< contains all created audio output devices |
AudioOutputDeviceMap mAudioOutputDevices; ///< contains all created audio output devices |
595 |
MidiInputDeviceMap MidiInputDevices; |
MidiInputDeviceMap mMidiInputDevices; ///< contains all created MIDI input devices |
|
|
|
|
template<class T> inline String ToString(T o) { |
|
|
std::stringstream ss; |
|
|
ss << o; |
|
|
return ss.str(); |
|
|
} |
|
596 |
|
|
597 |
friend class SamplerChannel; |
friend class SamplerChannel; |
598 |
|
|
599 |
|
private: |
600 |
|
ListenerList<ChannelCountListener*> llChannelCountListeners; |
601 |
|
ListenerList<AudioDeviceCountListener*> llAudioDeviceCountListeners; |
602 |
|
ListenerList<MidiDeviceCountListener*> llMidiDeviceCountListeners; |
603 |
|
ListenerList<VoiceCountListener*> llVoiceCountListeners; |
604 |
|
ListenerList<StreamCountListener*> llStreamCountListeners; |
605 |
|
ListenerList<BufferFillListener*> llBufferFillListeners; |
606 |
|
ListenerList<TotalStreamCountListener*> llTotalStreamCountListeners; |
607 |
|
ListenerList<TotalVoiceCountListener*> llTotalVoiceCountListeners; |
608 |
|
ListenerList<FxSendCountListener*> llFxSendCountListeners; |
609 |
|
|
610 |
|
class EventHandler : public EngineChangeListener, public FxSendCountListener { |
611 |
|
public: |
612 |
|
void SetSampler(Sampler* pSampler) { this->pSampler = pSampler; } |
613 |
|
|
614 |
|
/** |
615 |
|
* Invoked when the engine type of the specified sampler |
616 |
|
* channel is going to be changed soon. |
617 |
|
* @param ChannelId The numerical ID of the sampler channel |
618 |
|
*/ |
619 |
|
virtual void EngineToBeChanged(int ChannelId); |
620 |
|
|
621 |
|
/** |
622 |
|
* Invoked when the engine type of the |
623 |
|
* specified sampler channel is changed. |
624 |
|
* @param ChannelId The numerical ID of the sampler |
625 |
|
* channel, which engine type has been changed. |
626 |
|
*/ |
627 |
|
virtual void EngineChanged(int ChannelId); |
628 |
|
|
629 |
|
/** |
630 |
|
* Invoked when the number of effect sends |
631 |
|
* on the specified sampler channel has changed. |
632 |
|
* @param ChannelId The numerical ID of the sampler channel. |
633 |
|
* @param NewCount The new number of effect sends. |
634 |
|
*/ |
635 |
|
virtual void FxSendCountChanged(int ChannelId, int NewCount); |
636 |
|
|
637 |
|
private: |
638 |
|
Sampler* pSampler; |
639 |
|
} eventHandler; |
640 |
}; |
}; |
641 |
} |
} |
642 |
|
|