3 |
* LinuxSampler - modular, streaming capable sampler * |
* LinuxSampler - modular, streaming capable sampler * |
4 |
* * |
* * |
5 |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
6 |
* Copyright (C) 2005 Christian Schoenebeck * |
* Copyright (C) 2005, 2006 Christian Schoenebeck * |
7 |
* * |
* * |
8 |
* This library is free software; you can redistribute it and/or modify * |
* This library is free software; you can redistribute it and/or modify * |
9 |
* it under the terms of the GNU General Public License as published by * |
* it under the terms of the GNU General Public License as published by * |
128 |
FD_SET(hSocket, &fdSet); |
FD_SET(hSocket, &fdSet); |
129 |
int maxSessions = hSocket; |
int maxSessions = hSocket; |
130 |
|
|
131 |
|
timeval timeout; |
132 |
|
|
133 |
while (true) { |
while (true) { |
134 |
fd_set selectSet = fdSet; |
// check if some engine channel's parameter / status changed, if so notify the respective LSCP event subscribers |
135 |
int retval = select(maxSessions+1, &selectSet, NULL, NULL, NULL); |
{ |
136 |
|
std::set<EngineChannel*> engineChannels = EngineChannelFactory::EngineChannelInstances(); |
137 |
|
std::set<EngineChannel*>::iterator itEngineChannel = engineChannels.begin(); |
138 |
|
std::set<EngineChannel*>::iterator itEnd = engineChannels.end(); |
139 |
|
for (; itEngineChannel != itEnd; ++itEngineChannel) { |
140 |
|
if ((*itEngineChannel)->StatusChanged()) { |
141 |
|
SendLSCPNotify(LSCPEvent(LSCPEvent::event_channel_info, (*itEngineChannel)->iSamplerChannelIndex)); |
142 |
|
} |
143 |
|
} |
144 |
|
} |
145 |
|
|
146 |
|
//Now let's deliver late notifies (if any) |
147 |
|
NotifyBufferMutex.Lock(); |
148 |
|
for (std::map<int,String>::iterator iterNotify = bufferedNotifies.begin(); iterNotify != bufferedNotifies.end(); iterNotify++) { |
149 |
|
#ifdef MSG_NOSIGNAL |
150 |
|
send(iterNotify->first, iterNotify->second.c_str(), iterNotify->second.size(), MSG_NOSIGNAL); |
151 |
|
#else |
152 |
|
send(iterNotify->first, iterNotify->second.c_str(), iterNotify->second.size(), 0); |
153 |
|
#endif |
154 |
|
} |
155 |
|
bufferedNotifies.clear(); |
156 |
|
NotifyBufferMutex.Unlock(); |
157 |
|
|
158 |
|
fd_set selectSet = fdSet; |
159 |
|
timeout.tv_sec = 0; |
160 |
|
timeout.tv_usec = 100000; |
161 |
|
|
162 |
|
int retval = select(maxSessions+1, &selectSet, NULL, NULL, &timeout); |
163 |
|
|
164 |
if (retval == 0) |
if (retval == 0) |
165 |
continue; //Nothing try again |
continue; //Nothing try again |
166 |
if (retval == -1) { |
if (retval == -1) { |
220 |
break; |
break; |
221 |
} |
} |
222 |
} |
} |
|
|
|
|
// check if some engine channel's parameter / status changed, if so notify the respective LSCP event subscribers |
|
|
{ |
|
|
std::set<EngineChannel*> engineChannels = EngineChannelFactory::EngineChannelInstances(); |
|
|
std::set<EngineChannel*>::iterator itEngineChannel = engineChannels.begin(); |
|
|
std::set<EngineChannel*>::iterator itEnd = engineChannels.end(); |
|
|
for (; itEngineChannel != itEnd; ++itEngineChannel) { |
|
|
if ((*itEngineChannel)->StatusChanged()) { |
|
|
SendLSCPNotify(LSCPEvent(LSCPEvent::event_channel_info, (*itEngineChannel)->iSamplerChannelIndex)); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
//Now let's deliver late notifies (if any) |
|
|
NotifyBufferMutex.Lock(); |
|
|
for (std::map<int,String>::iterator iterNotify = bufferedNotifies.begin(); iterNotify != bufferedNotifies.end(); iterNotify++) { |
|
|
send(iterNotify->first, iterNotify->second.c_str(), iterNotify->second.size(), MSG_NOSIGNAL); |
|
|
bufferedNotifies.erase(iterNotify); |
|
|
} |
|
|
NotifyBufferMutex.Unlock(); |
|
223 |
} |
} |
224 |
} |
} |
225 |
|
|
266 |
while (true) { |
while (true) { |
267 |
if (NotifyMutex.Trylock()) { |
if (NotifyMutex.Trylock()) { |
268 |
for(;iter != end; iter++) |
for(;iter != end; iter++) |
269 |
|
#ifdef MSG_NOSIGNAL |
270 |
send(*iter, notify.c_str(), notify.size(), MSG_NOSIGNAL); |
send(*iter, notify.c_str(), notify.size(), MSG_NOSIGNAL); |
271 |
|
#else |
272 |
|
send(*iter, notify.c_str(), notify.size(), 0); |
273 |
|
#endif |
274 |
NotifyMutex.Unlock(); |
NotifyMutex.Unlock(); |
275 |
break; |
break; |
276 |
} else { |
} else { |
322 |
continue; //Ignore CR |
continue; //Ignore CR |
323 |
if (c == '\n') { |
if (c == '\n') { |
324 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_misc, "Received \'" + bufferedCommands[socket] + "\' on socket", socket)); |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_misc, "Received \'" + bufferedCommands[socket] + "\' on socket", socket)); |
325 |
bufferedCommands[socket] += "\n"; |
bufferedCommands[socket] += "\r\n"; |
326 |
return true; //Complete command was read |
return true; //Complete command was read |
327 |
} |
} |
328 |
bufferedCommands[socket] += c; |
bufferedCommands[socket] += c; |
379 |
dmsg(2,("LSCPServer::AnswerClient(ReturnMessage=%s)", ReturnMessage.c_str())); |
dmsg(2,("LSCPServer::AnswerClient(ReturnMessage=%s)", ReturnMessage.c_str())); |
380 |
if (currentSocket != -1) { |
if (currentSocket != -1) { |
381 |
NotifyMutex.Lock(); |
NotifyMutex.Lock(); |
382 |
|
#ifdef MSG_NOSIGNAL |
383 |
send(currentSocket, ReturnMessage.c_str(), ReturnMessage.size(), MSG_NOSIGNAL); |
send(currentSocket, ReturnMessage.c_str(), ReturnMessage.size(), MSG_NOSIGNAL); |
384 |
|
#else |
385 |
|
send(currentSocket, ReturnMessage.c_str(), ReturnMessage.size(), 0); |
386 |
|
#endif |
387 |
NotifyMutex.Unlock(); |
NotifyMutex.Unlock(); |
388 |
} |
} |
389 |
} |
} |
427 |
AudioOutputDevice* pDevice = pSampler->CreateAudioOutputDevice(Driver, Parameters); |
AudioOutputDevice* pDevice = pSampler->CreateAudioOutputDevice(Driver, Parameters); |
428 |
// search for the created device to get its index |
// search for the created device to get its index |
429 |
int index = GetAudioOutputDeviceIndex(pDevice); |
int index = GetAudioOutputDeviceIndex(pDevice); |
430 |
if (index == -1) throw LinuxSamplerException("Internal error: could not find created audio output device."); |
if (index == -1) throw Exception("Internal error: could not find created audio output device."); |
431 |
result = index; // success |
result = index; // success |
432 |
} |
} |
433 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
434 |
result.Error(e); |
result.Error(e); |
435 |
} |
} |
436 |
return result.Produce(); |
return result.Produce(); |
443 |
MidiInputDevice* pDevice = pSampler->CreateMidiInputDevice(Driver, Parameters); |
MidiInputDevice* pDevice = pSampler->CreateMidiInputDevice(Driver, Parameters); |
444 |
// search for the created device to get its index |
// search for the created device to get its index |
445 |
int index = GetMidiInputDeviceIndex(pDevice); |
int index = GetMidiInputDeviceIndex(pDevice); |
446 |
if (index == -1) throw LinuxSamplerException("Internal error: could not find created midi input device."); |
if (index == -1) throw Exception("Internal error: could not find created midi input device."); |
447 |
result = index; // success |
result = index; // success |
448 |
} |
} |
449 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
450 |
result.Error(e); |
result.Error(e); |
451 |
} |
} |
452 |
return result.Produce(); |
return result.Produce(); |
457 |
LSCPResultSet result; |
LSCPResultSet result; |
458 |
try { |
try { |
459 |
std::map<uint, AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
std::map<uint, AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
460 |
if (!devices.count(DeviceIndex)) throw LinuxSamplerException("There is no audio output device with index " + ToString(DeviceIndex) + "."); |
if (!devices.count(DeviceIndex)) throw Exception("There is no audio output device with index " + ToString(DeviceIndex) + "."); |
461 |
AudioOutputDevice* pDevice = devices[DeviceIndex]; |
AudioOutputDevice* pDevice = devices[DeviceIndex]; |
462 |
pSampler->DestroyAudioOutputDevice(pDevice); |
pSampler->DestroyAudioOutputDevice(pDevice); |
463 |
} |
} |
464 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
465 |
result.Error(e); |
result.Error(e); |
466 |
} |
} |
467 |
return result.Produce(); |
return result.Produce(); |
472 |
LSCPResultSet result; |
LSCPResultSet result; |
473 |
try { |
try { |
474 |
std::map<uint, MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
std::map<uint, MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
475 |
if (!devices.count(DeviceIndex)) throw LinuxSamplerException("There is no audio output device with index " + ToString(DeviceIndex) + "."); |
if (!devices.count(DeviceIndex)) throw Exception("There is no audio output device with index " + ToString(DeviceIndex) + "."); |
476 |
MidiInputDevice* pDevice = devices[DeviceIndex]; |
MidiInputDevice* pDevice = devices[DeviceIndex]; |
477 |
pSampler->DestroyMidiInputDevice(pDevice); |
pSampler->DestroyMidiInputDevice(pDevice); |
478 |
} |
} |
479 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
480 |
result.Error(e); |
result.Error(e); |
481 |
} |
} |
482 |
return result.Produce(); |
return result.Produce(); |
490 |
LSCPResultSet result; |
LSCPResultSet result; |
491 |
try { |
try { |
492 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
493 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
494 |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
495 |
if (!pEngineChannel) throw LinuxSamplerException("No engine type assigned to sampler channel yet"); |
if (!pEngineChannel) throw Exception("No engine type assigned to sampler channel yet"); |
496 |
if (!pSamplerChannel->GetAudioOutputDevice()) |
if (!pSamplerChannel->GetAudioOutputDevice()) |
497 |
throw LinuxSamplerException("No audio output device connected to sampler channel"); |
throw Exception("No audio output device connected to sampler channel"); |
498 |
if (bBackground) { |
if (bBackground) { |
499 |
InstrumentLoader.StartNewLoad(Filename, uiInstrument, pEngineChannel); |
InstrumentLoader.StartNewLoad(Filename, uiInstrument, pEngineChannel); |
500 |
} |
} |
505 |
pEngineChannel->LoadInstrument(); |
pEngineChannel->LoadInstrument(); |
506 |
} |
} |
507 |
} |
} |
508 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
509 |
result.Error(e); |
result.Error(e); |
510 |
} |
} |
511 |
return result.Produce(); |
return result.Produce(); |
520 |
LSCPResultSet result; |
LSCPResultSet result; |
521 |
try { |
try { |
522 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
523 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
524 |
LockRTNotify(); |
LockRTNotify(); |
525 |
pSamplerChannel->SetEngineType(EngineName); |
pSamplerChannel->SetEngineType(EngineName); |
526 |
if(HasSoloChannel()) pSamplerChannel->GetEngineChannel()->SetMute(-1); |
if(HasSoloChannel()) pSamplerChannel->GetEngineChannel()->SetMute(-1); |
527 |
UnlockRTNotify(); |
UnlockRTNotify(); |
528 |
} |
} |
529 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
530 |
result.Error(e); |
result.Error(e); |
531 |
} |
} |
532 |
return result.Produce(); |
return result.Produce(); |
564 |
*/ |
*/ |
565 |
String LSCPServer::AddChannel() { |
String LSCPServer::AddChannel() { |
566 |
dmsg(2,("LSCPServer: AddChannel()\n")); |
dmsg(2,("LSCPServer: AddChannel()\n")); |
567 |
|
LockRTNotify(); |
568 |
SamplerChannel* pSamplerChannel = pSampler->AddSamplerChannel(); |
SamplerChannel* pSamplerChannel = pSampler->AddSamplerChannel(); |
569 |
|
UnlockRTNotify(); |
570 |
LSCPResultSet result(pSamplerChannel->Index()); |
LSCPResultSet result(pSamplerChannel->Index()); |
571 |
return result.Produce(); |
return result.Produce(); |
572 |
} |
} |
588 |
*/ |
*/ |
589 |
String LSCPServer::GetAvailableEngines() { |
String LSCPServer::GetAvailableEngines() { |
590 |
dmsg(2,("LSCPServer: GetAvailableEngines()\n")); |
dmsg(2,("LSCPServer: GetAvailableEngines()\n")); |
591 |
LSCPResultSet result("1"); |
LSCPResultSet result; |
592 |
|
try { |
593 |
|
int n = EngineFactory::AvailableEngineTypes().size(); |
594 |
|
result.Add(n); |
595 |
|
} |
596 |
|
catch (Exception e) { |
597 |
|
result.Error(e); |
598 |
|
} |
599 |
return result.Produce(); |
return result.Produce(); |
600 |
} |
} |
601 |
|
|
604 |
*/ |
*/ |
605 |
String LSCPServer::ListAvailableEngines() { |
String LSCPServer::ListAvailableEngines() { |
606 |
dmsg(2,("LSCPServer: ListAvailableEngines()\n")); |
dmsg(2,("LSCPServer: ListAvailableEngines()\n")); |
607 |
LSCPResultSet result("\'GIG\'"); |
LSCPResultSet result; |
608 |
|
try { |
609 |
|
String s = EngineFactory::AvailableEngineTypesAsString(); |
610 |
|
result.Add(s); |
611 |
|
} |
612 |
|
catch (Exception e) { |
613 |
|
result.Error(e); |
614 |
|
} |
615 |
return result.Produce(); |
return result.Produce(); |
616 |
} |
} |
617 |
|
|
622 |
String LSCPServer::GetEngineInfo(String EngineName) { |
String LSCPServer::GetEngineInfo(String EngineName) { |
623 |
dmsg(2,("LSCPServer: GetEngineInfo(EngineName=%s)\n", EngineName.c_str())); |
dmsg(2,("LSCPServer: GetEngineInfo(EngineName=%s)\n", EngineName.c_str())); |
624 |
LSCPResultSet result; |
LSCPResultSet result; |
625 |
|
LockRTNotify(); |
626 |
try { |
try { |
627 |
Engine* pEngine = EngineFactory::Create(EngineName); |
Engine* pEngine = EngineFactory::Create(EngineName); |
628 |
result.Add("DESCRIPTION", pEngine->Description()); |
result.Add("DESCRIPTION", pEngine->Description()); |
629 |
result.Add("VERSION", pEngine->Version()); |
result.Add("VERSION", pEngine->Version()); |
630 |
EngineFactory::Destroy(pEngine); |
EngineFactory::Destroy(pEngine); |
631 |
} |
} |
632 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
633 |
result.Error(e); |
result.Error(e); |
634 |
} |
} |
635 |
|
UnlockRTNotify(); |
636 |
return result.Produce(); |
return result.Produce(); |
637 |
} |
} |
638 |
|
|
645 |
LSCPResultSet result; |
LSCPResultSet result; |
646 |
try { |
try { |
647 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
648 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
649 |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
650 |
|
|
651 |
//Defaults values |
//Defaults values |
698 |
result.Add("MUTE", Mute == -1 ? "MUTED_BY_SOLO" : (Mute ? "true" : "false")); |
result.Add("MUTE", Mute == -1 ? "MUTED_BY_SOLO" : (Mute ? "true" : "false")); |
699 |
result.Add("SOLO", Solo); |
result.Add("SOLO", Solo); |
700 |
} |
} |
701 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
702 |
result.Error(e); |
result.Error(e); |
703 |
} |
} |
704 |
return result.Produce(); |
return result.Produce(); |
713 |
LSCPResultSet result; |
LSCPResultSet result; |
714 |
try { |
try { |
715 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
716 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
717 |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
718 |
if (!pEngineChannel) throw LinuxSamplerException("No engine loaded on sampler channel"); |
if (!pEngineChannel) throw Exception("No engine loaded on sampler channel"); |
719 |
if (!pEngineChannel->GetEngine()) throw LinuxSamplerException("No audio output device connected to sampler channel"); |
if (!pEngineChannel->GetEngine()) throw Exception("No audio output device connected to sampler channel"); |
720 |
result.Add(pEngineChannel->GetEngine()->VoiceCount()); |
result.Add(pEngineChannel->GetEngine()->VoiceCount()); |
721 |
} |
} |
722 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
723 |
result.Error(e); |
result.Error(e); |
724 |
} |
} |
725 |
return result.Produce(); |
return result.Produce(); |
734 |
LSCPResultSet result; |
LSCPResultSet result; |
735 |
try { |
try { |
736 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
737 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
738 |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
739 |
if (!pEngineChannel) throw LinuxSamplerException("No engine type assigned to sampler channel"); |
if (!pEngineChannel) throw Exception("No engine type assigned to sampler channel"); |
740 |
if (!pEngineChannel->GetEngine()) throw LinuxSamplerException("No audio output device connected to sampler channel"); |
if (!pEngineChannel->GetEngine()) throw Exception("No audio output device connected to sampler channel"); |
741 |
result.Add(pEngineChannel->GetEngine()->DiskStreamCount()); |
result.Add(pEngineChannel->GetEngine()->DiskStreamCount()); |
742 |
} |
} |
743 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
744 |
result.Error(e); |
result.Error(e); |
745 |
} |
} |
746 |
return result.Produce(); |
return result.Produce(); |
755 |
LSCPResultSet result; |
LSCPResultSet result; |
756 |
try { |
try { |
757 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
758 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
759 |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
760 |
if (!pEngineChannel) throw LinuxSamplerException("No engine type assigned to sampler channel"); |
if (!pEngineChannel) throw Exception("No engine type assigned to sampler channel"); |
761 |
if (!pEngineChannel->GetEngine()) throw LinuxSamplerException("No audio output device connected to sampler channel"); |
if (!pEngineChannel->GetEngine()) throw Exception("No audio output device connected to sampler channel"); |
762 |
if (!pEngineChannel->GetEngine()->DiskStreamSupported()) result.Add("NA"); |
if (!pEngineChannel->GetEngine()->DiskStreamSupported()) result.Add("NA"); |
763 |
else { |
else { |
764 |
switch (ResponseType) { |
switch (ResponseType) { |
769 |
result.Add(pEngineChannel->GetEngine()->DiskStreamBufferFillPercentage()); |
result.Add(pEngineChannel->GetEngine()->DiskStreamBufferFillPercentage()); |
770 |
break; |
break; |
771 |
default: |
default: |
772 |
throw LinuxSamplerException("Unknown fill response type"); |
throw Exception("Unknown fill response type"); |
773 |
} |
} |
774 |
} |
} |
775 |
} |
} |
776 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
777 |
result.Error(e); |
result.Error(e); |
778 |
} |
} |
779 |
return result.Produce(); |
return result.Produce(); |
786 |
int n = AudioOutputDeviceFactory::AvailableDrivers().size(); |
int n = AudioOutputDeviceFactory::AvailableDrivers().size(); |
787 |
result.Add(n); |
result.Add(n); |
788 |
} |
} |
789 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
790 |
result.Error(e); |
result.Error(e); |
791 |
} |
} |
792 |
return result.Produce(); |
return result.Produce(); |
799 |
String s = AudioOutputDeviceFactory::AvailableDriversAsString(); |
String s = AudioOutputDeviceFactory::AvailableDriversAsString(); |
800 |
result.Add(s); |
result.Add(s); |
801 |
} |
} |
802 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
803 |
result.Error(e); |
result.Error(e); |
804 |
} |
} |
805 |
return result.Produce(); |
return result.Produce(); |
812 |
int n = MidiInputDeviceFactory::AvailableDrivers().size(); |
int n = MidiInputDeviceFactory::AvailableDrivers().size(); |
813 |
result.Add(n); |
result.Add(n); |
814 |
} |
} |
815 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
816 |
result.Error(e); |
result.Error(e); |
817 |
} |
} |
818 |
return result.Produce(); |
return result.Produce(); |
825 |
String s = MidiInputDeviceFactory::AvailableDriversAsString(); |
String s = MidiInputDeviceFactory::AvailableDriversAsString(); |
826 |
result.Add(s); |
result.Add(s); |
827 |
} |
} |
828 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
829 |
result.Error(e); |
result.Error(e); |
830 |
} |
} |
831 |
return result.Produce(); |
return result.Produce(); |
849 |
result.Add("PARAMETERS", s); |
result.Add("PARAMETERS", s); |
850 |
} |
} |
851 |
} |
} |
852 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
853 |
result.Error(e); |
result.Error(e); |
854 |
} |
} |
855 |
return result.Produce(); |
return result.Produce(); |
873 |
result.Add("PARAMETERS", s); |
result.Add("PARAMETERS", s); |
874 |
} |
} |
875 |
} |
} |
876 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
877 |
result.Error(e); |
result.Error(e); |
878 |
} |
} |
879 |
return result.Produce(); |
return result.Produce(); |
900 |
if (oRangeMax) result.Add("RANGE_MAX", *oRangeMax); |
if (oRangeMax) result.Add("RANGE_MAX", *oRangeMax); |
901 |
if (oPossibilities) result.Add("POSSIBILITIES", *oPossibilities); |
if (oPossibilities) result.Add("POSSIBILITIES", *oPossibilities); |
902 |
} |
} |
903 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
904 |
result.Error(e); |
result.Error(e); |
905 |
} |
} |
906 |
return result.Produce(); |
return result.Produce(); |
927 |
if (oRangeMax) result.Add("RANGE_MAX", *oRangeMax); |
if (oRangeMax) result.Add("RANGE_MAX", *oRangeMax); |
928 |
if (oPossibilities) result.Add("POSSIBILITIES", *oPossibilities); |
if (oPossibilities) result.Add("POSSIBILITIES", *oPossibilities); |
929 |
} |
} |
930 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
931 |
result.Error(e); |
result.Error(e); |
932 |
} |
} |
933 |
return result.Produce(); |
return result.Produce(); |
940 |
uint count = pSampler->AudioOutputDevices(); |
uint count = pSampler->AudioOutputDevices(); |
941 |
result.Add(count); // success |
result.Add(count); // success |
942 |
} |
} |
943 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
944 |
result.Error(e); |
result.Error(e); |
945 |
} |
} |
946 |
return result.Produce(); |
return result.Produce(); |
953 |
uint count = pSampler->MidiInputDevices(); |
uint count = pSampler->MidiInputDevices(); |
954 |
result.Add(count); // success |
result.Add(count); // success |
955 |
} |
} |
956 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
957 |
result.Error(e); |
result.Error(e); |
958 |
} |
} |
959 |
return result.Produce(); |
return result.Produce(); |
972 |
} |
} |
973 |
result.Add(s); |
result.Add(s); |
974 |
} |
} |
975 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
976 |
result.Error(e); |
result.Error(e); |
977 |
} |
} |
978 |
return result.Produce(); |
return result.Produce(); |
991 |
} |
} |
992 |
result.Add(s); |
result.Add(s); |
993 |
} |
} |
994 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
995 |
result.Error(e); |
result.Error(e); |
996 |
} |
} |
997 |
return result.Produce(); |
return result.Produce(); |
1002 |
LSCPResultSet result; |
LSCPResultSet result; |
1003 |
try { |
try { |
1004 |
std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
1005 |
if (!devices.count(DeviceIndex)) throw LinuxSamplerException("There is no audio output device with index " + ToString(DeviceIndex) + "."); |
if (!devices.count(DeviceIndex)) throw Exception("There is no audio output device with index " + ToString(DeviceIndex) + "."); |
1006 |
AudioOutputDevice* pDevice = devices[DeviceIndex]; |
AudioOutputDevice* pDevice = devices[DeviceIndex]; |
1007 |
result.Add("DRIVER", pDevice->Driver()); |
result.Add("DRIVER", pDevice->Driver()); |
1008 |
std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters(); |
std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters(); |
1011 |
result.Add(iter->first, iter->second->Value()); |
result.Add(iter->first, iter->second->Value()); |
1012 |
} |
} |
1013 |
} |
} |
1014 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
1015 |
result.Error(e); |
result.Error(e); |
1016 |
} |
} |
1017 |
return result.Produce(); |
return result.Produce(); |
1022 |
LSCPResultSet result; |
LSCPResultSet result; |
1023 |
try { |
try { |
1024 |
std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
1025 |
if (!devices.count(DeviceIndex)) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(DeviceIndex) + "."); |
if (!devices.count(DeviceIndex)) throw Exception("There is no MIDI input device with index " + ToString(DeviceIndex) + "."); |
1026 |
MidiInputDevice* pDevice = devices[DeviceIndex]; |
MidiInputDevice* pDevice = devices[DeviceIndex]; |
1027 |
result.Add("DRIVER", pDevice->Driver()); |
result.Add("DRIVER", pDevice->Driver()); |
1028 |
std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters(); |
std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters(); |
1031 |
result.Add(iter->first, iter->second->Value()); |
result.Add(iter->first, iter->second->Value()); |
1032 |
} |
} |
1033 |
} |
} |
1034 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
1035 |
result.Error(e); |
result.Error(e); |
1036 |
} |
} |
1037 |
return result.Produce(); |
return result.Produce(); |
1042 |
try { |
try { |
1043 |
// get MIDI input device |
// get MIDI input device |
1044 |
std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
1045 |
if (!devices.count(DeviceIndex)) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(DeviceIndex) + "."); |
if (!devices.count(DeviceIndex)) throw Exception("There is no MIDI input device with index " + ToString(DeviceIndex) + "."); |
1046 |
MidiInputDevice* pDevice = devices[DeviceIndex]; |
MidiInputDevice* pDevice = devices[DeviceIndex]; |
1047 |
|
|
1048 |
// get MIDI port |
// get MIDI port |
1049 |
MidiInputPort* pMidiInputPort = pDevice->GetPort(PortIndex); |
MidiInputPort* pMidiInputPort = pDevice->GetPort(PortIndex); |
1050 |
if (!pMidiInputPort) throw LinuxSamplerException("There is no MIDI input port with index " + ToString(PortIndex) + "."); |
if (!pMidiInputPort) throw Exception("There is no MIDI input port with index " + ToString(PortIndex) + "."); |
1051 |
|
|
1052 |
// return the values of all MIDI port parameters |
// return the values of all MIDI port parameters |
1053 |
std::map<String,DeviceRuntimeParameter*> parameters = pMidiInputPort->PortParameters(); |
std::map<String,DeviceRuntimeParameter*> parameters = pMidiInputPort->PortParameters(); |
1056 |
result.Add(iter->first, iter->second->Value()); |
result.Add(iter->first, iter->second->Value()); |
1057 |
} |
} |
1058 |
} |
} |
1059 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
1060 |
result.Error(e); |
result.Error(e); |
1061 |
} |
} |
1062 |
return result.Produce(); |
return result.Produce(); |
1068 |
try { |
try { |
1069 |
// get audio output device |
// get audio output device |
1070 |
std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
1071 |
if (!devices.count(DeviceId)) throw LinuxSamplerException("There is no audio output device with index " + ToString(DeviceId) + "."); |
if (!devices.count(DeviceId)) throw Exception("There is no audio output device with index " + ToString(DeviceId) + "."); |
1072 |
AudioOutputDevice* pDevice = devices[DeviceId]; |
AudioOutputDevice* pDevice = devices[DeviceId]; |
1073 |
|
|
1074 |
// get audio channel |
// get audio channel |
1075 |
AudioChannel* pChannel = pDevice->Channel(ChannelId); |
AudioChannel* pChannel = pDevice->Channel(ChannelId); |
1076 |
if (!pChannel) throw LinuxSamplerException("Audio output device does not have audio channel " + ToString(ChannelId) + "."); |
if (!pChannel) throw Exception("Audio output device does not have audio channel " + ToString(ChannelId) + "."); |
1077 |
|
|
1078 |
// return the values of all audio channel parameters |
// return the values of all audio channel parameters |
1079 |
std::map<String,DeviceRuntimeParameter*> parameters = pChannel->ChannelParameters(); |
std::map<String,DeviceRuntimeParameter*> parameters = pChannel->ChannelParameters(); |
1082 |
result.Add(iter->first, iter->second->Value()); |
result.Add(iter->first, iter->second->Value()); |
1083 |
} |
} |
1084 |
} |
} |
1085 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
1086 |
result.Error(e); |
result.Error(e); |
1087 |
} |
} |
1088 |
return result.Produce(); |
return result.Produce(); |
1094 |
try { |
try { |
1095 |
// get MIDI input device |
// get MIDI input device |
1096 |
std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
1097 |
if (!devices.count(DeviceId)) throw LinuxSamplerException("There is no midi input device with index " + ToString(DeviceId) + "."); |
if (!devices.count(DeviceId)) throw Exception("There is no midi input device with index " + ToString(DeviceId) + "."); |
1098 |
MidiInputDevice* pDevice = devices[DeviceId]; |
MidiInputDevice* pDevice = devices[DeviceId]; |
1099 |
|
|
1100 |
// get midi port |
// get midi port |
1101 |
MidiInputPort* pPort = pDevice->GetPort(PortId); |
MidiInputPort* pPort = pDevice->GetPort(PortId); |
1102 |
if (!pPort) throw LinuxSamplerException("Midi input device does not have port " + ToString(PortId) + "."); |
if (!pPort) throw Exception("Midi input device does not have port " + ToString(PortId) + "."); |
1103 |
|
|
1104 |
// get desired port parameter |
// get desired port parameter |
1105 |
std::map<String,DeviceRuntimeParameter*> parameters = pPort->PortParameters(); |
std::map<String,DeviceRuntimeParameter*> parameters = pPort->PortParameters(); |
1106 |
if (!parameters.count(ParameterName)) throw LinuxSamplerException("Midi port does not provide a parameter '" + ParameterName + "'."); |
if (!parameters.count(ParameterName)) throw Exception("Midi port does not provide a parameter '" + ParameterName + "'."); |
1107 |
DeviceRuntimeParameter* pParameter = parameters[ParameterName]; |
DeviceRuntimeParameter* pParameter = parameters[ParameterName]; |
1108 |
|
|
1109 |
// return all fields of this audio channel parameter |
// return all fields of this audio channel parameter |
1115 |
if (pParameter->RangeMax()) result.Add("RANGE_MAX", *pParameter->RangeMax()); |
if (pParameter->RangeMax()) result.Add("RANGE_MAX", *pParameter->RangeMax()); |
1116 |
if (pParameter->Possibilities()) result.Add("POSSIBILITIES", *pParameter->Possibilities()); |
if (pParameter->Possibilities()) result.Add("POSSIBILITIES", *pParameter->Possibilities()); |
1117 |
} |
} |
1118 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
1119 |
result.Error(e); |
result.Error(e); |
1120 |
} |
} |
1121 |
return result.Produce(); |
return result.Produce(); |
1127 |
try { |
try { |
1128 |
// get audio output device |
// get audio output device |
1129 |
std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
1130 |
if (!devices.count(DeviceId)) throw LinuxSamplerException("There is no audio output device with index " + ToString(DeviceId) + "."); |
if (!devices.count(DeviceId)) throw Exception("There is no audio output device with index " + ToString(DeviceId) + "."); |
1131 |
AudioOutputDevice* pDevice = devices[DeviceId]; |
AudioOutputDevice* pDevice = devices[DeviceId]; |
1132 |
|
|
1133 |
// get audio channel |
// get audio channel |
1134 |
AudioChannel* pChannel = pDevice->Channel(ChannelId); |
AudioChannel* pChannel = pDevice->Channel(ChannelId); |
1135 |
if (!pChannel) throw LinuxSamplerException("Audio output device does not have audio channel " + ToString(ChannelId) + "."); |
if (!pChannel) throw Exception("Audio output device does not have audio channel " + ToString(ChannelId) + "."); |
1136 |
|
|
1137 |
// get desired audio channel parameter |
// get desired audio channel parameter |
1138 |
std::map<String,DeviceRuntimeParameter*> parameters = pChannel->ChannelParameters(); |
std::map<String,DeviceRuntimeParameter*> parameters = pChannel->ChannelParameters(); |
1139 |
if (!parameters.count(ParameterName)) throw LinuxSamplerException("Audio channel does not provide a parameter '" + ParameterName + "'."); |
if (!parameters.count(ParameterName)) throw Exception("Audio channel does not provide a parameter '" + ParameterName + "'."); |
1140 |
DeviceRuntimeParameter* pParameter = parameters[ParameterName]; |
DeviceRuntimeParameter* pParameter = parameters[ParameterName]; |
1141 |
|
|
1142 |
// return all fields of this audio channel parameter |
// return all fields of this audio channel parameter |
1148 |
if (pParameter->RangeMax()) result.Add("RANGE_MAX", *pParameter->RangeMax()); |
if (pParameter->RangeMax()) result.Add("RANGE_MAX", *pParameter->RangeMax()); |
1149 |
if (pParameter->Possibilities()) result.Add("POSSIBILITIES", *pParameter->Possibilities()); |
if (pParameter->Possibilities()) result.Add("POSSIBILITIES", *pParameter->Possibilities()); |
1150 |
} |
} |
1151 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
1152 |
result.Error(e); |
result.Error(e); |
1153 |
} |
} |
1154 |
return result.Produce(); |
return result.Produce(); |
1160 |
try { |
try { |
1161 |
// get audio output device |
// get audio output device |
1162 |
std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
1163 |
if (!devices.count(DeviceId)) throw LinuxSamplerException("There is no audio output device with index " + ToString(DeviceId) + "."); |
if (!devices.count(DeviceId)) throw Exception("There is no audio output device with index " + ToString(DeviceId) + "."); |
1164 |
AudioOutputDevice* pDevice = devices[DeviceId]; |
AudioOutputDevice* pDevice = devices[DeviceId]; |
1165 |
|
|
1166 |
// get audio channel |
// get audio channel |
1167 |
AudioChannel* pChannel = pDevice->Channel(ChannelId); |
AudioChannel* pChannel = pDevice->Channel(ChannelId); |
1168 |
if (!pChannel) throw LinuxSamplerException("Audio output device does not have audio channel " + ToString(ChannelId) + "."); |
if (!pChannel) throw Exception("Audio output device does not have audio channel " + ToString(ChannelId) + "."); |
1169 |
|
|
1170 |
// get desired audio channel parameter |
// get desired audio channel parameter |
1171 |
std::map<String,DeviceRuntimeParameter*> parameters = pChannel->ChannelParameters(); |
std::map<String,DeviceRuntimeParameter*> parameters = pChannel->ChannelParameters(); |
1172 |
if (!parameters.count(ParamKey)) throw LinuxSamplerException("Audio channel does not provide a parameter '" + ParamKey + "'."); |
if (!parameters.count(ParamKey)) throw Exception("Audio channel does not provide a parameter '" + ParamKey + "'."); |
1173 |
DeviceRuntimeParameter* pParameter = parameters[ParamKey]; |
DeviceRuntimeParameter* pParameter = parameters[ParamKey]; |
1174 |
|
|
1175 |
// set new channel parameter value |
// set new channel parameter value |
1176 |
pParameter->SetValue(ParamVal); |
pParameter->SetValue(ParamVal); |
1177 |
} |
} |
1178 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
1179 |
result.Error(e); |
result.Error(e); |
1180 |
} |
} |
1181 |
return result.Produce(); |
return result.Produce(); |
1186 |
LSCPResultSet result; |
LSCPResultSet result; |
1187 |
try { |
try { |
1188 |
std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
1189 |
if (!devices.count(DeviceIndex)) throw LinuxSamplerException("There is no audio output device with index " + ToString(DeviceIndex) + "."); |
if (!devices.count(DeviceIndex)) throw Exception("There is no audio output device with index " + ToString(DeviceIndex) + "."); |
1190 |
AudioOutputDevice* pDevice = devices[DeviceIndex]; |
AudioOutputDevice* pDevice = devices[DeviceIndex]; |
1191 |
std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters(); |
std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters(); |
1192 |
if (!parameters.count(ParamKey)) throw LinuxSamplerException("Audio output device " + ToString(DeviceIndex) + " does not have a device parameter '" + ParamKey + "'"); |
if (!parameters.count(ParamKey)) throw Exception("Audio output device " + ToString(DeviceIndex) + " does not have a device parameter '" + ParamKey + "'"); |
1193 |
parameters[ParamKey]->SetValue(ParamVal); |
parameters[ParamKey]->SetValue(ParamVal); |
1194 |
} |
} |
1195 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
1196 |
result.Error(e); |
result.Error(e); |
1197 |
} |
} |
1198 |
return result.Produce(); |
return result.Produce(); |
1203 |
LSCPResultSet result; |
LSCPResultSet result; |
1204 |
try { |
try { |
1205 |
std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
1206 |
if (!devices.count(DeviceIndex)) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(DeviceIndex) + "."); |
if (!devices.count(DeviceIndex)) throw Exception("There is no MIDI input device with index " + ToString(DeviceIndex) + "."); |
1207 |
MidiInputDevice* pDevice = devices[DeviceIndex]; |
MidiInputDevice* pDevice = devices[DeviceIndex]; |
1208 |
std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters(); |
std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters(); |
1209 |
if (!parameters.count(ParamKey)) throw LinuxSamplerException("MIDI input device " + ToString(DeviceIndex) + " does not have a device parameter '" + ParamKey + "'"); |
if (!parameters.count(ParamKey)) throw Exception("MIDI input device " + ToString(DeviceIndex) + " does not have a device parameter '" + ParamKey + "'"); |
1210 |
parameters[ParamKey]->SetValue(ParamVal); |
parameters[ParamKey]->SetValue(ParamVal); |
1211 |
} |
} |
1212 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
1213 |
result.Error(e); |
result.Error(e); |
1214 |
} |
} |
1215 |
return result.Produce(); |
return result.Produce(); |
1221 |
try { |
try { |
1222 |
// get MIDI input device |
// get MIDI input device |
1223 |
std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
1224 |
if (!devices.count(DeviceIndex)) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(DeviceIndex) + "."); |
if (!devices.count(DeviceIndex)) throw Exception("There is no MIDI input device with index " + ToString(DeviceIndex) + "."); |
1225 |
MidiInputDevice* pDevice = devices[DeviceIndex]; |
MidiInputDevice* pDevice = devices[DeviceIndex]; |
1226 |
|
|
1227 |
// get MIDI port |
// get MIDI port |
1228 |
MidiInputPort* pMidiInputPort = pDevice->GetPort(PortIndex); |
MidiInputPort* pMidiInputPort = pDevice->GetPort(PortIndex); |
1229 |
if (!pMidiInputPort) throw LinuxSamplerException("There is no MIDI input port with index " + ToString(PortIndex) + "."); |
if (!pMidiInputPort) throw Exception("There is no MIDI input port with index " + ToString(PortIndex) + "."); |
1230 |
|
|
1231 |
// set port parameter value |
// set port parameter value |
1232 |
std::map<String,DeviceRuntimeParameter*> parameters = pMidiInputPort->PortParameters(); |
std::map<String,DeviceRuntimeParameter*> parameters = pMidiInputPort->PortParameters(); |
1233 |
if (!parameters.count(ParamKey)) throw LinuxSamplerException("MIDI input device " + ToString(PortIndex) + " does not have a parameter '" + ParamKey + "'"); |
if (!parameters.count(ParamKey)) throw Exception("MIDI input device " + ToString(PortIndex) + " does not have a parameter '" + ParamKey + "'"); |
1234 |
parameters[ParamKey]->SetValue(ParamVal); |
parameters[ParamKey]->SetValue(ParamVal); |
1235 |
} |
} |
1236 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
1237 |
result.Error(e); |
result.Error(e); |
1238 |
} |
} |
1239 |
return result.Produce(); |
return result.Produce(); |
1248 |
LSCPResultSet result; |
LSCPResultSet result; |
1249 |
try { |
try { |
1250 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1251 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1252 |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
1253 |
if (!pEngineChannel) throw LinuxSamplerException("No engine type yet assigned to sampler channel " + ToString(uiSamplerChannel)); |
if (!pEngineChannel) throw Exception("No engine type yet assigned to sampler channel " + ToString(uiSamplerChannel)); |
1254 |
if (!pSamplerChannel->GetAudioOutputDevice()) throw LinuxSamplerException("No audio output device connected to sampler channel " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel->GetAudioOutputDevice()) throw Exception("No audio output device connected to sampler channel " + ToString(uiSamplerChannel)); |
1255 |
pEngineChannel->SetOutputChannel(ChannelAudioOutputChannel, AudioOutputDeviceInputChannel); |
pEngineChannel->SetOutputChannel(ChannelAudioOutputChannel, AudioOutputDeviceInputChannel); |
1256 |
} |
} |
1257 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
1258 |
result.Error(e); |
result.Error(e); |
1259 |
} |
} |
1260 |
return result.Produce(); |
return result.Produce(); |
1263 |
String LSCPServer::SetAudioOutputDevice(uint AudioDeviceId, uint uiSamplerChannel) { |
String LSCPServer::SetAudioOutputDevice(uint AudioDeviceId, uint uiSamplerChannel) { |
1264 |
dmsg(2,("LSCPServer: SetAudiotOutputDevice(AudioDeviceId=%d, SamplerChannel=%d)\n",AudioDeviceId,uiSamplerChannel)); |
dmsg(2,("LSCPServer: SetAudiotOutputDevice(AudioDeviceId=%d, SamplerChannel=%d)\n",AudioDeviceId,uiSamplerChannel)); |
1265 |
LSCPResultSet result; |
LSCPResultSet result; |
1266 |
|
LockRTNotify(); |
1267 |
try { |
try { |
1268 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1269 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1270 |
std::map<uint, AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
std::map<uint, AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
1271 |
if (!devices.count(AudioDeviceId)) throw LinuxSamplerException("There is no audio output device with index " + ToString(AudioDeviceId)); |
if (!devices.count(AudioDeviceId)) throw Exception("There is no audio output device with index " + ToString(AudioDeviceId)); |
1272 |
AudioOutputDevice* pDevice = devices[AudioDeviceId]; |
AudioOutputDevice* pDevice = devices[AudioDeviceId]; |
1273 |
pSamplerChannel->SetAudioOutputDevice(pDevice); |
pSamplerChannel->SetAudioOutputDevice(pDevice); |
1274 |
} |
} |
1275 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
1276 |
result.Error(e); |
result.Error(e); |
1277 |
} |
} |
1278 |
|
UnlockRTNotify(); |
1279 |
return result.Produce(); |
return result.Produce(); |
1280 |
} |
} |
1281 |
|
|
1282 |
String LSCPServer::SetAudioOutputType(String AudioOutputDriver, uint uiSamplerChannel) { |
String LSCPServer::SetAudioOutputType(String AudioOutputDriver, uint uiSamplerChannel) { |
1283 |
dmsg(2,("LSCPServer: SetAudioOutputType(String AudioOutputDriver=%s, SamplerChannel=%d)\n",AudioOutputDriver.c_str(),uiSamplerChannel)); |
dmsg(2,("LSCPServer: SetAudioOutputType(String AudioOutputDriver=%s, SamplerChannel=%d)\n",AudioOutputDriver.c_str(),uiSamplerChannel)); |
1284 |
LSCPResultSet result; |
LSCPResultSet result; |
1285 |
|
LockRTNotify(); |
1286 |
try { |
try { |
1287 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1288 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1289 |
// Driver type name aliasing... |
// Driver type name aliasing... |
1290 |
if (AudioOutputDriver == "Alsa") AudioOutputDriver = "ALSA"; |
if (AudioOutputDriver == "Alsa") AudioOutputDriver = "ALSA"; |
1291 |
if (AudioOutputDriver == "Jack") AudioOutputDriver = "JACK"; |
if (AudioOutputDriver == "Jack") AudioOutputDriver = "JACK"; |
1307 |
} |
} |
1308 |
// Must have a device... |
// Must have a device... |
1309 |
if (pDevice == NULL) |
if (pDevice == NULL) |
1310 |
throw LinuxSamplerException("Internal error: could not create audio output device."); |
throw Exception("Internal error: could not create audio output device."); |
1311 |
// Set it as the current channel device... |
// Set it as the current channel device... |
1312 |
pSamplerChannel->SetAudioOutputDevice(pDevice); |
pSamplerChannel->SetAudioOutputDevice(pDevice); |
1313 |
} |
} |
1314 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
1315 |
result.Error(e); |
result.Error(e); |
1316 |
} |
} |
1317 |
|
UnlockRTNotify(); |
1318 |
return result.Produce(); |
return result.Produce(); |
1319 |
} |
} |
1320 |
|
|
1323 |
LSCPResultSet result; |
LSCPResultSet result; |
1324 |
try { |
try { |
1325 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1326 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1327 |
pSamplerChannel->SetMidiInputPort(MIDIPort); |
pSamplerChannel->SetMidiInputPort(MIDIPort); |
1328 |
} |
} |
1329 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
1330 |
result.Error(e); |
result.Error(e); |
1331 |
} |
} |
1332 |
return result.Produce(); |
return result.Produce(); |
1337 |
LSCPResultSet result; |
LSCPResultSet result; |
1338 |
try { |
try { |
1339 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1340 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1341 |
pSamplerChannel->SetMidiInputChannel((midi_chan_t) MIDIChannel); |
pSamplerChannel->SetMidiInputChannel((midi_chan_t) MIDIChannel); |
1342 |
} |
} |
1343 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
1344 |
result.Error(e); |
result.Error(e); |
1345 |
} |
} |
1346 |
return result.Produce(); |
return result.Produce(); |
1351 |
LSCPResultSet result; |
LSCPResultSet result; |
1352 |
try { |
try { |
1353 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1354 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1355 |
std::map<uint, MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
std::map<uint, MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
1356 |
if (!devices.count(MIDIDeviceId)) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(MIDIDeviceId)); |
if (!devices.count(MIDIDeviceId)) throw Exception("There is no MIDI input device with index " + ToString(MIDIDeviceId)); |
1357 |
MidiInputDevice* pDevice = devices[MIDIDeviceId]; |
MidiInputDevice* pDevice = devices[MIDIDeviceId]; |
1358 |
pSamplerChannel->SetMidiInputDevice(pDevice); |
pSamplerChannel->SetMidiInputDevice(pDevice); |
1359 |
} |
} |
1360 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
1361 |
result.Error(e); |
result.Error(e); |
1362 |
} |
} |
1363 |
return result.Produce(); |
return result.Produce(); |
1368 |
LSCPResultSet result; |
LSCPResultSet result; |
1369 |
try { |
try { |
1370 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1371 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1372 |
// Driver type name aliasing... |
// Driver type name aliasing... |
1373 |
if (MidiInputDriver == "Alsa") MidiInputDriver = "ALSA"; |
if (MidiInputDriver == "Alsa") MidiInputDriver = "ALSA"; |
1374 |
// Check if there's one MIDI input device already created |
// Check if there's one MIDI input device already created |
1392 |
} |
} |
1393 |
// Must have a device... |
// Must have a device... |
1394 |
if (pDevice == NULL) |
if (pDevice == NULL) |
1395 |
throw LinuxSamplerException("Internal error: could not create MIDI input device."); |
throw Exception("Internal error: could not create MIDI input device."); |
1396 |
// Set it as the current channel device... |
// Set it as the current channel device... |
1397 |
pSamplerChannel->SetMidiInputDevice(pDevice); |
pSamplerChannel->SetMidiInputDevice(pDevice); |
1398 |
} |
} |
1399 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
1400 |
result.Error(e); |
result.Error(e); |
1401 |
} |
} |
1402 |
return result.Produce(); |
return result.Produce(); |
1411 |
LSCPResultSet result; |
LSCPResultSet result; |
1412 |
try { |
try { |
1413 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1414 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1415 |
std::map<uint, MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
std::map<uint, MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
1416 |
if (!devices.count(MIDIDeviceId)) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(MIDIDeviceId)); |
if (!devices.count(MIDIDeviceId)) throw Exception("There is no MIDI input device with index " + ToString(MIDIDeviceId)); |
1417 |
MidiInputDevice* pDevice = devices[MIDIDeviceId]; |
MidiInputDevice* pDevice = devices[MIDIDeviceId]; |
1418 |
pSamplerChannel->SetMidiInput(pDevice, MIDIPort, (midi_chan_t) MIDIChannel); |
pSamplerChannel->SetMidiInput(pDevice, MIDIPort, (midi_chan_t) MIDIChannel); |
1419 |
} |
} |
1420 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
1421 |
result.Error(e); |
result.Error(e); |
1422 |
} |
} |
1423 |
return result.Produce(); |
return result.Produce(); |
1432 |
LSCPResultSet result; |
LSCPResultSet result; |
1433 |
try { |
try { |
1434 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1435 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1436 |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
1437 |
if (!pEngineChannel) throw LinuxSamplerException("No engine type assigned to sampler channel"); |
if (!pEngineChannel) throw Exception("No engine type assigned to sampler channel"); |
1438 |
pEngineChannel->Volume(dVolume); |
pEngineChannel->Volume(dVolume); |
1439 |
} |
} |
1440 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
1441 |
result.Error(e); |
result.Error(e); |
1442 |
} |
} |
1443 |
return result.Produce(); |
return result.Produce(); |
1451 |
LSCPResultSet result; |
LSCPResultSet result; |
1452 |
try { |
try { |
1453 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1454 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1455 |
|
|
1456 |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
1457 |
if (!pEngineChannel) throw LinuxSamplerException("No engine type assigned to sampler channel"); |
if (!pEngineChannel) throw Exception("No engine type assigned to sampler channel"); |
1458 |
|
|
1459 |
if(!bMute) pEngineChannel->SetMute((HasSoloChannel() && !pEngineChannel->GetSolo()) ? -1 : 0); |
if(!bMute) pEngineChannel->SetMute((HasSoloChannel() && !pEngineChannel->GetSolo()) ? -1 : 0); |
1460 |
else pEngineChannel->SetMute(1); |
else pEngineChannel->SetMute(1); |
1461 |
} catch (LinuxSamplerException e) { |
} catch (Exception e) { |
1462 |
result.Error(e); |
result.Error(e); |
1463 |
} |
} |
1464 |
return result.Produce(); |
return result.Produce(); |
1472 |
LSCPResultSet result; |
LSCPResultSet result; |
1473 |
try { |
try { |
1474 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1475 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1476 |
|
|
1477 |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
1478 |
if (!pEngineChannel) throw LinuxSamplerException("No engine type assigned to sampler channel"); |
if (!pEngineChannel) throw Exception("No engine type assigned to sampler channel"); |
1479 |
|
|
1480 |
bool oldSolo = pEngineChannel->GetSolo(); |
bool oldSolo = pEngineChannel->GetSolo(); |
1481 |
bool hadSoloChannel = HasSoloChannel(); |
bool hadSoloChannel = HasSoloChannel(); |
1491 |
if(!HasSoloChannel()) UnmuteChannels(); |
if(!HasSoloChannel()) UnmuteChannels(); |
1492 |
else if(!pEngineChannel->GetMute()) pEngineChannel->SetMute(-1); |
else if(!pEngineChannel->GetMute()) pEngineChannel->SetMute(-1); |
1493 |
} |
} |
1494 |
} catch (LinuxSamplerException e) { |
} catch (Exception e) { |
1495 |
result.Error(e); |
result.Error(e); |
1496 |
} |
} |
1497 |
return result.Produce(); |
return result.Produce(); |
1552 |
LSCPResultSet result; |
LSCPResultSet result; |
1553 |
try { |
try { |
1554 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1555 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1556 |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
1557 |
if (!pEngineChannel) throw LinuxSamplerException("No engine type assigned to sampler channel"); |
if (!pEngineChannel) throw Exception("No engine type assigned to sampler channel"); |
1558 |
pEngineChannel->Reset(); |
pEngineChannel->Reset(); |
1559 |
} |
} |
1560 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
1561 |
result.Error(e); |
result.Error(e); |
1562 |
} |
} |
1563 |
return result.Produce(); |
return result.Produce(); |
1674 |
try { |
try { |
1675 |
if (boolean_value == 0) pSession->bVerbose = false; |
if (boolean_value == 0) pSession->bVerbose = false; |
1676 |
else if (boolean_value == 1) pSession->bVerbose = true; |
else if (boolean_value == 1) pSession->bVerbose = true; |
1677 |
else throw LinuxSamplerException("Not a boolean value, must either be 0 or 1"); |
else throw Exception("Not a boolean value, must either be 0 or 1"); |
1678 |
} |
} |
1679 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
1680 |
result.Error(e); |
result.Error(e); |
1681 |
} |
} |
1682 |
return result.Produce(); |
return result.Produce(); |