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 |
|
|
209 |
|
//Defaults values |
210 |
|
String EngineName = "NONE"; |
211 |
|
float Volume = 0; |
212 |
|
String InstrumentFileName = "NONE"; |
213 |
|
int InstrumentIndex = 0; |
214 |
|
|
215 |
|
if (pEngine) { |
216 |
|
EngineName = pEngine->EngineName(); |
217 |
|
Volume = pEngine->Volume(); |
218 |
|
int iIdx = pEngine->InstrumentIndex(); |
219 |
|
if (iIdx != -1) { |
220 |
|
InstrumentFileName = pEngine->InstrumentFileName(); |
221 |
|
InstrumentIndex = iIdx; |
222 |
|
} |
223 |
|
} |
224 |
|
|
225 |
|
result.Add("ENGINE_NAME", EngineName); |
226 |
|
result.Add("VOLUME", Volume); |
227 |
|
|
228 |
|
//Some hardcoded stuff for now to make GUI look good |
229 |
|
result.Add("AUDIO_OUTPUT_DEVICE", "0"); |
230 |
|
result.Add("AUDIO_OUTPUT_CHANNELS", "2"); |
231 |
|
result.Add("AUDIO_OUTPUT_ROUTING", "0,1"); |
232 |
|
|
233 |
|
result.Add("INSTRUMENT_FILE", InstrumentFileName); |
234 |
|
result.Add("INSTRUMENT_NR", InstrumentIndex); |
235 |
|
|
236 |
|
//Some more hardcoded stuff for now to make GUI look good |
237 |
|
result.Add("MIDI_INPUT_DEVICE", "0"); |
238 |
|
result.Add("MIDI_INPUT_PORT", "0"); |
239 |
|
result.Add("MIDI_INPUT_CHANNEL", "1"); |
240 |
|
|
241 |
|
return result.Produce(); |
242 |
|
} |
243 |
|
catch (LinuxSamplerException e) { |
244 |
|
result_t result; |
245 |
|
e.PrintMessage(); |
246 |
|
result.type = result_type_error; |
247 |
|
result.code = LSCP_ERR_UNKNOWN; |
248 |
|
result.message = e.Message(); |
249 |
|
return ConvertResult(result); |
250 |
|
} |
251 |
} |
} |
252 |
|
|
253 |
/** |
/** |
331 |
* 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 |
332 |
* particular sampler channel. |
* particular sampler channel. |
333 |
*/ |
*/ |
334 |
String LSCPServer::SetAudioOutputType(audio_output_type_t AudioOutputType, uint uiSamplerChannel) { |
String LSCPServer::SetAudioOutputType(AudioOutputDevice::type_t AudioOutputType, uint uiSamplerChannel) { |
335 |
dmsg(2,("LSCPServer: SetAudioOutputType(AudioOutputType=%d, SamplerChannel=%d)\n", AudioOutputType, uiSamplerChannel)); |
dmsg(2,("LSCPServer: SetAudioOutputType(AudioOutputType=%d, SamplerChannel=%d)\n", AudioOutputType, uiSamplerChannel)); |
336 |
result_t result; |
result_t result; |
337 |
try { |
try { |
358 |
return "ERR:0:Not implemented yet.\r\n"; |
return "ERR:0:Not implemented yet.\r\n"; |
359 |
} |
} |
360 |
|
|
361 |
String LSCPServer::SetMIDIInputType(midi_input_type_t MidiInputType, uint uiSamplerChannel) { |
String LSCPServer::SetMIDIInputType(MidiInputDevice::type_t MidiInputType, uint uiSamplerChannel) { |
362 |
dmsg(2,("LSCPServer: SetMIDIInputType(MidiInputType=%d, SamplerChannel=%d)\n", MidiInputType, uiSamplerChannel)); |
dmsg(2,("LSCPServer: SetMIDIInputType(MidiInputType=%d, SamplerChannel=%d)\n", MidiInputType, uiSamplerChannel)); |
363 |
result_t result; |
result_t result; |
364 |
try { |
try { |
380 |
* 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 |
381 |
* engine of a particular sampler channel should listen to. |
* engine of a particular sampler channel should listen to. |
382 |
*/ |
*/ |
383 |
String LSCPServer::SetMIDIInputPort(String MIDIInputPort, uint uiSamplerchannel) { |
String LSCPServer::SetMIDIInputPort(String MIDIInputPort, uint uiSamplerChannel) { |
384 |
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)); |
385 |
return "ERR:0:Not implemented yet.\r\n"; |
result_t result; |
386 |
|
try { |
387 |
|
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
388 |
|
if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds"); |
389 |
|
if (!pSamplerChannel->GetMidiInputDevice()) throw LinuxSamplerException("No MIDI input device connected yet"); |
390 |
|
pSamplerChannel->GetMidiInputDevice()->SetInputPort(MIDIInputPort.c_str()); |
391 |
|
result.type = result_type_success; |
392 |
|
} |
393 |
|
catch (LinuxSamplerException e) { |
394 |
|
e.PrintMessage(); |
395 |
|
result.type = result_type_error; |
396 |
|
result.code = LSCP_ERR_UNKNOWN; |
397 |
|
result.message = e.Message(); |
398 |
|
} |
399 |
|
return ConvertResult(result); |
400 |
} |
} |
401 |
|
|
402 |
/** |
/** |
405 |
*/ |
*/ |
406 |
String LSCPServer::SetMIDIInputChannel(uint MIDIChannel, uint uiSamplerChannel) { |
String LSCPServer::SetMIDIInputChannel(uint MIDIChannel, uint uiSamplerChannel) { |
407 |
dmsg(2,("LSCPServer: SetMIDIInputChannel(MIDIChannel=%d, SamplerChannel=%d)\n", MIDIChannel, uiSamplerChannel)); |
dmsg(2,("LSCPServer: SetMIDIInputChannel(MIDIChannel=%d, SamplerChannel=%d)\n", MIDIChannel, uiSamplerChannel)); |
408 |
return "ERR:0:Not implemented yet.\r\n"; |
result_t result; |
409 |
|
try { |
410 |
|
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
411 |
|
if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds"); |
412 |
|
if (!pSamplerChannel->GetMidiInputDevice()) throw LinuxSamplerException("No MIDI input device connected yet"); |
413 |
|
MidiInputDevice::type_t oldtype = pSamplerChannel->GetMidiInputDevice()->Type(); |
414 |
|
pSamplerChannel->SetMidiInputDevice(oldtype, (MidiInputDevice::midi_chan_t) MIDIChannel); |
415 |
|
|
416 |
|
result.type = result_type_success; |
417 |
|
} |
418 |
|
catch (LinuxSamplerException e) { |
419 |
|
e.PrintMessage(); |
420 |
|
result.type = result_type_error; |
421 |
|
result.code = LSCP_ERR_UNKNOWN; |
422 |
|
result.message = e.Message(); |
423 |
|
} |
424 |
|
return ConvertResult(result); |
425 |
} |
} |
426 |
|
|
427 |
/** |
/** |