/[svn]/linuxsampler/trunk/src/network/lscpserver.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/network/lscpserver.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 56 by schoenebeck, Tue Apr 27 09:21:58 2004 UTC revision 117 by senkov, Tue Jun 8 01:29:08 2004 UTC
# Line 21  Line 21 
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    
# Line 118  String LSCPServer::LoadEngine(String Eng Line 119  String LSCPServer::LoadEngine(String Eng
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");
# Line 199  String LSCPServer::GetEngineInfo(String Line 200  String LSCPServer::GetEngineInfo(String
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  /**  /**
# Line 283  String LSCPServer::GetBufferFill(fill_re Line 331  String LSCPServer::GetBufferFill(fill_re
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 {
# Line 310  String LSCPServer::SetAudioOutputChannel Line 358  String LSCPServer::SetAudioOutputChannel
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 {
# Line 332  String LSCPServer::SetMIDIInputType(midi Line 380  String LSCPServer::SetMIDIInputType(midi
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  /**  /**
# Line 343  String LSCPServer::SetMIDIInputPort(Stri Line 405  String LSCPServer::SetMIDIInputPort(Stri
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  /**  /**

Legend:
Removed from v.56  
changed lines
  Added in v.117

  ViewVC Help
Powered by ViewVC