32 |
#include "drivers/audio/AudioOutputDeviceFactory.h" |
#include "drivers/audio/AudioOutputDeviceFactory.h" |
33 |
#include "drivers/midi/MidiInputDeviceFactory.h" |
#include "drivers/midi/MidiInputDeviceFactory.h" |
34 |
#include "drivers/midi/MidiInstrumentMapper.h" |
#include "drivers/midi/MidiInstrumentMapper.h" |
35 |
|
#include "common/Features.h" |
36 |
|
#include "network/lscpserver.h" |
37 |
|
|
38 |
namespace LinuxSampler { |
namespace LinuxSampler { |
39 |
|
|
84 |
EngineChannel* pNewEngineChannel = EngineChannelFactory::Create(EngineType); |
EngineChannel* pNewEngineChannel = EngineChannelFactory::Create(EngineType); |
85 |
if (!pNewEngineChannel) throw Exception("Unknown engine type"); |
if (!pNewEngineChannel) throw Exception("Unknown engine type"); |
86 |
|
|
87 |
//FIXME: hack to allow fast retrieval of engine channel's sampler channel index |
pNewEngineChannel->SetSamplerChannel(this); |
|
pNewEngineChannel->iSamplerChannelIndex = Index(); |
|
88 |
|
|
89 |
// dereference midi input port. |
// dereference midi input port. |
90 |
MidiInputPort* pMidiInputPort = __GetMidiInputDevicePort(GetMidiInputPort()); |
MidiInputPort* pMidiInputPort = __GetMidiInputDevicePort(GetMidiInputPort()); |
216 |
throw Exception("Internal error: SamplerChannel index not found"); |
throw Exception("Internal error: SamplerChannel index not found"); |
217 |
} |
} |
218 |
|
|
219 |
|
Sampler* SamplerChannel::GetSampler() { |
220 |
|
return pSampler; |
221 |
|
} |
222 |
|
|
223 |
void SamplerChannel::AddEngineChangeListener(EngineChangeListener* l) { |
void SamplerChannel::AddEngineChangeListener(EngineChangeListener* l) { |
224 |
llEngineChangeListeners.AddListener(l); |
llEngineChangeListeners.AddListener(l); |
225 |
} |
} |
323 |
} |
} |
324 |
} |
} |
325 |
|
|
326 |
|
void Sampler::fireMidiDeviceToBeDestroyed(MidiInputDevice* pDevice) { |
327 |
|
for (int i = 0; i < llMidiDeviceCountListeners.GetListenerCount(); i++) { |
328 |
|
llMidiDeviceCountListeners.GetListener(i)->MidiDeviceToBeDestroyed(pDevice); |
329 |
|
} |
330 |
|
} |
331 |
|
|
332 |
|
void Sampler::fireMidiDeviceCreated(MidiInputDevice* pDevice) { |
333 |
|
for (int i = 0; i < llMidiDeviceCountListeners.GetListenerCount(); i++) { |
334 |
|
llMidiDeviceCountListeners.GetListener(i)->MidiDeviceCreated(pDevice); |
335 |
|
} |
336 |
|
} |
337 |
|
|
338 |
void Sampler::AddVoiceCountListener(VoiceCountListener* l) { |
void Sampler::AddVoiceCountListener(VoiceCountListener* l) { |
339 |
llVoiceCountListeners.AddListener(l); |
llVoiceCountListeners.AddListener(l); |
340 |
} |
} |
576 |
for (uint i = 0; i < SamplerChannels(); i++) |
for (uint i = 0; i < SamplerChannels(); i++) |
577 |
if (GetSamplerChannel(i)->GetMidiInputDevice() == pDevice) throw Exception("Sampler channel " + ToString(i) + " is still connected to the midi input device."); |
if (GetSamplerChannel(i)->GetMidiInputDevice() == pDevice) throw Exception("Sampler channel " + ToString(i) + " is still connected to the midi input device."); |
578 |
|
|
579 |
|
fireMidiDeviceToBeDestroyed(pDevice); |
580 |
|
|
581 |
// disable device |
// disable device |
582 |
pDevice->StopListen(); |
pDevice->StopListen(); |
583 |
|
|
605 |
} |
} |
606 |
} |
} |
607 |
|
|
608 |
|
fireMidiDeviceCreated(pDevice); |
609 |
fireMidiDeviceCountChanged(MidiInputDevices()); |
fireMidiDeviceCountChanged(MidiInputDevices()); |
610 |
return pDevice; |
return pDevice; |
611 |
} |
} |
685 |
InstrumentEditorFactory::ClosePlugins(); |
InstrumentEditorFactory::ClosePlugins(); |
686 |
} |
} |
687 |
|
|
688 |
|
bool Sampler::EnableDenormalsAreZeroMode() { |
689 |
|
Features::detect(); |
690 |
|
return Features::enableDenormalsAreZeroMode(); |
691 |
|
} |
692 |
|
|
693 |
|
void Sampler::fireStatistics() { |
694 |
|
static const LSCPEvent::event_t eventsArr[] = { |
695 |
|
LSCPEvent::event_voice_count, LSCPEvent::event_stream_count, |
696 |
|
LSCPEvent::event_buffer_fill, LSCPEvent::event_total_voice_count |
697 |
|
}; |
698 |
|
static const std::list<LSCPEvent::event_t> events(eventsArr, eventsArr + 4); |
699 |
|
|
700 |
|
if (LSCPServer::EventSubscribers(events)) |
701 |
|
{ |
702 |
|
LSCPServer::LockRTNotify(); |
703 |
|
std::map<uint,SamplerChannel*> channels = GetSamplerChannels(); |
704 |
|
std::map<uint,SamplerChannel*>::iterator iter = channels.begin(); |
705 |
|
for (; iter != channels.end(); iter++) { |
706 |
|
SamplerChannel* pSamplerChannel = iter->second; |
707 |
|
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
708 |
|
if (!pEngineChannel) continue; |
709 |
|
Engine* pEngine = pEngineChannel->GetEngine(); |
710 |
|
if (!pEngine) continue; |
711 |
|
fireVoiceCountChanged(iter->first, pEngineChannel->GetVoiceCount()); |
712 |
|
fireStreamCountChanged(iter->first, pEngineChannel->GetDiskStreamCount()); |
713 |
|
fireBufferFillChanged(iter->first, pEngine->DiskStreamBufferFillPercentage()); |
714 |
|
fireTotalStreamCountChanged(GetDiskStreamCount()); |
715 |
|
fireTotalVoiceCountChanged(GetVoiceCount()); |
716 |
|
} |
717 |
|
LSCPServer::UnlockRTNotify(); |
718 |
|
} |
719 |
|
} |
720 |
|
|
721 |
} // namespace LinuxSampler |
} // namespace LinuxSampler |