21 |
***************************************************************************/ |
***************************************************************************/ |
22 |
|
|
23 |
#include "lscpserver.h" |
#include "lscpserver.h" |
24 |
|
#include "lscpresultset.h" |
25 |
|
|
26 |
#include "../engines/gig/Engine.h" |
#include "../engines/gig/Engine.h" |
27 |
|
|
119 |
dmsg(2,("LSCPServer: LoadEngine(EngineName=%s,SamplerChannel=%d)\n", EngineName.c_str(), uiSamplerChannel)); |
dmsg(2,("LSCPServer: LoadEngine(EngineName=%s,SamplerChannel=%d)\n", EngineName.c_str(), uiSamplerChannel)); |
120 |
result_t result; |
result_t result; |
121 |
try { |
try { |
122 |
engine_type_t type; |
Engine::type_t type; |
123 |
if (EngineName == "gig") type = engine_type_gig; |
if (EngineName == "gig") type = Engine::type_gig; |
124 |
else throw LinuxSamplerException("Unknown engine type"); |
else throw LinuxSamplerException("Unknown engine type"); |
125 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
126 |
if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds"); |
if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds"); |
200 |
*/ |
*/ |
201 |
String LSCPServer::GetChannelInfo(uint uiSamplerChannel) { |
String LSCPServer::GetChannelInfo(uint uiSamplerChannel) { |
202 |
dmsg(2,("LSCPServer: GetChannelInfo(SamplerChannel=%d)\n", uiSamplerChannel)); |
dmsg(2,("LSCPServer: GetChannelInfo(SamplerChannel=%d)\n", uiSamplerChannel)); |
203 |
return "ERR:0:Not implemented yet.\r\n"; |
try { |
204 |
|
LSCPResultSet result; |
205 |
|
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
206 |
|
if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds"); |
207 |
|
Engine* pEngine = pSamplerChannel->GetEngine(); |
208 |
|
if (pEngine) { |
209 |
|
result.Add("ENGINE_NAME", pEngine->EngineName()); |
210 |
|
result.Add("VOLUME", pEngine->Volume()); |
211 |
|
} |
212 |
|
//Some hardcoded stuff for now to make GUI look good |
213 |
|
result.Add("AUDIO_OUTPUT_DEVICE", "0"); |
214 |
|
result.Add("AUDIO_OUTPUT_CHANNELS", "2"); |
215 |
|
result.Add("AUDIO_OUTPUT_ROUTING", "0,1"); |
216 |
|
|
217 |
|
if (pEngine) { |
218 |
|
int iIdx = pEngine->InstrumentIndex(); |
219 |
|
if (iIdx != -1) { |
220 |
|
result.Add("INSTRUMENT_FILE", pEngine->InstrumentFileName()); |
221 |
|
result.Add("INSTRUMENT_NR", iIdx); |
222 |
|
} |
223 |
|
} |
224 |
|
//Some hardcoded stuff for now to make GUI look good |
225 |
|
result.Add("MIDI_INPUT_DEVICE", "0"); |
226 |
|
result.Add("MIDI_INPUT_PORT", "0"); |
227 |
|
result.Add("MIDI_INPUT_CHANNEL", "1"); |
228 |
|
|
229 |
|
return result.Produce(); |
230 |
|
} |
231 |
|
catch (LinuxSamplerException e) { |
232 |
|
result_t result; |
233 |
|
e.PrintMessage(); |
234 |
|
result.type = result_type_error; |
235 |
|
result.code = LSCP_ERR_UNKNOWN; |
236 |
|
result.message = e.Message(); |
237 |
|
return ConvertResult(result); |
238 |
|
} |
239 |
} |
} |
240 |
|
|
241 |
/** |
/** |
319 |
* Will be called by the parser to change the audio output type on a |
* Will be called by the parser to change the audio output type on a |
320 |
* particular sampler channel. |
* particular sampler channel. |
321 |
*/ |
*/ |
322 |
String LSCPServer::SetAudioOutputType(audio_output_type_t AudioOutputType, uint uiSamplerChannel) { |
String LSCPServer::SetAudioOutputType(AudioOutputDevice::type_t AudioOutputType, uint uiSamplerChannel) { |
323 |
dmsg(2,("LSCPServer: SetAudioOutputType(AudioOutputType=%d, SamplerChannel=%d)\n", AudioOutputType, uiSamplerChannel)); |
dmsg(2,("LSCPServer: SetAudioOutputType(AudioOutputType=%d, SamplerChannel=%d)\n", AudioOutputType, uiSamplerChannel)); |
324 |
result_t result; |
result_t result; |
325 |
try { |
try { |
346 |
return "ERR:0:Not implemented yet.\r\n"; |
return "ERR:0:Not implemented yet.\r\n"; |
347 |
} |
} |
348 |
|
|
349 |
String LSCPServer::SetMIDIInputType(midi_input_type_t MidiInputType, uint uiSamplerChannel) { |
String LSCPServer::SetMIDIInputType(MidiInputDevice::type_t MidiInputType, uint uiSamplerChannel) { |
350 |
dmsg(2,("LSCPServer: SetMIDIInputType(MidiInputType=%d, SamplerChannel=%d)\n", MidiInputType, uiSamplerChannel)); |
dmsg(2,("LSCPServer: SetMIDIInputType(MidiInputType=%d, SamplerChannel=%d)\n", MidiInputType, uiSamplerChannel)); |
351 |
result_t result; |
result_t result; |
352 |
try { |
try { |
368 |
* 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 port on which the |
369 |
* engine of a particular sampler channel should listen to. |
* engine of a particular sampler channel should listen to. |
370 |
*/ |
*/ |
371 |
String LSCPServer::SetMIDIInputPort(String MIDIInputPort, uint uiSamplerchannel) { |
String LSCPServer::SetMIDIInputPort(String MIDIInputPort, uint uiSamplerChannel) { |
372 |
dmsg(2,("LSCPServer: SetMIDIInputPort(MIDIInputPort=%s, Samplerchannel=%d)\n", MIDIInputPort.c_str(), uiSamplerchannel)); |
dmsg(2,("LSCPServer: SetMIDIInputPort(MIDIInputPort=%s, Samplerchannel=%d)\n", MIDIInputPort.c_str(), uiSamplerChannel)); |
373 |
return "ERR:0:Not implemented yet.\r\n"; |
result_t result; |
374 |
|
try { |
375 |
|
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
376 |
|
if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds"); |
377 |
|
if (!pSamplerChannel->GetMidiInputDevice()) throw LinuxSamplerException("No MIDI input device connected yet"); |
378 |
|
pSamplerChannel->GetMidiInputDevice()->SetInputPort(MIDIInputPort.c_str()); |
379 |
|
result.type = result_type_success; |
380 |
|
} |
381 |
|
catch (LinuxSamplerException e) { |
382 |
|
e.PrintMessage(); |
383 |
|
result.type = result_type_error; |
384 |
|
result.code = LSCP_ERR_UNKNOWN; |
385 |
|
result.message = e.Message(); |
386 |
|
} |
387 |
|
return ConvertResult(result); |
388 |
} |
} |
389 |
|
|
390 |
/** |
/** |
393 |
*/ |
*/ |
394 |
String LSCPServer::SetMIDIInputChannel(uint MIDIChannel, uint uiSamplerChannel) { |
String LSCPServer::SetMIDIInputChannel(uint MIDIChannel, uint uiSamplerChannel) { |
395 |
dmsg(2,("LSCPServer: SetMIDIInputChannel(MIDIChannel=%d, SamplerChannel=%d)\n", MIDIChannel, uiSamplerChannel)); |
dmsg(2,("LSCPServer: SetMIDIInputChannel(MIDIChannel=%d, SamplerChannel=%d)\n", MIDIChannel, uiSamplerChannel)); |
396 |
return "ERR:0:Not implemented yet.\r\n"; |
result_t result; |
397 |
|
try { |
398 |
|
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
399 |
|
if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds"); |
400 |
|
if (!pSamplerChannel->GetMidiInputDevice()) throw LinuxSamplerException("No MIDI input device connected yet"); |
401 |
|
MidiInputDevice::type_t oldtype = pSamplerChannel->GetMidiInputDevice()->Type(); |
402 |
|
pSamplerChannel->SetMidiInputDevice(oldtype, (MidiInputDevice::midi_chan_t) MIDIChannel); |
403 |
|
|
404 |
|
result.type = result_type_success; |
405 |
|
} |
406 |
|
catch (LinuxSamplerException e) { |
407 |
|
e.PrintMessage(); |
408 |
|
result.type = result_type_error; |
409 |
|
result.code = LSCP_ERR_UNKNOWN; |
410 |
|
result.message = e.Message(); |
411 |
|
} |
412 |
|
return ConvertResult(result); |
413 |
} |
} |
414 |
|
|
415 |
/** |
/** |