--- linuxsampler/trunk/src/network/lscpserver.cpp 2004/05/06 20:06:20 64 +++ linuxsampler/trunk/src/network/lscpserver.cpp 2004/06/08 01:29:08 117 @@ -21,6 +21,7 @@ ***************************************************************************/ #include "lscpserver.h" +#include "lscpresultset.h" #include "../engines/gig/Engine.h" @@ -199,7 +200,54 @@ */ 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(); + + //Defaults values + String EngineName = "NONE"; + float Volume = 0; + String InstrumentFileName = "NONE"; + int InstrumentIndex = 0; + + if (pEngine) { + EngineName = pEngine->EngineName(); + Volume = pEngine->Volume(); + int iIdx = pEngine->InstrumentIndex(); + if (iIdx != -1) { + InstrumentFileName = pEngine->InstrumentFileName(); + InstrumentIndex = iIdx; + } + } + + result.Add("ENGINE_NAME", EngineName); + result.Add("VOLUME", 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"); + + result.Add("INSTRUMENT_FILE", InstrumentFileName); + result.Add("INSTRUMENT_NR", InstrumentIndex); + + //Some more 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); + } } /** @@ -332,9 +380,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); } /** @@ -349,7 +411,7 @@ 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) uiSamplerChannel); + pSamplerChannel->SetMidiInputDevice(oldtype, (MidiInputDevice::midi_chan_t) MIDIChannel); result.type = result_type_success; }