49 |
if (pEngineChannel) { |
if (pEngineChannel) { |
50 |
MidiInputPort* pMidiInputPort = GetMidiInputDevicePort(this->midiPort); |
MidiInputPort* pMidiInputPort = GetMidiInputDevicePort(this->midiPort); |
51 |
if (pMidiInputPort) pMidiInputPort->Disconnect(pEngineChannel); |
if (pMidiInputPort) pMidiInputPort->Disconnect(pEngineChannel); |
52 |
if (pAudioOutputDevice) pEngineChannel->DisconnectAudioOutputDevice(); |
if (pEngineChannel) { |
53 |
delete pEngineChannel; |
if (pAudioOutputDevice) pEngineChannel->DisconnectAudioOutputDevice(); |
54 |
|
delete pEngineChannel; |
55 |
|
} |
56 |
} |
} |
57 |
} |
} |
58 |
|
|
185 |
if (!mSamplerChannels.size()) { |
if (!mSamplerChannels.size()) { |
186 |
SamplerChannel* pChannel = new SamplerChannel(this); |
SamplerChannel* pChannel = new SamplerChannel(this); |
187 |
mSamplerChannels[0] = pChannel; |
mSamplerChannels[0] = pChannel; |
188 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_channels, 1)); |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_channel_count, 1)); |
189 |
return pChannel; |
return pChannel; |
190 |
} |
} |
191 |
|
|
200 |
// we found an unused index, so insert the new channel there |
// we found an unused index, so insert the new channel there |
201 |
SamplerChannel* pChannel = new SamplerChannel(this); |
SamplerChannel* pChannel = new SamplerChannel(this); |
202 |
mSamplerChannels[i] = pChannel; |
mSamplerChannels[i] = pChannel; |
203 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_channels, i)); |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_channel_count, i)); |
204 |
return pChannel; |
return pChannel; |
205 |
} |
} |
206 |
throw LinuxSamplerException("Internal error: could not find unoccupied sampler channel index."); |
throw LinuxSamplerException("Internal error: could not find unoccupied sampler channel index."); |
209 |
// we have not reached the index limit so we just add the channel past the highest index |
// we have not reached the index limit so we just add the channel past the highest index |
210 |
SamplerChannel* pChannel = new SamplerChannel(this); |
SamplerChannel* pChannel = new SamplerChannel(this); |
211 |
mSamplerChannels[lastIndex + 1] = pChannel; |
mSamplerChannels[lastIndex + 1] = pChannel; |
212 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_channels, lastIndex + 1)); |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_channel_count, lastIndex + 1)); |
213 |
return pChannel; |
return pChannel; |
214 |
} |
} |
215 |
|
|
227 |
if (iterChan->second == pSamplerChannel) { |
if (iterChan->second == pSamplerChannel) { |
228 |
mSamplerChannels.erase(iterChan); |
mSamplerChannels.erase(iterChan); |
229 |
delete pSamplerChannel; |
delete pSamplerChannel; |
230 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_channels, mSamplerChannels.size())); |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_channel_count, mSamplerChannels.size())); |
231 |
return; |
return; |
232 |
} |
} |
233 |
} |
} |
316 |
|
|
317 |
MidiInputDevice* Sampler::CreateMidiInputDevice(String MidiDriver, std::map<String,String> Parameters) throw (LinuxSamplerException) { |
MidiInputDevice* Sampler::CreateMidiInputDevice(String MidiDriver, std::map<String,String> Parameters) throw (LinuxSamplerException) { |
318 |
// create new device |
// create new device |
319 |
MidiInputDevice* pDevice = MidiInputDeviceFactory::Create(MidiDriver, Parameters); |
MidiInputDevice* pDevice = MidiInputDeviceFactory::Create(MidiDriver, Parameters, this); |
320 |
|
|
321 |
// add new device to the midi device list |
// add new device to the midi device list |
322 |
for (uint i = 0; ; i++) { // seek for a free place starting from the beginning |
for (uint i = 0; ; i++) { // seek for a free place starting from the beginning |