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 - 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/Exception.h" |
#include "common/Exception.h" |
32 |
#include "engines/EngineChannel.h" |
#include "engines/EngineChannel.h" |
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); |
197 |
private: |
private: |
198 |
int iMidiPort; ///< Don't access directly, read GetMidiInputPort() instead ! |
int iMidiPort; ///< Don't access directly, read GetMidiInputPort() instead ! |
199 |
midi_chan_t midiChannel; ///< Don't access directly, read GetMidiInputChannel() instead ! |
midi_chan_t midiChannel; ///< Don't access directly, read GetMidiInputChannel() instead ! |
200 |
|
ListenerList<EngineChangeListener*> llEngineChangeListeners; |
201 |
}; |
}; |
202 |
|
|
203 |
/** @brief LinuxSampler main class |
/** @brief LinuxSampler main class |
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. |
* Returns the names of all available audio output drivers. |
442 |
*/ |
*/ |
443 |
std::vector<String> AvailableAudioOutputDrivers(); |
std::vector<String> AvailableAudioOutputDrivers(); |
513 |
*/ |
*/ |
514 |
void DestroyMidiInputDevice(MidiInputDevice* pDevice) throw (Exception); |
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 |
|
int GetDiskStreamCount(); |
521 |
|
|
522 |
/** |
/** |
523 |
* Gets the current number of all active voices. |
* Gets the current number of all active voices. |
524 |
* @returns The current number of all active voices. |
* @returns The current number of all active voices. |
532 |
void Reset(); |
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<uint, MidiInputDevice*> MidiInputDeviceMap; |
typedef std::map<uint, MidiInputDevice*> MidiInputDeviceMap; |
591 |
typedef std::map<uint, SamplerChannel*> SamplerChannelMap; |
typedef std::map<uint, SamplerChannel*> SamplerChannelMap; |
595 |
MidiInputDeviceMap mMidiInputDevices; ///< contains all created MIDI input devices |
MidiInputDeviceMap mMidiInputDevices; ///< contains all created MIDI input devices |
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 |
|
|