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 * |
* Copyright (C) 2005 - 2009 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 * |
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 |
167 |
* Sampler instance. |
* Sampler instance. |
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 |
* Registers the specified listener to be notified |
179 |
* when the engine type of this sampler channel is changed. |
* when the engine type of this sampler channel is changed. |
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. |
347 |
|
*/ |
348 |
|
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. |
363 |
|
* |
364 |
|
* @param AudioDriver - name of the audio driver |
365 |
|
* @param Parameters - eventually needed driver parameters to |
366 |
|
* create the device |
367 |
|
* @returns pointer to created audio output device |
368 |
|
* @throws Exception if device could not be created |
369 |
|
*/ |
370 |
|
AudioOutputDevice* CreateAudioOutputDevice(String AudioDriver, std::map<String,String> Parameters) throw (Exception); |
371 |
|
|
372 |
|
/** |
373 |
|
* Create a midi input device. |
374 |
|
* |
375 |
|
* @param MidiDriver - name of the midi driver |
376 |
|
* @param Parameters - eventually needed driver parameters to |
377 |
|
* create the device |
378 |
|
* @returns pointer to created midi input device |
379 |
|
* @throws Exception if device could not be created |
380 |
|
*/ |
381 |
|
MidiInputDevice* CreateMidiInputDevice(String MidiDriver, std::map<String,String> Parameters) throw (Exception); |
382 |
|
|
383 |
|
/** |
384 |
|
* Returns the number of all created audio output devices. |
385 |
|
*/ |
386 |
|
uint AudioOutputDevices(); |
387 |
|
|
388 |
|
/** |
389 |
|
* Returns the number of all created MIDI input devices. |
390 |
|
*/ |
391 |
|
uint MidiInputDevices(); |
392 |
|
|
393 |
|
/** |
394 |
|
* Returns all created audio output devices. |
395 |
|
*/ |
396 |
|
std::map<uint, AudioOutputDevice*> GetAudioOutputDevices(); |
397 |
|
|
398 |
|
/** |
399 |
|
* Returns all created MIDI input devices. |
400 |
|
*/ |
401 |
|
std::map<uint, MidiInputDevice*> GetMidiInputDevices(); |
402 |
|
|
403 |
|
/** |
404 |
|
* Destroy the given audio output device and takes care if there |
405 |
|
* are still sampler engines connected to this device, etc. |
406 |
|
* |
407 |
|
* @throws Exception if sampler channels are still |
408 |
|
* connected to the device |
409 |
|
*/ |
410 |
|
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 |
427 |
|
* are still sampler engines connected to this device, etc. |
428 |
|
* |
429 |
|
* @throws Exception if sampler channels are still |
430 |
|
* connected to the device |
431 |
|
*/ |
432 |
|
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. |
455 |
|
* @returns The current number of all active voices. |
456 |
|
*/ |
457 |
|
int GetVoiceCount(); |
458 |
|
|
459 |
|
/** |
460 |
|
* Reset the whole sampler. Destroy all engines, sampler |
461 |
|
* channels, MIDI input devices and audio output devices. |
462 |
|
*/ |
463 |
|
void Reset(); |
464 |
|
|
465 |
|
/////////////////////////////////////////////////////////////// |
466 |
|
// Event Listener methods |
467 |
|
|
468 |
|
/** |
469 |
* Registers the specified listener to be notified |
* Registers the specified listener to be notified |
470 |
* when the number of sampler chanels is changed. |
* when the number of sampler chanels is changed. |
471 |
*/ |
*/ |
487 |
*/ |
*/ |
488 |
void RemoveAudioDeviceCountListener(AudioDeviceCountListener* l); |
void RemoveAudioDeviceCountListener(AudioDeviceCountListener* l); |
489 |
|
|
|
|
|
490 |
/** |
/** |
491 |
* Registers the specified listener to be notified |
* Registers the specified listener to be notified |
492 |
* when the number of MIDI input devices is changed. |
* when the number of MIDI input devices is changed. |
572 |
* @param NewCount The new number of active voices. |
* @param NewCount The new number of active voices. |
573 |
*/ |
*/ |
574 |
void fireTotalVoiceCountChanged(int NewCount); |
void fireTotalVoiceCountChanged(int NewCount); |
|
|
|
|
void AddTotalStreamCountListener(TotalStreamCountListener* l); |
|
|
void RemoveTotalStreamCountListener(TotalStreamCountListener* l); |
|
|
void fireTotalStreamCountChanged(int NewCount); |
|
575 |
|
|
576 |
/** |
/** |
577 |
* Registers the specified listener to be notified when the number |
* Registers the specified listener to be notified when the number |
578 |
* of effect sends on a particular sampler channel is changed. |
* of total streams is changed. |
579 |
*/ |
*/ |
580 |
void AddFxSendCountListener(FxSendCountListener* l); |
void AddTotalStreamCountListener(TotalStreamCountListener* l); |
581 |
|
|
582 |
/** |
/** |
583 |
* Removes the specified listener. |
* Removes the specified listener. |
584 |
*/ |
*/ |
585 |
void RemoveFxSendCountListener(FxSendCountListener* l); |
void RemoveTotalStreamCountListener(TotalStreamCountListener* l); |
|
|
|
|
/** |
|
|
* Returns the names of all available audio output drivers. |
|
|
*/ |
|
|
std::vector<String> AvailableAudioOutputDrivers(); |
|
|
|
|
|
/** |
|
|
* Returns the names of all available MIDI input drivers. |
|
|
*/ |
|
|
std::vector<String> AvailableMidiInputDrivers(); |
|
|
|
|
|
/** |
|
|
* Returns the names of all available sampler engine types. |
|
|
* @see SamplerChannel::SetEngineType() |
|
|
*/ |
|
|
std::vector<String> AvailableEngineTypes(); |
|
|
|
|
|
/** |
|
|
* Create an audio output device. |
|
|
* |
|
|
* @param AudioDriver - name of the audio driver |
|
|
* @param Parameters - eventually needed driver parameters to |
|
|
* create the device |
|
|
* @returns pointer to created audio output device |
|
|
* @throws Exception if device could not be created |
|
|
*/ |
|
|
AudioOutputDevice* CreateAudioOutputDevice(String AudioDriver, std::map<String,String> Parameters) throw (Exception); |
|
|
|
|
|
/** |
|
|
* Create a midi input device. |
|
|
* |
|
|
* @param MidiDriver - name of the midi driver |
|
|
* @param Parameters - eventually needed driver parameters to |
|
|
* create the device |
|
|
* @returns pointer to created midi input device |
|
|
* @throws Exception if device could not be created |
|
|
*/ |
|
|
MidiInputDevice* CreateMidiInputDevice(String MidiDriver, std::map<String,String> Parameters) throw (Exception); |
|
586 |
|
|
587 |
/** |
/** |
588 |
* Returns the number of all created audio output devices. |
* Notifies listeners that the total number of total streams changed. |
589 |
|
* @param NewCount The new number of total streams. |
590 |
*/ |
*/ |
591 |
uint AudioOutputDevices(); |
void fireTotalStreamCountChanged(int NewCount); |
592 |
|
|
593 |
/** |
/** |
594 |
* Returns the number of all created MIDI input devices. |
* Registers the specified listener to be notified when the number |
595 |
|
* of effect sends on a particular sampler channel is changed. |
596 |
*/ |
*/ |
597 |
uint MidiInputDevices(); |
void AddFxSendCountListener(FxSendCountListener* l); |
598 |
|
|
599 |
/** |
/** |
600 |
* Returns all created audio output devices. |
* Removes the specified listener. |
601 |
*/ |
*/ |
602 |
std::map<uint, AudioOutputDevice*> GetAudioOutputDevices(); |
void RemoveFxSendCountListener(FxSendCountListener* l); |
603 |
|
|
604 |
/** |
/** |
605 |
* Returns all created MIDI input devices. |
* Notifies listeners about the current number of voices, |
606 |
|
* streams and total voices, and the current fill state of |
607 |
|
* the disk stream buffers. |
608 |
*/ |
*/ |
609 |
std::map<uint, MidiInputDevice*> GetMidiInputDevices(); |
void fireStatistics(); |
610 |
|
|
611 |
/** |
/////////////////////////////////////////////////////////////// |
612 |
* Destroy the given audio output device and takes care if there |
// system specific methods |
|
* are still sampler angines connected to this device, etc. |
|
|
* |
|
|
* @throws Exception if sampler channels are still |
|
|
* connected to the device |
|
|
*/ |
|
|
void DestroyAudioOutputDevice(AudioOutputDevice* pDevice) throw (Exception); |
|
613 |
|
|
614 |
/** |
/** |
615 |
* Destroy the given MIDI input device and takes care if there |
* Advise the FPU to treat denormal floating point numbers as |
616 |
* are still sampler angines connected to this device, etc. |
* zero, to avoid severe performance penalty when dealing with |
617 |
|
* such extreme floating point values. |
618 |
* |
* |
619 |
* @throws Exception if sampler channels are still |
* @returns @c true if FPU supports it, @c false otherwise |
|
* connected to the device |
|
620 |
*/ |
*/ |
621 |
void DestroyMidiInputDevice(MidiInputDevice* pDevice) throw (Exception); |
static bool EnableDenormalsAreZeroMode(); |
|
|
|
|
/** |
|
|
* Gets the current number of all active streams. |
|
|
* @returns The current number of all active streams. |
|
|
*/ |
|
|
int GetDiskStreamCount(); |
|
|
|
|
|
/** |
|
|
* Gets the current number of all active voices. |
|
|
* @returns The current number of all active voices. |
|
|
*/ |
|
|
int GetVoiceCount(); |
|
622 |
|
|
623 |
|
#if defined(WIN32) |
624 |
/** |
/** |
625 |
* Reset the whole sampler. Destroy all engines, sampler |
* Gets the directory where the liblinuxsampler dll is located. |
626 |
* channels, MIDI input devices and audio output devices. |
* Note: this method is currently only available for Windows. |
627 |
|
* @returns installation directory |
628 |
*/ |
*/ |
629 |
void Reset(); |
static String GetInstallDir(); |
630 |
|
#endif |
631 |
protected: |
protected: |
632 |
/** |
/** |
633 |
* Notifies listeners that the number of sampler channels has been changed. |
* Notifies listeners that the number of sampler channels has been changed. |
683 |
*/ |
*/ |
684 |
void fireFxSendCountChanged(int ChannelId, int NewCount); |
void fireFxSendCountChanged(int ChannelId, int NewCount); |
685 |
|
|
|
typedef std::map<uint, AudioOutputDevice*> AudioOutputDeviceMap; |
|
|
typedef std::map<uint, MidiInputDevice*> MidiInputDeviceMap; |
|
686 |
typedef std::map<uint, SamplerChannel*> SamplerChannelMap; |
typedef std::map<uint, SamplerChannel*> SamplerChannelMap; |
687 |
|
|
688 |
SamplerChannelMap mSamplerChannels; ///< contains all created sampler channels |
SamplerChannelMap mSamplerChannels; ///< contains all created sampler channels |
689 |
AudioOutputDeviceMap mAudioOutputDevices; ///< contains all created audio output devices |
|
690 |
MidiInputDeviceMap mMidiInputDevices; ///< contains all created MIDI input devices |
// statistics cache |
691 |
|
uint uiOldTotalVoiceCount; |
692 |
|
uint uiOldTotalStreamCount; |
693 |
|
std::map<uint, uint> mOldVoiceCounts; |
694 |
|
std::map<uint, uint> mOldStreamCounts; |
695 |
|
|
696 |
friend class SamplerChannel; |
friend class SamplerChannel; |
697 |
|
|