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 |
608 |
|
|
609 |
result.Add("MIDI_INPUT_DEVICE", GetMidiInputDeviceIndex(pSamplerChannel->GetMidiInputDevice())); |
result.Add("MIDI_INPUT_DEVICE", GetMidiInputDeviceIndex(pSamplerChannel->GetMidiInputDevice())); |
610 |
result.Add("MIDI_INPUT_PORT", pSamplerChannel->GetMidiInputPort()); |
result.Add("MIDI_INPUT_PORT", pSamplerChannel->GetMidiInputPort()); |
611 |
if (pSamplerChannel->GetMidiInputChannel()) result.Add("MIDI_INPUT_CHANNEL", pSamplerChannel->GetMidiInputChannel()); |
if (pSamplerChannel->GetMidiInputChannel() == MidiInputPort::midi_chan_all) result.Add("MIDI_INPUT_CHANNEL", "ALL"); |
612 |
else result.Add("MIDI_INPUT_CHANNEL", "ALL"); |
else result.Add("MIDI_INPUT_CHANNEL", pSamplerChannel->GetMidiInputChannel()); |
613 |
|
|
614 |
result.Add("INSTRUMENT_FILE", InstrumentFileName); |
result.Add("INSTRUMENT_FILE", InstrumentFileName); |
615 |
result.Add("INSTRUMENT_NR", InstrumentIndex); |
result.Add("INSTRUMENT_NR", InstrumentIndex); |
630 |
LSCPResultSet result; |
LSCPResultSet result; |
631 |
try { |
try { |
632 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
633 |
if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds"); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
634 |
Engine* pEngine = pSamplerChannel->GetEngine(); |
Engine* pEngine = pSamplerChannel->GetEngine(); |
635 |
if (!pEngine) throw LinuxSamplerException("No engine loaded on channel"); |
if (!pEngine) throw LinuxSamplerException("No engine loaded on sampler channel"); |
636 |
result.Add(pEngine->VoiceCount()); |
result.Add(pEngine->VoiceCount()); |
637 |
} |
} |
638 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
650 |
LSCPResultSet result; |
LSCPResultSet result; |
651 |
try { |
try { |
652 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
653 |
if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds"); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
654 |
Engine* pEngine = pSamplerChannel->GetEngine(); |
Engine* pEngine = pSamplerChannel->GetEngine(); |
655 |
if (!pEngine) throw LinuxSamplerException("No engine loaded on channel"); |
if (!pEngine) throw LinuxSamplerException("No engine loaded on sampler channel"); |
656 |
result.Add(pEngine->DiskStreamCount()); |
result.Add(pEngine->DiskStreamCount()); |
657 |
} |
} |
658 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
670 |
LSCPResultSet result; |
LSCPResultSet result; |
671 |
try { |
try { |
672 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
673 |
if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds"); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
674 |
Engine* pEngine = pSamplerChannel->GetEngine(); |
Engine* pEngine = pSamplerChannel->GetEngine(); |
675 |
if (!pEngine) throw LinuxSamplerException("No engine loaded on channel"); |
if (!pEngine) throw LinuxSamplerException("No engine loaded on sampler channel"); |
676 |
if (!pEngine->DiskStreamSupported()) |
if (!pEngine->DiskStreamSupported()) |
677 |
result.Add("NA"); |
result.Add("NA"); |
678 |
else { |
else { |
769 |
} |
} |
770 |
|
|
771 |
String LSCPServer::GetMidiInputDriverParameterInfo(String Driver, String Parameter, std::map<String,String> DependencyList) { |
String LSCPServer::GetMidiInputDriverParameterInfo(String Driver, String Parameter, std::map<String,String> DependencyList) { |
772 |
dmsg(2,("LSCPServer: GetMidiInputDriverParameterInfo(Driver=%s,Parameter=%s)\n",Driver.c_str(),Parameter.c_str())); |
dmsg(2,("LSCPServer: GetMidiInputDriverParameterInfo(Driver=%s,Parameter=%s,DependencyListSize=%d)\n",Driver.c_str(),Parameter.c_str(),DependencyList.size())); |
773 |
LSCPResultSet result; |
LSCPResultSet result; |
774 |
try { |
try { |
775 |
DeviceCreationParameter* pParameter = MidiInputDeviceFactory::GetDriverParameter(Driver, Parameter); |
DeviceCreationParameter* pParameter = MidiInputDeviceFactory::GetDriverParameter(Driver, Parameter); |
778 |
result.Add("MANDATORY", pParameter->Mandatory()); |
result.Add("MANDATORY", pParameter->Mandatory()); |
779 |
result.Add("FIX", pParameter->Fix()); |
result.Add("FIX", pParameter->Fix()); |
780 |
result.Add("MULTIPLICITY", pParameter->Multiplicity()); |
result.Add("MULTIPLICITY", pParameter->Multiplicity()); |
781 |
if (pParameter->Depends()) result.Add("DEPENDS", *pParameter->Depends()); |
optional<String> oDepends = pParameter->Depends(); |
782 |
if (pParameter->Default()) result.Add("DEFAULT", *pParameter->Default()); |
optional<String> oDefault = pParameter->Default(DependencyList); |
783 |
if (pParameter->RangeMin()) result.Add("RANGE_MIN", *pParameter->RangeMin()); |
optional<String> oRangeMin = pParameter->RangeMin(DependencyList); |
784 |
if (pParameter->RangeMax()) result.Add("RANGE_MAX", *pParameter->RangeMax()); |
optional<String> oRangeMax = pParameter->RangeMax(DependencyList); |
785 |
if (pParameter->Possibilities()) result.Add("POSSIBILITIES", *pParameter->Possibilities()); |
optional<String> oPossibilities = pParameter->Possibilities(DependencyList); |
786 |
|
if (oDepends) result.Add("DEPENDS", *oDepends); |
787 |
|
if (oDefault) result.Add("DEFAULT", *oDefault); |
788 |
|
if (oRangeMin) result.Add("RANGE_MIN", *oRangeMin); |
789 |
|
if (oRangeMax) result.Add("RANGE_MAX", *oRangeMax); |
790 |
|
if (oPossibilities) result.Add("POSSIBILITIES", *oPossibilities); |
791 |
} |
} |
792 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
793 |
result.Error(e); |
result.Error(e); |
796 |
} |
} |
797 |
|
|
798 |
String LSCPServer::GetAudioOutputDriverParameterInfo(String Driver, String Parameter, std::map<String,String> DependencyList) { |
String LSCPServer::GetAudioOutputDriverParameterInfo(String Driver, String Parameter, std::map<String,String> DependencyList) { |
799 |
dmsg(2,("LSCPServer: GetAudioOutputDriverParameterInfo(Driver=%s,Parameter=%s)\n",Driver.c_str(),Parameter.c_str())); |
dmsg(2,("LSCPServer: GetAudioOutputDriverParameterInfo(Driver=%s,Parameter=%s,DependencyListSize=%d)\n",Driver.c_str(),Parameter.c_str(),DependencyList.size())); |
800 |
LSCPResultSet result; |
LSCPResultSet result; |
801 |
try { |
try { |
802 |
DeviceCreationParameter* pParameter = AudioOutputDeviceFactory::GetDriverParameter(Driver, Parameter); |
DeviceCreationParameter* pParameter = AudioOutputDeviceFactory::GetDriverParameter(Driver, Parameter); |
805 |
result.Add("MANDATORY", pParameter->Mandatory()); |
result.Add("MANDATORY", pParameter->Mandatory()); |
806 |
result.Add("FIX", pParameter->Fix()); |
result.Add("FIX", pParameter->Fix()); |
807 |
result.Add("MULTIPLICITY", pParameter->Multiplicity()); |
result.Add("MULTIPLICITY", pParameter->Multiplicity()); |
808 |
if (pParameter->Depends()) result.Add("DEPENDS", *pParameter->Depends()); |
optional<String> oDepends = pParameter->Depends(); |
809 |
if (pParameter->Default()) result.Add("DEFAULT", *pParameter->Default()); |
optional<String> oDefault = pParameter->Default(DependencyList); |
810 |
if (pParameter->RangeMin()) result.Add("RANGE_MIN", *pParameter->RangeMin()); |
optional<String> oRangeMin = pParameter->RangeMin(DependencyList); |
811 |
if (pParameter->RangeMax()) result.Add("RANGE_MAX", *pParameter->RangeMax()); |
optional<String> oRangeMax = pParameter->RangeMax(DependencyList); |
812 |
if (pParameter->Possibilities()) result.Add("POSSIBILITIES", *pParameter->Possibilities()); |
optional<String> oPossibilities = pParameter->Possibilities(DependencyList); |
813 |
|
if (oDepends) result.Add("DEPENDS", *oDepends); |
814 |
|
if (oDefault) result.Add("DEFAULT", *oDefault); |
815 |
|
if (oRangeMin) result.Add("RANGE_MIN", *oRangeMin); |
816 |
|
if (oRangeMax) result.Add("RANGE_MAX", *oRangeMax); |
817 |
|
if (oPossibilities) result.Add("POSSIBILITIES", *oPossibilities); |
818 |
} |
} |
819 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
820 |
result.Error(e); |
result.Error(e); |
962 |
|
|
963 |
// get audio channel |
// get audio channel |
964 |
AudioChannel* pChannel = pDevice->Channel(ChannelId); |
AudioChannel* pChannel = pDevice->Channel(ChannelId); |
965 |
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) + "."); |
966 |
|
|
967 |
// return the values of all audio channel parameters |
// return the values of all audio channel parameters |
968 |
std::map<String,DeviceRuntimeParameter*> parameters = pChannel->ChannelParameters(); |
std::map<String,DeviceRuntimeParameter*> parameters = pChannel->ChannelParameters(); |
1021 |
|
|
1022 |
// get audio channel |
// get audio channel |
1023 |
AudioChannel* pChannel = pDevice->Channel(ChannelId); |
AudioChannel* pChannel = pDevice->Channel(ChannelId); |
1024 |
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) + "."); |
1025 |
|
|
1026 |
// get desired audio channel parameter |
// get desired audio channel parameter |
1027 |
std::map<String,DeviceRuntimeParameter*> parameters = pChannel->ChannelParameters(); |
std::map<String,DeviceRuntimeParameter*> parameters = pChannel->ChannelParameters(); |
1054 |
|
|
1055 |
// get audio channel |
// get audio channel |
1056 |
AudioChannel* pChannel = pDevice->Channel(ChannelId); |
AudioChannel* pChannel = pDevice->Channel(ChannelId); |
1057 |
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) + "."); |
1058 |
|
|
1059 |
// get desired audio channel parameter |
// get desired audio channel parameter |
1060 |
std::map<String,DeviceRuntimeParameter*> parameters = pChannel->ChannelParameters(); |
std::map<String,DeviceRuntimeParameter*> parameters = pChannel->ChannelParameters(); |
1137 |
LSCPResultSet result; |
LSCPResultSet result; |
1138 |
try { |
try { |
1139 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1140 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1141 |
Engine* pEngine = pSamplerChannel->GetEngine(); |
Engine* pEngine = pSamplerChannel->GetEngine(); |
1142 |
if (!pEngine) throw LinuxSamplerException("No engine deployed on sampler channel " + ToString(uiSamplerChannel)); |
if (!pEngine) throw LinuxSamplerException("No engine deployed on sampler channel " + ToString(uiSamplerChannel)); |
1143 |
|
if (!pSamplerChannel->GetAudioOutputDevice()) throw LinuxSamplerException("No audio output device connected to sampler channel " + ToString(uiSamplerChannel)); |
1144 |
pEngine->SetOutputChannel(ChannelAudioOutputChannel, AudioOutputDeviceInputChannel); |
pEngine->SetOutputChannel(ChannelAudioOutputChannel, AudioOutputDeviceInputChannel); |
1145 |
} |
} |
1146 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
1154 |
LSCPResultSet result; |
LSCPResultSet result; |
1155 |
try { |
try { |
1156 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1157 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1158 |
std::map<uint, AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
std::map<uint, AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
1159 |
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)); |
1160 |
AudioOutputDevice* pDevice = devices[AudioDeviceId]; |
AudioOutputDevice* pDevice = devices[AudioDeviceId]; |
1171 |
LSCPResultSet result; |
LSCPResultSet result; |
1172 |
try { |
try { |
1173 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1174 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1175 |
// Driver type name aliasing... |
// Driver type name aliasing... |
1176 |
if (AudioOutputDriver == "ALSA") AudioOutputDriver = "Alsa"; |
if (AudioOutputDriver == "Alsa") AudioOutputDriver = "ALSA"; |
1177 |
if (AudioOutputDriver == "JACK") AudioOutputDriver = "Jack"; |
if (AudioOutputDriver == "Jack") AudioOutputDriver = "JACK"; |
1178 |
// Check if there's one audio output device already created |
// Check if there's one audio output device already created |
1179 |
// for the intended audio driver type (AudioOutputDriver)... |
// for the intended audio driver type (AudioOutputDriver)... |
1180 |
AudioOutputDevice *pDevice = NULL; |
AudioOutputDevice *pDevice = NULL; |
1208 |
LSCPResultSet result; |
LSCPResultSet result; |
1209 |
try { |
try { |
1210 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1211 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1212 |
pSamplerChannel->SetMidiInputPort(MIDIPort); |
pSamplerChannel->SetMidiInputPort(MIDIPort); |
1213 |
} |
} |
1214 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
1222 |
LSCPResultSet result; |
LSCPResultSet result; |
1223 |
try { |
try { |
1224 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1225 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1226 |
pSamplerChannel->SetMidiInputChannel((MidiInputPort::midi_chan_t) MIDIChannel); |
pSamplerChannel->SetMidiInputChannel((MidiInputPort::midi_chan_t) MIDIChannel); |
1227 |
} |
} |
1228 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
1236 |
LSCPResultSet result; |
LSCPResultSet result; |
1237 |
try { |
try { |
1238 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1239 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1240 |
std::map<uint, MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
std::map<uint, MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
1241 |
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)); |
1242 |
MidiInputDevice* pDevice = devices[MIDIDeviceId]; |
MidiInputDevice* pDevice = devices[MIDIDeviceId]; |
1253 |
LSCPResultSet result; |
LSCPResultSet result; |
1254 |
try { |
try { |
1255 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1256 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1257 |
// Driver type name aliasing... |
// Driver type name aliasing... |
1258 |
if (MidiInputDriver == "ALSA") MidiInputDriver = "Alsa"; |
if (MidiInputDriver == "Alsa") MidiInputDriver = "ALSA"; |
1259 |
// Check if there's one MIDI input device already created |
// Check if there's one MIDI input device already created |
1260 |
// for the intended MIDI driver type (MidiInputDriver)... |
// for the intended MIDI driver type (MidiInputDriver)... |
1261 |
MidiInputDevice *pDevice = NULL; |
MidiInputDevice *pDevice = NULL; |
1296 |
LSCPResultSet result; |
LSCPResultSet result; |
1297 |
try { |
try { |
1298 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1299 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1300 |
std::map<uint, MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
std::map<uint, MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
1301 |
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)); |
1302 |
MidiInputDevice* pDevice = devices[MIDIDeviceId]; |
MidiInputDevice* pDevice = devices[MIDIDeviceId]; |
1317 |
LSCPResultSet result; |
LSCPResultSet result; |
1318 |
try { |
try { |
1319 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1320 |
if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds"); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1321 |
Engine* pEngine = pSamplerChannel->GetEngine(); |
Engine* pEngine = pSamplerChannel->GetEngine(); |
1322 |
if (!pEngine) throw LinuxSamplerException("No engine loaded on channel"); |
if (!pEngine) throw LinuxSamplerException("No engine loaded on sampler channel"); |
1323 |
pEngine->Volume(dVolume); |
pEngine->Volume(dVolume); |
1324 |
} |
} |
1325 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
1336 |
LSCPResultSet result; |
LSCPResultSet result; |
1337 |
try { |
try { |
1338 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1339 |
if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds"); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1340 |
Engine* pEngine = pSamplerChannel->GetEngine(); |
Engine* pEngine = pSamplerChannel->GetEngine(); |
1341 |
if (!pEngine) throw LinuxSamplerException("No engine loaded on channel"); |
if (!pEngine) throw LinuxSamplerException("No engine loaded on sampler channel"); |
1342 |
pEngine->Reset(); |
pEngine->Reset(); |
1343 |
} |
} |
1344 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |