--- linuxsampler/trunk/src/drivers/midi/MidiInputDevice.cpp 2007/08/13 17:44:32 1294 +++ linuxsampler/trunk/src/drivers/midi/MidiInputDevice.cpp 2007/08/13 20:05:56 1295 @@ -23,6 +23,8 @@ #include "MidiInputDevice.h" +#include "../../Sampler.h" + namespace LinuxSampler { // *************** ParameterActive *************** @@ -109,6 +111,24 @@ } void MidiInputDevice::ParameterPorts::OnSetValue(int i) throw (Exception) { + MidiInputDevice* dev = static_cast (pDevice); + Sampler* s = static_cast (dev->pSampler); + std::map channels = s->GetSamplerChannels(); + std::map::iterator iter = channels.begin(); + for (; iter != channels.end(); iter++) { + SamplerChannel* chn = iter->second; + if (chn->GetMidiInputDevice() == NULL || chn->GetMidiInputDevice() != pDevice) { + continue; + } + + int port = chn->GetMidiInputPort(); + if (port >= i) { + String err = "Sampler channel " + ToString(iter->first); + err += " is still connected to MIDI port " + ToString(port); + throw Exception(err); + } + } + ((MidiInputDevice*)pDevice)->AcquirePorts(i); }