/[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 53 by schoenebeck, Mon Apr 26 17:15:51 2004 UTC revision 113 by senkov, Sun Jun 6 20:59:49 2004 UTC
# Line 2  Line 2 
2   *                                                                         *   *                                                                         *
3   *   LinuxSampler - modular, streaming capable sampler                     *   *   LinuxSampler - modular, streaming capable sampler                     *
4   *                                                                         *   *                                                                         *
5   *   Copyright (C) 2003 by Benno Senoner and Christian Schoenebeck         *   *   Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck   *
6   *                                                                         *   *                                                                         *
7   *   This program is free software; you can redistribute it and/or modify  *   *   This program is free software; you can redistribute it and/or modify  *
8   *   it under the terms of the GNU General Public License as published by  *   *   it under the terms of the GNU General Public License as published by  *
# 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            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  /**  /**
# Line 283  String LSCPServer::GetBufferFill(fill_re Line 319  String LSCPServer::GetBufferFill(fill_re
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 {
# Line 310  String LSCPServer::SetAudioOutputChannel Line 346  String LSCPServer::SetAudioOutputChannel
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 {
# Line 332  String LSCPServer::SetMIDIInputType(midi Line 368  String LSCPServer::SetMIDIInputType(midi
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  /**  /**
# Line 343  String LSCPServer::SetMIDIInputPort(Stri Line 393  String LSCPServer::SetMIDIInputPort(Stri
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  /**  /**

Legend:
Removed from v.53  
changed lines
  Added in v.113

  ViewVC Help
Powered by ViewVC