25 |
|
|
26 |
#include "../engines/gig/Engine.h" |
#include "../engines/gig/Engine.h" |
27 |
#include "../audiodriver/AudioOutputDeviceFactory.h" |
#include "../audiodriver/AudioOutputDeviceFactory.h" |
28 |
|
#include "../mididriver/MidiInputDeviceFactory.h" |
29 |
|
|
30 |
LSCPServer::LSCPServer(Sampler* pSampler) : Thread(false, 0, -4) { |
LSCPServer::LSCPServer(Sampler* pSampler) : Thread(false, 0, -4) { |
31 |
this->pSampler = pSampler; |
this->pSampler = pSampler; |
107 |
return -1; |
return -1; |
108 |
} |
} |
109 |
|
|
110 |
|
/** |
111 |
|
* Find a created midi input device index. |
112 |
|
*/ |
113 |
|
int LSCPServer::GetMidiInputDeviceIndex ( MidiInputDevice *pDevice ) |
114 |
|
{ |
115 |
|
// Search for the created device to get its index |
116 |
|
std::map<uint, MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
117 |
|
std::map<uint, MidiInputDevice*>::iterator iter = devices.begin(); |
118 |
|
for (; iter != devices.end(); iter++) { |
119 |
|
if (iter->second == pDevice) |
120 |
|
return iter->first; |
121 |
|
} |
122 |
|
// Not found. |
123 |
|
return -1; |
124 |
|
} |
125 |
|
|
126 |
String LSCPServer::CreateAudioOutputDevice(String Driver, std::map<String,String> Parameters) { |
String LSCPServer::CreateAudioOutputDevice(String Driver, std::map<String,String> Parameters) { |
127 |
dmsg(2,("LSCPServer: CreateAudioOutputDevice(Driver=%s)\n", Driver.c_str())); |
dmsg(2,("LSCPServer: CreateAudioOutputDevice(Driver=%s)\n", Driver.c_str())); |
128 |
LSCPResultSet result; |
LSCPResultSet result; |
139 |
return result.Produce(); |
return result.Produce(); |
140 |
} |
} |
141 |
|
|
142 |
|
String LSCPServer::CreateMidiInputDevice(String Driver, std::map<String,String> Parameters) { |
143 |
|
dmsg(2,("LSCPServer: CreateMidiInputDevice(Driver=%s)\n", Driver.c_str())); |
144 |
|
LSCPResultSet result; |
145 |
|
try { |
146 |
|
MidiInputDevice* pDevice = pSampler->CreateMidiInputDevice(Driver, Parameters); |
147 |
|
// search for the created device to get its index |
148 |
|
int index = GetMidiInputDeviceIndex(pDevice); |
149 |
|
if (index == -1) throw LinuxSamplerException("Internal error: could not find created midi input device."); |
150 |
|
result = index; // success |
151 |
|
} |
152 |
|
catch (LinuxSamplerException e) { |
153 |
|
result.Error(e); |
154 |
|
} |
155 |
|
return result.Produce(); |
156 |
|
} |
157 |
|
|
158 |
String LSCPServer::DestroyAudioOutputDevice(uint DeviceIndex) { |
String LSCPServer::DestroyAudioOutputDevice(uint DeviceIndex) { |
159 |
dmsg(2,("LSCPServer: DestroyAudioOutputDevice(DeviceIndex=%d)\n", DeviceIndex)); |
dmsg(2,("LSCPServer: DestroyAudioOutputDevice(DeviceIndex=%d)\n", DeviceIndex)); |
160 |
LSCPResultSet result; |
LSCPResultSet result; |
170 |
return result.Produce(); |
return result.Produce(); |
171 |
} |
} |
172 |
|
|
173 |
|
String LSCPServer::DestroyMidiInputDevice(uint DeviceIndex) { |
174 |
|
dmsg(2,("LSCPServer: DestroyMidiInputDevice(DeviceIndex=%d)\n", DeviceIndex)); |
175 |
|
LSCPResultSet result; |
176 |
|
try { |
177 |
|
std::map<uint, MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
178 |
|
MidiInputDevice* pDevice = devices[DeviceIndex]; |
179 |
|
if (!pDevice) throw LinuxSamplerException("There is no audio output device with index " + ToString(DeviceIndex) + "."); |
180 |
|
pSampler->DestroyMidiInputDevice(pDevice); |
181 |
|
} |
182 |
|
catch (LinuxSamplerException e) { |
183 |
|
result.Error(e); |
184 |
|
} |
185 |
|
return result.Produce(); |
186 |
|
} |
187 |
|
|
188 |
/** |
/** |
189 |
* Will be called by the parser to load an instrument. |
* Will be called by the parser to load an instrument. |
190 |
*/ |
*/ |
330 |
result.Add("INSTRUMENT_NR", InstrumentIndex); |
result.Add("INSTRUMENT_NR", InstrumentIndex); |
331 |
result.Add("INSTRUMENT_STATUS", InstrumentStatus); |
result.Add("INSTRUMENT_STATUS", InstrumentStatus); |
332 |
|
|
333 |
//Some more hardcoded stuff for now to make GUI look good |
MidiInputDevice *pDevice = pSamplerChannel->GetMidiInputDevice(); |
334 |
result.Add("MIDI_INPUT_DEVICE", "0"); |
if (pDevice) { |
335 |
result.Add("MIDI_INPUT_PORT", "0"); |
result.Add("MIDI_INPUT_DEVICE", GetMidiInputDeviceIndex(pDevice)); |
336 |
result.Add("MIDI_INPUT_CHANNEL", "1"); |
MidiInputDevice::MidiInputPort *pPort = pSamplerChannel->GetMidiInputPort(); |
337 |
|
if (pPort) { |
338 |
|
result.Add("MIDI_INPUT_PORT", (int)pPort->GetPortNumber()); |
339 |
|
result.Add("MIDI_INPUT_CHANNEL", (int)pSamplerChannel->GetMidiInputChannel()); |
340 |
|
} |
341 |
|
|
342 |
|
} |
343 |
} |
} |
344 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
345 |
result.Error(e); |
result.Error(e); |
433 |
return result.Produce(); |
return result.Produce(); |
434 |
} |
} |
435 |
|
|
436 |
|
String LSCPServer::GetAvailableMidiInputDrivers() { |
437 |
|
dmsg(2,("LSCPServer: GetAvailableMidiInputDrivers()\n")); |
438 |
|
LSCPResultSet result; |
439 |
|
try { |
440 |
|
String s = MidiInputDeviceFactory::AvailableDriversAsString(); |
441 |
|
result.Add(s); |
442 |
|
} |
443 |
|
catch (LinuxSamplerException e) { |
444 |
|
result.Error(e); |
445 |
|
} |
446 |
|
return result.Produce(); |
447 |
|
} |
448 |
|
|
449 |
|
String LSCPServer::GetMidiInputDriverInfo(String Driver) { |
450 |
|
dmsg(2,("LSCPServer: GetMidiInputDriverInfo(Driver=%s)\n",Driver.c_str())); |
451 |
|
LSCPResultSet result; |
452 |
|
try { |
453 |
|
result.Add("DESCRIPTION", MidiInputDeviceFactory::GetDriverDescription(Driver)); |
454 |
|
result.Add("VERSION", MidiInputDeviceFactory::GetDriverVersion(Driver)); |
455 |
|
|
456 |
|
std::map<String,DeviceCreationParameter*> parameters = MidiInputDeviceFactory::GetAvailableDriverParameters(Driver); |
457 |
|
if (parameters.size()) { // if there are parameters defined for this driver |
458 |
|
String s; |
459 |
|
std::map<String,DeviceCreationParameter*>::iterator iter = parameters.begin(); |
460 |
|
for (;iter != parameters.end(); iter++) { |
461 |
|
if (s != "") s += ","; |
462 |
|
s += iter->first; |
463 |
|
} |
464 |
|
result.Add("PARAMETERS", s); |
465 |
|
} |
466 |
|
} |
467 |
|
catch (LinuxSamplerException e) { |
468 |
|
result.Error(e); |
469 |
|
} |
470 |
|
return result.Produce(); |
471 |
|
} |
472 |
|
|
473 |
String LSCPServer::GetAudioOutputDriverInfo(String Driver) { |
String LSCPServer::GetAudioOutputDriverInfo(String Driver) { |
474 |
dmsg(2,("LSCPServer: GetAudioOutputDriverInfo(Driver=%s)\n",Driver.c_str())); |
dmsg(2,("LSCPServer: GetAudioOutputDriverInfo(Driver=%s)\n",Driver.c_str())); |
475 |
LSCPResultSet result; |
LSCPResultSet result; |
494 |
return result.Produce(); |
return result.Produce(); |
495 |
} |
} |
496 |
|
|
497 |
|
String LSCPServer::GetMidiInputDriverParameterInfo(String Driver, String Parameter, std::map<String,String> DependencyList) { |
498 |
|
dmsg(2,("LSCPServer: GetMidiInputDriverParameterInfo(Driver=%s,Parameter=%s)\n",Driver.c_str(),Parameter.c_str())); |
499 |
|
LSCPResultSet result; |
500 |
|
try { |
501 |
|
DeviceCreationParameter* pParameter = MidiInputDeviceFactory::GetDriverParameter(Driver, Parameter); |
502 |
|
result.Add("TYPE", pParameter->Type()); |
503 |
|
result.Add("DESCRIPTION", pParameter->Description()); |
504 |
|
result.Add("MANDATORY", pParameter->Mandatory()); |
505 |
|
result.Add("FIX", pParameter->Fix()); |
506 |
|
result.Add("MULTIPLICITY", pParameter->Multiplicity()); |
507 |
|
if (pParameter->Depends()) result.Add("DEPENDS", pParameter->Depends()); |
508 |
|
if (pParameter->Default()) result.Add("DEFAULT", pParameter->Default()); |
509 |
|
if (pParameter->RangeMin()) result.Add("RANGE_MIN", pParameter->RangeMin()); |
510 |
|
if (pParameter->RangeMax()) result.Add("RANGE_MAX", pParameter->RangeMax()); |
511 |
|
if (pParameter->Possibilities()) result.Add("POSSIBILITIES", pParameter->Possibilities()); |
512 |
|
} |
513 |
|
catch (LinuxSamplerException e) { |
514 |
|
result.Error(e); |
515 |
|
} |
516 |
|
return result.Produce(); |
517 |
|
} |
518 |
|
|
519 |
String LSCPServer::GetAudioOutputDriverParameterInfo(String Driver, String Parameter, std::map<String,String> DependencyList) { |
String LSCPServer::GetAudioOutputDriverParameterInfo(String Driver, String Parameter, std::map<String,String> DependencyList) { |
520 |
dmsg(2,("LSCPServer: GetAudioOutputDriverParameterInfo(Driver=%s,Parameter=%s)\n",Driver.c_str(),Parameter.c_str())); |
dmsg(2,("LSCPServer: GetAudioOutputDriverParameterInfo(Driver=%s,Parameter=%s)\n",Driver.c_str(),Parameter.c_str())); |
521 |
LSCPResultSet result; |
LSCPResultSet result; |
551 |
return result.Produce(); |
return result.Produce(); |
552 |
} |
} |
553 |
|
|
554 |
|
String LSCPServer::GetMidiInputDeviceCount() { |
555 |
|
dmsg(2,("LSCPServer: GetMidiInputDeviceCount()\n")); |
556 |
|
LSCPResultSet result; |
557 |
|
try { |
558 |
|
uint count = pSampler->MidiInputDevices(); |
559 |
|
result.Add(count); // success |
560 |
|
} |
561 |
|
catch (LinuxSamplerException e) { |
562 |
|
result.Error(e); |
563 |
|
} |
564 |
|
return result.Produce(); |
565 |
|
} |
566 |
|
|
567 |
String LSCPServer::GetAudioOutputDevices() { |
String LSCPServer::GetAudioOutputDevices() { |
568 |
dmsg(2,("LSCPServer: GetAudioOutputDevices()\n")); |
dmsg(2,("LSCPServer: GetAudioOutputDevices()\n")); |
569 |
LSCPResultSet result; |
LSCPResultSet result; |
583 |
return result.Produce(); |
return result.Produce(); |
584 |
} |
} |
585 |
|
|
586 |
|
String LSCPServer::GetMidiInputDevices() { |
587 |
|
dmsg(2,("LSCPServer: GetMidiInputDevices()\n")); |
588 |
|
LSCPResultSet result; |
589 |
|
try { |
590 |
|
String s; |
591 |
|
std::map<uint, MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
592 |
|
std::map<uint, MidiInputDevice*>::iterator iter = devices.begin(); |
593 |
|
for (; iter != devices.end(); iter++) { |
594 |
|
if (s != "") s += ","; |
595 |
|
s += ToString(iter->first); |
596 |
|
} |
597 |
|
result.Add(s); |
598 |
|
} |
599 |
|
catch (LinuxSamplerException e) { |
600 |
|
result.Error(e); |
601 |
|
} |
602 |
|
return result.Produce(); |
603 |
|
} |
604 |
|
|
605 |
String LSCPServer::GetAudioOutputDeviceInfo(uint DeviceIndex) { |
String LSCPServer::GetAudioOutputDeviceInfo(uint DeviceIndex) { |
606 |
dmsg(2,("LSCPServer: GetAudioOutputDeviceInfo(DeviceIndex=%d)\n",DeviceIndex)); |
dmsg(2,("LSCPServer: GetAudioOutputDeviceInfo(DeviceIndex=%d)\n",DeviceIndex)); |
607 |
LSCPResultSet result; |
LSCPResultSet result; |
622 |
return result.Produce(); |
return result.Produce(); |
623 |
} |
} |
624 |
|
|
625 |
|
String LSCPServer::GetMidiInputDeviceInfo(uint DeviceIndex) { |
626 |
|
dmsg(2,("LSCPServer: GetMidiInputDeviceInfo(DeviceIndex=%d)\n",DeviceIndex)); |
627 |
|
LSCPResultSet result; |
628 |
|
try { |
629 |
|
std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
630 |
|
MidiInputDevice* pDevice = devices[DeviceIndex]; |
631 |
|
if (!pDevice) throw LinuxSamplerException("There is no midi input device with index " + ToString(DeviceIndex) + "."); |
632 |
|
result.Add("driver", pDevice->Driver()); |
633 |
|
std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters(); |
634 |
|
std::map<String,DeviceCreationParameter*>::iterator iter = parameters.begin(); |
635 |
|
for (; iter != parameters.end(); iter++) { |
636 |
|
result.Add(iter->first, iter->second->Value()); |
637 |
|
} |
638 |
|
} |
639 |
|
catch (LinuxSamplerException e) { |
640 |
|
result.Error(e); |
641 |
|
} |
642 |
|
return result.Produce(); |
643 |
|
} |
644 |
|
String LSCPServer::GetMidiInputPortInfo(uint DeviceIndex, uint PortIndex) { |
645 |
|
dmsg(2,("LSCPServer: GetMidiInputPortInfo(DeviceIndex=%d, PortIndex=%d)\n",DeviceIndex, PortIndex)); |
646 |
|
LSCPResultSet result; |
647 |
|
try { |
648 |
|
std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
649 |
|
MidiInputDevice* pDevice = devices[DeviceIndex]; |
650 |
|
if (!pDevice) throw LinuxSamplerException("There is no midi input device with index " + ToString(DeviceIndex) + "."); |
651 |
|
MidiInputDevice::MidiInputPort* pMidiInputPort = pDevice->GetPort(PortIndex); |
652 |
|
if (!pMidiInputPort) throw LinuxSamplerException("There is no midi input port with index " + ToString(PortIndex) + "."); |
653 |
|
std::map<String,DeviceCreationParameter*> parameters = pMidiInputPort->DeviceParameters(); |
654 |
|
std::map<String,DeviceCreationParameter*>::iterator iter = parameters.begin(); |
655 |
|
for (; iter != parameters.end(); iter++) { |
656 |
|
result.Add(iter->first, iter->second->Value()); |
657 |
|
} |
658 |
|
} |
659 |
|
catch (LinuxSamplerException e) { |
660 |
|
result.Error(e); |
661 |
|
} |
662 |
|
return result.Produce(); |
663 |
|
} |
664 |
|
|
665 |
String LSCPServer::GetAudioOutputChannelInfo(uint DeviceId, uint ChannelId) { |
String LSCPServer::GetAudioOutputChannelInfo(uint DeviceId, uint ChannelId) { |
666 |
dmsg(2,("LSCPServer: GetAudioOutputChannelInfo(DeviceId=%d,ChannelId)\n",DeviceId,ChannelId)); |
dmsg(2,("LSCPServer: GetAudioOutputChannelInfo(DeviceId=%d,ChannelId)\n",DeviceId,ChannelId)); |
667 |
LSCPResultSet result; |
LSCPResultSet result; |
765 |
return result.Produce(); |
return result.Produce(); |
766 |
} |
} |
767 |
|
|
768 |
|
String LSCPServer::SetMidiInputDeviceParameter(uint DeviceIndex, String ParamKey, String ParamVal) { |
769 |
|
dmsg(2,("LSCPServer: SetMidiOutputDeviceParameter(DeviceIndex=%d,ParamKey=%s,ParamVal=%s)\n",DeviceIndex,ParamKey.c_str(),ParamVal.c_str())); |
770 |
|
LSCPResultSet result; |
771 |
|
try { |
772 |
|
std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
773 |
|
if (!devices[DeviceIndex]) throw LinuxSamplerException("There is no midi input device with index " + ToString(DeviceIndex) + "."); |
774 |
|
MidiInputDevice* pDevice = devices[DeviceIndex]; |
775 |
|
std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters(); |
776 |
|
if (!parameters[ParamKey]) throw LinuxSamplerException("Midi input device " + ToString(DeviceIndex) + " does not have a device parameter '" + ParamKey + "'"); |
777 |
|
parameters[ParamKey]->SetValue(ParamVal); |
778 |
|
} |
779 |
|
catch (LinuxSamplerException e) { |
780 |
|
result.Error(e); |
781 |
|
} |
782 |
|
return result.Produce(); |
783 |
|
} |
784 |
|
|
785 |
|
String LSCPServer::SetMidiInputPortParameter(uint DeviceIndex, uint PortIndex, String ParamKey, String ParamVal) { |
786 |
|
dmsg(2,("LSCPServer: SetMidiOutputDeviceParameter(DeviceIndex=%d,ParamKey=%s,ParamVal=%s)\n",DeviceIndex,ParamKey.c_str(),ParamVal.c_str())); |
787 |
|
LSCPResultSet result; |
788 |
|
try { |
789 |
|
std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
790 |
|
MidiInputDevice* pDevice = devices[DeviceIndex]; |
791 |
|
if (!pDevice) throw LinuxSamplerException("There is no midi input device with index " + ToString(DeviceIndex) + "."); |
792 |
|
MidiInputDevice::MidiInputPort* pMidiInputPort = pDevice->GetPort(PortIndex); |
793 |
|
if (!pMidiInputPort) throw LinuxSamplerException("There is no midi input port with index " + ToString(PortIndex) + "."); |
794 |
|
std::map<String,DeviceCreationParameter*> parameters = pMidiInputPort->DeviceParameters(); |
795 |
|
if (!parameters[ParamKey]) throw LinuxSamplerException("Midi input device " + ToString(PortIndex) + " does not have a parameter '" + ParamKey + "'"); |
796 |
|
parameters[ParamKey]->SetValue(ParamVal); |
797 |
|
} |
798 |
|
catch (LinuxSamplerException e) { |
799 |
|
result.Error(e); |
800 |
|
} |
801 |
|
return result.Produce(); |
802 |
|
} |
803 |
|
|
804 |
/** |
/** |
805 |
* Will be called by the parser to change the audio output channel for |
* Will be called by the parser to change the audio output channel for |
806 |
* playback on a particular sampler channel. |
* playback on a particular sampler channel. |
847 |
return result.Produce(); |
return result.Produce(); |
848 |
} |
} |
849 |
|
|
|
|
|
850 |
String LSCPServer::SetMIDIInputType(String MidiInputDriver, uint uiSamplerChannel) { |
String LSCPServer::SetMIDIInputType(String MidiInputDriver, uint uiSamplerChannel) { |
851 |
dmsg(2,("LSCPServer: SetMIDIInputType(String MidiInputDriver=%s, SamplerChannel=%d)\n",MidiInputDriver.c_str(),uiSamplerChannel)); |
dmsg(2,("LSCPServer: SetMIDIInputType(String MidiInputDriver=%s, SamplerChannel=%d)\n",MidiInputDriver.c_str(),uiSamplerChannel)); |
852 |
LSCPResultSet result; |
LSCPResultSet result; |
853 |
try { |
try { |
854 |
|
#if 1 |
855 |
|
throw LinuxSamplerException("Command deprecated"); |
856 |
|
#else |
857 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
858 |
if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds"); |
if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds"); |
859 |
// FIXME: workaround until MIDI driver configuration is implemented (using a Factory class for the MIDI input drivers then, like its already done for audio output drivers) |
// FIXME: workaround until MIDI driver configuration is implemented (using a Factory class for the MIDI input drivers then, like its already done for audio output drivers) |
861 |
if (MidiInputDriver != "Alsa") throw LinuxSamplerException("Unknown MIDI input driver '" + MidiInputDriver + "'."); |
if (MidiInputDriver != "Alsa") throw LinuxSamplerException("Unknown MIDI input driver '" + MidiInputDriver + "'."); |
862 |
MidiInputDevice::type_t MidiInputType = MidiInputDevice::type_alsa; |
MidiInputDevice::type_t MidiInputType = MidiInputDevice::type_alsa; |
863 |
pSamplerChannel->SetMidiInputDevice(MidiInputType); |
pSamplerChannel->SetMidiInputDevice(MidiInputType); |
864 |
|
#endif |
865 |
} |
} |
866 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
867 |
result.Error(e); |
result.Error(e); |
870 |
} |
} |
871 |
|
|
872 |
/** |
/** |
873 |
* Will be called by the parser to change the MIDI input port on which the |
* Will be called by the parser to change the MIDI input device, port and channel on which |
874 |
* engine of a particular sampler channel should listen to. |
* engine of a particular sampler channel should listen to. |
875 |
*/ |
*/ |
876 |
String LSCPServer::SetMIDIInputPort(String MIDIInputPort, uint uiSamplerChannel) { |
String LSCPServer::SetMIDIInput(uint MIDIDevice, uint MIDIPort, uint MIDIChannel, uint uiSamplerChannel) { |
877 |
dmsg(2,("LSCPServer: SetMIDIInputPort(MIDIInputPort=%s, Samplerchannel=%d)\n", MIDIInputPort.c_str(), uiSamplerChannel)); |
dmsg(2,("LSCPServer: SetMIDIInput(MIDIDevice=%d, MIDIPort=%d, MIDIChannel=%d, SamplerChannel=%d)\n", MIDIDevice, MIDIPort, MIDIChannel, uiSamplerChannel)); |
878 |
LSCPResultSet result; |
LSCPResultSet result; |
879 |
try { |
try { |
880 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
881 |
if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds"); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); |
882 |
if (!pSamplerChannel->GetMidiInputDevice()) throw LinuxSamplerException("No MIDI input device connected yet"); |
std::map<uint, MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
883 |
pSamplerChannel->GetMidiInputDevice()->SetInputPort(MIDIInputPort.c_str()); |
MidiInputDevice* pDevice = devices[MIDIDevice]; |
884 |
} |
if (!pDevice) throw LinuxSamplerException("There is no midi input device with index " + ToString(MIDIDevice)); |
885 |
catch (LinuxSamplerException e) { |
pSamplerChannel->SetMidiInputPort(pDevice, MIDIPort, (MidiInputDevice::MidiInputPort::midi_chan_t) MIDIChannel); |
|
result.Error(e); |
|
|
} |
|
|
return result.Produce(); |
|
|
} |
|
|
|
|
|
/** |
|
|
* Will be called by the parser to change the MIDI input channel on which the |
|
|
* engine of a particular sampler channel should listen to. |
|
|
*/ |
|
|
String LSCPServer::SetMIDIInputChannel(uint MIDIChannel, uint uiSamplerChannel) { |
|
|
dmsg(2,("LSCPServer: SetMIDIInputChannel(MIDIChannel=%d, SamplerChannel=%d)\n", MIDIChannel, uiSamplerChannel)); |
|
|
LSCPResultSet result; |
|
|
try { |
|
|
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
|
|
if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds"); |
|
|
if (!pSamplerChannel->GetMidiInputDevice()) throw LinuxSamplerException("No MIDI input device connected yet"); |
|
|
MidiInputDevice::type_t oldtype = pSamplerChannel->GetMidiInputDevice()->Type(); |
|
|
pSamplerChannel->SetMidiInputDevice(oldtype, (MidiInputDevice::midi_chan_t) MIDIChannel); |
|
886 |
} |
} |
887 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
888 |
result.Error(e); |
result.Error(e); |
896 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
897 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); |
898 |
std::map<uint, AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
std::map<uint, AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
|
if (!devices[AudioDeviceId]) throw LinuxSamplerException("There is no audio output device with index " + ToString(AudioDeviceId)); |
|
899 |
AudioOutputDevice* pDevice = devices[AudioDeviceId]; |
AudioOutputDevice* pDevice = devices[AudioDeviceId]; |
900 |
|
if (!pDevice) throw LinuxSamplerException("There is no audio output device with index " + ToString(AudioDeviceId)); |
901 |
pSamplerChannel->SetAudioOutputDevice(pDevice); |
pSamplerChannel->SetAudioOutputDevice(pDevice); |
902 |
} |
} |
903 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |