50 |
Mutex LSCPServer::NotifyMutex = Mutex(); |
Mutex LSCPServer::NotifyMutex = Mutex(); |
51 |
Mutex LSCPServer::NotifyBufferMutex = Mutex(); |
Mutex LSCPServer::NotifyBufferMutex = Mutex(); |
52 |
Mutex LSCPServer::SubscriptionMutex = Mutex(); |
Mutex LSCPServer::SubscriptionMutex = Mutex(); |
53 |
|
Mutex LSCPServer::RTNotifyMutex = Mutex(); |
54 |
|
|
55 |
LSCPServer::LSCPServer(Sampler* pSampler) : Thread(false, 0, -4) { |
LSCPServer::LSCPServer(Sampler* pSampler) : Thread(false, 0, -4) { |
56 |
this->pSampler = pSampler; |
this->pSampler = pSampler; |
89 |
SocketAddress.sin_addr.s_addr = htonl(INADDR_ANY); |
SocketAddress.sin_addr.s_addr = htonl(INADDR_ANY); |
90 |
|
|
91 |
if (bind(hSocket, (sockaddr*) &SocketAddress, sizeof(sockaddr_in)) < 0) { |
if (bind(hSocket, (sockaddr*) &SocketAddress, sizeof(sockaddr_in)) < 0) { |
92 |
std::cerr << "LSCPServer: Could not bind server socket." << std::endl; |
std::cerr << "LSCPServer: Could not bind server socket, retrying for " << ToString(LSCP_SERVER_BIND_TIMEOUT) << " seconds..."; |
93 |
close(hSocket); |
for (int trial = 0; true; trial++) { // retry for LSCP_SERVER_BIND_TIMEOUT seconds |
94 |
//return -1; |
if (bind(hSocket, (sockaddr*) &SocketAddress, sizeof(sockaddr_in)) < 0) { |
95 |
exit(EXIT_FAILURE); |
if (trial > LSCP_SERVER_BIND_TIMEOUT) { |
96 |
|
std::cerr << "gave up!" << std::endl; |
97 |
|
close(hSocket); |
98 |
|
//return -1; |
99 |
|
exit(EXIT_FAILURE); |
100 |
|
} |
101 |
|
else sleep(1); // sleep 1s |
102 |
|
} |
103 |
|
else break; // success |
104 |
|
} |
105 |
} |
} |
106 |
|
|
107 |
listen(hSocket, 1); |
listen(hSocket, 1); |
204 |
NotifyMutex.Unlock(); |
NotifyMutex.Unlock(); |
205 |
} |
} |
206 |
|
|
207 |
|
int LSCPServer::EventSubscribers( std::list<LSCPEvent::event_t> events ) { |
208 |
|
int subs = 0; |
209 |
|
SubscriptionMutex.Lock(); |
210 |
|
for( std::list<LSCPEvent::event_t>::iterator iter = events.begin(); |
211 |
|
iter != events.end(); iter++) |
212 |
|
{ |
213 |
|
subs += eventSubscriptions.count(*iter); |
214 |
|
} |
215 |
|
SubscriptionMutex.Unlock(); |
216 |
|
return subs; |
217 |
|
} |
218 |
|
|
219 |
void LSCPServer::SendLSCPNotify( LSCPEvent event ) { |
void LSCPServer::SendLSCPNotify( LSCPEvent event ) { |
220 |
SubscriptionMutex.Lock(); |
SubscriptionMutex.Lock(); |
221 |
if (eventSubscriptions.count(event.GetType()) == 0) { |
if (eventSubscriptions.count(event.GetType()) == 0) { |
445 |
LSCPResultSet result; |
LSCPResultSet result; |
446 |
try { |
try { |
447 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
448 |
if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds"); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
449 |
Engine* pEngine = pSamplerChannel->GetEngine(); |
Engine* pEngine = pSamplerChannel->GetEngine(); |
450 |
if (!pEngine) throw LinuxSamplerException("No engine loaded on channel"); |
if (!pEngine) throw LinuxSamplerException("No engine loaded on sampler channel"); |
451 |
if (!pSamplerChannel->GetAudioOutputDevice()) |
if (!pSamplerChannel->GetAudioOutputDevice()) |
452 |
throw LinuxSamplerException("No audio output device on channel"); |
throw LinuxSamplerException("No audio output device connected to sampler channel"); |
453 |
if (bBackground) { |
if (bBackground) { |
454 |
LSCPLoadInstrument *pLoadInstrument = new LSCPLoadInstrument(pEngine, Filename.c_str(), uiInstrument); |
LSCPLoadInstrument *pLoadInstrument = new LSCPLoadInstrument(pEngine, Filename.c_str(), uiInstrument); |
455 |
pLoadInstrument->StartThread(); |
pLoadInstrument->StartThread(); |
473 |
if ((EngineName == "GigEngine") || (EngineName == "gig")) type = Engine::type_gig; |
if ((EngineName == "GigEngine") || (EngineName == "gig")) type = Engine::type_gig; |
474 |
else throw LinuxSamplerException("Unknown engine type"); |
else throw LinuxSamplerException("Unknown engine type"); |
475 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
476 |
if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds"); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
477 |
|
LockRTNotify(); |
478 |
pSamplerChannel->LoadEngine(type); |
pSamplerChannel->LoadEngine(type); |
479 |
|
UnlockRTNotify(); |
480 |
} |
} |
481 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
482 |
result.Error(e); |
result.Error(e); |
527 |
String LSCPServer::RemoveChannel(uint uiSamplerChannel) { |
String LSCPServer::RemoveChannel(uint uiSamplerChannel) { |
528 |
dmsg(2,("LSCPServer: RemoveChannel(SamplerChannel=%d)\n", uiSamplerChannel)); |
dmsg(2,("LSCPServer: RemoveChannel(SamplerChannel=%d)\n", uiSamplerChannel)); |
529 |
LSCPResultSet result; |
LSCPResultSet result; |
530 |
|
LockRTNotify(); |
531 |
pSampler->RemoveSamplerChannel(uiSamplerChannel); |
pSampler->RemoveSamplerChannel(uiSamplerChannel); |
532 |
|
UnlockRTNotify(); |
533 |
return result.Produce(); |
return result.Produce(); |
534 |
} |
} |
535 |
|
|
572 |
LSCPResultSet result; |
LSCPResultSet result; |
573 |
try { |
try { |
574 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
575 |
if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds"); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
576 |
Engine* pEngine = pSamplerChannel->GetEngine(); |
Engine* pEngine = pSamplerChannel->GetEngine(); |
577 |
|
|
578 |
//Defaults values |
//Defaults values |
579 |
String EngineName = "NONE"; |
String EngineName = "NONE"; |
580 |
float Volume = 0.0f; |
float Volume = 0.0f; |
581 |
String InstrumentFileName = "NONE"; |
String InstrumentFileName = "NONE"; |
582 |
|
String InstrumentName = "NONE"; |
583 |
int InstrumentIndex = -1; |
int InstrumentIndex = -1; |
584 |
int InstrumentStatus = -1; |
int InstrumentStatus = -1; |
585 |
int AudioOutputChannels = 0; |
int AudioOutputChannels = 0; |
592 |
InstrumentStatus = pEngine->InstrumentStatus(); |
InstrumentStatus = pEngine->InstrumentStatus(); |
593 |
InstrumentIndex = pEngine->InstrumentIndex(); |
InstrumentIndex = pEngine->InstrumentIndex(); |
594 |
if (InstrumentIndex != -1) |
if (InstrumentIndex != -1) |
595 |
|
{ |
596 |
InstrumentFileName = pEngine->InstrumentFileName(); |
InstrumentFileName = pEngine->InstrumentFileName(); |
597 |
|
InstrumentName = pEngine->InstrumentName(); |
598 |
|
} |
599 |
for (int chan = 0; chan < pEngine->Channels(); chan++) { |
for (int chan = 0; chan < pEngine->Channels(); chan++) { |
600 |
if (AudioRouting != "") AudioRouting += ","; |
if (AudioRouting != "") AudioRouting += ","; |
601 |
AudioRouting += ToString(pEngine->OutputChannel(chan)); |
AudioRouting += ToString(pEngine->OutputChannel(chan)); |
612 |
|
|
613 |
result.Add("MIDI_INPUT_DEVICE", GetMidiInputDeviceIndex(pSamplerChannel->GetMidiInputDevice())); |
result.Add("MIDI_INPUT_DEVICE", GetMidiInputDeviceIndex(pSamplerChannel->GetMidiInputDevice())); |
614 |
result.Add("MIDI_INPUT_PORT", pSamplerChannel->GetMidiInputPort()); |
result.Add("MIDI_INPUT_PORT", pSamplerChannel->GetMidiInputPort()); |
615 |
if (pSamplerChannel->GetMidiInputChannel()) result.Add("MIDI_INPUT_CHANNEL", pSamplerChannel->GetMidiInputChannel()); |
if (pSamplerChannel->GetMidiInputChannel() == MidiInputPort::midi_chan_all) result.Add("MIDI_INPUT_CHANNEL", "ALL"); |
616 |
else result.Add("MIDI_INPUT_CHANNEL", "ALL"); |
else result.Add("MIDI_INPUT_CHANNEL", pSamplerChannel->GetMidiInputChannel()); |
617 |
|
|
618 |
result.Add("INSTRUMENT_FILE", InstrumentFileName); |
result.Add("INSTRUMENT_FILE", InstrumentFileName); |
619 |
result.Add("INSTRUMENT_NR", InstrumentIndex); |
result.Add("INSTRUMENT_NR", InstrumentIndex); |
620 |
|
result.Add("INSTRUMENT_NAME", InstrumentName); |
621 |
result.Add("INSTRUMENT_STATUS", InstrumentStatus); |
result.Add("INSTRUMENT_STATUS", InstrumentStatus); |
622 |
} |
} |
623 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
635 |
LSCPResultSet result; |
LSCPResultSet result; |
636 |
try { |
try { |
637 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
638 |
if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds"); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
639 |
Engine* pEngine = pSamplerChannel->GetEngine(); |
Engine* pEngine = pSamplerChannel->GetEngine(); |
640 |
if (!pEngine) throw LinuxSamplerException("No engine loaded on channel"); |
if (!pEngine) throw LinuxSamplerException("No engine loaded on sampler channel"); |
641 |
result.Add(pEngine->VoiceCount()); |
result.Add(pEngine->VoiceCount()); |
642 |
} |
} |
643 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
655 |
LSCPResultSet result; |
LSCPResultSet result; |
656 |
try { |
try { |
657 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
658 |
if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds"); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
659 |
Engine* pEngine = pSamplerChannel->GetEngine(); |
Engine* pEngine = pSamplerChannel->GetEngine(); |
660 |
if (!pEngine) throw LinuxSamplerException("No engine loaded on channel"); |
if (!pEngine) throw LinuxSamplerException("No engine loaded on sampler channel"); |
661 |
result.Add(pEngine->DiskStreamCount()); |
result.Add(pEngine->DiskStreamCount()); |
662 |
} |
} |
663 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
675 |
LSCPResultSet result; |
LSCPResultSet result; |
676 |
try { |
try { |
677 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
678 |
if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds"); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
679 |
Engine* pEngine = pSamplerChannel->GetEngine(); |
Engine* pEngine = pSamplerChannel->GetEngine(); |
680 |
if (!pEngine) throw LinuxSamplerException("No engine loaded on channel"); |
if (!pEngine) throw LinuxSamplerException("No engine loaded on sampler channel"); |
681 |
if (!pEngine->DiskStreamSupported()) |
if (!pEngine->DiskStreamSupported()) |
682 |
result.Add("NA"); |
result.Add("NA"); |
683 |
else { |
else { |
967 |
|
|
968 |
// get audio channel |
// get audio channel |
969 |
AudioChannel* pChannel = pDevice->Channel(ChannelId); |
AudioChannel* pChannel = pDevice->Channel(ChannelId); |
970 |
if (!pChannel) throw LinuxSamplerException("Audio ouotput device does not have channel " + ToString(ChannelId) + "."); |
if (!pChannel) throw LinuxSamplerException("Audio output device does not have audio channel " + ToString(ChannelId) + "."); |
971 |
|
|
972 |
// return the values of all audio channel parameters |
// return the values of all audio channel parameters |
973 |
std::map<String,DeviceRuntimeParameter*> parameters = pChannel->ChannelParameters(); |
std::map<String,DeviceRuntimeParameter*> parameters = pChannel->ChannelParameters(); |
1026 |
|
|
1027 |
// get audio channel |
// get audio channel |
1028 |
AudioChannel* pChannel = pDevice->Channel(ChannelId); |
AudioChannel* pChannel = pDevice->Channel(ChannelId); |
1029 |
if (!pChannel) throw LinuxSamplerException("Audio output device does not have channel " + ToString(ChannelId) + "."); |
if (!pChannel) throw LinuxSamplerException("Audio output device does not have audio channel " + ToString(ChannelId) + "."); |
1030 |
|
|
1031 |
// get desired audio channel parameter |
// get desired audio channel parameter |
1032 |
std::map<String,DeviceRuntimeParameter*> parameters = pChannel->ChannelParameters(); |
std::map<String,DeviceRuntimeParameter*> parameters = pChannel->ChannelParameters(); |
1059 |
|
|
1060 |
// get audio channel |
// get audio channel |
1061 |
AudioChannel* pChannel = pDevice->Channel(ChannelId); |
AudioChannel* pChannel = pDevice->Channel(ChannelId); |
1062 |
if (!pChannel) throw LinuxSamplerException("Audio output device does not have channel " + ToString(ChannelId) + "."); |
if (!pChannel) throw LinuxSamplerException("Audio output device does not have audio channel " + ToString(ChannelId) + "."); |
1063 |
|
|
1064 |
// get desired audio channel parameter |
// get desired audio channel parameter |
1065 |
std::map<String,DeviceRuntimeParameter*> parameters = pChannel->ChannelParameters(); |
std::map<String,DeviceRuntimeParameter*> parameters = pChannel->ChannelParameters(); |
1142 |
LSCPResultSet result; |
LSCPResultSet result; |
1143 |
try { |
try { |
1144 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1145 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1146 |
Engine* pEngine = pSamplerChannel->GetEngine(); |
Engine* pEngine = pSamplerChannel->GetEngine(); |
1147 |
if (!pEngine) throw LinuxSamplerException("No engine deployed on sampler channel " + ToString(uiSamplerChannel)); |
if (!pEngine) throw LinuxSamplerException("No engine deployed on sampler channel " + ToString(uiSamplerChannel)); |
1148 |
|
if (!pSamplerChannel->GetAudioOutputDevice()) throw LinuxSamplerException("No audio output device connected to sampler channel " + ToString(uiSamplerChannel)); |
1149 |
pEngine->SetOutputChannel(ChannelAudioOutputChannel, AudioOutputDeviceInputChannel); |
pEngine->SetOutputChannel(ChannelAudioOutputChannel, AudioOutputDeviceInputChannel); |
1150 |
} |
} |
1151 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
1159 |
LSCPResultSet result; |
LSCPResultSet result; |
1160 |
try { |
try { |
1161 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1162 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1163 |
std::map<uint, AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
std::map<uint, AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
1164 |
if (!devices.count(AudioDeviceId)) throw LinuxSamplerException("There is no audio output device with index " + ToString(AudioDeviceId)); |
if (!devices.count(AudioDeviceId)) throw LinuxSamplerException("There is no audio output device with index " + ToString(AudioDeviceId)); |
1165 |
AudioOutputDevice* pDevice = devices[AudioDeviceId]; |
AudioOutputDevice* pDevice = devices[AudioDeviceId]; |
1176 |
LSCPResultSet result; |
LSCPResultSet result; |
1177 |
try { |
try { |
1178 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1179 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1180 |
// Driver type name aliasing... |
// Driver type name aliasing... |
1181 |
if (AudioOutputDriver == "Alsa") AudioOutputDriver = "ALSA"; |
if (AudioOutputDriver == "Alsa") AudioOutputDriver = "ALSA"; |
1182 |
if (AudioOutputDriver == "Jack") AudioOutputDriver = "JACK"; |
if (AudioOutputDriver == "Jack") AudioOutputDriver = "JACK"; |
1213 |
LSCPResultSet result; |
LSCPResultSet result; |
1214 |
try { |
try { |
1215 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1216 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1217 |
pSamplerChannel->SetMidiInputPort(MIDIPort); |
pSamplerChannel->SetMidiInputPort(MIDIPort); |
1218 |
} |
} |
1219 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
1227 |
LSCPResultSet result; |
LSCPResultSet result; |
1228 |
try { |
try { |
1229 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1230 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1231 |
pSamplerChannel->SetMidiInputChannel((MidiInputPort::midi_chan_t) MIDIChannel); |
pSamplerChannel->SetMidiInputChannel((MidiInputPort::midi_chan_t) MIDIChannel); |
1232 |
} |
} |
1233 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
1241 |
LSCPResultSet result; |
LSCPResultSet result; |
1242 |
try { |
try { |
1243 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1244 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1245 |
std::map<uint, MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
std::map<uint, MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
1246 |
if (!devices.count(MIDIDeviceId)) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(MIDIDeviceId)); |
if (!devices.count(MIDIDeviceId)) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(MIDIDeviceId)); |
1247 |
MidiInputDevice* pDevice = devices[MIDIDeviceId]; |
MidiInputDevice* pDevice = devices[MIDIDeviceId]; |
1258 |
LSCPResultSet result; |
LSCPResultSet result; |
1259 |
try { |
try { |
1260 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1261 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1262 |
// Driver type name aliasing... |
// Driver type name aliasing... |
1263 |
if (MidiInputDriver == "Alsa") MidiInputDriver = "ALSA"; |
if (MidiInputDriver == "Alsa") MidiInputDriver = "ALSA"; |
1264 |
// Check if there's one MIDI input device already created |
// Check if there's one MIDI input device already created |
1301 |
LSCPResultSet result; |
LSCPResultSet result; |
1302 |
try { |
try { |
1303 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1304 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1305 |
std::map<uint, MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
std::map<uint, MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
1306 |
if (!devices.count(MIDIDeviceId)) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(MIDIDeviceId)); |
if (!devices.count(MIDIDeviceId)) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(MIDIDeviceId)); |
1307 |
MidiInputDevice* pDevice = devices[MIDIDeviceId]; |
MidiInputDevice* pDevice = devices[MIDIDeviceId]; |
1322 |
LSCPResultSet result; |
LSCPResultSet result; |
1323 |
try { |
try { |
1324 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1325 |
if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds"); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1326 |
Engine* pEngine = pSamplerChannel->GetEngine(); |
Engine* pEngine = pSamplerChannel->GetEngine(); |
1327 |
if (!pEngine) throw LinuxSamplerException("No engine loaded on channel"); |
if (!pEngine) throw LinuxSamplerException("No engine loaded on sampler channel"); |
1328 |
pEngine->Volume(dVolume); |
pEngine->Volume(dVolume); |
1329 |
} |
} |
1330 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
1341 |
LSCPResultSet result; |
LSCPResultSet result; |
1342 |
try { |
try { |
1343 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1344 |
if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds"); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1345 |
Engine* pEngine = pSamplerChannel->GetEngine(); |
Engine* pEngine = pSamplerChannel->GetEngine(); |
1346 |
if (!pEngine) throw LinuxSamplerException("No engine loaded on channel"); |
if (!pEngine) throw LinuxSamplerException("No engine loaded on sampler channel"); |
1347 |
pEngine->Reset(); |
pEngine->Reset(); |
1348 |
} |
} |
1349 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |