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, 2006 Christian Schoenebeck * |
* Copyright (C) 2005 - 2012 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/Exception.h" |
#include "common/Exception.h" |
32 |
#include "engines/common/EngineChannel.h" |
#include "engines/EngineChannel.h" |
33 |
#include "drivers/midi/MidiInputDevice.h" |
#include "drivers/midi/MidiInputDevice.h" |
34 |
#include "drivers/audio/AudioOutputDevice.h" |
#include "drivers/audio/AudioOutputDevice.h" |
35 |
|
|
53 |
* |
* |
54 |
* @param EngineType - type of the engine to use |
* @param EngineType - type of the engine to use |
55 |
* @throws Exception - if \a EngineType is invalid |
* @throws Exception - if \a EngineType is invalid |
56 |
|
* @see Sampler::AvailableEngineTypes() |
57 |
*/ |
*/ |
58 |
void SetEngineType(String EngineType) throw (Exception); |
void SetEngineType(String EngineType) throw (Exception); |
59 |
|
|
64 |
* the old connection will automatically be removed before. |
* the old connection will automatically be removed before. |
65 |
* |
* |
66 |
* @param pDevice - audio output device to connect to |
* @param pDevice - audio output device to connect to |
67 |
|
* @throws Exception in case the audio device is tried to be |
68 |
|
* changed while the sampler channel is used by a |
69 |
|
* host plugin (e.g. VST, AU, DSSI, LV2) which |
70 |
|
* don't allow to change the audio output device |
71 |
*/ |
*/ |
72 |
void SetAudioOutputDevice(AudioOutputDevice* pDevice); |
void SetAudioOutputDevice(AudioOutputDevice* pDevice) throw (Exception); |
73 |
|
|
74 |
/** |
/** |
75 |
* Connect this sampler channel to a MIDI input device. |
* Connect this sampler channel to a MIDI input device. |
76 |
* |
* |
77 |
* @param pDevice - MIDI input device to connect to |
* @param pDevice - MIDI input device to connect to |
78 |
|
* @throws Exception in case the MIDI device is tried to be changed |
79 |
|
* while the sampler channel is being used by a |
80 |
|
* host plugin (e.g. VST, AU, DSSI, LV2) which |
81 |
|
* don't allow to change the MIDI port or even |
82 |
|
* device |
83 |
*/ |
*/ |
84 |
void SetMidiInputDevice(MidiInputDevice *pDevice); |
void SetMidiInputDevice(MidiInputDevice *pDevice) throw (Exception); |
85 |
|
|
86 |
/** |
/** |
87 |
* Connect this sampler channel to a MIDI input port. |
* Connect this sampler channel to a MIDI input port. |
88 |
* |
* |
89 |
* @param MidiPort - MIDI port to connect to |
* @param MidiPort - MIDI port to connect to |
90 |
|
* @throws Exception in case the MIDI port is tried to be changed |
91 |
|
* while the sampler channel is being used by a |
92 |
|
* host plugin (e.g. VST, AU, DSSI, LV2) which |
93 |
|
* don't allow to change the MIDI port |
94 |
*/ |
*/ |
95 |
void SetMidiInputPort(int MidiPort); |
void SetMidiInputPort(int MidiPort) throw (Exception); |
96 |
|
|
97 |
/** |
/** |
98 |
* Define on which MIDI channel(s) this sampler channel should |
* Define on which MIDI channel(s) this sampler channel should |
112 |
* @param MidiChannel - optional: MIDI channel on which the |
* @param MidiChannel - optional: MIDI channel on which the |
113 |
* sampler channel should listen to |
* sampler channel should listen to |
114 |
* (default: listen on all MIDI channels) |
* (default: listen on all MIDI channels) |
115 |
|
* @throws Exception in case the MIDI port is tried to be changed |
116 |
|
* while the sampler channel is being used by a |
117 |
|
* host plugin (e.g. VST, AU, DSSI, LV2) which |
118 |
|
* don't allow to change the MIDI port |
119 |
*/ |
*/ |
120 |
void SetMidiInput(MidiInputDevice* pDevice, int iMidiPort, midi_chan_t MidiChannel = midi_chan_all); |
void SetMidiInput(MidiInputDevice* pDevice, int iMidiPort, midi_chan_t MidiChannel = midi_chan_all) throw (Exception); |
121 |
|
|
122 |
/** |
/** |
123 |
* Returns the EngineChannel object that was deployed on this |
* Returns the EngineChannel object that was deployed on this |
168 |
*/ |
*/ |
169 |
uint Index(); |
uint Index(); |
170 |
|
|
171 |
|
/** Returns the sampler to which this channel belongs */ |
172 |
|
Sampler* GetSampler(); |
173 |
|
|
174 |
|
/////////////////////////////////////////////////////////////// |
175 |
|
// Event Listener methods |
176 |
|
|
177 |
|
/** |
178 |
|
* Registers the specified listener to be notified |
179 |
|
* when the engine type of this sampler channel is changed. |
180 |
|
*/ |
181 |
|
void AddEngineChangeListener(EngineChangeListener* l); |
182 |
|
|
183 |
|
/** |
184 |
|
* Removes the specified listener. |
185 |
|
*/ |
186 |
|
void RemoveEngineChangeListener(EngineChangeListener* l); |
187 |
|
|
188 |
|
/** |
189 |
|
* Removes the specified listener. |
190 |
|
*/ |
191 |
|
void RemoveAllEngineChangeListeners(); |
192 |
|
|
193 |
|
/** |
194 |
|
* Notifies listeners that the engine type of this sampler |
195 |
|
* channel is going to be changed soon. |
196 |
|
*/ |
197 |
|
void fireEngineToBeChanged(); |
198 |
|
|
199 |
|
/** |
200 |
|
* Notifies listeners that the engine |
201 |
|
* type of this sampler channel is changed. |
202 |
|
*/ |
203 |
|
void fireEngineChanged(); |
204 |
|
|
205 |
|
|
206 |
protected: |
protected: |
207 |
SamplerChannel(Sampler* pS); |
SamplerChannel(Sampler* pS); |
208 |
virtual ~SamplerChannel(); |
virtual ~SamplerChannel(); |
220 |
private: |
private: |
221 |
int iMidiPort; ///< Don't access directly, read GetMidiInputPort() instead ! |
int iMidiPort; ///< Don't access directly, read GetMidiInputPort() instead ! |
222 |
midi_chan_t midiChannel; ///< Don't access directly, read GetMidiInputChannel() instead ! |
midi_chan_t midiChannel; ///< Don't access directly, read GetMidiInputChannel() instead ! |
223 |
|
ListenerList<EngineChangeListener*> llEngineChangeListeners; |
224 |
}; |
}; |
225 |
|
|
226 |
/** @brief LinuxSampler main class |
/** @brief LinuxSampler main class |
232 |
* engine, connected to an arbitrary MIDI input device and connected to |
* engine, connected to an arbitrary MIDI input device and connected to |
233 |
* an arbitrary audio output device. Here an example setup: |
* an arbitrary audio output device. Here an example setup: |
234 |
* @code |
* @code |
235 |
* S.Channel. MIDI in S.Engine Audio out |
* S.Channel MIDI in S.Engine Audio out |
236 |
* ------------------------------------------------------------------- |
* ------------------------------------------------------------------- |
237 |
* 0 Alsa -> gig::Engine -> Jack |
* 0 Alsa -> gig::Engine -> Jack |
238 |
* 1 VSTi -> Akai::Engine -> VSTi |
* 1 VSTi -> Akai::Engine -> VSTi |
239 |
* 2 Jack -> DLS::Engine -> Jack |
* 2 Jack -> DLS::Engine -> Jack |
240 |
* 3 Jack -> SF::Engine -> Alsa |
* 3 Jack -> SF::Engine -> Alsa |
241 |
* |
* |
242 |
* ... (and so on) ... |
* ... (and so on) ... |
243 |
* @endcode |
* @endcode |
244 |
* |
* |
245 |
* Note that not all audio and MIDI backends and sampler engines listed |
* Note that not all audio and MIDI backends and sampler engines listed |
246 |
* in the example above are already implemented! |
* in the example above might already been implemented! |
247 |
* |
* |
248 |
* 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 |
249 |
* several, different audio output and MIDI input systems |
* several, different audio output and MIDI input systems |
250 |
* simultaniously at the same time. Here the example setup shown in the |
* simultaniously at the same time. Here the example setup shown in the |
251 |
* ascpect of MIDI input and audio output devices / drivers: |
* aspect of MIDI input and audio output devices / drivers: |
252 |
* @code |
* @code |
253 |
* ######################### ######################### |
* ######################### ######################### |
254 |
* # AudioOutputDeviceJack # # AudioOutputDeviceVSTi # |
* # AudioOutputDeviceJack # # AudioOutputDeviceVSTi # |
255 |
* ######################### ######################### |
* ######################### ######################### |
256 |
* ^ ^ ^ |
* ^ ^ ^ |
257 |
* /------------>|Sampler Channel 0|-----/ | | |
* /------------>|Sampler Channel 0|-----/ | | |
258 |
* | /--------->|Sampler Channel 1|---------------------/ |
* | /--------->|Sampler Channel 1|---------------------/ |
259 |
* | | /------>|Sampler Channel 2|---------/ |
* | | /------>|Sampler Channel 2|---------/ |
260 |
* | | | /--->|Sampler Channel 3|------------>######################### |
* | | | /--->|Sampler Channel 3|------------>######################### |
261 |
* | | | | ... (and so on) ... # AudioOutputDeviceAlsa # |
* | | | | ... (and so on) ... # AudioOutputDeviceAlsa # |
262 |
* | | | | ######################### |
* | | | | ######################### |
263 |
* | | | \-----------------------------------------------------\ |
* | | | \-----------------------------------------------------\ |
264 |
* | | \--------------------------------------------\ | |
* | | \--------------------------------------------\ | |
265 |
* | \--------------------\ | | |
* | \--------------------\ | | |
266 |
* | | | | |
* | | | | |
267 |
* ####################### ####################### ####################### |
* ####################### ####################### ####################### |
268 |
* # MidiInputDeviceAlsa # # MidiInputDeviceVSTi # # MidiInputDeviceJack # |
* # MidiInputDeviceAlsa # # MidiInputDeviceVSTi # # MidiInputDeviceJack # |
269 |
* ####################### ####################### ####################### |
* ####################### ####################### ####################### |
272 |
* 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 |
273 |
* driver / audio output driver) can be connected multiple times to |
* driver / audio output driver) can be connected multiple times to |
274 |
* different sampler channels. |
* different sampler channels. |
275 |
|
* |
276 |
|
* It's even possible to create multiple instances of the same driver, for |
277 |
|
* example multiple instances of the Alsa output driver to use multiple |
278 |
|
* sound cards at the same time, or multiple instances of the JACK audio |
279 |
|
* output driver to leverage SMP systems or boxes with several hard discs. |
280 |
*/ |
*/ |
281 |
class Sampler { |
class Sampler { |
282 |
public: |
public: |
337 |
void RemoveSamplerChannel(uint uiSamplerChannel); |
void RemoveSamplerChannel(uint uiSamplerChannel); |
338 |
|
|
339 |
/** |
/** |
340 |
|
* Destroy and remove all sampler channels from this |
341 |
|
* Sampler instance. |
342 |
|
*/ |
343 |
|
void RemoveAllSamplerChannels(); |
344 |
|
|
345 |
|
/** |
346 |
* Returns the names of all available audio output drivers. |
* Returns the names of all available audio output drivers. |
347 |
*/ |
*/ |
348 |
std::vector<String> AvailableAudioOutputDrivers(); |
std::vector<String> AvailableAudioOutputDrivers(); |
349 |
|
|
350 |
/** |
/** |
351 |
|
* Returns the names of all available MIDI input drivers. |
352 |
|
*/ |
353 |
|
std::vector<String> AvailableMidiInputDrivers(); |
354 |
|
|
355 |
|
/** |
356 |
|
* Returns the names of all available sampler engine types. |
357 |
|
* @see SamplerChannel::SetEngineType() |
358 |
|
*/ |
359 |
|
std::vector<String> AvailableEngineTypes(); |
360 |
|
|
361 |
|
/** |
362 |
* Create an audio output device. |
* Create an audio output device. |
363 |
* |
* |
364 |
* @param AudioDriver - name of the audio driver |
* @param AudioDriver - name of the audio driver |
402 |
|
|
403 |
/** |
/** |
404 |
* Destroy the given audio output device and takes care if there |
* Destroy the given audio output device and takes care if there |
405 |
* are still sampler angines connected to this device, etc. |
* are still sampler engines connected to this device, etc. |
406 |
* |
* |
407 |
* @throws Exception if sampler channels are still |
* @throws Exception if sampler channels are still |
408 |
* connected to the device |
* connected to the device |
410 |
void DestroyAudioOutputDevice(AudioOutputDevice* pDevice) throw (Exception); |
void DestroyAudioOutputDevice(AudioOutputDevice* pDevice) throw (Exception); |
411 |
|
|
412 |
/** |
/** |
413 |
|
* Destroy all audio output devices and takes care if there |
414 |
|
* are still sampler engines connected to devices, etc. |
415 |
|
* |
416 |
|
* Note: non-autonomous devices, that is devices associated with |
417 |
|
* host plugin instances like VST, AU, DSSI, LV2 are not |
418 |
|
* destroyed by this method. |
419 |
|
* |
420 |
|
* @throws Exception if sampler channels are still |
421 |
|
* connected to device |
422 |
|
*/ |
423 |
|
void DestroyAllAudioOutputDevices() throw (Exception); |
424 |
|
|
425 |
|
/** |
426 |
* Destroy the given MIDI input device and takes care if there |
* Destroy the given MIDI input device and takes care if there |
427 |
* are still sampler angines connected to this device, etc. |
* are still sampler engines connected to this device, etc. |
428 |
* |
* |
429 |
* @throws Exception if sampler channels are still |
* @throws Exception if sampler channels are still |
430 |
* connected to the device |
* connected to the device |
432 |
void DestroyMidiInputDevice(MidiInputDevice* pDevice) throw (Exception); |
void DestroyMidiInputDevice(MidiInputDevice* pDevice) throw (Exception); |
433 |
|
|
434 |
/** |
/** |
435 |
|
* Destroy all MIDI input devices and take care if there |
436 |
|
* are still sampler engines connected to device, etc. |
437 |
|
* |
438 |
|
* Note: non-autonomous devices, that is devices associated with |
439 |
|
* host plugin instances like VST, AU, DSSI, LV2 are not |
440 |
|
* destroyed by this method. |
441 |
|
* |
442 |
|
* @throws Exception if sampler channels are still |
443 |
|
* connected to device |
444 |
|
*/ |
445 |
|
void DestroyAllMidiInputDevices() throw (Exception); |
446 |
|
|
447 |
|
/** |
448 |
|
* Gets the current number of all active streams. |
449 |
|
* @returns The current number of all active streams. |
450 |
|
*/ |
451 |
|
int GetDiskStreamCount(); |
452 |
|
|
453 |
|
/** |
454 |
* Gets the current number of all active voices. |
* Gets the current number of all active voices. |
455 |
* @returns The current number of all active voices. |
* @returns The current number of all active voices. |
456 |
*/ |
*/ |
457 |
int GetVoiceCount(); |
int GetVoiceCount(); |
458 |
|
|
459 |
/** |
/** |
460 |
|
* @see SetGlobalMaxVoices() |
461 |
|
*/ |
462 |
|
int GetGlobalMaxVoices(); |
463 |
|
|
464 |
|
/** |
465 |
|
* @see SetGlobalMaxStreams() |
466 |
|
*/ |
467 |
|
int GetGlobalMaxStreams(); |
468 |
|
|
469 |
|
/** |
470 |
|
* Sets the global maximum amount limit of voices. |
471 |
|
* |
472 |
|
* Note that this voice limit can also be altered for |
473 |
|
* each sampler engine instance individually instead. |
474 |
|
* |
475 |
|
* @throws Exception if \a n is invalid |
476 |
|
*/ |
477 |
|
void SetGlobalMaxVoices(int n) throw (Exception); |
478 |
|
|
479 |
|
/** |
480 |
|
* Sets the global maximum amount limit of disk streams. |
481 |
|
* |
482 |
|
* Note that this stream limit can also be altered for |
483 |
|
* each sampler engine instance individually instead. |
484 |
|
* |
485 |
|
* @throws Exception if \a n is invalid |
486 |
|
*/ |
487 |
|
void SetGlobalMaxStreams(int n) throw (Exception); |
488 |
|
|
489 |
|
/** |
490 |
* Reset the whole sampler. Destroy all engines, sampler |
* Reset the whole sampler. Destroy all engines, sampler |
491 |
* channels, MIDI input devices and audio output devices. |
* channels, MIDI input devices and audio output devices. |
492 |
*/ |
*/ |
493 |
void Reset(); |
void Reset(); |
494 |
|
|
495 |
|
/////////////////////////////////////////////////////////////// |
496 |
|
// Event Listener methods |
497 |
|
|
498 |
|
/** |
499 |
|
* Registers the specified listener to be notified |
500 |
|
* when the number of sampler chanels is changed. |
501 |
|
*/ |
502 |
|
void AddChannelCountListener(ChannelCountListener* l); |
503 |
|
|
504 |
|
/** |
505 |
|
* Removes the specified listener. |
506 |
|
*/ |
507 |
|
void RemoveChannelCountListener(ChannelCountListener* l); |
508 |
|
|
509 |
|
/** |
510 |
|
* Registers the specified listener to be notified |
511 |
|
* when the number of audio output devices is changed. |
512 |
|
*/ |
513 |
|
void AddAudioDeviceCountListener(AudioDeviceCountListener* l); |
514 |
|
|
515 |
|
/** |
516 |
|
* Removes the specified listener. |
517 |
|
*/ |
518 |
|
void RemoveAudioDeviceCountListener(AudioDeviceCountListener* l); |
519 |
|
|
520 |
|
/** |
521 |
|
* Registers the specified listener to be notified |
522 |
|
* when the number of MIDI input devices is changed. |
523 |
|
*/ |
524 |
|
void AddMidiDeviceCountListener(MidiDeviceCountListener* l); |
525 |
|
|
526 |
|
/** |
527 |
|
* Removes the specified listener. |
528 |
|
*/ |
529 |
|
void RemoveMidiDeviceCountListener(MidiDeviceCountListener* l); |
530 |
|
|
531 |
|
/** |
532 |
|
* Registers the specified listener to be notified when the number |
533 |
|
* of active voices in a particular sampler channel is changed. |
534 |
|
*/ |
535 |
|
void AddVoiceCountListener(VoiceCountListener* l); |
536 |
|
|
537 |
|
/** |
538 |
|
* Removes the specified listener. |
539 |
|
*/ |
540 |
|
void RemoveVoiceCountListener(VoiceCountListener* l); |
541 |
|
|
542 |
|
/** |
543 |
|
* Notifies listeners that the number of active voices |
544 |
|
* on the specified sampler channel is changed. |
545 |
|
* @param ChannelId The numerical ID of the sampler channel. |
546 |
|
* @param NewCount The new number of active voices. |
547 |
|
*/ |
548 |
|
void fireVoiceCountChanged(int ChannelId, int NewCount); |
549 |
|
|
550 |
|
/** |
551 |
|
* Registers the specified listener to be notified when the number |
552 |
|
* of active disk streams in a particular sampler channel is changed. |
553 |
|
*/ |
554 |
|
void AddStreamCountListener(StreamCountListener* l); |
555 |
|
|
556 |
|
/** |
557 |
|
* Removes the specified listener. |
558 |
|
*/ |
559 |
|
void RemoveStreamCountListener(StreamCountListener* l); |
560 |
|
|
561 |
|
/** |
562 |
|
* Notifies listeners that the number of active disk streams |
563 |
|
* on the specified sampler channel is changed. |
564 |
|
* @param ChannelId The numerical ID of the sampler channel. |
565 |
|
* @param NewCount The new number of active disk streams. |
566 |
|
*/ |
567 |
|
void fireStreamCountChanged(int ChannelId, int NewCount); |
568 |
|
|
569 |
|
/** |
570 |
|
* Registers the specified listener to be |
571 |
|
* notified when the fill state of the disk stream |
572 |
|
* buffers on a specific sampler channel is changed. |
573 |
|
*/ |
574 |
|
void AddBufferFillListener(BufferFillListener* l); |
575 |
|
|
576 |
|
/** |
577 |
|
* Removes the specified listener. |
578 |
|
*/ |
579 |
|
void RemoveBufferFillListener(BufferFillListener* l); |
580 |
|
|
581 |
|
/** |
582 |
|
* Notifies listeners that the fill state of the disk stream |
583 |
|
* buffers on the specified sampler channel is changed. |
584 |
|
* @param ChannelId The numerical ID of the sampler channel. |
585 |
|
* @param FillData The buffer fill data for the specified sampler channel. |
586 |
|
*/ |
587 |
|
void fireBufferFillChanged(int ChannelId, String FillData); |
588 |
|
|
589 |
|
/** |
590 |
|
* Registers the specified listener to be notified |
591 |
|
* when total number of active voices is changed. |
592 |
|
*/ |
593 |
|
void AddTotalVoiceCountListener(TotalVoiceCountListener* l); |
594 |
|
|
595 |
|
/** |
596 |
|
* Removes the specified listener. |
597 |
|
*/ |
598 |
|
void RemoveTotalVoiceCountListener(TotalVoiceCountListener* l); |
599 |
|
|
600 |
|
/** |
601 |
|
* Notifies listeners that the total number of active voices is changed. |
602 |
|
* @param NewCount The new number of active voices. |
603 |
|
*/ |
604 |
|
void fireTotalVoiceCountChanged(int NewCount); |
605 |
|
|
606 |
|
/** |
607 |
|
* Registers the specified listener to be notified when the number |
608 |
|
* of total streams is changed. |
609 |
|
*/ |
610 |
|
void AddTotalStreamCountListener(TotalStreamCountListener* l); |
611 |
|
|
612 |
|
/** |
613 |
|
* Removes the specified listener. |
614 |
|
*/ |
615 |
|
void RemoveTotalStreamCountListener(TotalStreamCountListener* l); |
616 |
|
|
617 |
|
/** |
618 |
|
* Notifies listeners that the total number of total streams changed. |
619 |
|
* @param NewCount The new number of total streams. |
620 |
|
*/ |
621 |
|
void fireTotalStreamCountChanged(int NewCount); |
622 |
|
|
623 |
|
/** |
624 |
|
* Registers the specified listener to be notified when the number |
625 |
|
* of effect sends on a particular sampler channel is changed. |
626 |
|
*/ |
627 |
|
void AddFxSendCountListener(FxSendCountListener* l); |
628 |
|
|
629 |
|
/** |
630 |
|
* Removes the specified listener. |
631 |
|
*/ |
632 |
|
void RemoveFxSendCountListener(FxSendCountListener* l); |
633 |
|
|
634 |
|
/** |
635 |
|
* Notifies listeners about the current number of voices, |
636 |
|
* streams and total voices, and the current fill state of |
637 |
|
* the disk stream buffers. |
638 |
|
*/ |
639 |
|
void fireStatistics(); |
640 |
|
|
641 |
|
/////////////////////////////////////////////////////////////// |
642 |
|
// system specific methods |
643 |
|
|
644 |
|
/** |
645 |
|
* Advise the FPU to treat denormal floating point numbers as |
646 |
|
* zero, to avoid severe performance penalty when dealing with |
647 |
|
* such extreme floating point values. |
648 |
|
* |
649 |
|
* @returns @c true if FPU supports it, @c false otherwise |
650 |
|
*/ |
651 |
|
static bool EnableDenormalsAreZeroMode(); |
652 |
|
|
653 |
|
#if defined(WIN32) |
654 |
|
/** |
655 |
|
* Gets the directory where the liblinuxsampler dll is located. |
656 |
|
* Note: this method is currently only available for Windows. |
657 |
|
* @returns installation directory |
658 |
|
*/ |
659 |
|
static String GetInstallDir(); |
660 |
|
#endif |
661 |
protected: |
protected: |
662 |
typedef std::map<uint, AudioOutputDevice*> AudioOutputDeviceMap; |
/** |
663 |
typedef std::map<uint, MidiInputDevice*> MidiInputDeviceMap; |
* Notifies listeners that the number of sampler channels has been changed. |
664 |
|
* @param NewCount The new number of sampler channels. |
665 |
|
*/ |
666 |
|
void fireChannelCountChanged(int NewCount); |
667 |
|
|
668 |
|
/** |
669 |
|
* Notifies listeners that the specified sampler channel has just |
670 |
|
* been added. |
671 |
|
* @param pChannel The new sampler channel. |
672 |
|
*/ |
673 |
|
void fireChannelAdded(SamplerChannel* pChannel); |
674 |
|
|
675 |
|
/** |
676 |
|
* Notifies listeners that the specified sampler channel is |
677 |
|
* going to be removed soon. |
678 |
|
* @param pChannel sampler channel to be removed. |
679 |
|
*/ |
680 |
|
void fireChannelToBeRemoved(SamplerChannel* pChannel); |
681 |
|
|
682 |
|
/** |
683 |
|
* Notifies listeners that the number of audio output devices has been changed. |
684 |
|
* @param NewCount The new number of audio output devices. |
685 |
|
*/ |
686 |
|
void fireAudioDeviceCountChanged(int NewCount); |
687 |
|
|
688 |
|
/** |
689 |
|
* Notifies listeners that the number of MIDI input devices has been changed. |
690 |
|
* @param NewCount The new number of MIDI input devices. |
691 |
|
*/ |
692 |
|
void fireMidiDeviceCountChanged(int NewCount); |
693 |
|
|
694 |
|
/** |
695 |
|
* Notifies listeners that the supplied MIDI input device is |
696 |
|
* going to be destroyed soon. |
697 |
|
* @param pDevice MIDI input device to be destroyed |
698 |
|
*/ |
699 |
|
void fireMidiDeviceToBeDestroyed(MidiInputDevice* pDevice); |
700 |
|
|
701 |
|
/** |
702 |
|
* Notifies listeners that the supplied MIDI input device was |
703 |
|
* just created. |
704 |
|
* @param pDevice new MIDI input device |
705 |
|
*/ |
706 |
|
void fireMidiDeviceCreated(MidiInputDevice* pDevice); |
707 |
|
|
708 |
|
/** |
709 |
|
* Notifies listeners that the number of effect sends |
710 |
|
* on a particular sampler channel is changed. |
711 |
|
* @param ChannelId The numerical ID of the sampler channel. |
712 |
|
* @param NewCount The new number of sampler channels. |
713 |
|
*/ |
714 |
|
void fireFxSendCountChanged(int ChannelId, int NewCount); |
715 |
|
|
716 |
typedef std::map<uint, SamplerChannel*> SamplerChannelMap; |
typedef std::map<uint, SamplerChannel*> SamplerChannelMap; |
717 |
|
|
718 |
SamplerChannelMap mSamplerChannels; ///< contains all created sampler channels |
SamplerChannelMap mSamplerChannels; ///< contains all created sampler channels |
719 |
AudioOutputDeviceMap mAudioOutputDevices; ///< contains all created audio output devices |
|
720 |
MidiInputDeviceMap mMidiInputDevices; ///< contains all created MIDI input devices |
// statistics cache |
721 |
|
uint uiOldTotalVoiceCount; |
722 |
|
uint uiOldTotalStreamCount; |
723 |
|
std::map<uint, uint> mOldVoiceCounts; |
724 |
|
std::map<uint, uint> mOldStreamCounts; |
725 |
|
|
726 |
friend class SamplerChannel; |
friend class SamplerChannel; |
727 |
|
|
728 |
|
private: |
729 |
|
ListenerList<ChannelCountListener*> llChannelCountListeners; |
730 |
|
ListenerList<AudioDeviceCountListener*> llAudioDeviceCountListeners; |
731 |
|
ListenerList<MidiDeviceCountListener*> llMidiDeviceCountListeners; |
732 |
|
ListenerList<VoiceCountListener*> llVoiceCountListeners; |
733 |
|
ListenerList<StreamCountListener*> llStreamCountListeners; |
734 |
|
ListenerList<BufferFillListener*> llBufferFillListeners; |
735 |
|
ListenerList<TotalStreamCountListener*> llTotalStreamCountListeners; |
736 |
|
ListenerList<TotalVoiceCountListener*> llTotalVoiceCountListeners; |
737 |
|
ListenerList<FxSendCountListener*> llFxSendCountListeners; |
738 |
|
|
739 |
|
class EventHandler : public EngineChangeListener, public FxSendCountListener { |
740 |
|
public: |
741 |
|
void SetSampler(Sampler* pSampler) { this->pSampler = pSampler; } |
742 |
|
|
743 |
|
/** |
744 |
|
* Invoked when the engine type of the specified sampler |
745 |
|
* channel is going to be changed soon. |
746 |
|
* @param ChannelId The numerical ID of the sampler channel |
747 |
|
*/ |
748 |
|
virtual void EngineToBeChanged(int ChannelId); |
749 |
|
|
750 |
|
/** |
751 |
|
* Invoked when the engine type of the |
752 |
|
* specified sampler channel is changed. |
753 |
|
* @param ChannelId The numerical ID of the sampler |
754 |
|
* channel, which engine type has been changed. |
755 |
|
*/ |
756 |
|
virtual void EngineChanged(int ChannelId); |
757 |
|
|
758 |
|
/** |
759 |
|
* Invoked when the number of effect sends |
760 |
|
* on the specified sampler channel has changed. |
761 |
|
* @param ChannelId The numerical ID of the sampler channel. |
762 |
|
* @param NewCount The new number of effect sends. |
763 |
|
*/ |
764 |
|
virtual void FxSendCountChanged(int ChannelId, int NewCount); |
765 |
|
|
766 |
|
private: |
767 |
|
Sampler* pSampler; |
768 |
|
} eventHandler; |
769 |
}; |
}; |
770 |
} |
} |
771 |
|
|