526 |
RemoveSamplerChannel(pChannel); |
RemoveSamplerChannel(pChannel); |
527 |
} |
} |
528 |
|
|
529 |
|
void Sampler::RemoveAllSamplerChannels() { |
530 |
|
/* |
531 |
|
* In maps iterator invalidation occurs when the iterator point |
532 |
|
* to the element that is being erased. So we need to copy the map |
533 |
|
* by calling GetSamplerChannels() to prevent that. |
534 |
|
*/ |
535 |
|
SamplerChannelMap chns = GetSamplerChannels(); |
536 |
|
SamplerChannelMap::iterator iter = chns.begin(); |
537 |
|
for(; iter != chns.end(); iter++) { |
538 |
|
RemoveSamplerChannel(iter->second); |
539 |
|
} |
540 |
|
} |
541 |
|
|
542 |
std::vector<String> Sampler::AvailableAudioOutputDrivers() { |
std::vector<String> Sampler::AvailableAudioOutputDrivers() { |
543 |
return AudioOutputDeviceFactory::AvailableDrivers(); |
return AudioOutputDeviceFactory::AvailableDrivers(); |
544 |
} |
} |
607 |
} |
} |
608 |
} |
} |
609 |
|
|
610 |
|
void Sampler::DestroyAllAudioOutputDevices() throw (Exception) { |
611 |
|
/* |
612 |
|
* In maps iterator invalidation occurs when the iterator point |
613 |
|
* to the element that is being erased. So we need to copy the map |
614 |
|
* by calling GetAudioOutputDevices() to prevent that. |
615 |
|
*/ |
616 |
|
AudioOutputDeviceMap devs = GetAudioOutputDevices(); |
617 |
|
AudioOutputDeviceMap::iterator iter = devs.begin(); |
618 |
|
for(; iter != devs.end(); iter++) { |
619 |
|
DestroyAudioOutputDevice(iter->second); |
620 |
|
} |
621 |
|
} |
622 |
|
|
623 |
void Sampler::DestroyMidiInputDevice(MidiInputDevice* pDevice) throw (Exception) { |
void Sampler::DestroyMidiInputDevice(MidiInputDevice* pDevice) throw (Exception) { |
624 |
MidiInputDeviceMap::iterator iter = mMidiInputDevices.begin(); |
MidiInputDeviceMap::iterator iter = mMidiInputDevices.begin(); |
625 |
for (; iter != mMidiInputDevices.end(); iter++) { |
for (; iter != mMidiInputDevices.end(); iter++) { |
646 |
} |
} |
647 |
} |
} |
648 |
|
|
649 |
|
void Sampler::DestroyAllMidiInputDevices() throw (Exception) { |
650 |
|
/* |
651 |
|
* In maps iterator invalidation occurs when the iterator point |
652 |
|
* to the element that is being erased. So we need to copy the map |
653 |
|
* by calling GetMidiInputDevices() to prevent that. |
654 |
|
*/ |
655 |
|
MidiInputDeviceMap devs = GetMidiInputDevices(); |
656 |
|
MidiInputDeviceMap::iterator iter = devs.begin(); |
657 |
|
for(; iter != devs.end(); iter++) { |
658 |
|
DestroyMidiInputDevice(iter->second); |
659 |
|
} |
660 |
|
} |
661 |
|
|
662 |
MidiInputDevice* Sampler::CreateMidiInputDevice(String MidiDriver, std::map<String,String> Parameters) throw (Exception) { |
MidiInputDevice* Sampler::CreateMidiInputDevice(String MidiDriver, std::map<String,String> Parameters) throw (Exception) { |
663 |
// create new device |
// create new device |
664 |
MidiInputDevice* pDevice = MidiInputDeviceFactory::Create(MidiDriver, Parameters, this); |
MidiInputDevice* pDevice = MidiInputDeviceFactory::Create(MidiDriver, Parameters, this); |
701 |
void Sampler::Reset() { |
void Sampler::Reset() { |
702 |
// delete sampler channels |
// delete sampler channels |
703 |
try { |
try { |
704 |
while (true) { |
RemoveAllSamplerChannels(); |
|
SamplerChannelMap::iterator iter = mSamplerChannels.begin(); |
|
|
if (iter == mSamplerChannels.end()) break; |
|
|
RemoveSamplerChannel(iter->second); |
|
|
} |
|
705 |
} |
} |
706 |
catch(...) { |
catch(...) { |
707 |
std::cerr << "Sampler::Reset(): Exception occured while trying to delete all sampler channels, exiting.\n" << std::flush; |
std::cerr << "Sampler::Reset(): Exception occured while trying to delete all sampler channels, exiting.\n" << std::flush; |
710 |
|
|
711 |
// delete midi input devices |
// delete midi input devices |
712 |
try { |
try { |
713 |
while (true) { |
DestroyAllMidiInputDevices(); |
|
MidiInputDeviceMap::iterator iter = mMidiInputDevices.begin(); |
|
|
if (iter == mMidiInputDevices.end()) break; |
|
|
DestroyMidiInputDevice(iter->second); |
|
|
} |
|
714 |
} |
} |
715 |
catch(...) { |
catch(...) { |
716 |
std::cerr << "Sampler::Reset(): Exception occured while trying to delete all MIDI input devices, exiting.\n" << std::flush; |
std::cerr << "Sampler::Reset(): Exception occured while trying to delete all MIDI input devices, exiting.\n" << std::flush; |
719 |
|
|
720 |
// delete audio output devices |
// delete audio output devices |
721 |
try { |
try { |
722 |
while (true) { |
DestroyAllAudioOutputDevices(); |
|
AudioOutputDeviceMap::iterator iter = mAudioOutputDevices.begin(); |
|
|
if (iter == mAudioOutputDevices.end()) break; |
|
|
DestroyAudioOutputDevice(iter->second); |
|
|
} |
|
723 |
} |
} |
724 |
catch(...) { |
catch(...) { |
725 |
std::cerr << "Sampler::Reset(): Exception occured while trying to delete all audio output devices, exiting.\n" << std::flush; |
std::cerr << "Sampler::Reset(): Exception occured while trying to delete all audio output devices, exiting.\n" << std::flush; |