--- linuxsampler/trunk/src/network/lscpserver.cpp 2004/04/27 09:21:58 56 +++ linuxsampler/trunk/src/network/lscpserver.cpp 2004/06/06 20:59:49 113 @@ -21,6 +21,7 @@ ***************************************************************************/ #include "lscpserver.h" +#include "lscpresultset.h" #include "../engines/gig/Engine.h" @@ -118,8 +119,8 @@ dmsg(2,("LSCPServer: LoadEngine(EngineName=%s,SamplerChannel=%d)\n", EngineName.c_str(), uiSamplerChannel)); result_t result; try { - engine_type_t type; - if (EngineName == "gig") type = engine_type_gig; + Engine::type_t type; + if (EngineName == "gig") type = Engine::type_gig; else throw LinuxSamplerException("Unknown engine type"); SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds"); @@ -199,7 +200,42 @@ */ String LSCPServer::GetChannelInfo(uint uiSamplerChannel) { dmsg(2,("LSCPServer: GetChannelInfo(SamplerChannel=%d)\n", uiSamplerChannel)); - return "ERR:0:Not implemented yet.\r\n"; + try { + LSCPResultSet result; + SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); + if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds"); + Engine* pEngine = pSamplerChannel->GetEngine(); + if (pEngine) { + result.Add("ENGINE_NAME", pEngine->EngineName()); + result.Add("VOLUME", pEngine->Volume()); + } + //Some hardcoded stuff for now to make GUI look good + result.Add("AUDIO_OUTPUT_DEVICE", "0"); + result.Add("AUDIO_OUTPUT_CHANNELS", "2"); + result.Add("AUDIO_OUTPUT_ROUTING", "0,1"); + + if (pEngine) { + int iIdx = pEngine->InstrumentIndex(); + if (iIdx != -1) { + result.Add("INSTRUMENT_FILE", pEngine->InstrumentFileName()); + result.Add("INSTRUMENT_NR", iIdx); + } + } + //Some hardcoded stuff for now to make GUI look good + result.Add("MIDI_INPUT_DEVICE", "0"); + result.Add("MIDI_INPUT_PORT", "0"); + result.Add("MIDI_INPUT_CHANNEL", "1"); + + return result.Produce(); + } + catch (LinuxSamplerException e) { + result_t result; + e.PrintMessage(); + result.type = result_type_error; + result.code = LSCP_ERR_UNKNOWN; + result.message = e.Message(); + return ConvertResult(result); + } } /** @@ -283,7 +319,7 @@ * Will be called by the parser to change the audio output type on a * particular sampler channel. */ -String LSCPServer::SetAudioOutputType(audio_output_type_t AudioOutputType, uint uiSamplerChannel) { +String LSCPServer::SetAudioOutputType(AudioOutputDevice::type_t AudioOutputType, uint uiSamplerChannel) { dmsg(2,("LSCPServer: SetAudioOutputType(AudioOutputType=%d, SamplerChannel=%d)\n", AudioOutputType, uiSamplerChannel)); result_t result; try { @@ -310,7 +346,7 @@ return "ERR:0:Not implemented yet.\r\n"; } -String LSCPServer::SetMIDIInputType(midi_input_type_t MidiInputType, uint uiSamplerChannel) { +String LSCPServer::SetMIDIInputType(MidiInputDevice::type_t MidiInputType, uint uiSamplerChannel) { dmsg(2,("LSCPServer: SetMIDIInputType(MidiInputType=%d, SamplerChannel=%d)\n", MidiInputType, uiSamplerChannel)); result_t result; try { @@ -332,9 +368,23 @@ * Will be called by the parser to change the MIDI input port on which the * engine of a particular sampler channel should listen to. */ -String LSCPServer::SetMIDIInputPort(String MIDIInputPort, uint uiSamplerchannel) { - dmsg(2,("LSCPServer: SetMIDIInputPort(MIDIInputPort=%s, Samplerchannel=%d)\n", MIDIInputPort.c_str(), uiSamplerchannel)); - return "ERR:0:Not implemented yet.\r\n"; +String LSCPServer::SetMIDIInputPort(String MIDIInputPort, uint uiSamplerChannel) { + dmsg(2,("LSCPServer: SetMIDIInputPort(MIDIInputPort=%s, Samplerchannel=%d)\n", MIDIInputPort.c_str(), uiSamplerChannel)); + result_t 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"); + pSamplerChannel->GetMidiInputDevice()->SetInputPort(MIDIInputPort.c_str()); + result.type = result_type_success; + } + catch (LinuxSamplerException e) { + e.PrintMessage(); + result.type = result_type_error; + result.code = LSCP_ERR_UNKNOWN; + result.message = e.Message(); + } + return ConvertResult(result); } /** @@ -343,7 +393,23 @@ */ String LSCPServer::SetMIDIInputChannel(uint MIDIChannel, uint uiSamplerChannel) { dmsg(2,("LSCPServer: SetMIDIInputChannel(MIDIChannel=%d, SamplerChannel=%d)\n", MIDIChannel, uiSamplerChannel)); - return "ERR:0:Not implemented yet.\r\n"; + result_t 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); + + result.type = result_type_success; + } + catch (LinuxSamplerException e) { + e.PrintMessage(); + result.type = result_type_error; + result.code = LSCP_ERR_UNKNOWN; + result.message = e.Message(); + } + return ConvertResult(result); } /**