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 |
172 |
|
* type of this sampler channel is changed. |
173 |
|
*/ |
174 |
|
void fireEngineChanged(); |
175 |
|
|
176 |
|
|
177 |
protected: |
protected: |
178 |
SamplerChannel(Sampler* pS); |
SamplerChannel(Sampler* pS); |
191 |
private: |
private: |
192 |
int iMidiPort; ///< Don't access directly, read GetMidiInputPort() instead ! |
int iMidiPort; ///< Don't access directly, read GetMidiInputPort() instead ! |
193 |
midi_chan_t midiChannel; ///< Don't access directly, read GetMidiInputChannel() instead ! |
midi_chan_t midiChannel; ///< Don't access directly, read GetMidiInputChannel() instead ! |
194 |
|
ListenerList<EngineChangeListener*> llEngineChangeListeners; |
195 |
}; |
}; |
196 |
|
|
197 |
/** @brief LinuxSampler main class |
/** @brief LinuxSampler main class |
308 |
void RemoveSamplerChannel(uint uiSamplerChannel); |
void RemoveSamplerChannel(uint uiSamplerChannel); |
309 |
|
|
310 |
/** |
/** |
311 |
|
* Registers the specified listener to be notified |
312 |
|
* when the number of sampler chanels is changed. |
313 |
|
*/ |
314 |
|
void AddChannelCountListener(ChannelCountListener* l); |
315 |
|
|
316 |
|
/** |
317 |
|
* Removes the specified listener. |
318 |
|
*/ |
319 |
|
void RemoveChannelCountListener(ChannelCountListener* l); |
320 |
|
|
321 |
|
/** |
322 |
|
* Registers the specified listener to be notified |
323 |
|
* when the number of audio output devices is changed. |
324 |
|
*/ |
325 |
|
void AddAudioDeviceCountListener(AudioDeviceCountListener* l); |
326 |
|
|
327 |
|
/** |
328 |
|
* Removes the specified listener. |
329 |
|
*/ |
330 |
|
void RemoveAudioDeviceCountListener(AudioDeviceCountListener* l); |
331 |
|
|
332 |
|
|
333 |
|
/** |
334 |
|
* Registers the specified listener to be notified |
335 |
|
* when the number of MIDI input devices is changed. |
336 |
|
*/ |
337 |
|
void AddMidiDeviceCountListener(MidiDeviceCountListener* l); |
338 |
|
|
339 |
|
/** |
340 |
|
* Removes the specified listener. |
341 |
|
*/ |
342 |
|
void RemoveMidiDeviceCountListener(MidiDeviceCountListener* l); |
343 |
|
|
344 |
|
/** |
345 |
|
* Registers the specified listener to be notified when the number |
346 |
|
* of active voices in a particular sampler channel is changed. |
347 |
|
*/ |
348 |
|
void AddVoiceCountListener(VoiceCountListener* l); |
349 |
|
|
350 |
|
/** |
351 |
|
* Removes the specified listener. |
352 |
|
*/ |
353 |
|
void RemoveVoiceCountListener(VoiceCountListener* l); |
354 |
|
|
355 |
|
/** |
356 |
|
* Notifies listeners that the number of active voices |
357 |
|
* on the specified sampler channel is changed. |
358 |
|
* @param ChannelId The numerical ID of the sampler channel. |
359 |
|
* @param NewCount The new number of active voices. |
360 |
|
*/ |
361 |
|
void fireVoiceCountChanged(int ChannelId, int NewCount); |
362 |
|
|
363 |
|
/** |
364 |
|
* Registers the specified listener to be notified when the number |
365 |
|
* of active disk streams in a particular sampler channel is changed. |
366 |
|
*/ |
367 |
|
void AddStreamCountListener(StreamCountListener* l); |
368 |
|
|
369 |
|
/** |
370 |
|
* Removes the specified listener. |
371 |
|
*/ |
372 |
|
void RemoveStreamCountListener(StreamCountListener* l); |
373 |
|
|
374 |
|
/** |
375 |
|
* Notifies listeners that the number of active disk streams |
376 |
|
* on the specified sampler channel is changed. |
377 |
|
* @param ChannelId The numerical ID of the sampler channel. |
378 |
|
* @param NewCount The new number of active disk streams. |
379 |
|
*/ |
380 |
|
void fireStreamCountChanged(int ChannelId, int NewCount); |
381 |
|
|
382 |
|
/** |
383 |
|
* Registers the specified listener to be |
384 |
|
* notified when the fill state of the disk stream |
385 |
|
* buffers on a specific sampler channel is changed. |
386 |
|
*/ |
387 |
|
void AddBufferFillListener(BufferFillListener* l); |
388 |
|
|
389 |
|
/** |
390 |
|
* Removes the specified listener. |
391 |
|
*/ |
392 |
|
void RemoveBufferFillListener(BufferFillListener* l); |
393 |
|
|
394 |
|
/** |
395 |
|
* Notifies listeners that the fill state of the disk stream |
396 |
|
* buffers on the specified sampler channel is changed. |
397 |
|
* @param ChannelId The numerical ID of the sampler channel. |
398 |
|
* @param FillData The buffer fill data for the specified sampler channel. |
399 |
|
*/ |
400 |
|
void fireBufferFillChanged(int ChannelId, String FillData); |
401 |
|
|
402 |
|
/** |
403 |
|
* Registers the specified listener to be notified |
404 |
|
* when total number of active voices is changed. |
405 |
|
*/ |
406 |
|
void AddTotalVoiceCountListener(TotalVoiceCountListener* l); |
407 |
|
|
408 |
|
/** |
409 |
|
* Removes the specified listener. |
410 |
|
*/ |
411 |
|
void RemoveTotalVoiceCountListener(TotalVoiceCountListener* l); |
412 |
|
|
413 |
|
/** |
414 |
|
* Notifies listeners that the total number of active voices is changed. |
415 |
|
* @param NewCount The new number of active voices. |
416 |
|
*/ |
417 |
|
void fireTotalVoiceCountChanged(int NewCount); |
418 |
|
|
419 |
|
/** |
420 |
|
* Registers the specified listener to be notified when the number |
421 |
|
* of effect sends on a particular sampler channel is changed. |
422 |
|
*/ |
423 |
|
void AddFxSendCountListener(FxSendCountListener* l); |
424 |
|
|
425 |
|
/** |
426 |
|
* Removes the specified listener. |
427 |
|
*/ |
428 |
|
void RemoveFxSendCountListener(FxSendCountListener* l); |
429 |
|
|
430 |
|
/** |
431 |
* Returns the names of all available audio output drivers. |
* Returns the names of all available audio output drivers. |
432 |
*/ |
*/ |
433 |
std::vector<String> AvailableAudioOutputDrivers(); |
std::vector<String> AvailableAudioOutputDrivers(); |
516 |
void Reset(); |
void Reset(); |
517 |
|
|
518 |
protected: |
protected: |
519 |
|
/** |
520 |
|
* Notifies listeners that the number of sampler channels has been changed. |
521 |
|
* @param NewCount The new number of sampler channels. |
522 |
|
*/ |
523 |
|
void fireChannelCountChanged(int NewCount); |
524 |
|
|
525 |
|
/** |
526 |
|
* Notifies listeners that the number of audio output devices has been changed. |
527 |
|
* @param NewCount The new number of audio output devices. |
528 |
|
*/ |
529 |
|
void fireAudioDeviceCountChanged(int NewCount); |
530 |
|
|
531 |
|
/** |
532 |
|
* Notifies listeners that the number of MIDI input devices has been changed. |
533 |
|
* @param NewCount The new number of MIDI input devices. |
534 |
|
*/ |
535 |
|
void fireMidiDeviceCountChanged(int NewCount); |
536 |
|
|
537 |
|
/** |
538 |
|
* Notifies listeners that the number of effect sends |
539 |
|
* on a particular sampler channel is changed. |
540 |
|
* @param ChannelId The numerical ID of the sampler channel. |
541 |
|
* @param NewCount The new number of sampler channels. |
542 |
|
*/ |
543 |
|
void fireFxSendCountChanged(int ChannelId, int NewCount); |
544 |
|
|
545 |
typedef std::map<uint, AudioOutputDevice*> AudioOutputDeviceMap; |
typedef std::map<uint, AudioOutputDevice*> AudioOutputDeviceMap; |
546 |
typedef std::map<uint, MidiInputDevice*> MidiInputDeviceMap; |
typedef std::map<uint, MidiInputDevice*> MidiInputDeviceMap; |
547 |
typedef std::map<uint, SamplerChannel*> SamplerChannelMap; |
typedef std::map<uint, SamplerChannel*> SamplerChannelMap; |
551 |
MidiInputDeviceMap mMidiInputDevices; ///< contains all created MIDI input devices |
MidiInputDeviceMap mMidiInputDevices; ///< contains all created MIDI input devices |
552 |
|
|
553 |
friend class SamplerChannel; |
friend class SamplerChannel; |
554 |
|
|
555 |
|
private: |
556 |
|
ListenerList<ChannelCountListener*> llChannelCountListeners; |
557 |
|
ListenerList<AudioDeviceCountListener*> llAudioDeviceCountListeners; |
558 |
|
ListenerList<MidiDeviceCountListener*> llMidiDeviceCountListeners; |
559 |
|
ListenerList<VoiceCountListener*> llVoiceCountListeners; |
560 |
|
ListenerList<StreamCountListener*> llStreamCountListeners; |
561 |
|
ListenerList<BufferFillListener*> llBufferFillListeners; |
562 |
|
ListenerList<TotalVoiceCountListener*> llTotalVoiceCountListeners; |
563 |
|
ListenerList<FxSendCountListener*> llFxSendCountListeners; |
564 |
|
|
565 |
|
class EventHandler : public EngineChangeListener, public FxSendCountListener { |
566 |
|
public: |
567 |
|
void SetSampler(Sampler* pSampler) { this->pSampler = pSampler; } |
568 |
|
|
569 |
|
/** |
570 |
|
* Invoked when the engine type of the |
571 |
|
* specified sampler channel is changed. |
572 |
|
* @param ChannelId The numerical ID of the sampler |
573 |
|
* channel, which engine type has been changed. |
574 |
|
*/ |
575 |
|
virtual void EngineChanged(int ChannelId); |
576 |
|
|
577 |
|
/** |
578 |
|
* Invoked when the number of effect sends |
579 |
|
* on the specified sampler channel has changed. |
580 |
|
* @param ChannelId The numerical ID of the sampler channel. |
581 |
|
* @param NewCount The new number of effect sends. |
582 |
|
*/ |
583 |
|
virtual void FxSendCountChanged(int ChannelId, int NewCount); |
584 |
|
|
585 |
|
private: |
586 |
|
Sampler* pSampler; |
587 |
|
} eventHandler; |
588 |
}; |
}; |
589 |
} |
} |
590 |
|
|