132 |
/** |
/** |
133 |
* Will be called by the parser to load an instrument. |
* Will be called by the parser to load an instrument. |
134 |
*/ |
*/ |
135 |
String LSCPServer::LoadInstrument(String Filename, uint uiInstrument, uint uiSamplerChannel) { |
String LSCPServer::LoadInstrument(String Filename, uint uiInstrument, uint uiSamplerChannel, bool bBackground) { |
136 |
dmsg(2,("LSCPServer: LoadInstrument(Filename=%s,Instrument=%d,SamplerChannel=%d)\n", Filename.c_str(), uiInstrument, uiSamplerChannel)); |
dmsg(2,("LSCPServer: LoadInstrument(Filename=%s,Instrument=%d,SamplerChannel=%d)\n", Filename.c_str(), uiInstrument, uiSamplerChannel)); |
137 |
LSCPResultSet result; |
LSCPResultSet result; |
138 |
try { |
try { |
140 |
if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds"); |
if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds"); |
141 |
Engine* pEngine = pSamplerChannel->GetEngine(); |
Engine* pEngine = pSamplerChannel->GetEngine(); |
142 |
if (!pEngine) throw LinuxSamplerException("No engine loaded on channel"); |
if (!pEngine) throw LinuxSamplerException("No engine loaded on channel"); |
143 |
LSCPLoadInstrument *pLoadInstrument = new LSCPLoadInstrument(pEngine, Filename.c_str(), uiInstrument); |
if (bBackground) { |
144 |
pLoadInstrument->StartThread(); |
LSCPLoadInstrument *pLoadInstrument = new LSCPLoadInstrument(pEngine, Filename.c_str(), uiInstrument); |
145 |
|
pLoadInstrument->StartThread(); |
146 |
|
} |
147 |
|
else pEngine->LoadInstrument(Filename.c_str(), uiInstrument); |
148 |
} |
} |
149 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
150 |
result.Error(e); |
result.Error(e); |
420 |
LSCPResultSet result; |
LSCPResultSet result; |
421 |
try { |
try { |
422 |
uint count = pSampler->AudioOutputDevices(); |
uint count = pSampler->AudioOutputDevices(); |
423 |
result = count; // success |
result.Add(count); // success |
424 |
} |
} |
425 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
426 |
result.Error(e); |
result.Error(e); |
585 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
586 |
if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds"); |
if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds"); |
587 |
// 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) |
588 |
if (MidiInputDriver != "ALSA") throw LinuxSamplerException("Unknown MIDI input driver '" + MidiInputDriver + "'."); |
if (MidiInputDriver != "Alsa") throw LinuxSamplerException("Unknown MIDI input driver '" + MidiInputDriver + "'."); |
589 |
MidiInputDevice::type_t MidiInputType = MidiInputDevice::type_alsa; |
MidiInputDevice::type_t MidiInputType = MidiInputDevice::type_alsa; |
590 |
pSamplerChannel->SetMidiInputDevice(MidiInputType); |
pSamplerChannel->SetMidiInputDevice(MidiInputType); |
591 |
} |
} |
634 |
return result.Produce(); |
return result.Produce(); |
635 |
} |
} |
636 |
|
|
637 |
String LSCPServer::SetAudioOutputDevice(uint AudioDeviceId, uint SamplerChannel) { |
String LSCPServer::SetAudioOutputDevice(uint AudioDeviceId, uint uiSamplerChannel) { |
638 |
LSCPResultSet result; |
LSCPResultSet result; |
639 |
try { |
try { |
640 |
throw LinuxSamplerException("Command not yet implemented"); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
641 |
|
if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); |
642 |
|
Engine* pEngine = pSamplerChannel->GetEngine(); |
643 |
|
if (!pEngine) throw LinuxSamplerException("No engine loaded on channel"); |
644 |
|
std::map<uint, AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
645 |
|
if (!devices[AudioDeviceId]) throw LinuxSamplerException("There is no audio output device with index " + ToString(AudioDeviceId)); |
646 |
|
AudioOutputDevice* pDevice = devices[AudioDeviceId]; |
647 |
|
pSamplerChannel->SetAudioOutputDevice(pDevice); |
648 |
} |
} |
649 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
650 |
result.Error(e); |
result.Error(e); |
695 |
* Will be called by the parser to subscribe a client (frontend) on the |
* Will be called by the parser to subscribe a client (frontend) on the |
696 |
* server for receiving event messages. |
* server for receiving event messages. |
697 |
*/ |
*/ |
698 |
String LSCPServer::SubscribeNotification(uint UDPPort) { |
String LSCPServer::SubscribeNotification(event_t Event) { |
699 |
dmsg(2,("LSCPServer: SubscribeNotification(UDPPort=%d)\n", UDPPort)); |
dmsg(2,("LSCPServer: SubscribeNotification(Event=%d)\n", Event)); |
700 |
return "ERR:0:Not implemented yet.\r\n"; |
return "ERR:0:Not implemented yet.\r\n"; |
701 |
} |
} |
702 |
|
|
704 |
* Will be called by the parser to unsubscribe a client on the server |
* Will be called by the parser to unsubscribe a client on the server |
705 |
* for not receiving further event messages. |
* for not receiving further event messages. |
706 |
*/ |
*/ |
707 |
String LSCPServer::UnsubscribeNotification(String SessionID) { |
String LSCPServer::UnsubscribeNotification(event_t Event) { |
708 |
dmsg(2,("LSCPServer: UnsubscribeNotification(SessionID=%s)\n", SessionID.c_str())); |
dmsg(2,("LSCPServer: UnsubscribeNotification(Event=%d)\n", Event)); |
709 |
return "ERR:0:Not implemented yet.\r\n"; |
return "ERR:0:Not implemented yet.\r\n"; |
710 |
} |
} |
711 |
|
|