61 |
LSCPEvent::RegisterEvent(LSCPEvent::event_misc, "MISCELLANEOUS"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_misc, "MISCELLANEOUS"); |
62 |
} |
} |
63 |
|
|
64 |
|
/** |
65 |
|
* Blocks the calling thread until the LSCP Server is initialized and |
66 |
|
* accepting socket connections, if the server is already initialized then |
67 |
|
* this method will return immediately. |
68 |
|
* @param TimeoutSeconds - optional: max. wait time in seconds |
69 |
|
* (default: 0s) |
70 |
|
* @param TimeoutNanoSeconds - optional: max wait time in nano seconds |
71 |
|
* (default: 0ns) |
72 |
|
* @returns 0 on success, a value less than 0 if timeout exceeded |
73 |
|
*/ |
74 |
|
int LSCPServer::WaitUntilInitialized(long TimeoutSeconds, long TimeoutNanoSeconds) { |
75 |
|
return Initialized.WaitAndUnlockIf(false, TimeoutSeconds, TimeoutNanoSeconds); |
76 |
|
} |
77 |
|
|
78 |
int LSCPServer::Main() { |
int LSCPServer::Main() { |
79 |
int hSocket = socket(AF_INET, SOCK_STREAM, 0); |
int hSocket = socket(AF_INET, SOCK_STREAM, 0); |
80 |
if (hSocket < 0) { |
if (hSocket < 0) { |
88 |
SocketAddress.sin_addr.s_addr = htonl(INADDR_ANY); |
SocketAddress.sin_addr.s_addr = htonl(INADDR_ANY); |
89 |
|
|
90 |
if (bind(hSocket, (sockaddr*) &SocketAddress, sizeof(sockaddr_in)) < 0) { |
if (bind(hSocket, (sockaddr*) &SocketAddress, sizeof(sockaddr_in)) < 0) { |
91 |
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..."; |
92 |
close(hSocket); |
for (int trial = 0; true; trial++) { // retry for LSCP_SERVER_BIND_TIMEOUT seconds |
93 |
//return -1; |
if (bind(hSocket, (sockaddr*) &SocketAddress, sizeof(sockaddr_in)) < 0) { |
94 |
exit(EXIT_FAILURE); |
if (trial > LSCP_SERVER_BIND_TIMEOUT) { |
95 |
|
std::cerr << "gave up!" << std::endl; |
96 |
|
close(hSocket); |
97 |
|
//return -1; |
98 |
|
exit(EXIT_FAILURE); |
99 |
|
} |
100 |
|
else sleep(1); // sleep 1s |
101 |
|
} |
102 |
|
else break; // success |
103 |
|
} |
104 |
} |
} |
105 |
|
|
106 |
listen(hSocket, 1); |
listen(hSocket, 1); |
107 |
dmsg(1,("LSCPServer: Server running.\n")); // server running |
Initialized.Set(true); |
108 |
|
|
109 |
// now wait for client connections and handle their requests |
// now wait for client connections and handle their requests |
110 |
sockaddr_in client; |
sockaddr_in client; |
156 |
if (FD_ISSET((*iter).hSession, &selectSet)) { //Was it this socket? |
if (FD_ISSET((*iter).hSession, &selectSet)) { //Was it this socket? |
157 |
if (GetLSCPCommand(iter)) { //Have we read the entire command? |
if (GetLSCPCommand(iter)) { //Have we read the entire command? |
158 |
dmsg(3,("LSCPServer: Got command on socket %d, calling parser.\n", currentSocket)); |
dmsg(3,("LSCPServer: Got command on socket %d, calling parser.\n", currentSocket)); |
159 |
yylex_init(&((*iter).pScanner)); //FIXME: should me moved out of this loop and initialized only when a new session is created |
int dummy; // just a temporary hack to fulfill the restart() function prototype |
160 |
|
restart(NULL, dummy); // restart the 'scanner' |
161 |
currentSocket = (*iter).hSession; //a hack |
currentSocket = (*iter).hSession; //a hack |
162 |
if ((*iter).bVerbose) { // if echo mode enabled |
if ((*iter).bVerbose) { // if echo mode enabled |
163 |
AnswerClient(bufferedCommands[currentSocket]); |
AnswerClient(bufferedCommands[currentSocket]); |
183 |
} |
} |
184 |
NotifyBufferMutex.Unlock(); |
NotifyBufferMutex.Unlock(); |
185 |
} |
} |
|
//It will never get here anyway |
|
|
//yylex_destroy(yyparse_param.pScanner); |
|
186 |
} |
} |
187 |
|
|
188 |
void LSCPServer::CloseConnection( std::vector<yyparse_param_t>::iterator iter ) { |
void LSCPServer::CloseConnection( std::vector<yyparse_param_t>::iterator iter ) { |
201 |
bufferedNotifies.erase(socket); |
bufferedNotifies.erase(socket); |
202 |
close(socket); |
close(socket); |
203 |
NotifyMutex.Unlock(); |
NotifyMutex.Unlock(); |
|
//yylex_destroy((*iter).pScanner); |
|
204 |
} |
} |
205 |
|
|
206 |
void LSCPServer::SendLSCPNotify( LSCPEvent event ) { |
void LSCPServer::SendLSCPNotify( LSCPEvent event ) { |
399 |
LSCPResultSet result; |
LSCPResultSet result; |
400 |
try { |
try { |
401 |
std::map<uint, AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
std::map<uint, AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
402 |
if (!devices[DeviceIndex]) throw LinuxSamplerException("There is no audio output device with index " + ToString(DeviceIndex) + "."); |
if (!devices.count(DeviceIndex)) throw LinuxSamplerException("There is no audio output device with index " + ToString(DeviceIndex) + "."); |
403 |
AudioOutputDevice* pDevice = devices[DeviceIndex]; |
AudioOutputDevice* pDevice = devices[DeviceIndex]; |
404 |
pSampler->DestroyAudioOutputDevice(pDevice); |
pSampler->DestroyAudioOutputDevice(pDevice); |
405 |
} |
} |
414 |
LSCPResultSet result; |
LSCPResultSet result; |
415 |
try { |
try { |
416 |
std::map<uint, MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
std::map<uint, MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
417 |
|
if (!devices.count(DeviceIndex)) throw LinuxSamplerException("There is no audio output device with index " + ToString(DeviceIndex) + "."); |
418 |
MidiInputDevice* pDevice = devices[DeviceIndex]; |
MidiInputDevice* pDevice = devices[DeviceIndex]; |
|
if (!pDevice) throw LinuxSamplerException("There is no audio output device with index " + ToString(DeviceIndex) + "."); |
|
419 |
pSampler->DestroyMidiInputDevice(pDevice); |
pSampler->DestroyMidiInputDevice(pDevice); |
420 |
} |
} |
421 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
435 |
if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds"); |
if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds"); |
436 |
Engine* pEngine = pSamplerChannel->GetEngine(); |
Engine* pEngine = pSamplerChannel->GetEngine(); |
437 |
if (!pEngine) throw LinuxSamplerException("No engine loaded on channel"); |
if (!pEngine) throw LinuxSamplerException("No engine loaded on channel"); |
438 |
if (pSamplerChannel->GetAudioOutputDevice() == NULL) |
if (!pSamplerChannel->GetAudioOutputDevice()) |
439 |
throw LinuxSamplerException("No audio output device on channel"); |
throw LinuxSamplerException("No audio output device on channel"); |
440 |
if (bBackground) { |
if (bBackground) { |
441 |
LSCPLoadInstrument *pLoadInstrument = new LSCPLoadInstrument(pEngine, Filename.c_str(), uiInstrument); |
LSCPLoadInstrument *pLoadInstrument = new LSCPLoadInstrument(pEngine, Filename.c_str(), uiInstrument); |
534 |
try { |
try { |
535 |
if ((EngineName == "GigEngine") || (EngineName == "gig")) { |
if ((EngineName == "GigEngine") || (EngineName == "gig")) { |
536 |
Engine* pEngine = new LinuxSampler::gig::Engine; |
Engine* pEngine = new LinuxSampler::gig::Engine; |
537 |
result.Add(pEngine->Description()); |
result.Add("DESCRIPTION", pEngine->Description()); |
538 |
result.Add(pEngine->Version()); |
result.Add("VERSION", pEngine->Version()); |
539 |
delete pEngine; |
delete pEngine; |
540 |
} |
} |
541 |
else throw LinuxSamplerException("Unknown engine type"); |
else throw LinuxSamplerException("Unknown engine type"); |
560 |
|
|
561 |
//Defaults values |
//Defaults values |
562 |
String EngineName = "NONE"; |
String EngineName = "NONE"; |
563 |
float Volume = 0; |
float Volume = 0.0f; |
564 |
String InstrumentFileName = "NONE"; |
String InstrumentFileName = "NONE"; |
565 |
int InstrumentIndex = -1; |
int InstrumentIndex = -1; |
566 |
int InstrumentStatus = -1; |
int InstrumentStatus = -1; |
567 |
|
int AudioOutputChannels = 0; |
568 |
|
String AudioRouting; |
569 |
|
|
570 |
if (pEngine) { |
if (pEngine) { |
571 |
EngineName = pEngine->EngineName(); |
EngineName = pEngine->EngineName(); |
572 |
|
AudioOutputChannels = pEngine->Channels(); |
573 |
Volume = pEngine->Volume(); |
Volume = pEngine->Volume(); |
574 |
InstrumentStatus = pEngine->InstrumentStatus(); |
InstrumentStatus = pEngine->InstrumentStatus(); |
575 |
InstrumentIndex = pEngine->InstrumentIndex(); |
InstrumentIndex = pEngine->InstrumentIndex(); |
576 |
if (InstrumentIndex != -1) |
if (InstrumentIndex != -1) |
577 |
InstrumentFileName = pEngine->InstrumentFileName(); |
InstrumentFileName = pEngine->InstrumentFileName(); |
578 |
|
for (int chan = 0; chan < pEngine->Channels(); chan++) { |
579 |
|
if (AudioRouting != "") AudioRouting += ","; |
580 |
|
AudioRouting += ToString(pEngine->OutputChannel(chan)); |
581 |
|
} |
582 |
} |
} |
583 |
|
|
584 |
result.Add("ENGINE_NAME", EngineName); |
result.Add("ENGINE_NAME", EngineName); |
586 |
|
|
587 |
//Some not-so-hardcoded stuff to make GUI look good |
//Some not-so-hardcoded stuff to make GUI look good |
588 |
result.Add("AUDIO_OUTPUT_DEVICE", GetAudioOutputDeviceIndex(pSamplerChannel->GetAudioOutputDevice())); |
result.Add("AUDIO_OUTPUT_DEVICE", GetAudioOutputDeviceIndex(pSamplerChannel->GetAudioOutputDevice())); |
589 |
result.Add("AUDIO_OUTPUT_CHANNELS", "2"); |
result.Add("AUDIO_OUTPUT_CHANNELS", AudioOutputChannels); |
590 |
result.Add("AUDIO_OUTPUT_ROUTING", "0,1"); |
result.Add("AUDIO_OUTPUT_ROUTING", AudioRouting); |
591 |
|
|
592 |
result.Add("MIDI_INPUT_DEVICE", GetMidiInputDeviceIndex(pSamplerChannel->GetMidiInputDevice())); |
result.Add("MIDI_INPUT_DEVICE", GetMidiInputDeviceIndex(pSamplerChannel->GetMidiInputDevice())); |
593 |
result.Add("MIDI_INPUT_PORT", pSamplerChannel->GetMidiInputPort()); |
result.Add("MIDI_INPUT_PORT", pSamplerChannel->GetMidiInputPort()); |
594 |
result.Add("MIDI_INPUT_CHANNEL", pSamplerChannel->GetMidiInputChannel()); |
if (pSamplerChannel->GetMidiInputChannel() == MidiInputPort::midi_chan_all) result.Add("MIDI_INPUT_CHANNEL", "ALL"); |
595 |
|
else result.Add("MIDI_INPUT_CHANNEL", pSamplerChannel->GetMidiInputChannel()); |
596 |
|
|
597 |
result.Add("INSTRUMENT_FILE", InstrumentFileName); |
result.Add("INSTRUMENT_FILE", InstrumentFileName); |
598 |
result.Add("INSTRUMENT_NR", InstrumentIndex); |
result.Add("INSTRUMENT_NR", InstrumentIndex); |
752 |
} |
} |
753 |
|
|
754 |
String LSCPServer::GetMidiInputDriverParameterInfo(String Driver, String Parameter, std::map<String,String> DependencyList) { |
String LSCPServer::GetMidiInputDriverParameterInfo(String Driver, String Parameter, std::map<String,String> DependencyList) { |
755 |
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())); |
756 |
LSCPResultSet result; |
LSCPResultSet result; |
757 |
try { |
try { |
758 |
DeviceCreationParameter* pParameter = MidiInputDeviceFactory::GetDriverParameter(Driver, Parameter); |
DeviceCreationParameter* pParameter = MidiInputDeviceFactory::GetDriverParameter(Driver, Parameter); |
761 |
result.Add("MANDATORY", pParameter->Mandatory()); |
result.Add("MANDATORY", pParameter->Mandatory()); |
762 |
result.Add("FIX", pParameter->Fix()); |
result.Add("FIX", pParameter->Fix()); |
763 |
result.Add("MULTIPLICITY", pParameter->Multiplicity()); |
result.Add("MULTIPLICITY", pParameter->Multiplicity()); |
764 |
if (pParameter->Depends()) result.Add("DEPENDS", pParameter->Depends()); |
optional<String> oDepends = pParameter->Depends(); |
765 |
if (pParameter->Default()) result.Add("DEFAULT", pParameter->Default()); |
optional<String> oDefault = pParameter->Default(DependencyList); |
766 |
if (pParameter->RangeMin()) result.Add("RANGE_MIN", pParameter->RangeMin()); |
optional<String> oRangeMin = pParameter->RangeMin(DependencyList); |
767 |
if (pParameter->RangeMax()) result.Add("RANGE_MAX", pParameter->RangeMax()); |
optional<String> oRangeMax = pParameter->RangeMax(DependencyList); |
768 |
if (pParameter->Possibilities()) result.Add("POSSIBILITIES", pParameter->Possibilities()); |
optional<String> oPossibilities = pParameter->Possibilities(DependencyList); |
769 |
|
if (oDepends) result.Add("DEPENDS", *oDepends); |
770 |
|
if (oDefault) result.Add("DEFAULT", *oDefault); |
771 |
|
if (oRangeMin) result.Add("RANGE_MIN", *oRangeMin); |
772 |
|
if (oRangeMax) result.Add("RANGE_MAX", *oRangeMax); |
773 |
|
if (oPossibilities) result.Add("POSSIBILITIES", *oPossibilities); |
774 |
} |
} |
775 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
776 |
result.Error(e); |
result.Error(e); |
779 |
} |
} |
780 |
|
|
781 |
String LSCPServer::GetAudioOutputDriverParameterInfo(String Driver, String Parameter, std::map<String,String> DependencyList) { |
String LSCPServer::GetAudioOutputDriverParameterInfo(String Driver, String Parameter, std::map<String,String> DependencyList) { |
782 |
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())); |
783 |
LSCPResultSet result; |
LSCPResultSet result; |
784 |
try { |
try { |
785 |
DeviceCreationParameter* pParameter = AudioOutputDeviceFactory::GetDriverParameter(Driver, Parameter); |
DeviceCreationParameter* pParameter = AudioOutputDeviceFactory::GetDriverParameter(Driver, Parameter); |
788 |
result.Add("MANDATORY", pParameter->Mandatory()); |
result.Add("MANDATORY", pParameter->Mandatory()); |
789 |
result.Add("FIX", pParameter->Fix()); |
result.Add("FIX", pParameter->Fix()); |
790 |
result.Add("MULTIPLICITY", pParameter->Multiplicity()); |
result.Add("MULTIPLICITY", pParameter->Multiplicity()); |
791 |
if (pParameter->Depends()) result.Add("DEPENDS", pParameter->Depends()); |
optional<String> oDepends = pParameter->Depends(); |
792 |
if (pParameter->Default()) result.Add("DEFAULT", pParameter->Default()); |
optional<String> oDefault = pParameter->Default(DependencyList); |
793 |
if (pParameter->RangeMin()) result.Add("RANGE_MIN", pParameter->RangeMin()); |
optional<String> oRangeMin = pParameter->RangeMin(DependencyList); |
794 |
if (pParameter->RangeMax()) result.Add("RANGE_MAX", pParameter->RangeMax()); |
optional<String> oRangeMax = pParameter->RangeMax(DependencyList); |
795 |
if (pParameter->Possibilities()) result.Add("POSSIBILITIES", pParameter->Possibilities()); |
optional<String> oPossibilities = pParameter->Possibilities(DependencyList); |
796 |
|
if (oDepends) result.Add("DEPENDS", *oDepends); |
797 |
|
if (oDefault) result.Add("DEFAULT", *oDefault); |
798 |
|
if (oRangeMin) result.Add("RANGE_MIN", *oRangeMin); |
799 |
|
if (oRangeMax) result.Add("RANGE_MAX", *oRangeMax); |
800 |
|
if (oPossibilities) result.Add("POSSIBILITIES", *oPossibilities); |
801 |
} |
} |
802 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
803 |
result.Error(e); |
result.Error(e); |
874 |
LSCPResultSet result; |
LSCPResultSet result; |
875 |
try { |
try { |
876 |
std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
877 |
if (!devices[DeviceIndex]) throw LinuxSamplerException("There is no audio output device with index " + ToString(DeviceIndex) + "."); |
if (!devices.count(DeviceIndex)) throw LinuxSamplerException("There is no audio output device with index " + ToString(DeviceIndex) + "."); |
878 |
AudioOutputDevice* pDevice = devices[DeviceIndex]; |
AudioOutputDevice* pDevice = devices[DeviceIndex]; |
879 |
result.Add("driver", pDevice->Driver()); |
result.Add("DRIVER", pDevice->Driver()); |
880 |
std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters(); |
std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters(); |
881 |
std::map<String,DeviceCreationParameter*>::iterator iter = parameters.begin(); |
std::map<String,DeviceCreationParameter*>::iterator iter = parameters.begin(); |
882 |
for (; iter != parameters.end(); iter++) { |
for (; iter != parameters.end(); iter++) { |
894 |
LSCPResultSet result; |
LSCPResultSet result; |
895 |
try { |
try { |
896 |
std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
897 |
|
if (!devices.count(DeviceIndex)) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(DeviceIndex) + "."); |
898 |
MidiInputDevice* pDevice = devices[DeviceIndex]; |
MidiInputDevice* pDevice = devices[DeviceIndex]; |
899 |
if (!pDevice) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(DeviceIndex) + "."); |
result.Add("DRIVER", pDevice->Driver()); |
|
result.Add("driver", pDevice->Driver()); |
|
900 |
std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters(); |
std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters(); |
901 |
std::map<String,DeviceCreationParameter*>::iterator iter = parameters.begin(); |
std::map<String,DeviceCreationParameter*>::iterator iter = parameters.begin(); |
902 |
for (; iter != parameters.end(); iter++) { |
for (; iter != parameters.end(); iter++) { |
912 |
dmsg(2,("LSCPServer: GetMidiInputPortInfo(DeviceIndex=%d, PortIndex=%d)\n",DeviceIndex, PortIndex)); |
dmsg(2,("LSCPServer: GetMidiInputPortInfo(DeviceIndex=%d, PortIndex=%d)\n",DeviceIndex, PortIndex)); |
913 |
LSCPResultSet result; |
LSCPResultSet result; |
914 |
try { |
try { |
915 |
|
// get MIDI input device |
916 |
std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
917 |
|
if (!devices.count(DeviceIndex)) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(DeviceIndex) + "."); |
918 |
MidiInputDevice* pDevice = devices[DeviceIndex]; |
MidiInputDevice* pDevice = devices[DeviceIndex]; |
919 |
if (!pDevice) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(DeviceIndex) + "."); |
|
920 |
MidiInputDevice::MidiInputPort* pMidiInputPort = pDevice->GetPort(PortIndex); |
// get MIDI port |
921 |
if (!pMidiInputPort) throw LinuxSamplerException("There is no MIDI input port with index " + ToString(PortIndex) + "."); |
MidiInputPort* pMidiInputPort = pDevice->GetPort(PortIndex); |
922 |
std::map<String,DeviceCreationParameter*> parameters = pMidiInputPort->DeviceParameters(); |
if (!pMidiInputPort) throw LinuxSamplerException("There is no MIDI input port with index " + ToString(PortIndex) + "."); |
923 |
std::map<String,DeviceCreationParameter*>::iterator iter = parameters.begin(); |
|
924 |
|
// return the values of all MIDI port parameters |
925 |
|
std::map<String,DeviceRuntimeParameter*> parameters = pMidiInputPort->PortParameters(); |
926 |
|
std::map<String,DeviceRuntimeParameter*>::iterator iter = parameters.begin(); |
927 |
for (; iter != parameters.end(); iter++) { |
for (; iter != parameters.end(); iter++) { |
928 |
result.Add(iter->first, iter->second->Value()); |
result.Add(iter->first, iter->second->Value()); |
929 |
} |
} |
940 |
try { |
try { |
941 |
// get audio output device |
// get audio output device |
942 |
std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
943 |
if (!devices[DeviceId]) throw LinuxSamplerException("There is no audio output device with index " + ToString(DeviceId) + "."); |
if (!devices.count(DeviceId)) throw LinuxSamplerException("There is no audio output device with index " + ToString(DeviceId) + "."); |
944 |
AudioOutputDevice* pDevice = devices[DeviceId]; |
AudioOutputDevice* pDevice = devices[DeviceId]; |
945 |
|
|
946 |
// get audio channel |
// get audio channel |
964 |
dmsg(2,("LSCPServer: GetMidiInputPortParameterInfo(DeviceId=%d,PortId=%d,ParameterName=%s)\n",DeviceId,PortId,ParameterName.c_str())); |
dmsg(2,("LSCPServer: GetMidiInputPortParameterInfo(DeviceId=%d,PortId=%d,ParameterName=%s)\n",DeviceId,PortId,ParameterName.c_str())); |
965 |
LSCPResultSet result; |
LSCPResultSet result; |
966 |
try { |
try { |
967 |
// get audio output device |
// get MIDI input device |
968 |
std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
969 |
if (!devices[DeviceId]) throw LinuxSamplerException("There is no midi input device with index " + ToString(DeviceId) + "."); |
if (!devices.count(DeviceId)) throw LinuxSamplerException("There is no midi input device with index " + ToString(DeviceId) + "."); |
970 |
MidiInputDevice* pDevice = devices[DeviceId]; |
MidiInputDevice* pDevice = devices[DeviceId]; |
971 |
|
|
972 |
// get midi port |
// get midi port |
973 |
MidiInputDevice::MidiInputPort* pPort = pDevice->GetPort(PortId); |
MidiInputPort* pPort = pDevice->GetPort(PortId); |
974 |
if (!pPort) throw LinuxSamplerException("Midi input device does not have port " + ToString(PortId) + "."); |
if (!pPort) throw LinuxSamplerException("Midi input device does not have port " + ToString(PortId) + "."); |
975 |
|
|
976 |
// get desired port parameter |
// get desired port parameter |
977 |
std::map<String,DeviceCreationParameter*> parameters = pPort->DeviceParameters(); |
std::map<String,DeviceRuntimeParameter*> parameters = pPort->PortParameters(); |
978 |
if (!parameters[ParameterName]) throw LinuxSamplerException("Midi port does not provice a parameters '" + ParameterName + "'."); |
if (!parameters.count(ParameterName)) throw LinuxSamplerException("Midi port does not provide a parameter '" + ParameterName + "'."); |
979 |
DeviceCreationParameter* pParameter = parameters[ParameterName]; |
DeviceRuntimeParameter* pParameter = parameters[ParameterName]; |
980 |
|
|
981 |
// return all fields of this audio channel parameter |
// return all fields of this audio channel parameter |
982 |
result.Add("TYPE", pParameter->Type()); |
result.Add("TYPE", pParameter->Type()); |
983 |
result.Add("DESCRIPTION", pParameter->Description()); |
result.Add("DESCRIPTION", pParameter->Description()); |
984 |
result.Add("FIX", pParameter->Fix()); |
result.Add("FIX", pParameter->Fix()); |
985 |
result.Add("MULTIPLICITY", pParameter->Multiplicity()); |
result.Add("MULTIPLICITY", pParameter->Multiplicity()); |
986 |
if (pParameter->RangeMin()) result.Add("RANGE_MIN", pParameter->RangeMin()); |
if (pParameter->RangeMin()) result.Add("RANGE_MIN", *pParameter->RangeMin()); |
987 |
if (pParameter->RangeMax()) result.Add("RANGE_MAX", pParameter->RangeMax()); |
if (pParameter->RangeMax()) result.Add("RANGE_MAX", *pParameter->RangeMax()); |
988 |
if (pParameter->Possibilities()) result.Add("POSSIBILITIES", pParameter->Possibilities()); |
if (pParameter->Possibilities()) result.Add("POSSIBILITIES", *pParameter->Possibilities()); |
989 |
} |
} |
990 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
991 |
result.Error(e); |
result.Error(e); |
999 |
try { |
try { |
1000 |
// get audio output device |
// get audio output device |
1001 |
std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
1002 |
if (!devices[DeviceId]) throw LinuxSamplerException("There is no audio output device with index " + ToString(DeviceId) + "."); |
if (!devices.count(DeviceId)) throw LinuxSamplerException("There is no audio output device with index " + ToString(DeviceId) + "."); |
1003 |
AudioOutputDevice* pDevice = devices[DeviceId]; |
AudioOutputDevice* pDevice = devices[DeviceId]; |
1004 |
|
|
1005 |
// get audio channel |
// get audio channel |
1008 |
|
|
1009 |
// get desired audio channel parameter |
// get desired audio channel parameter |
1010 |
std::map<String,DeviceRuntimeParameter*> parameters = pChannel->ChannelParameters(); |
std::map<String,DeviceRuntimeParameter*> parameters = pChannel->ChannelParameters(); |
1011 |
if (!parameters[ParameterName]) throw LinuxSamplerException("Audio channel does not provide a parameter '" + ParameterName + "'."); |
if (!parameters.count(ParameterName)) throw LinuxSamplerException("Audio channel does not provide a parameter '" + ParameterName + "'."); |
1012 |
DeviceRuntimeParameter* pParameter = parameters[ParameterName]; |
DeviceRuntimeParameter* pParameter = parameters[ParameterName]; |
1013 |
|
|
1014 |
// return all fields of this audio channel parameter |
// return all fields of this audio channel parameter |
1016 |
result.Add("DESCRIPTION", pParameter->Description()); |
result.Add("DESCRIPTION", pParameter->Description()); |
1017 |
result.Add("FIX", pParameter->Fix()); |
result.Add("FIX", pParameter->Fix()); |
1018 |
result.Add("MULTIPLICITY", pParameter->Multiplicity()); |
result.Add("MULTIPLICITY", pParameter->Multiplicity()); |
1019 |
if (pParameter->RangeMin()) result.Add("RANGE_MIN", pParameter->RangeMin()); |
if (pParameter->RangeMin()) result.Add("RANGE_MIN", *pParameter->RangeMin()); |
1020 |
if (pParameter->RangeMax()) result.Add("RANGE_MAX", pParameter->RangeMax()); |
if (pParameter->RangeMax()) result.Add("RANGE_MAX", *pParameter->RangeMax()); |
1021 |
if (pParameter->Possibilities()) result.Add("POSSIBILITIES", pParameter->Possibilities()); |
if (pParameter->Possibilities()) result.Add("POSSIBILITIES", *pParameter->Possibilities()); |
1022 |
} |
} |
1023 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
1024 |
result.Error(e); |
result.Error(e); |
1032 |
try { |
try { |
1033 |
// get audio output device |
// get audio output device |
1034 |
std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
1035 |
if (!devices[DeviceId]) throw LinuxSamplerException("There is no audio output device with index " + ToString(DeviceId) + "."); |
if (!devices.count(DeviceId)) throw LinuxSamplerException("There is no audio output device with index " + ToString(DeviceId) + "."); |
1036 |
AudioOutputDevice* pDevice = devices[DeviceId]; |
AudioOutputDevice* pDevice = devices[DeviceId]; |
1037 |
|
|
1038 |
// get audio channel |
// get audio channel |
1041 |
|
|
1042 |
// get desired audio channel parameter |
// get desired audio channel parameter |
1043 |
std::map<String,DeviceRuntimeParameter*> parameters = pChannel->ChannelParameters(); |
std::map<String,DeviceRuntimeParameter*> parameters = pChannel->ChannelParameters(); |
1044 |
if (!parameters[ParamKey]) throw LinuxSamplerException("Audio channel does not provide a parameter '" + ParamKey + "'."); |
if (!parameters.count(ParamKey)) throw LinuxSamplerException("Audio channel does not provide a parameter '" + ParamKey + "'."); |
1045 |
DeviceRuntimeParameter* pParameter = parameters[ParamKey]; |
DeviceRuntimeParameter* pParameter = parameters[ParamKey]; |
1046 |
|
|
1047 |
// set new channel parameter value |
// set new channel parameter value |
1058 |
LSCPResultSet result; |
LSCPResultSet result; |
1059 |
try { |
try { |
1060 |
std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
1061 |
if (!devices[DeviceIndex]) throw LinuxSamplerException("There is no audio output device with index " + ToString(DeviceIndex) + "."); |
if (!devices.count(DeviceIndex)) throw LinuxSamplerException("There is no audio output device with index " + ToString(DeviceIndex) + "."); |
1062 |
AudioOutputDevice* pDevice = devices[DeviceIndex]; |
AudioOutputDevice* pDevice = devices[DeviceIndex]; |
1063 |
std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters(); |
std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters(); |
1064 |
if (!parameters[ParamKey]) throw LinuxSamplerException("Audio output device " + ToString(DeviceIndex) + " does not have a device parameter '" + ParamKey + "'"); |
if (!parameters.count(ParamKey)) throw LinuxSamplerException("Audio output device " + ToString(DeviceIndex) + " does not have a device parameter '" + ParamKey + "'"); |
1065 |
parameters[ParamKey]->SetValue(ParamVal); |
parameters[ParamKey]->SetValue(ParamVal); |
1066 |
} |
} |
1067 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
1075 |
LSCPResultSet result; |
LSCPResultSet result; |
1076 |
try { |
try { |
1077 |
std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
1078 |
if (!devices[DeviceIndex]) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(DeviceIndex) + "."); |
if (!devices.count(DeviceIndex)) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(DeviceIndex) + "."); |
1079 |
MidiInputDevice* pDevice = devices[DeviceIndex]; |
MidiInputDevice* pDevice = devices[DeviceIndex]; |
1080 |
std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters(); |
std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters(); |
1081 |
if (!parameters[ParamKey]) throw LinuxSamplerException("MIDI input device " + ToString(DeviceIndex) + " does not have a device parameter '" + ParamKey + "'"); |
if (!parameters.count(ParamKey)) throw LinuxSamplerException("MIDI input device " + ToString(DeviceIndex) + " does not have a device parameter '" + ParamKey + "'"); |
1082 |
parameters[ParamKey]->SetValue(ParamVal); |
parameters[ParamKey]->SetValue(ParamVal); |
1083 |
} |
} |
1084 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
1091 |
dmsg(2,("LSCPServer: SetMidiOutputDeviceParameter(DeviceIndex=%d,ParamKey=%s,ParamVal=%s)\n",DeviceIndex,ParamKey.c_str(),ParamVal.c_str())); |
dmsg(2,("LSCPServer: SetMidiOutputDeviceParameter(DeviceIndex=%d,ParamKey=%s,ParamVal=%s)\n",DeviceIndex,ParamKey.c_str(),ParamVal.c_str())); |
1092 |
LSCPResultSet result; |
LSCPResultSet result; |
1093 |
try { |
try { |
1094 |
|
// get MIDI input device |
1095 |
std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
1096 |
|
if (!devices.count(DeviceIndex)) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(DeviceIndex) + "."); |
1097 |
MidiInputDevice* pDevice = devices[DeviceIndex]; |
MidiInputDevice* pDevice = devices[DeviceIndex]; |
1098 |
if (!pDevice) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(DeviceIndex) + "."); |
|
1099 |
MidiInputDevice::MidiInputPort* pMidiInputPort = pDevice->GetPort(PortIndex); |
// get MIDI port |
1100 |
if (!pMidiInputPort) throw LinuxSamplerException("There is no MIDI input port with index " + ToString(PortIndex) + "."); |
MidiInputPort* pMidiInputPort = pDevice->GetPort(PortIndex); |
1101 |
std::map<String,DeviceCreationParameter*> parameters = pMidiInputPort->DeviceParameters(); |
if (!pMidiInputPort) throw LinuxSamplerException("There is no MIDI input port with index " + ToString(PortIndex) + "."); |
1102 |
if (!parameters[ParamKey]) throw LinuxSamplerException("MIDI input device " + ToString(PortIndex) + " does not have a parameter '" + ParamKey + "'"); |
|
1103 |
|
// set port parameter value |
1104 |
|
std::map<String,DeviceRuntimeParameter*> parameters = pMidiInputPort->PortParameters(); |
1105 |
|
if (!parameters.count(ParamKey)) throw LinuxSamplerException("MIDI input device " + ToString(PortIndex) + " does not have a parameter '" + ParamKey + "'"); |
1106 |
parameters[ParamKey]->SetValue(ParamVal); |
parameters[ParamKey]->SetValue(ParamVal); |
1107 |
} |
} |
1108 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
1117 |
*/ |
*/ |
1118 |
String LSCPServer::SetAudioOutputChannel(uint ChannelAudioOutputChannel, uint AudioOutputDeviceInputChannel, uint uiSamplerChannel) { |
String LSCPServer::SetAudioOutputChannel(uint ChannelAudioOutputChannel, uint AudioOutputDeviceInputChannel, uint uiSamplerChannel) { |
1119 |
dmsg(2,("LSCPServer: SetAudioOutputChannel(ChannelAudioOutputChannel=%d, AudioOutputDeviceInputChannel=%d, SamplerChannel=%d)\n",ChannelAudioOutputChannel,AudioOutputDeviceInputChannel,uiSamplerChannel)); |
dmsg(2,("LSCPServer: SetAudioOutputChannel(ChannelAudioOutputChannel=%d, AudioOutputDeviceInputChannel=%d, SamplerChannel=%d)\n",ChannelAudioOutputChannel,AudioOutputDeviceInputChannel,uiSamplerChannel)); |
1120 |
return "ERR:0:Not implemented yet.\r\n"; //FIXME: Add support for this in resultset class? |
LSCPResultSet result; |
1121 |
|
try { |
1122 |
|
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1123 |
|
if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); |
1124 |
|
Engine* pEngine = pSamplerChannel->GetEngine(); |
1125 |
|
if (!pEngine) throw LinuxSamplerException("No engine deployed on sampler channel " + ToString(uiSamplerChannel)); |
1126 |
|
pEngine->SetOutputChannel(ChannelAudioOutputChannel, AudioOutputDeviceInputChannel); |
1127 |
|
} |
1128 |
|
catch (LinuxSamplerException e) { |
1129 |
|
result.Error(e); |
1130 |
|
} |
1131 |
|
return result.Produce(); |
1132 |
} |
} |
1133 |
|
|
1134 |
String LSCPServer::SetAudioOutputDevice(uint AudioDeviceId, uint uiSamplerChannel) { |
String LSCPServer::SetAudioOutputDevice(uint AudioDeviceId, uint uiSamplerChannel) { |
1138 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1139 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); |
1140 |
std::map<uint, AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
std::map<uint, AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
1141 |
|
if (!devices.count(AudioDeviceId)) throw LinuxSamplerException("There is no audio output device with index " + ToString(AudioDeviceId)); |
1142 |
AudioOutputDevice* pDevice = devices[AudioDeviceId]; |
AudioOutputDevice* pDevice = devices[AudioDeviceId]; |
|
if (!pDevice) throw LinuxSamplerException("There is no audio output device with index " + ToString(AudioDeviceId)); |
|
1143 |
pSamplerChannel->SetAudioOutputDevice(pDevice); |
pSamplerChannel->SetAudioOutputDevice(pDevice); |
1144 |
} |
} |
1145 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
1155 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1156 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); |
1157 |
// Driver type name aliasing... |
// Driver type name aliasing... |
1158 |
if (AudioOutputDriver == "ALSA") AudioOutputDriver = "Alsa"; |
if (AudioOutputDriver == "Alsa") AudioOutputDriver = "ALSA"; |
1159 |
if (AudioOutputDriver == "JACK") AudioOutputDriver = "Jack"; |
if (AudioOutputDriver == "Jack") AudioOutputDriver = "JACK"; |
1160 |
// Check if there's one audio output device already created |
// Check if there's one audio output device already created |
1161 |
// for the intended audio driver type (AudioOutputDriver)... |
// for the intended audio driver type (AudioOutputDriver)... |
1162 |
AudioOutputDevice *pDevice = NULL; |
AudioOutputDevice *pDevice = NULL; |
1205 |
try { |
try { |
1206 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1207 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); |
1208 |
pSamplerChannel->SetMidiInputChannel((MidiInputDevice::MidiInputPort::midi_chan_t) MIDIChannel); |
pSamplerChannel->SetMidiInputChannel((MidiInputPort::midi_chan_t) MIDIChannel); |
1209 |
} |
} |
1210 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
1211 |
result.Error(e); |
result.Error(e); |
1220 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1221 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); |
1222 |
std::map<uint, MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
std::map<uint, MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
1223 |
|
if (!devices.count(MIDIDeviceId)) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(MIDIDeviceId)); |
1224 |
MidiInputDevice* pDevice = devices[MIDIDeviceId]; |
MidiInputDevice* pDevice = devices[MIDIDeviceId]; |
|
if (!pDevice) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(MIDIDeviceId)); |
|
1225 |
pSamplerChannel->SetMidiInputDevice(pDevice); |
pSamplerChannel->SetMidiInputDevice(pDevice); |
1226 |
} |
} |
1227 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
1237 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1238 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); |
1239 |
// Driver type name aliasing... |
// Driver type name aliasing... |
1240 |
if (MidiInputDriver == "ALSA") MidiInputDriver = "Alsa"; |
if (MidiInputDriver == "Alsa") MidiInputDriver = "ALSA"; |
1241 |
// Check if there's one MIDI input device already created |
// Check if there's one MIDI input device already created |
1242 |
// for the intended MIDI driver type (MidiInputDriver)... |
// for the intended MIDI driver type (MidiInputDriver)... |
1243 |
MidiInputDevice *pDevice = NULL; |
MidiInputDevice *pDevice = NULL; |
1255 |
pDevice = pSampler->CreateMidiInputDevice(MidiInputDriver, params); |
pDevice = pSampler->CreateMidiInputDevice(MidiInputDriver, params); |
1256 |
// Make it with at least one initial port. |
// Make it with at least one initial port. |
1257 |
std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters(); |
std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters(); |
1258 |
parameters["ports"]->SetValue("1"); |
parameters["PORTS"]->SetValue("1"); |
1259 |
} |
} |
1260 |
// Must have a device... |
// Must have a device... |
1261 |
if (pDevice == NULL) |
if (pDevice == NULL) |
1280 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1281 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); |
1282 |
std::map<uint, MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
std::map<uint, MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
1283 |
|
if (!devices.count(MIDIDeviceId)) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(MIDIDeviceId)); |
1284 |
MidiInputDevice* pDevice = devices[MIDIDeviceId]; |
MidiInputDevice* pDevice = devices[MIDIDeviceId]; |
1285 |
if (!pDevice) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(MIDIDeviceId)); |
pSamplerChannel->SetMidiInput(pDevice, MIDIPort, (MidiInputPort::midi_chan_t) MIDIChannel); |
|
pSamplerChannel->SetMidiInput(pDevice, MIDIPort, (MidiInputDevice::MidiInputPort::midi_chan_t) MIDIChannel); |
|
1286 |
} |
} |
1287 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
1288 |
result.Error(e); |
result.Error(e); |
1294 |
* Will be called by the parser to change the global volume factor on a |
* Will be called by the parser to change the global volume factor on a |
1295 |
* particular sampler channel. |
* particular sampler channel. |
1296 |
*/ |
*/ |
1297 |
String LSCPServer::SetVolume(double Volume, uint uiSamplerChannel) { |
String LSCPServer::SetVolume(double dVolume, uint uiSamplerChannel) { |
1298 |
dmsg(2,("LSCPServer: SetVolume(Volume=%f, SamplerChannel=%d)\n", Volume, uiSamplerChannel)); |
dmsg(2,("LSCPServer: SetVolume(Volume=%f, SamplerChannel=%d)\n", dVolume, uiSamplerChannel)); |
1299 |
LSCPResultSet result; |
LSCPResultSet result; |
1300 |
try { |
try { |
1301 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1302 |
if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds"); |
if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds"); |
1303 |
Engine* pEngine = pSamplerChannel->GetEngine(); |
Engine* pEngine = pSamplerChannel->GetEngine(); |
1304 |
if (!pEngine) throw LinuxSamplerException("No engine loaded on channel"); |
if (!pEngine) throw LinuxSamplerException("No engine loaded on channel"); |
1305 |
pEngine->Volume(Volume); |
pEngine->Volume(dVolume); |
1306 |
} |
} |
1307 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
1308 |
result.Error(e); |
result.Error(e); |
1329 |
return result.Produce(); |
return result.Produce(); |
1330 |
} |
} |
1331 |
|
|
1332 |
|
/** |
1333 |
|
* Will be called by the parser to reset the whole sampler. |
1334 |
|
*/ |
1335 |
|
String LSCPServer::ResetSampler() { |
1336 |
|
dmsg(2,("LSCPServer: ResetSampler()\n")); |
1337 |
|
pSampler->Reset(); |
1338 |
|
LSCPResultSet result; |
1339 |
|
return result.Produce(); |
1340 |
|
} |
1341 |
|
|
1342 |
/** |
/** |
1343 |
* Will be called by the parser to subscribe a client (frontend) on the |
* Will be called by the parser to subscribe a client (frontend) on the |
1344 |
* server for receiving event messages. |
* server for receiving event messages. |