259 |
|
|
260 |
Sampler::Sampler() { |
Sampler::Sampler() { |
261 |
eventHandler.SetSampler(this); |
eventHandler.SetSampler(this); |
262 |
|
uiOldTotalVoiceCount = uiOldTotalStreamCount = 0; |
263 |
} |
} |
264 |
|
|
265 |
Sampler::~Sampler() { |
Sampler::~Sampler() { |
345 |
} |
} |
346 |
|
|
347 |
void Sampler::fireVoiceCountChanged(int ChannelId, int NewCount) { |
void Sampler::fireVoiceCountChanged(int ChannelId, int NewCount) { |
348 |
|
std::map<uint, uint>::iterator it = mOldVoiceCounts.find(ChannelId); |
349 |
|
if (it != mOldVoiceCounts.end()) { |
350 |
|
uint oldCount = it->second; |
351 |
|
if (NewCount == oldCount) return; |
352 |
|
} |
353 |
|
|
354 |
|
mOldVoiceCounts[ChannelId] = NewCount; |
355 |
|
|
356 |
for (int i = 0; i < llVoiceCountListeners.GetListenerCount(); i++) { |
for (int i = 0; i < llVoiceCountListeners.GetListenerCount(); i++) { |
357 |
llVoiceCountListeners.GetListener(i)->VoiceCountChanged(ChannelId, NewCount); |
llVoiceCountListeners.GetListener(i)->VoiceCountChanged(ChannelId, NewCount); |
358 |
} |
} |
367 |
} |
} |
368 |
|
|
369 |
void Sampler::fireStreamCountChanged(int ChannelId, int NewCount) { |
void Sampler::fireStreamCountChanged(int ChannelId, int NewCount) { |
370 |
|
std::map<uint, uint>::iterator it = mOldStreamCounts.find(ChannelId); |
371 |
|
if (it != mOldStreamCounts.end()) { |
372 |
|
uint oldCount = it->second; |
373 |
|
if (NewCount == oldCount) return; |
374 |
|
} |
375 |
|
|
376 |
|
mOldStreamCounts[ChannelId] = NewCount; |
377 |
|
|
378 |
for (int i = 0; i < llStreamCountListeners.GetListenerCount(); i++) { |
for (int i = 0; i < llStreamCountListeners.GetListenerCount(); i++) { |
379 |
llStreamCountListeners.GetListener(i)->StreamCountChanged(ChannelId, NewCount); |
llStreamCountListeners.GetListener(i)->StreamCountChanged(ChannelId, NewCount); |
380 |
} |
} |
403 |
} |
} |
404 |
|
|
405 |
void Sampler::fireTotalStreamCountChanged(int NewCount) { |
void Sampler::fireTotalStreamCountChanged(int NewCount) { |
406 |
|
if (NewCount == uiOldTotalStreamCount) return; |
407 |
|
uiOldTotalStreamCount = NewCount; |
408 |
|
|
409 |
for (int i = 0; i < llTotalStreamCountListeners.GetListenerCount(); i++) { |
for (int i = 0; i < llTotalStreamCountListeners.GetListenerCount(); i++) { |
410 |
llTotalStreamCountListeners.GetListener(i)->TotalStreamCountChanged(NewCount); |
llTotalStreamCountListeners.GetListener(i)->TotalStreamCountChanged(NewCount); |
411 |
} |
} |
420 |
} |
} |
421 |
|
|
422 |
void Sampler::fireTotalVoiceCountChanged(int NewCount) { |
void Sampler::fireTotalVoiceCountChanged(int NewCount) { |
423 |
|
if (NewCount == uiOldTotalVoiceCount) return; |
424 |
|
uiOldTotalVoiceCount = NewCount; |
425 |
|
|
426 |
for (int i = 0; i < llTotalVoiceCountListeners.GetListenerCount(); i++) { |
for (int i = 0; i < llTotalVoiceCountListeners.GetListenerCount(); i++) { |
427 |
llTotalVoiceCountListeners.GetListener(i)->TotalVoiceCountChanged(NewCount); |
llTotalVoiceCountListeners.GetListener(i)->TotalVoiceCountChanged(NewCount); |
428 |
} |
} |
509 |
for (; iterChan != mSamplerChannels.end(); iterChan++) { |
for (; iterChan != mSamplerChannels.end(); iterChan++) { |
510 |
if (iterChan->second == pSamplerChannel) { |
if (iterChan->second == pSamplerChannel) { |
511 |
fireChannelToBeRemoved(pSamplerChannel); |
fireChannelToBeRemoved(pSamplerChannel); |
512 |
|
mOldVoiceCounts.erase(pSamplerChannel->Index()); |
513 |
|
mOldStreamCounts.erase(pSamplerChannel->Index()); |
514 |
pSamplerChannel->RemoveAllEngineChangeListeners(); |
pSamplerChannel->RemoveAllEngineChangeListeners(); |
515 |
mSamplerChannels.erase(iterChan); |
mSamplerChannels.erase(iterChan); |
516 |
delete pSamplerChannel; |
delete pSamplerChannel; |
575 |
for (; iter != mAudioOutputDevices.end(); iter++) { |
for (; iter != mAudioOutputDevices.end(); iter++) { |
576 |
if (iter->second == pDevice) { |
if (iter->second == pDevice) { |
577 |
// check if there are still sampler engines connected to this device |
// check if there are still sampler engines connected to this device |
578 |
for (uint i = 0; i < SamplerChannels(); i++) |
for (SamplerChannelMap::iterator iterChan = mSamplerChannels.begin(); |
579 |
if (GetSamplerChannel(i)->GetAudioOutputDevice() == pDevice) throw Exception("Sampler channel " + ToString(i) + " is still connected to the audio output device."); |
iterChan != mSamplerChannels.end(); iterChan++) |
580 |
|
if (iterChan->second->GetAudioOutputDevice() == pDevice) throw Exception("Sampler channel " + ToString(iterChan->first) + " is still connected to the audio output device."); |
581 |
|
|
582 |
// disable device |
// disable device |
583 |
pDevice->Stop(); |
pDevice->Stop(); |
599 |
for (; iter != mMidiInputDevices.end(); iter++) { |
for (; iter != mMidiInputDevices.end(); iter++) { |
600 |
if (iter->second == pDevice) { |
if (iter->second == pDevice) { |
601 |
// check if there are still sampler engines connected to this device |
// check if there are still sampler engines connected to this device |
602 |
for (uint i = 0; i < SamplerChannels(); i++) |
for (SamplerChannelMap::iterator iterChan = mSamplerChannels.begin(); |
603 |
if (GetSamplerChannel(i)->GetMidiInputDevice() == pDevice) throw Exception("Sampler channel " + ToString(i) + " is still connected to the midi input device."); |
iterChan != mSamplerChannels.end(); iterChan++) |
604 |
|
if (iterChan->second->GetMidiInputDevice() == pDevice) throw Exception("Sampler channel " + ToString(iterChan->first) + " is still connected to the midi input device."); |
605 |
|
|
606 |
fireMidiDeviceToBeDestroyed(pDevice); |
fireMidiDeviceToBeDestroyed(pDevice); |
607 |
|
|
738 |
fireVoiceCountChanged(iter->first, pEngineChannel->GetVoiceCount()); |
fireVoiceCountChanged(iter->first, pEngineChannel->GetVoiceCount()); |
739 |
fireStreamCountChanged(iter->first, pEngineChannel->GetDiskStreamCount()); |
fireStreamCountChanged(iter->first, pEngineChannel->GetDiskStreamCount()); |
740 |
fireBufferFillChanged(iter->first, pEngine->DiskStreamBufferFillPercentage()); |
fireBufferFillChanged(iter->first, pEngine->DiskStreamBufferFillPercentage()); |
|
fireTotalStreamCountChanged(GetDiskStreamCount()); |
|
|
fireTotalVoiceCountChanged(GetVoiceCount()); |
|
741 |
} |
} |
742 |
|
|
743 |
|
fireTotalStreamCountChanged(GetDiskStreamCount()); |
744 |
|
fireTotalVoiceCountChanged(GetVoiceCount()); |
745 |
|
|
746 |
LSCPServer::UnlockRTNotify(); |
LSCPServer::UnlockRTNotify(); |
747 |
} |
} |
748 |
} |
} |