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 * |
24 |
#include "lscpserver.h" |
#include "lscpserver.h" |
25 |
#include "lscpresultset.h" |
#include "lscpresultset.h" |
26 |
#include "lscpevent.h" |
#include "lscpevent.h" |
27 |
//#include "../common/global.h" |
#include "../common/global.h" |
28 |
|
|
29 |
#include <fcntl.h> |
#include <fcntl.h> |
30 |
|
|
66 |
SocketAddress.sin_addr.s_addr = addr; |
SocketAddress.sin_addr.s_addr = addr; |
67 |
SocketAddress.sin_port = port; |
SocketAddress.sin_port = port; |
68 |
this->pSampler = pSampler; |
this->pSampler = pSampler; |
69 |
|
LSCPEvent::RegisterEvent(LSCPEvent::event_audio_device_count, "AUDIO_OUTPUT_DEVICE_COUNT"); |
70 |
|
LSCPEvent::RegisterEvent(LSCPEvent::event_audio_device_info, "AUDIO_OUTPUT_DEVICE_INFO"); |
71 |
|
LSCPEvent::RegisterEvent(LSCPEvent::event_midi_device_count, "MIDI_INPUT_DEVICE_COUNT"); |
72 |
|
LSCPEvent::RegisterEvent(LSCPEvent::event_midi_device_info, "MIDI_INPUT_DEVICE_INFO"); |
73 |
LSCPEvent::RegisterEvent(LSCPEvent::event_channel_count, "CHANNEL_COUNT"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_channel_count, "CHANNEL_COUNT"); |
74 |
LSCPEvent::RegisterEvent(LSCPEvent::event_voice_count, "VOICE_COUNT"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_voice_count, "VOICE_COUNT"); |
75 |
LSCPEvent::RegisterEvent(LSCPEvent::event_stream_count, "STREAM_COUNT"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_stream_count, "STREAM_COUNT"); |
76 |
LSCPEvent::RegisterEvent(LSCPEvent::event_buffer_fill, "BUFFER_FILL"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_buffer_fill, "BUFFER_FILL"); |
77 |
LSCPEvent::RegisterEvent(LSCPEvent::event_channel_info, "CHANNEL_INFO"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_channel_info, "CHANNEL_INFO"); |
78 |
|
LSCPEvent::RegisterEvent(LSCPEvent::event_midi_instr_map_count, "MIDI_INSTRUMENT_MAP_COUNT"); |
79 |
|
LSCPEvent::RegisterEvent(LSCPEvent::event_midi_instr_map_info, "MIDI_INSTRUMENT_MAP_INFO"); |
80 |
|
LSCPEvent::RegisterEvent(LSCPEvent::event_midi_instr_count, "MIDI_INSTRUMENT_COUNT"); |
81 |
|
LSCPEvent::RegisterEvent(LSCPEvent::event_midi_instr_info, "MIDI_INSTRUMENT_INFO"); |
82 |
LSCPEvent::RegisterEvent(LSCPEvent::event_misc, "MISCELLANEOUS"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_misc, "MISCELLANEOUS"); |
83 |
|
LSCPEvent::RegisterEvent(LSCPEvent::event_total_voice_count, "TOTAL_VOICE_COUNT"); |
84 |
hSocket = -1; |
hSocket = -1; |
85 |
} |
} |
86 |
|
|
136 |
FD_SET(hSocket, &fdSet); |
FD_SET(hSocket, &fdSet); |
137 |
int maxSessions = hSocket; |
int maxSessions = hSocket; |
138 |
|
|
139 |
|
timeval timeout; |
140 |
|
|
141 |
while (true) { |
while (true) { |
142 |
fd_set selectSet = fdSet; |
// check if some engine channel's parameter / status changed, if so notify the respective LSCP event subscribers |
143 |
int retval = select(maxSessions+1, &selectSet, NULL, NULL, NULL); |
{ |
144 |
|
std::set<EngineChannel*> engineChannels = EngineChannelFactory::EngineChannelInstances(); |
145 |
|
std::set<EngineChannel*>::iterator itEngineChannel = engineChannels.begin(); |
146 |
|
std::set<EngineChannel*>::iterator itEnd = engineChannels.end(); |
147 |
|
for (; itEngineChannel != itEnd; ++itEngineChannel) { |
148 |
|
if ((*itEngineChannel)->StatusChanged()) { |
149 |
|
SendLSCPNotify(LSCPEvent(LSCPEvent::event_channel_info, (*itEngineChannel)->iSamplerChannelIndex)); |
150 |
|
} |
151 |
|
} |
152 |
|
} |
153 |
|
|
154 |
|
//Now let's deliver late notifies (if any) |
155 |
|
NotifyBufferMutex.Lock(); |
156 |
|
for (std::map<int,String>::iterator iterNotify = bufferedNotifies.begin(); iterNotify != bufferedNotifies.end(); iterNotify++) { |
157 |
|
#ifdef MSG_NOSIGNAL |
158 |
|
send(iterNotify->first, iterNotify->second.c_str(), iterNotify->second.size(), MSG_NOSIGNAL); |
159 |
|
#else |
160 |
|
send(iterNotify->first, iterNotify->second.c_str(), iterNotify->second.size(), 0); |
161 |
|
#endif |
162 |
|
} |
163 |
|
bufferedNotifies.clear(); |
164 |
|
NotifyBufferMutex.Unlock(); |
165 |
|
|
166 |
|
fd_set selectSet = fdSet; |
167 |
|
timeout.tv_sec = 0; |
168 |
|
timeout.tv_usec = 100000; |
169 |
|
|
170 |
|
int retval = select(maxSessions+1, &selectSet, NULL, NULL, &timeout); |
171 |
|
|
172 |
if (retval == 0) |
if (retval == 0) |
173 |
continue; //Nothing try again |
continue; //Nothing try again |
174 |
if (retval == -1) { |
if (retval == -1) { |
228 |
break; |
break; |
229 |
} |
} |
230 |
} |
} |
|
|
|
|
// 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(), 0); |
|
|
bufferedNotifies.erase(iterNotify); |
|
|
} |
|
|
NotifyBufferMutex.Unlock(); |
|
231 |
} |
} |
232 |
} |
} |
233 |
|
|
274 |
while (true) { |
while (true) { |
275 |
if (NotifyMutex.Trylock()) { |
if (NotifyMutex.Trylock()) { |
276 |
for(;iter != end; iter++) |
for(;iter != end; iter++) |
277 |
|
#ifdef MSG_NOSIGNAL |
278 |
|
send(*iter, notify.c_str(), notify.size(), MSG_NOSIGNAL); |
279 |
|
#else |
280 |
send(*iter, notify.c_str(), notify.size(), 0); |
send(*iter, notify.c_str(), notify.size(), 0); |
281 |
|
#endif |
282 |
NotifyMutex.Unlock(); |
NotifyMutex.Unlock(); |
283 |
break; |
break; |
284 |
} else { |
} else { |
330 |
continue; //Ignore CR |
continue; //Ignore CR |
331 |
if (c == '\n') { |
if (c == '\n') { |
332 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_misc, "Received \'" + bufferedCommands[socket] + "\' on socket", socket)); |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_misc, "Received \'" + bufferedCommands[socket] + "\' on socket", socket)); |
333 |
bufferedCommands[socket] += "\n"; |
bufferedCommands[socket] += "\r\n"; |
334 |
return true; //Complete command was read |
return true; //Complete command was read |
335 |
} |
} |
336 |
bufferedCommands[socket] += c; |
bufferedCommands[socket] += c; |
387 |
dmsg(2,("LSCPServer::AnswerClient(ReturnMessage=%s)", ReturnMessage.c_str())); |
dmsg(2,("LSCPServer::AnswerClient(ReturnMessage=%s)", ReturnMessage.c_str())); |
388 |
if (currentSocket != -1) { |
if (currentSocket != -1) { |
389 |
NotifyMutex.Lock(); |
NotifyMutex.Lock(); |
390 |
|
#ifdef MSG_NOSIGNAL |
391 |
|
send(currentSocket, ReturnMessage.c_str(), ReturnMessage.size(), MSG_NOSIGNAL); |
392 |
|
#else |
393 |
send(currentSocket, ReturnMessage.c_str(), ReturnMessage.size(), 0); |
send(currentSocket, ReturnMessage.c_str(), ReturnMessage.size(), 0); |
394 |
|
#endif |
395 |
NotifyMutex.Unlock(); |
NotifyMutex.Unlock(); |
396 |
} |
} |
397 |
} |
} |
435 |
AudioOutputDevice* pDevice = pSampler->CreateAudioOutputDevice(Driver, Parameters); |
AudioOutputDevice* pDevice = pSampler->CreateAudioOutputDevice(Driver, Parameters); |
436 |
// search for the created device to get its index |
// search for the created device to get its index |
437 |
int index = GetAudioOutputDeviceIndex(pDevice); |
int index = GetAudioOutputDeviceIndex(pDevice); |
438 |
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."); |
439 |
result = index; // success |
result = index; // success |
440 |
} |
} |
441 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
442 |
result.Error(e); |
result.Error(e); |
443 |
} |
} |
444 |
return result.Produce(); |
return result.Produce(); |
451 |
MidiInputDevice* pDevice = pSampler->CreateMidiInputDevice(Driver, Parameters); |
MidiInputDevice* pDevice = pSampler->CreateMidiInputDevice(Driver, Parameters); |
452 |
// search for the created device to get its index |
// search for the created device to get its index |
453 |
int index = GetMidiInputDeviceIndex(pDevice); |
int index = GetMidiInputDeviceIndex(pDevice); |
454 |
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."); |
455 |
result = index; // success |
result = index; // success |
456 |
} |
} |
457 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
458 |
result.Error(e); |
result.Error(e); |
459 |
} |
} |
460 |
return result.Produce(); |
return result.Produce(); |
465 |
LSCPResultSet result; |
LSCPResultSet result; |
466 |
try { |
try { |
467 |
std::map<uint, AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
std::map<uint, AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
468 |
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) + "."); |
469 |
AudioOutputDevice* pDevice = devices[DeviceIndex]; |
AudioOutputDevice* pDevice = devices[DeviceIndex]; |
470 |
pSampler->DestroyAudioOutputDevice(pDevice); |
pSampler->DestroyAudioOutputDevice(pDevice); |
471 |
} |
} |
472 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
473 |
result.Error(e); |
result.Error(e); |
474 |
} |
} |
475 |
return result.Produce(); |
return result.Produce(); |
480 |
LSCPResultSet result; |
LSCPResultSet result; |
481 |
try { |
try { |
482 |
std::map<uint, MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
std::map<uint, MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
483 |
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) + "."); |
484 |
MidiInputDevice* pDevice = devices[DeviceIndex]; |
MidiInputDevice* pDevice = devices[DeviceIndex]; |
485 |
pSampler->DestroyMidiInputDevice(pDevice); |
pSampler->DestroyMidiInputDevice(pDevice); |
486 |
} |
} |
487 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
488 |
result.Error(e); |
result.Error(e); |
489 |
} |
} |
490 |
return result.Produce(); |
return result.Produce(); |
498 |
LSCPResultSet result; |
LSCPResultSet result; |
499 |
try { |
try { |
500 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
501 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
502 |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
503 |
if (!pEngineChannel) throw LinuxSamplerException("No engine type assigned to sampler channel yet"); |
if (!pEngineChannel) throw Exception("No engine type assigned to sampler channel yet"); |
504 |
if (!pSamplerChannel->GetAudioOutputDevice()) |
if (!pSamplerChannel->GetAudioOutputDevice()) |
505 |
throw LinuxSamplerException("No audio output device connected to sampler channel"); |
throw Exception("No audio output device connected to sampler channel"); |
506 |
if (bBackground) { |
if (bBackground) { |
507 |
InstrumentLoader.StartNewLoad(Filename, uiInstrument, pEngineChannel); |
InstrumentManager::instrument_id_t id; |
508 |
|
id.FileName = Filename; |
509 |
|
id.Index = uiInstrument; |
510 |
|
InstrumentManager::LoadInstrumentInBackground(id, pEngineChannel); |
511 |
} |
} |
512 |
else { |
else { |
513 |
// tell the engine channel which instrument to load |
// tell the engine channel which instrument to load |
516 |
pEngineChannel->LoadInstrument(); |
pEngineChannel->LoadInstrument(); |
517 |
} |
} |
518 |
} |
} |
519 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
520 |
result.Error(e); |
result.Error(e); |
521 |
} |
} |
522 |
return result.Produce(); |
return result.Produce(); |
527 |
* sampler channel. |
* sampler channel. |
528 |
*/ |
*/ |
529 |
String LSCPServer::SetEngineType(String EngineName, uint uiSamplerChannel) { |
String LSCPServer::SetEngineType(String EngineName, uint uiSamplerChannel) { |
530 |
dmsg(2,("LSCPServer: LoadEngine(EngineName=%s,SamplerChannel=%d)\n", EngineName.c_str(), uiSamplerChannel)); |
dmsg(2,("LSCPServer: SetEngineType(EngineName=%s,uiSamplerChannel=%d)\n", EngineName.c_str(), uiSamplerChannel)); |
531 |
LSCPResultSet result; |
LSCPResultSet result; |
532 |
try { |
try { |
533 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
534 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
535 |
LockRTNotify(); |
LockRTNotify(); |
536 |
pSamplerChannel->SetEngineType(EngineName); |
pSamplerChannel->SetEngineType(EngineName); |
537 |
|
if(HasSoloChannel()) pSamplerChannel->GetEngineChannel()->SetMute(-1); |
538 |
UnlockRTNotify(); |
UnlockRTNotify(); |
539 |
} |
} |
540 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
541 |
result.Error(e); |
result.Error(e); |
542 |
} |
} |
543 |
return result.Produce(); |
return result.Produce(); |
575 |
*/ |
*/ |
576 |
String LSCPServer::AddChannel() { |
String LSCPServer::AddChannel() { |
577 |
dmsg(2,("LSCPServer: AddChannel()\n")); |
dmsg(2,("LSCPServer: AddChannel()\n")); |
578 |
|
LockRTNotify(); |
579 |
SamplerChannel* pSamplerChannel = pSampler->AddSamplerChannel(); |
SamplerChannel* pSamplerChannel = pSampler->AddSamplerChannel(); |
580 |
|
UnlockRTNotify(); |
581 |
LSCPResultSet result(pSamplerChannel->Index()); |
LSCPResultSet result(pSamplerChannel->Index()); |
582 |
return result.Produce(); |
return result.Produce(); |
583 |
} |
} |
599 |
*/ |
*/ |
600 |
String LSCPServer::GetAvailableEngines() { |
String LSCPServer::GetAvailableEngines() { |
601 |
dmsg(2,("LSCPServer: GetAvailableEngines()\n")); |
dmsg(2,("LSCPServer: GetAvailableEngines()\n")); |
602 |
LSCPResultSet result("1"); |
LSCPResultSet result; |
603 |
|
try { |
604 |
|
int n = EngineFactory::AvailableEngineTypes().size(); |
605 |
|
result.Add(n); |
606 |
|
} |
607 |
|
catch (Exception e) { |
608 |
|
result.Error(e); |
609 |
|
} |
610 |
return result.Produce(); |
return result.Produce(); |
611 |
} |
} |
612 |
|
|
615 |
*/ |
*/ |
616 |
String LSCPServer::ListAvailableEngines() { |
String LSCPServer::ListAvailableEngines() { |
617 |
dmsg(2,("LSCPServer: ListAvailableEngines()\n")); |
dmsg(2,("LSCPServer: ListAvailableEngines()\n")); |
618 |
LSCPResultSet result("\'GIG\'"); |
LSCPResultSet result; |
619 |
|
try { |
620 |
|
String s = EngineFactory::AvailableEngineTypesAsString(); |
621 |
|
result.Add(s); |
622 |
|
} |
623 |
|
catch (Exception e) { |
624 |
|
result.Error(e); |
625 |
|
} |
626 |
return result.Produce(); |
return result.Produce(); |
627 |
} |
} |
628 |
|
|
633 |
String LSCPServer::GetEngineInfo(String EngineName) { |
String LSCPServer::GetEngineInfo(String EngineName) { |
634 |
dmsg(2,("LSCPServer: GetEngineInfo(EngineName=%s)\n", EngineName.c_str())); |
dmsg(2,("LSCPServer: GetEngineInfo(EngineName=%s)\n", EngineName.c_str())); |
635 |
LSCPResultSet result; |
LSCPResultSet result; |
636 |
|
LockRTNotify(); |
637 |
try { |
try { |
638 |
Engine* pEngine = EngineFactory::Create(EngineName); |
Engine* pEngine = EngineFactory::Create(EngineName); |
639 |
result.Add("DESCRIPTION", pEngine->Description()); |
result.Add("DESCRIPTION", pEngine->Description()); |
640 |
result.Add("VERSION", pEngine->Version()); |
result.Add("VERSION", pEngine->Version()); |
641 |
EngineFactory::Destroy(pEngine); |
EngineFactory::Destroy(pEngine); |
642 |
} |
} |
643 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
644 |
result.Error(e); |
result.Error(e); |
645 |
} |
} |
646 |
|
UnlockRTNotify(); |
647 |
return result.Produce(); |
return result.Produce(); |
648 |
} |
} |
649 |
|
|
656 |
LSCPResultSet result; |
LSCPResultSet result; |
657 |
try { |
try { |
658 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
659 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
660 |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
661 |
|
|
662 |
//Defaults values |
//Defaults values |
668 |
int InstrumentStatus = -1; |
int InstrumentStatus = -1; |
669 |
int AudioOutputChannels = 0; |
int AudioOutputChannels = 0; |
670 |
String AudioRouting; |
String AudioRouting; |
671 |
|
int Mute = 0; |
672 |
|
bool Solo = false; |
673 |
|
String MidiInstrumentMap; |
674 |
|
|
675 |
if (pEngineChannel) { |
if (pEngineChannel) { |
676 |
EngineName = pEngineChannel->EngineName(); |
EngineName = pEngineChannel->EngineName(); |
686 |
if (AudioRouting != "") AudioRouting += ","; |
if (AudioRouting != "") AudioRouting += ","; |
687 |
AudioRouting += ToString(pEngineChannel->OutputChannel(chan)); |
AudioRouting += ToString(pEngineChannel->OutputChannel(chan)); |
688 |
} |
} |
689 |
|
Mute = pEngineChannel->GetMute(); |
690 |
|
Solo = pEngineChannel->GetSolo(); |
691 |
|
if (pEngineChannel->UsesNoMidiInstrumentMap()) |
692 |
|
MidiInstrumentMap = "NONE"; |
693 |
|
else if (pEngineChannel->UsesDefaultMidiInstrumentMap()) |
694 |
|
MidiInstrumentMap = "DEFAULT"; |
695 |
|
else |
696 |
|
MidiInstrumentMap = ToString(pEngineChannel->GetMidiInstrumentMap()); |
697 |
} |
} |
698 |
|
|
699 |
result.Add("ENGINE_NAME", EngineName); |
result.Add("ENGINE_NAME", EngineName); |
706 |
|
|
707 |
result.Add("MIDI_INPUT_DEVICE", GetMidiInputDeviceIndex(pSamplerChannel->GetMidiInputDevice())); |
result.Add("MIDI_INPUT_DEVICE", GetMidiInputDeviceIndex(pSamplerChannel->GetMidiInputDevice())); |
708 |
result.Add("MIDI_INPUT_PORT", pSamplerChannel->GetMidiInputPort()); |
result.Add("MIDI_INPUT_PORT", pSamplerChannel->GetMidiInputPort()); |
709 |
if (pSamplerChannel->GetMidiInputChannel() == MidiInputPort::midi_chan_all) result.Add("MIDI_INPUT_CHANNEL", "ALL"); |
if (pSamplerChannel->GetMidiInputChannel() == midi_chan_all) result.Add("MIDI_INPUT_CHANNEL", "ALL"); |
710 |
else result.Add("MIDI_INPUT_CHANNEL", pSamplerChannel->GetMidiInputChannel()); |
else result.Add("MIDI_INPUT_CHANNEL", pSamplerChannel->GetMidiInputChannel()); |
711 |
|
|
712 |
result.Add("INSTRUMENT_FILE", InstrumentFileName); |
result.Add("INSTRUMENT_FILE", InstrumentFileName); |
713 |
result.Add("INSTRUMENT_NR", InstrumentIndex); |
result.Add("INSTRUMENT_NR", InstrumentIndex); |
714 |
result.Add("INSTRUMENT_NAME", InstrumentName); |
result.Add("INSTRUMENT_NAME", InstrumentName); |
715 |
result.Add("INSTRUMENT_STATUS", InstrumentStatus); |
result.Add("INSTRUMENT_STATUS", InstrumentStatus); |
716 |
|
result.Add("MUTE", Mute == -1 ? "MUTED_BY_SOLO" : (Mute ? "true" : "false")); |
717 |
|
result.Add("SOLO", Solo); |
718 |
|
result.Add("MIDI_INSTRUMENT_MAP", MidiInstrumentMap); |
719 |
} |
} |
720 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
721 |
result.Error(e); |
result.Error(e); |
722 |
} |
} |
723 |
return result.Produce(); |
return result.Produce(); |
732 |
LSCPResultSet result; |
LSCPResultSet result; |
733 |
try { |
try { |
734 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
735 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
736 |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
737 |
if (!pEngineChannel) throw LinuxSamplerException("No engine loaded on sampler channel"); |
if (!pEngineChannel) throw Exception("No engine loaded on sampler channel"); |
738 |
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"); |
739 |
result.Add(pEngineChannel->GetEngine()->VoiceCount()); |
result.Add(pEngineChannel->GetEngine()->VoiceCount()); |
740 |
} |
} |
741 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
742 |
result.Error(e); |
result.Error(e); |
743 |
} |
} |
744 |
return result.Produce(); |
return result.Produce(); |
753 |
LSCPResultSet result; |
LSCPResultSet result; |
754 |
try { |
try { |
755 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
756 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
757 |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
758 |
if (!pEngineChannel) throw LinuxSamplerException("No engine type assigned to sampler channel"); |
if (!pEngineChannel) throw Exception("No engine type assigned to sampler channel"); |
759 |
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"); |
760 |
result.Add(pEngineChannel->GetEngine()->DiskStreamCount()); |
result.Add(pEngineChannel->GetEngine()->DiskStreamCount()); |
761 |
} |
} |
762 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
763 |
result.Error(e); |
result.Error(e); |
764 |
} |
} |
765 |
return result.Produce(); |
return result.Produce(); |
774 |
LSCPResultSet result; |
LSCPResultSet result; |
775 |
try { |
try { |
776 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
777 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
778 |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
779 |
if (!pEngineChannel) throw LinuxSamplerException("No engine type assigned to sampler channel"); |
if (!pEngineChannel) throw Exception("No engine type assigned to sampler channel"); |
780 |
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"); |
781 |
if (!pEngineChannel->GetEngine()->DiskStreamSupported()) result.Add("NA"); |
if (!pEngineChannel->GetEngine()->DiskStreamSupported()) result.Add("NA"); |
782 |
else { |
else { |
783 |
switch (ResponseType) { |
switch (ResponseType) { |
788 |
result.Add(pEngineChannel->GetEngine()->DiskStreamBufferFillPercentage()); |
result.Add(pEngineChannel->GetEngine()->DiskStreamBufferFillPercentage()); |
789 |
break; |
break; |
790 |
default: |
default: |
791 |
throw LinuxSamplerException("Unknown fill response type"); |
throw Exception("Unknown fill response type"); |
792 |
} |
} |
793 |
} |
} |
794 |
} |
} |
795 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
796 |
result.Error(e); |
result.Error(e); |
797 |
} |
} |
798 |
return result.Produce(); |
return result.Produce(); |
805 |
int n = AudioOutputDeviceFactory::AvailableDrivers().size(); |
int n = AudioOutputDeviceFactory::AvailableDrivers().size(); |
806 |
result.Add(n); |
result.Add(n); |
807 |
} |
} |
808 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
809 |
result.Error(e); |
result.Error(e); |
810 |
} |
} |
811 |
return result.Produce(); |
return result.Produce(); |
818 |
String s = AudioOutputDeviceFactory::AvailableDriversAsString(); |
String s = AudioOutputDeviceFactory::AvailableDriversAsString(); |
819 |
result.Add(s); |
result.Add(s); |
820 |
} |
} |
821 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
822 |
result.Error(e); |
result.Error(e); |
823 |
} |
} |
824 |
return result.Produce(); |
return result.Produce(); |
831 |
int n = MidiInputDeviceFactory::AvailableDrivers().size(); |
int n = MidiInputDeviceFactory::AvailableDrivers().size(); |
832 |
result.Add(n); |
result.Add(n); |
833 |
} |
} |
834 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
835 |
result.Error(e); |
result.Error(e); |
836 |
} |
} |
837 |
return result.Produce(); |
return result.Produce(); |
844 |
String s = MidiInputDeviceFactory::AvailableDriversAsString(); |
String s = MidiInputDeviceFactory::AvailableDriversAsString(); |
845 |
result.Add(s); |
result.Add(s); |
846 |
} |
} |
847 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
848 |
result.Error(e); |
result.Error(e); |
849 |
} |
} |
850 |
return result.Produce(); |
return result.Produce(); |
868 |
result.Add("PARAMETERS", s); |
result.Add("PARAMETERS", s); |
869 |
} |
} |
870 |
} |
} |
871 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
872 |
result.Error(e); |
result.Error(e); |
873 |
} |
} |
874 |
return result.Produce(); |
return result.Produce(); |
892 |
result.Add("PARAMETERS", s); |
result.Add("PARAMETERS", s); |
893 |
} |
} |
894 |
} |
} |
895 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
896 |
result.Error(e); |
result.Error(e); |
897 |
} |
} |
898 |
return result.Produce(); |
return result.Produce(); |
919 |
if (oRangeMax) result.Add("RANGE_MAX", *oRangeMax); |
if (oRangeMax) result.Add("RANGE_MAX", *oRangeMax); |
920 |
if (oPossibilities) result.Add("POSSIBILITIES", *oPossibilities); |
if (oPossibilities) result.Add("POSSIBILITIES", *oPossibilities); |
921 |
} |
} |
922 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
923 |
result.Error(e); |
result.Error(e); |
924 |
} |
} |
925 |
return result.Produce(); |
return result.Produce(); |
946 |
if (oRangeMax) result.Add("RANGE_MAX", *oRangeMax); |
if (oRangeMax) result.Add("RANGE_MAX", *oRangeMax); |
947 |
if (oPossibilities) result.Add("POSSIBILITIES", *oPossibilities); |
if (oPossibilities) result.Add("POSSIBILITIES", *oPossibilities); |
948 |
} |
} |
949 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
950 |
result.Error(e); |
result.Error(e); |
951 |
} |
} |
952 |
return result.Produce(); |
return result.Produce(); |
959 |
uint count = pSampler->AudioOutputDevices(); |
uint count = pSampler->AudioOutputDevices(); |
960 |
result.Add(count); // success |
result.Add(count); // success |
961 |
} |
} |
962 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
963 |
result.Error(e); |
result.Error(e); |
964 |
} |
} |
965 |
return result.Produce(); |
return result.Produce(); |
972 |
uint count = pSampler->MidiInputDevices(); |
uint count = pSampler->MidiInputDevices(); |
973 |
result.Add(count); // success |
result.Add(count); // success |
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(); |
1010 |
} |
} |
1011 |
result.Add(s); |
result.Add(s); |
1012 |
} |
} |
1013 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
1014 |
result.Error(e); |
result.Error(e); |
1015 |
} |
} |
1016 |
return result.Produce(); |
return result.Produce(); |
1021 |
LSCPResultSet result; |
LSCPResultSet result; |
1022 |
try { |
try { |
1023 |
std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
1024 |
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) + "."); |
1025 |
AudioOutputDevice* pDevice = devices[DeviceIndex]; |
AudioOutputDevice* pDevice = devices[DeviceIndex]; |
1026 |
result.Add("DRIVER", pDevice->Driver()); |
result.Add("DRIVER", pDevice->Driver()); |
1027 |
std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters(); |
std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters(); |
1030 |
result.Add(iter->first, iter->second->Value()); |
result.Add(iter->first, iter->second->Value()); |
1031 |
} |
} |
1032 |
} |
} |
1033 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
1034 |
result.Error(e); |
result.Error(e); |
1035 |
} |
} |
1036 |
return result.Produce(); |
return result.Produce(); |
1041 |
LSCPResultSet result; |
LSCPResultSet result; |
1042 |
try { |
try { |
1043 |
std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
1044 |
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) + "."); |
1045 |
MidiInputDevice* pDevice = devices[DeviceIndex]; |
MidiInputDevice* pDevice = devices[DeviceIndex]; |
1046 |
result.Add("DRIVER", pDevice->Driver()); |
result.Add("DRIVER", pDevice->Driver()); |
1047 |
std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters(); |
std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters(); |
1050 |
result.Add(iter->first, iter->second->Value()); |
result.Add(iter->first, iter->second->Value()); |
1051 |
} |
} |
1052 |
} |
} |
1053 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
1054 |
result.Error(e); |
result.Error(e); |
1055 |
} |
} |
1056 |
return result.Produce(); |
return result.Produce(); |
1061 |
try { |
try { |
1062 |
// get MIDI input device |
// get MIDI input device |
1063 |
std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
1064 |
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) + "."); |
1065 |
MidiInputDevice* pDevice = devices[DeviceIndex]; |
MidiInputDevice* pDevice = devices[DeviceIndex]; |
1066 |
|
|
1067 |
// get MIDI port |
// get MIDI port |
1068 |
MidiInputPort* pMidiInputPort = pDevice->GetPort(PortIndex); |
MidiInputPort* pMidiInputPort = pDevice->GetPort(PortIndex); |
1069 |
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) + "."); |
1070 |
|
|
1071 |
// return the values of all MIDI port parameters |
// return the values of all MIDI port parameters |
1072 |
std::map<String,DeviceRuntimeParameter*> parameters = pMidiInputPort->PortParameters(); |
std::map<String,DeviceRuntimeParameter*> parameters = pMidiInputPort->PortParameters(); |
1075 |
result.Add(iter->first, iter->second->Value()); |
result.Add(iter->first, iter->second->Value()); |
1076 |
} |
} |
1077 |
} |
} |
1078 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
1079 |
result.Error(e); |
result.Error(e); |
1080 |
} |
} |
1081 |
return result.Produce(); |
return result.Produce(); |
1087 |
try { |
try { |
1088 |
// get audio output device |
// get audio output device |
1089 |
std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
1090 |
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) + "."); |
1091 |
AudioOutputDevice* pDevice = devices[DeviceId]; |
AudioOutputDevice* pDevice = devices[DeviceId]; |
1092 |
|
|
1093 |
// get audio channel |
// get audio channel |
1094 |
AudioChannel* pChannel = pDevice->Channel(ChannelId); |
AudioChannel* pChannel = pDevice->Channel(ChannelId); |
1095 |
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) + "."); |
1096 |
|
|
1097 |
// return the values of all audio channel parameters |
// return the values of all audio channel parameters |
1098 |
std::map<String,DeviceRuntimeParameter*> parameters = pChannel->ChannelParameters(); |
std::map<String,DeviceRuntimeParameter*> parameters = pChannel->ChannelParameters(); |
1101 |
result.Add(iter->first, iter->second->Value()); |
result.Add(iter->first, iter->second->Value()); |
1102 |
} |
} |
1103 |
} |
} |
1104 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
1105 |
result.Error(e); |
result.Error(e); |
1106 |
} |
} |
1107 |
return result.Produce(); |
return result.Produce(); |
1113 |
try { |
try { |
1114 |
// get MIDI input device |
// get MIDI input device |
1115 |
std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
1116 |
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) + "."); |
1117 |
MidiInputDevice* pDevice = devices[DeviceId]; |
MidiInputDevice* pDevice = devices[DeviceId]; |
1118 |
|
|
1119 |
// get midi port |
// get midi port |
1120 |
MidiInputPort* pPort = pDevice->GetPort(PortId); |
MidiInputPort* pPort = pDevice->GetPort(PortId); |
1121 |
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) + "."); |
1122 |
|
|
1123 |
// get desired port parameter |
// get desired port parameter |
1124 |
std::map<String,DeviceRuntimeParameter*> parameters = pPort->PortParameters(); |
std::map<String,DeviceRuntimeParameter*> parameters = pPort->PortParameters(); |
1125 |
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 + "'."); |
1126 |
DeviceRuntimeParameter* pParameter = parameters[ParameterName]; |
DeviceRuntimeParameter* pParameter = parameters[ParameterName]; |
1127 |
|
|
1128 |
// return all fields of this audio channel parameter |
// return all fields of this audio channel parameter |
1134 |
if (pParameter->RangeMax()) result.Add("RANGE_MAX", *pParameter->RangeMax()); |
if (pParameter->RangeMax()) result.Add("RANGE_MAX", *pParameter->RangeMax()); |
1135 |
if (pParameter->Possibilities()) result.Add("POSSIBILITIES", *pParameter->Possibilities()); |
if (pParameter->Possibilities()) result.Add("POSSIBILITIES", *pParameter->Possibilities()); |
1136 |
} |
} |
1137 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
1138 |
result.Error(e); |
result.Error(e); |
1139 |
} |
} |
1140 |
return result.Produce(); |
return result.Produce(); |
1146 |
try { |
try { |
1147 |
// get audio output device |
// get audio output device |
1148 |
std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
1149 |
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) + "."); |
1150 |
AudioOutputDevice* pDevice = devices[DeviceId]; |
AudioOutputDevice* pDevice = devices[DeviceId]; |
1151 |
|
|
1152 |
// get audio channel |
// get audio channel |
1153 |
AudioChannel* pChannel = pDevice->Channel(ChannelId); |
AudioChannel* pChannel = pDevice->Channel(ChannelId); |
1154 |
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) + "."); |
1155 |
|
|
1156 |
// get desired audio channel parameter |
// get desired audio channel parameter |
1157 |
std::map<String,DeviceRuntimeParameter*> parameters = pChannel->ChannelParameters(); |
std::map<String,DeviceRuntimeParameter*> parameters = pChannel->ChannelParameters(); |
1158 |
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 + "'."); |
1159 |
DeviceRuntimeParameter* pParameter = parameters[ParameterName]; |
DeviceRuntimeParameter* pParameter = parameters[ParameterName]; |
1160 |
|
|
1161 |
// return all fields of this audio channel parameter |
// return all fields of this audio channel parameter |
1167 |
if (pParameter->RangeMax()) result.Add("RANGE_MAX", *pParameter->RangeMax()); |
if (pParameter->RangeMax()) result.Add("RANGE_MAX", *pParameter->RangeMax()); |
1168 |
if (pParameter->Possibilities()) result.Add("POSSIBILITIES", *pParameter->Possibilities()); |
if (pParameter->Possibilities()) result.Add("POSSIBILITIES", *pParameter->Possibilities()); |
1169 |
} |
} |
1170 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
1171 |
result.Error(e); |
result.Error(e); |
1172 |
} |
} |
1173 |
return result.Produce(); |
return result.Produce(); |
1179 |
try { |
try { |
1180 |
// get audio output device |
// get audio output device |
1181 |
std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
1182 |
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) + "."); |
1183 |
AudioOutputDevice* pDevice = devices[DeviceId]; |
AudioOutputDevice* pDevice = devices[DeviceId]; |
1184 |
|
|
1185 |
// get audio channel |
// get audio channel |
1186 |
AudioChannel* pChannel = pDevice->Channel(ChannelId); |
AudioChannel* pChannel = pDevice->Channel(ChannelId); |
1187 |
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) + "."); |
1188 |
|
|
1189 |
// get desired audio channel parameter |
// get desired audio channel parameter |
1190 |
std::map<String,DeviceRuntimeParameter*> parameters = pChannel->ChannelParameters(); |
std::map<String,DeviceRuntimeParameter*> parameters = pChannel->ChannelParameters(); |
1191 |
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 + "'."); |
1192 |
DeviceRuntimeParameter* pParameter = parameters[ParamKey]; |
DeviceRuntimeParameter* pParameter = parameters[ParamKey]; |
1193 |
|
|
1194 |
// set new channel parameter value |
// set new channel parameter value |
1195 |
pParameter->SetValue(ParamVal); |
pParameter->SetValue(ParamVal); |
1196 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_audio_device_info, DeviceId)); |
1197 |
} |
} |
1198 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
1199 |
result.Error(e); |
result.Error(e); |
1200 |
} |
} |
1201 |
return result.Produce(); |
return result.Produce(); |
1206 |
LSCPResultSet result; |
LSCPResultSet result; |
1207 |
try { |
try { |
1208 |
std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
1209 |
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) + "."); |
1210 |
AudioOutputDevice* pDevice = devices[DeviceIndex]; |
AudioOutputDevice* pDevice = devices[DeviceIndex]; |
1211 |
std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters(); |
std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters(); |
1212 |
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 + "'"); |
1213 |
parameters[ParamKey]->SetValue(ParamVal); |
parameters[ParamKey]->SetValue(ParamVal); |
1214 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_audio_device_info, DeviceIndex)); |
1215 |
} |
} |
1216 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
1217 |
result.Error(e); |
result.Error(e); |
1218 |
} |
} |
1219 |
return result.Produce(); |
return result.Produce(); |
1224 |
LSCPResultSet result; |
LSCPResultSet result; |
1225 |
try { |
try { |
1226 |
std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
1227 |
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) + "."); |
1228 |
MidiInputDevice* pDevice = devices[DeviceIndex]; |
MidiInputDevice* pDevice = devices[DeviceIndex]; |
1229 |
std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters(); |
std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters(); |
1230 |
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 + "'"); |
1231 |
parameters[ParamKey]->SetValue(ParamVal); |
parameters[ParamKey]->SetValue(ParamVal); |
1232 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_midi_device_info, DeviceIndex)); |
1233 |
} |
} |
1234 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
1235 |
result.Error(e); |
result.Error(e); |
1236 |
} |
} |
1237 |
return result.Produce(); |
return result.Produce(); |
1243 |
try { |
try { |
1244 |
// get MIDI input device |
// get MIDI input device |
1245 |
std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
1246 |
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) + "."); |
1247 |
MidiInputDevice* pDevice = devices[DeviceIndex]; |
MidiInputDevice* pDevice = devices[DeviceIndex]; |
1248 |
|
|
1249 |
// get MIDI port |
// get MIDI port |
1250 |
MidiInputPort* pMidiInputPort = pDevice->GetPort(PortIndex); |
MidiInputPort* pMidiInputPort = pDevice->GetPort(PortIndex); |
1251 |
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) + "."); |
1252 |
|
|
1253 |
// set port parameter value |
// set port parameter value |
1254 |
std::map<String,DeviceRuntimeParameter*> parameters = pMidiInputPort->PortParameters(); |
std::map<String,DeviceRuntimeParameter*> parameters = pMidiInputPort->PortParameters(); |
1255 |
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 + "'"); |
1256 |
parameters[ParamKey]->SetValue(ParamVal); |
parameters[ParamKey]->SetValue(ParamVal); |
1257 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_midi_device_info, DeviceIndex)); |
1258 |
} |
} |
1259 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
1260 |
result.Error(e); |
result.Error(e); |
1261 |
} |
} |
1262 |
return result.Produce(); |
return result.Produce(); |
1271 |
LSCPResultSet result; |
LSCPResultSet result; |
1272 |
try { |
try { |
1273 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1274 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1275 |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
1276 |
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)); |
1277 |
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)); |
1278 |
pEngineChannel->SetOutputChannel(ChannelAudioOutputChannel, AudioOutputDeviceInputChannel); |
pEngineChannel->SetOutputChannel(ChannelAudioOutputChannel, AudioOutputDeviceInputChannel); |
1279 |
} |
} |
1280 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
1281 |
result.Error(e); |
result.Error(e); |
1282 |
} |
} |
1283 |
return result.Produce(); |
return result.Produce(); |
1286 |
String LSCPServer::SetAudioOutputDevice(uint AudioDeviceId, uint uiSamplerChannel) { |
String LSCPServer::SetAudioOutputDevice(uint AudioDeviceId, uint uiSamplerChannel) { |
1287 |
dmsg(2,("LSCPServer: SetAudiotOutputDevice(AudioDeviceId=%d, SamplerChannel=%d)\n",AudioDeviceId,uiSamplerChannel)); |
dmsg(2,("LSCPServer: SetAudiotOutputDevice(AudioDeviceId=%d, SamplerChannel=%d)\n",AudioDeviceId,uiSamplerChannel)); |
1288 |
LSCPResultSet result; |
LSCPResultSet result; |
1289 |
|
LockRTNotify(); |
1290 |
try { |
try { |
1291 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1292 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1293 |
std::map<uint, AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
std::map<uint, AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
1294 |
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)); |
1295 |
AudioOutputDevice* pDevice = devices[AudioDeviceId]; |
AudioOutputDevice* pDevice = devices[AudioDeviceId]; |
1296 |
pSamplerChannel->SetAudioOutputDevice(pDevice); |
pSamplerChannel->SetAudioOutputDevice(pDevice); |
1297 |
} |
} |
1298 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
1299 |
result.Error(e); |
result.Error(e); |
1300 |
} |
} |
1301 |
|
UnlockRTNotify(); |
1302 |
return result.Produce(); |
return result.Produce(); |
1303 |
} |
} |
1304 |
|
|
1305 |
String LSCPServer::SetAudioOutputType(String AudioOutputDriver, uint uiSamplerChannel) { |
String LSCPServer::SetAudioOutputType(String AudioOutputDriver, uint uiSamplerChannel) { |
1306 |
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)); |
1307 |
LSCPResultSet result; |
LSCPResultSet result; |
1308 |
|
LockRTNotify(); |
1309 |
try { |
try { |
1310 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1311 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1312 |
// Driver type name aliasing... |
// Driver type name aliasing... |
1313 |
if (AudioOutputDriver == "Alsa") AudioOutputDriver = "ALSA"; |
if (AudioOutputDriver == "Alsa") AudioOutputDriver = "ALSA"; |
1314 |
if (AudioOutputDriver == "Jack") AudioOutputDriver = "JACK"; |
if (AudioOutputDriver == "Jack") AudioOutputDriver = "JACK"; |
1330 |
} |
} |
1331 |
// Must have a device... |
// Must have a device... |
1332 |
if (pDevice == NULL) |
if (pDevice == NULL) |
1333 |
throw LinuxSamplerException("Internal error: could not create audio output device."); |
throw Exception("Internal error: could not create audio output device."); |
1334 |
// Set it as the current channel device... |
// Set it as the current channel device... |
1335 |
pSamplerChannel->SetAudioOutputDevice(pDevice); |
pSamplerChannel->SetAudioOutputDevice(pDevice); |
1336 |
} |
} |
1337 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
1338 |
result.Error(e); |
result.Error(e); |
1339 |
} |
} |
1340 |
|
UnlockRTNotify(); |
1341 |
return result.Produce(); |
return result.Produce(); |
1342 |
} |
} |
1343 |
|
|
1346 |
LSCPResultSet result; |
LSCPResultSet result; |
1347 |
try { |
try { |
1348 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1349 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1350 |
pSamplerChannel->SetMidiInputPort(MIDIPort); |
pSamplerChannel->SetMidiInputPort(MIDIPort); |
1351 |
} |
} |
1352 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
1353 |
result.Error(e); |
result.Error(e); |
1354 |
} |
} |
1355 |
return result.Produce(); |
return result.Produce(); |
1360 |
LSCPResultSet result; |
LSCPResultSet result; |
1361 |
try { |
try { |
1362 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1363 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1364 |
pSamplerChannel->SetMidiInputChannel((MidiInputPort::midi_chan_t) MIDIChannel); |
pSamplerChannel->SetMidiInputChannel((midi_chan_t) MIDIChannel); |
1365 |
} |
} |
1366 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
1367 |
result.Error(e); |
result.Error(e); |
1368 |
} |
} |
1369 |
return result.Produce(); |
return result.Produce(); |
1374 |
LSCPResultSet result; |
LSCPResultSet result; |
1375 |
try { |
try { |
1376 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1377 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1378 |
std::map<uint, MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
std::map<uint, MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
1379 |
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)); |
1380 |
MidiInputDevice* pDevice = devices[MIDIDeviceId]; |
MidiInputDevice* pDevice = devices[MIDIDeviceId]; |
1381 |
pSamplerChannel->SetMidiInputDevice(pDevice); |
pSamplerChannel->SetMidiInputDevice(pDevice); |
1382 |
} |
} |
1383 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
1384 |
result.Error(e); |
result.Error(e); |
1385 |
} |
} |
1386 |
return result.Produce(); |
return result.Produce(); |
1391 |
LSCPResultSet result; |
LSCPResultSet result; |
1392 |
try { |
try { |
1393 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1394 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1395 |
// Driver type name aliasing... |
// Driver type name aliasing... |
1396 |
if (MidiInputDriver == "Alsa") MidiInputDriver = "ALSA"; |
if (MidiInputDriver == "Alsa") MidiInputDriver = "ALSA"; |
1397 |
// Check if there's one MIDI input device already created |
// Check if there's one MIDI input device already created |
1415 |
} |
} |
1416 |
// Must have a device... |
// Must have a device... |
1417 |
if (pDevice == NULL) |
if (pDevice == NULL) |
1418 |
throw LinuxSamplerException("Internal error: could not create MIDI input device."); |
throw Exception("Internal error: could not create MIDI input device."); |
1419 |
// Set it as the current channel device... |
// Set it as the current channel device... |
1420 |
pSamplerChannel->SetMidiInputDevice(pDevice); |
pSamplerChannel->SetMidiInputDevice(pDevice); |
1421 |
} |
} |
1422 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
1423 |
result.Error(e); |
result.Error(e); |
1424 |
} |
} |
1425 |
return result.Produce(); |
return result.Produce(); |
1434 |
LSCPResultSet result; |
LSCPResultSet result; |
1435 |
try { |
try { |
1436 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1437 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1438 |
std::map<uint, MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
std::map<uint, MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
1439 |
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)); |
1440 |
MidiInputDevice* pDevice = devices[MIDIDeviceId]; |
MidiInputDevice* pDevice = devices[MIDIDeviceId]; |
1441 |
pSamplerChannel->SetMidiInput(pDevice, MIDIPort, (MidiInputPort::midi_chan_t) MIDIChannel); |
pSamplerChannel->SetMidiInput(pDevice, MIDIPort, (midi_chan_t) MIDIChannel); |
1442 |
} |
} |
1443 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
1444 |
result.Error(e); |
result.Error(e); |
1445 |
} |
} |
1446 |
return result.Produce(); |
return result.Produce(); |
1455 |
LSCPResultSet result; |
LSCPResultSet result; |
1456 |
try { |
try { |
1457 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1458 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1459 |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
1460 |
if (!pEngineChannel) throw LinuxSamplerException("No engine type assigned to sampler channel"); |
if (!pEngineChannel) throw Exception("No engine type assigned to sampler channel"); |
1461 |
pEngineChannel->Volume(dVolume); |
pEngineChannel->Volume(dVolume); |
1462 |
} |
} |
1463 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
1464 |
result.Error(e); |
result.Error(e); |
1465 |
} |
} |
1466 |
return result.Produce(); |
return result.Produce(); |
1467 |
} |
} |
1468 |
|
|
1469 |
/** |
/** |
1470 |
|
* Will be called by the parser to mute/unmute particular sampler channel. |
1471 |
|
*/ |
1472 |
|
String LSCPServer::SetChannelMute(bool bMute, uint uiSamplerChannel) { |
1473 |
|
dmsg(2,("LSCPServer: SetChannelMute(bMute=%d,uiSamplerChannel=%d)\n",bMute,uiSamplerChannel)); |
1474 |
|
LSCPResultSet result; |
1475 |
|
try { |
1476 |
|
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1477 |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1478 |
|
|
1479 |
|
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
1480 |
|
if (!pEngineChannel) throw Exception("No engine type assigned to sampler channel"); |
1481 |
|
|
1482 |
|
if(!bMute) pEngineChannel->SetMute((HasSoloChannel() && !pEngineChannel->GetSolo()) ? -1 : 0); |
1483 |
|
else pEngineChannel->SetMute(1); |
1484 |
|
} catch (Exception e) { |
1485 |
|
result.Error(e); |
1486 |
|
} |
1487 |
|
return result.Produce(); |
1488 |
|
} |
1489 |
|
|
1490 |
|
/** |
1491 |
|
* Will be called by the parser to solo particular sampler channel. |
1492 |
|
*/ |
1493 |
|
String LSCPServer::SetChannelSolo(bool bSolo, uint uiSamplerChannel) { |
1494 |
|
dmsg(2,("LSCPServer: SetChannelSolo(bSolo=%d,uiSamplerChannel=%d)\n",bSolo,uiSamplerChannel)); |
1495 |
|
LSCPResultSet result; |
1496 |
|
try { |
1497 |
|
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1498 |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1499 |
|
|
1500 |
|
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
1501 |
|
if (!pEngineChannel) throw Exception("No engine type assigned to sampler channel"); |
1502 |
|
|
1503 |
|
bool oldSolo = pEngineChannel->GetSolo(); |
1504 |
|
bool hadSoloChannel = HasSoloChannel(); |
1505 |
|
|
1506 |
|
pEngineChannel->SetSolo(bSolo); |
1507 |
|
|
1508 |
|
if(!oldSolo && bSolo) { |
1509 |
|
if(pEngineChannel->GetMute() == -1) pEngineChannel->SetMute(0); |
1510 |
|
if(!hadSoloChannel) MuteNonSoloChannels(); |
1511 |
|
} |
1512 |
|
|
1513 |
|
if(oldSolo && !bSolo) { |
1514 |
|
if(!HasSoloChannel()) UnmuteChannels(); |
1515 |
|
else if(!pEngineChannel->GetMute()) pEngineChannel->SetMute(-1); |
1516 |
|
} |
1517 |
|
} catch (Exception e) { |
1518 |
|
result.Error(e); |
1519 |
|
} |
1520 |
|
return result.Produce(); |
1521 |
|
} |
1522 |
|
|
1523 |
|
/** |
1524 |
|
* Determines whether there is at least one solo channel in the channel list. |
1525 |
|
* |
1526 |
|
* @returns true if there is at least one solo channel in the channel list, |
1527 |
|
* false otherwise. |
1528 |
|
*/ |
1529 |
|
bool LSCPServer::HasSoloChannel() { |
1530 |
|
std::map<uint,SamplerChannel*> channels = pSampler->GetSamplerChannels(); |
1531 |
|
std::map<uint,SamplerChannel*>::iterator iter = channels.begin(); |
1532 |
|
for (; iter != channels.end(); iter++) { |
1533 |
|
EngineChannel* c = iter->second->GetEngineChannel(); |
1534 |
|
if(c && c->GetSolo()) return true; |
1535 |
|
} |
1536 |
|
|
1537 |
|
return false; |
1538 |
|
} |
1539 |
|
|
1540 |
|
/** |
1541 |
|
* Mutes all unmuted non-solo channels. Notice that the channels are muted |
1542 |
|
* with -1 which indicates that they are muted because of the presence |
1543 |
|
* of a solo channel(s). Channels muted with -1 will be automatically unmuted |
1544 |
|
* when there are no solo channels left. |
1545 |
|
*/ |
1546 |
|
void LSCPServer::MuteNonSoloChannels() { |
1547 |
|
dmsg(2,("LSCPServer: MuteNonSoloChannels()\n")); |
1548 |
|
std::map<uint,SamplerChannel*> channels = pSampler->GetSamplerChannels(); |
1549 |
|
std::map<uint,SamplerChannel*>::iterator iter = channels.begin(); |
1550 |
|
for (; iter != channels.end(); iter++) { |
1551 |
|
EngineChannel* c = iter->second->GetEngineChannel(); |
1552 |
|
if(c && !c->GetSolo() && !c->GetMute()) c->SetMute(-1); |
1553 |
|
} |
1554 |
|
} |
1555 |
|
|
1556 |
|
/** |
1557 |
|
* Unmutes all channels that are muted because of the presence |
1558 |
|
* of a solo channel(s). |
1559 |
|
*/ |
1560 |
|
void LSCPServer::UnmuteChannels() { |
1561 |
|
dmsg(2,("LSCPServer: UnmuteChannels()\n")); |
1562 |
|
std::map<uint,SamplerChannel*> channels = pSampler->GetSamplerChannels(); |
1563 |
|
std::map<uint,SamplerChannel*>::iterator iter = channels.begin(); |
1564 |
|
for (; iter != channels.end(); iter++) { |
1565 |
|
EngineChannel* c = iter->second->GetEngineChannel(); |
1566 |
|
if(c && c->GetMute() == -1) c->SetMute(0); |
1567 |
|
} |
1568 |
|
} |
1569 |
|
|
1570 |
|
String LSCPServer::AddOrReplaceMIDIInstrumentMapping(uint MidiMapID, uint MidiBank, uint MidiProg, String EngineType, String InstrumentFile, uint InstrumentIndex, float Volume, MidiInstrumentMapper::mode_t LoadMode, String Name) { |
1571 |
|
dmsg(2,("LSCPServer: AddOrReplaceMIDIInstrumentMapping()\n")); |
1572 |
|
|
1573 |
|
midi_prog_index_t idx; |
1574 |
|
idx.midi_bank_msb = (MidiBank >> 7) & 0x7f; |
1575 |
|
idx.midi_bank_lsb = MidiBank & 0x7f; |
1576 |
|
idx.midi_prog = MidiProg; |
1577 |
|
|
1578 |
|
MidiInstrumentMapper::entry_t entry; |
1579 |
|
entry.EngineName = EngineType; |
1580 |
|
entry.InstrumentFile = InstrumentFile; |
1581 |
|
entry.InstrumentIndex = InstrumentIndex; |
1582 |
|
entry.LoadMode = LoadMode; |
1583 |
|
entry.Volume = Volume; |
1584 |
|
entry.Name = Name; |
1585 |
|
|
1586 |
|
LSCPResultSet result; |
1587 |
|
try { |
1588 |
|
// PERSISTENT mapping commands might bloock for a long time, so in |
1589 |
|
// that case we add/replace the mapping in another thread |
1590 |
|
bool bInBackground = (entry.LoadMode == MidiInstrumentMapper::PERSISTENT); |
1591 |
|
MidiInstrumentMapper::AddOrReplaceEntry(MidiMapID, idx, entry, bInBackground); |
1592 |
|
} catch (Exception e) { |
1593 |
|
result.Error(e); |
1594 |
|
} |
1595 |
|
return result.Produce(); |
1596 |
|
} |
1597 |
|
|
1598 |
|
String LSCPServer::RemoveMIDIInstrumentMapping(uint MidiMapID, uint MidiBank, uint MidiProg) { |
1599 |
|
dmsg(2,("LSCPServer: RemoveMIDIInstrumentMapping()\n")); |
1600 |
|
|
1601 |
|
midi_prog_index_t idx; |
1602 |
|
idx.midi_bank_msb = (MidiBank >> 7) & 0x7f; |
1603 |
|
idx.midi_bank_lsb = MidiBank & 0x7f; |
1604 |
|
idx.midi_prog = MidiProg; |
1605 |
|
|
1606 |
|
LSCPResultSet result; |
1607 |
|
try { |
1608 |
|
MidiInstrumentMapper::RemoveEntry(MidiMapID, idx); |
1609 |
|
} catch (Exception e) { |
1610 |
|
result.Error(e); |
1611 |
|
} |
1612 |
|
return result.Produce(); |
1613 |
|
} |
1614 |
|
|
1615 |
|
String LSCPServer::GetMidiInstrumentMappings(uint MidiMapID) { |
1616 |
|
dmsg(2,("LSCPServer: GetMidiInstrumentMappings()\n")); |
1617 |
|
LSCPResultSet result; |
1618 |
|
try { |
1619 |
|
result.Add(MidiInstrumentMapper::Entries(MidiMapID).size()); |
1620 |
|
} catch (Exception e) { |
1621 |
|
result.Error(e); |
1622 |
|
} |
1623 |
|
return result.Produce(); |
1624 |
|
} |
1625 |
|
|
1626 |
|
|
1627 |
|
String LSCPServer::GetAllMidiInstrumentMappings() { |
1628 |
|
dmsg(2,("LSCPServer: GetAllMidiInstrumentMappings()\n")); |
1629 |
|
LSCPResultSet result; |
1630 |
|
std::vector<int> maps = MidiInstrumentMapper::Maps(); |
1631 |
|
int totalMappings = 0; |
1632 |
|
for (int i = 0; i < maps.size(); i++) { |
1633 |
|
try { |
1634 |
|
totalMappings += MidiInstrumentMapper::Entries(maps[i]).size(); |
1635 |
|
} catch (Exception e) { /*NOOP*/ } |
1636 |
|
} |
1637 |
|
result.Add(totalMappings); |
1638 |
|
return result.Produce(); |
1639 |
|
} |
1640 |
|
|
1641 |
|
String LSCPServer::GetMidiInstrumentMapping(uint MidiMapID, uint MidiBank, uint MidiProg) { |
1642 |
|
dmsg(2,("LSCPServer: GetMidiIstrumentMapping()\n")); |
1643 |
|
LSCPResultSet result; |
1644 |
|
try { |
1645 |
|
midi_prog_index_t idx; |
1646 |
|
idx.midi_bank_msb = (MidiBank >> 7) & 0x7f; |
1647 |
|
idx.midi_bank_lsb = MidiBank & 0x7f; |
1648 |
|
idx.midi_prog = MidiProg; |
1649 |
|
|
1650 |
|
std::map<midi_prog_index_t,MidiInstrumentMapper::entry_t> mappings = MidiInstrumentMapper::Entries(MidiMapID); |
1651 |
|
std::map<midi_prog_index_t,MidiInstrumentMapper::entry_t>::iterator iter = mappings.find(idx); |
1652 |
|
if (iter == mappings.end()) result.Error("there is no map entry with that index"); |
1653 |
|
else { // found |
1654 |
|
result.Add("NAME", iter->second.Name); |
1655 |
|
result.Add("ENGINE_NAME", iter->second.EngineName); |
1656 |
|
result.Add("INSTRUMENT_FILE", iter->second.InstrumentFile); |
1657 |
|
result.Add("INSTRUMENT_NR", (int) iter->second.InstrumentIndex); |
1658 |
|
String instrumentName; |
1659 |
|
Engine* pEngine = EngineFactory::Create(iter->second.EngineName); |
1660 |
|
if (pEngine) { |
1661 |
|
if (pEngine->GetInstrumentManager()) { |
1662 |
|
InstrumentManager::instrument_id_t instrID; |
1663 |
|
instrID.FileName = iter->second.InstrumentFile; |
1664 |
|
instrID.Index = iter->second.InstrumentIndex; |
1665 |
|
instrumentName = pEngine->GetInstrumentManager()->GetInstrumentName(instrID); |
1666 |
|
} |
1667 |
|
EngineFactory::Destroy(pEngine); |
1668 |
|
} |
1669 |
|
result.Add("INSTRUMENT_NAME", instrumentName); |
1670 |
|
switch (iter->second.LoadMode) { |
1671 |
|
case MidiInstrumentMapper::ON_DEMAND: |
1672 |
|
result.Add("LOAD_MODE", "ON_DEMAND"); |
1673 |
|
break; |
1674 |
|
case MidiInstrumentMapper::ON_DEMAND_HOLD: |
1675 |
|
result.Add("LOAD_MODE", "ON_DEMAND_HOLD"); |
1676 |
|
break; |
1677 |
|
case MidiInstrumentMapper::PERSISTENT: |
1678 |
|
result.Add("LOAD_MODE", "PERSISTENT"); |
1679 |
|
break; |
1680 |
|
default: |
1681 |
|
throw Exception("entry reflects invalid LOAD_MODE, consider this as a bug!"); |
1682 |
|
} |
1683 |
|
result.Add("VOLUME", iter->second.Volume); |
1684 |
|
} |
1685 |
|
} catch (Exception e) { |
1686 |
|
result.Error(e); |
1687 |
|
} |
1688 |
|
return result.Produce(); |
1689 |
|
} |
1690 |
|
|
1691 |
|
String LSCPServer::ListMidiInstrumentMappings(uint MidiMapID) { |
1692 |
|
dmsg(2,("LSCPServer: ListMidiInstrumentMappings()\n")); |
1693 |
|
LSCPResultSet result; |
1694 |
|
try { |
1695 |
|
String s; |
1696 |
|
std::map<midi_prog_index_t,MidiInstrumentMapper::entry_t> mappings = MidiInstrumentMapper::Entries(MidiMapID); |
1697 |
|
std::map<midi_prog_index_t,MidiInstrumentMapper::entry_t>::iterator iter = mappings.begin(); |
1698 |
|
for (; iter != mappings.end(); iter++) { |
1699 |
|
if (s.size()) s += ","; |
1700 |
|
s += "{" + ToString(MidiMapID) + "," |
1701 |
|
+ ToString((int(iter->first.midi_bank_msb) << 7) & int(iter->first.midi_bank_lsb)) + "," |
1702 |
|
+ ToString(int(iter->first.midi_prog)) + "}"; |
1703 |
|
} |
1704 |
|
result.Add(s); |
1705 |
|
} catch (Exception e) { |
1706 |
|
result.Error(e); |
1707 |
|
} |
1708 |
|
return result.Produce(); |
1709 |
|
} |
1710 |
|
|
1711 |
|
String LSCPServer::ListAllMidiInstrumentMappings() { |
1712 |
|
dmsg(2,("LSCPServer: ListAllMidiInstrumentMappings()\n")); |
1713 |
|
LSCPResultSet result; |
1714 |
|
try { |
1715 |
|
std::vector<int> maps = MidiInstrumentMapper::Maps(); |
1716 |
|
String s; |
1717 |
|
for (int i = 0; i < maps.size(); i++) { |
1718 |
|
std::map<midi_prog_index_t,MidiInstrumentMapper::entry_t> mappings = MidiInstrumentMapper::Entries(maps[i]); |
1719 |
|
std::map<midi_prog_index_t,MidiInstrumentMapper::entry_t>::iterator iter = mappings.begin(); |
1720 |
|
for (; iter != mappings.end(); iter++) { |
1721 |
|
if (s.size()) s += ","; |
1722 |
|
s += "{" + ToString(maps[i]) + "," |
1723 |
|
+ ToString((int(iter->first.midi_bank_msb) << 7) & int(iter->first.midi_bank_lsb)) + "," |
1724 |
|
+ ToString(int(iter->first.midi_prog)) + "}"; |
1725 |
|
} |
1726 |
|
} |
1727 |
|
result.Add(s); |
1728 |
|
} catch (Exception e) { |
1729 |
|
result.Error(e); |
1730 |
|
} |
1731 |
|
return result.Produce(); |
1732 |
|
} |
1733 |
|
|
1734 |
|
String LSCPServer::ClearMidiInstrumentMappings(uint MidiMapID) { |
1735 |
|
dmsg(2,("LSCPServer: ClearMidiInstrumentMappings()\n")); |
1736 |
|
LSCPResultSet result; |
1737 |
|
try { |
1738 |
|
MidiInstrumentMapper::RemoveAllEntries(MidiMapID); |
1739 |
|
} catch (Exception e) { |
1740 |
|
result.Error(e); |
1741 |
|
} |
1742 |
|
return result.Produce(); |
1743 |
|
} |
1744 |
|
|
1745 |
|
String LSCPServer::ClearAllMidiInstrumentMappings() { |
1746 |
|
dmsg(2,("LSCPServer: ClearAllMidiInstrumentMappings()\n")); |
1747 |
|
LSCPResultSet result; |
1748 |
|
try { |
1749 |
|
std::vector<int> maps = MidiInstrumentMapper::Maps(); |
1750 |
|
for (int i = 0; i < maps.size(); i++) |
1751 |
|
MidiInstrumentMapper::RemoveAllEntries(maps[i]); |
1752 |
|
} catch (Exception e) { |
1753 |
|
result.Error(e); |
1754 |
|
} |
1755 |
|
return result.Produce(); |
1756 |
|
} |
1757 |
|
|
1758 |
|
String LSCPServer::AddMidiInstrumentMap(String MapName) { |
1759 |
|
dmsg(2,("LSCPServer: AddMidiInstrumentMap()\n")); |
1760 |
|
LSCPResultSet result; |
1761 |
|
try { |
1762 |
|
int MapID = MidiInstrumentMapper::AddMap(MapName); |
1763 |
|
result = LSCPResultSet(MapID); |
1764 |
|
} catch (Exception e) { |
1765 |
|
result.Error(e); |
1766 |
|
} |
1767 |
|
return result.Produce(); |
1768 |
|
} |
1769 |
|
|
1770 |
|
String LSCPServer::RemoveMidiInstrumentMap(uint MidiMapID) { |
1771 |
|
dmsg(2,("LSCPServer: RemoveMidiInstrumentMap()\n")); |
1772 |
|
LSCPResultSet result; |
1773 |
|
try { |
1774 |
|
MidiInstrumentMapper::RemoveMap(MidiMapID); |
1775 |
|
} catch (Exception e) { |
1776 |
|
result.Error(e); |
1777 |
|
} |
1778 |
|
return result.Produce(); |
1779 |
|
} |
1780 |
|
|
1781 |
|
String LSCPServer::RemoveAllMidiInstrumentMaps() { |
1782 |
|
dmsg(2,("LSCPServer: RemoveAllMidiInstrumentMaps()\n")); |
1783 |
|
LSCPResultSet result; |
1784 |
|
try { |
1785 |
|
MidiInstrumentMapper::RemoveAllMaps(); |
1786 |
|
} catch (Exception e) { |
1787 |
|
result.Error(e); |
1788 |
|
} |
1789 |
|
return result.Produce(); |
1790 |
|
} |
1791 |
|
|
1792 |
|
String LSCPServer::GetMidiInstrumentMaps() { |
1793 |
|
dmsg(2,("LSCPServer: GetMidiInstrumentMaps()\n")); |
1794 |
|
LSCPResultSet result; |
1795 |
|
try { |
1796 |
|
result.Add(MidiInstrumentMapper::Maps().size()); |
1797 |
|
} catch (Exception e) { |
1798 |
|
result.Error(e); |
1799 |
|
} |
1800 |
|
return result.Produce(); |
1801 |
|
} |
1802 |
|
|
1803 |
|
String LSCPServer::ListMidiInstrumentMaps() { |
1804 |
|
dmsg(2,("LSCPServer: ListMidiInstrumentMaps()\n")); |
1805 |
|
LSCPResultSet result; |
1806 |
|
try { |
1807 |
|
std::vector<int> maps = MidiInstrumentMapper::Maps(); |
1808 |
|
String sList; |
1809 |
|
for (int i = 0; i < maps.size(); i++) { |
1810 |
|
if (sList != "") sList += ","; |
1811 |
|
sList += ToString(maps[i]); |
1812 |
|
} |
1813 |
|
result.Add(sList); |
1814 |
|
} catch (Exception e) { |
1815 |
|
result.Error(e); |
1816 |
|
} |
1817 |
|
return result.Produce(); |
1818 |
|
} |
1819 |
|
|
1820 |
|
String LSCPServer::GetMidiInstrumentMap(uint MidiMapID) { |
1821 |
|
dmsg(2,("LSCPServer: GetMidiInstrumentMap()\n")); |
1822 |
|
LSCPResultSet result; |
1823 |
|
try { |
1824 |
|
result.Add("NAME", MidiInstrumentMapper::MapName(MidiMapID)); |
1825 |
|
} catch (Exception e) { |
1826 |
|
result.Error(e); |
1827 |
|
} |
1828 |
|
return result.Produce(); |
1829 |
|
} |
1830 |
|
|
1831 |
|
String LSCPServer::SetMidiInstrumentMapName(uint MidiMapID, String NewName) { |
1832 |
|
dmsg(2,("LSCPServer: SetMidiInstrumentMapName()\n")); |
1833 |
|
LSCPResultSet result; |
1834 |
|
try { |
1835 |
|
MidiInstrumentMapper::RenameMap(MidiMapID, NewName); |
1836 |
|
} catch (Exception e) { |
1837 |
|
result.Error(e); |
1838 |
|
} |
1839 |
|
return result.Produce(); |
1840 |
|
} |
1841 |
|
|
1842 |
|
/** |
1843 |
|
* Set the MIDI instrument map the given sampler channel shall use for |
1844 |
|
* handling MIDI program change messages. There are the following two |
1845 |
|
* special (negative) values: |
1846 |
|
* |
1847 |
|
* - (-1) : set to NONE (ignore program changes) |
1848 |
|
* - (-2) : set to DEFAULT map |
1849 |
|
*/ |
1850 |
|
String LSCPServer::SetChannelMap(uint uiSamplerChannel, int MidiMapID) { |
1851 |
|
dmsg(2,("LSCPServer: SetChannelMap()\n")); |
1852 |
|
LSCPResultSet result; |
1853 |
|
try { |
1854 |
|
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1855 |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1856 |
|
|
1857 |
|
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
1858 |
|
if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet"); |
1859 |
|
|
1860 |
|
if (MidiMapID == -1) pEngineChannel->SetMidiInstrumentMapToNone(); |
1861 |
|
else if (MidiMapID == -2) pEngineChannel->SetMidiInstrumentMapToDefault(); |
1862 |
|
else pEngineChannel->SetMidiInstrumentMap(MidiMapID); |
1863 |
|
} catch (Exception e) { |
1864 |
|
result.Error(e); |
1865 |
|
} |
1866 |
|
return result.Produce(); |
1867 |
|
} |
1868 |
|
|
1869 |
|
String LSCPServer::CreateFxSend(uint uiSamplerChannel, uint MidiCtrl, String Name) { |
1870 |
|
dmsg(2,("LSCPServer: CreateFxSend()\n")); |
1871 |
|
LSCPResultSet result; |
1872 |
|
try { |
1873 |
|
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1874 |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1875 |
|
|
1876 |
|
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
1877 |
|
if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet"); |
1878 |
|
|
1879 |
|
FxSend* pFxSend = pEngineChannel->AddFxSend(MidiCtrl, Name); |
1880 |
|
if (!pFxSend) throw Exception("Could not add FxSend, don't ask, I don't know why (probably a bug)"); |
1881 |
|
|
1882 |
|
result = LSCPResultSet(pFxSend->Id()); // success |
1883 |
|
} catch (Exception e) { |
1884 |
|
result.Error(e); |
1885 |
|
} |
1886 |
|
return result.Produce(); |
1887 |
|
} |
1888 |
|
|
1889 |
|
String LSCPServer::DestroyFxSend(uint uiSamplerChannel, uint FxSendID) { |
1890 |
|
dmsg(2,("LSCPServer: DestroyFxSend()\n")); |
1891 |
|
LSCPResultSet result; |
1892 |
|
try { |
1893 |
|
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1894 |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1895 |
|
|
1896 |
|
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
1897 |
|
if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet"); |
1898 |
|
|
1899 |
|
FxSend* pFxSend = NULL; |
1900 |
|
for (int i = 0; i < pEngineChannel->GetFxSendCount(); i++) { |
1901 |
|
if (pEngineChannel->GetFxSend(i)->Id() == FxSendID) { |
1902 |
|
pFxSend = pEngineChannel->GetFxSend(i); |
1903 |
|
break; |
1904 |
|
} |
1905 |
|
} |
1906 |
|
if (!pFxSend) throw Exception("There is no FxSend with that ID on the given sampler channel"); |
1907 |
|
pEngineChannel->RemoveFxSend(pFxSend); |
1908 |
|
} catch (Exception e) { |
1909 |
|
result.Error(e); |
1910 |
|
} |
1911 |
|
return result.Produce(); |
1912 |
|
} |
1913 |
|
|
1914 |
|
String LSCPServer::GetFxSends(uint uiSamplerChannel) { |
1915 |
|
dmsg(2,("LSCPServer: GetFxSends()\n")); |
1916 |
|
LSCPResultSet result; |
1917 |
|
try { |
1918 |
|
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1919 |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1920 |
|
|
1921 |
|
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
1922 |
|
if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet"); |
1923 |
|
|
1924 |
|
result.Add(pEngineChannel->GetFxSendCount()); |
1925 |
|
} catch (Exception e) { |
1926 |
|
result.Error(e); |
1927 |
|
} |
1928 |
|
return result.Produce(); |
1929 |
|
} |
1930 |
|
|
1931 |
|
String LSCPServer::ListFxSends(uint uiSamplerChannel) { |
1932 |
|
dmsg(2,("LSCPServer: ListFxSends()\n")); |
1933 |
|
LSCPResultSet result; |
1934 |
|
String list; |
1935 |
|
try { |
1936 |
|
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1937 |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1938 |
|
|
1939 |
|
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
1940 |
|
if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet"); |
1941 |
|
|
1942 |
|
for (int i = 0; i < pEngineChannel->GetFxSendCount(); i++) { |
1943 |
|
FxSend* pFxSend = pEngineChannel->GetFxSend(i); |
1944 |
|
if (list != "") list += ","; |
1945 |
|
list += ToString(pFxSend->Id()); |
1946 |
|
} |
1947 |
|
result.Add(list); |
1948 |
|
} catch (Exception e) { |
1949 |
|
result.Error(e); |
1950 |
|
} |
1951 |
|
return result.Produce(); |
1952 |
|
} |
1953 |
|
|
1954 |
|
String LSCPServer::GetFxSendInfo(uint uiSamplerChannel, uint FxSendID) { |
1955 |
|
dmsg(2,("LSCPServer: GetFxSendInfo()\n")); |
1956 |
|
LSCPResultSet result; |
1957 |
|
try { |
1958 |
|
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1959 |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1960 |
|
|
1961 |
|
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
1962 |
|
if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet"); |
1963 |
|
|
1964 |
|
FxSend* pFxSend = NULL; |
1965 |
|
for (int i = 0; i < pEngineChannel->GetFxSendCount(); i++) { |
1966 |
|
if (pEngineChannel->GetFxSend(i)->Id() == FxSendID) { |
1967 |
|
pFxSend = pEngineChannel->GetFxSend(i); |
1968 |
|
break; |
1969 |
|
} |
1970 |
|
} |
1971 |
|
if (!pFxSend) throw Exception("There is no FxSend with that ID on the given sampler channel"); |
1972 |
|
|
1973 |
|
// gather audio routing informations |
1974 |
|
String AudioRouting; |
1975 |
|
for (int chan = 0; chan < pEngineChannel->Channels(); chan++) { |
1976 |
|
if (AudioRouting != "") AudioRouting += ","; |
1977 |
|
AudioRouting += ToString(pFxSend->DestinationChannel(chan)); |
1978 |
|
} |
1979 |
|
|
1980 |
|
// success |
1981 |
|
result.Add("NAME", pFxSend->Name()); |
1982 |
|
result.Add("AUDIO_OUTPUT_ROUTING", AudioRouting); |
1983 |
|
} catch (Exception e) { |
1984 |
|
result.Error(e); |
1985 |
|
} |
1986 |
|
return result.Produce(); |
1987 |
|
} |
1988 |
|
|
1989 |
|
String LSCPServer::SetFxSendAudioOutputChannel(uint uiSamplerChannel, uint FxSendID, uint FxSendChannel, uint DeviceChannel) { |
1990 |
|
dmsg(2,("LSCPServer: SetFxSendAudioOutputChannel()\n")); |
1991 |
|
LSCPResultSet result; |
1992 |
|
try { |
1993 |
|
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1994 |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1995 |
|
|
1996 |
|
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
1997 |
|
if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet"); |
1998 |
|
|
1999 |
|
FxSend* pFxSend = NULL; |
2000 |
|
for (int i = 0; i < pEngineChannel->GetFxSendCount(); i++) { |
2001 |
|
if (pEngineChannel->GetFxSend(i)->Id() == FxSendID) { |
2002 |
|
pFxSend = pEngineChannel->GetFxSend(i); |
2003 |
|
break; |
2004 |
|
} |
2005 |
|
} |
2006 |
|
if (!pFxSend) throw Exception("There is no FxSend with that ID on the given sampler channel"); |
2007 |
|
|
2008 |
|
pFxSend->SetDestinationChannel(FxSendChannel, DeviceChannel); |
2009 |
|
} catch (Exception e) { |
2010 |
|
result.Error(e); |
2011 |
|
} |
2012 |
|
return result.Produce(); |
2013 |
|
} |
2014 |
|
|
2015 |
|
/** |
2016 |
* Will be called by the parser to reset a particular sampler channel. |
* Will be called by the parser to reset a particular sampler channel. |
2017 |
*/ |
*/ |
2018 |
String LSCPServer::ResetChannel(uint uiSamplerChannel) { |
String LSCPServer::ResetChannel(uint uiSamplerChannel) { |
2020 |
LSCPResultSet result; |
LSCPResultSet result; |
2021 |
try { |
try { |
2022 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
2023 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
2024 |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
2025 |
if (!pEngineChannel) throw LinuxSamplerException("No engine type assigned to sampler channel"); |
if (!pEngineChannel) throw Exception("No engine type assigned to sampler channel"); |
2026 |
pEngineChannel->Reset(); |
pEngineChannel->Reset(); |
2027 |
} |
} |
2028 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
2029 |
result.Error(e); |
result.Error(e); |
2030 |
} |
} |
2031 |
return result.Produce(); |
return result.Produce(); |
2050 |
LSCPResultSet result; |
LSCPResultSet result; |
2051 |
result.Add("DESCRIPTION", "LinuxSampler - modular, streaming capable sampler"); |
result.Add("DESCRIPTION", "LinuxSampler - modular, streaming capable sampler"); |
2052 |
result.Add("VERSION", VERSION); |
result.Add("VERSION", VERSION); |
2053 |
result.Add("PROTOCOL_VERSION", "1.0"); |
result.Add("PROTOCOL_VERSION", ToString(LSCP_RELEASE_MAJOR) + "." + ToString(LSCP_RELEASE_MINOR)); |
2054 |
|
return result.Produce(); |
2055 |
|
} |
2056 |
|
|
2057 |
|
/** |
2058 |
|
* Will be called by the parser to return the current number of all active voices. |
2059 |
|
*/ |
2060 |
|
String LSCPServer::GetTotalVoiceCount() { |
2061 |
|
dmsg(2,("LSCPServer: GetTotalVoiceCount()\n")); |
2062 |
|
LSCPResultSet result; |
2063 |
|
result.Add(pSampler->GetVoiceCount()); |
2064 |
|
return result.Produce(); |
2065 |
|
} |
2066 |
|
|
2067 |
|
/** |
2068 |
|
* Will be called by the parser to return the maximum number of voices. |
2069 |
|
*/ |
2070 |
|
String LSCPServer::GetTotalVoiceCountMax() { |
2071 |
|
dmsg(2,("LSCPServer: GetTotalVoiceCountMax()\n")); |
2072 |
|
LSCPResultSet result; |
2073 |
|
result.Add(EngineFactory::EngineInstances().size() * CONFIG_MAX_VOICES); |
2074 |
|
return result.Produce(); |
2075 |
|
} |
2076 |
|
|
2077 |
|
String LSCPServer::GetGlobalVolume() { |
2078 |
|
LSCPResultSet result; |
2079 |
|
result.Add(ToString(GLOBAL_VOLUME)); // see common/global.cpp |
2080 |
|
return result.Produce(); |
2081 |
|
} |
2082 |
|
|
2083 |
|
String LSCPServer::SetGlobalVolume(double dVolume) { |
2084 |
|
LSCPResultSet result; |
2085 |
|
try { |
2086 |
|
if (dVolume < 0) throw Exception("Volume may not be negative"); |
2087 |
|
GLOBAL_VOLUME = dVolume; // see common/global.cpp |
2088 |
|
} catch (Exception e) { |
2089 |
|
result.Error(e); |
2090 |
|
} |
2091 |
return result.Produce(); |
return result.Produce(); |
2092 |
} |
} |
2093 |
|
|
2159 |
try { |
try { |
2160 |
if (boolean_value == 0) pSession->bVerbose = false; |
if (boolean_value == 0) pSession->bVerbose = false; |
2161 |
else if (boolean_value == 1) pSession->bVerbose = true; |
else if (boolean_value == 1) pSession->bVerbose = true; |
2162 |
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"); |
2163 |
} |
} |
2164 |
catch (LinuxSamplerException e) { |
catch (Exception e) { |
2165 |
result.Error(e); |
result.Error(e); |
2166 |
} |
} |
2167 |
return result.Produce(); |
return result.Produce(); |