/[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 1761 by iliev, Fri Aug 29 15:42:06 2008 UTC revision 1765 by persson, Sat Sep 6 16:44:42 2008 UTC
# Line 42  Line 42 
42  #include "../drivers/audio/AudioOutputDeviceFactory.h"  #include "../drivers/audio/AudioOutputDeviceFactory.h"
43  #include "../drivers/midi/MidiInputDeviceFactory.h"  #include "../drivers/midi/MidiInputDeviceFactory.h"
44    
45    namespace LinuxSampler {
46    
47  /**  /**
48   * Returns a copy of the given string where all special characters are   * Returns a copy of the given string where all special characters are
# Line 2020  String LSCPServer::GetMidiInstrumentMapp Line 2021  String LSCPServer::GetMidiInstrumentMapp
2021      dmsg(2,("LSCPServer: GetMidiInstrumentMappings()\n"));      dmsg(2,("LSCPServer: GetMidiInstrumentMappings()\n"));
2022      LSCPResultSet result;      LSCPResultSet result;
2023      try {      try {
2024          result.Add(MidiInstrumentMapper::Entries(MidiMapID).size());          result.Add(MidiInstrumentMapper::GetInstrumentCount(MidiMapID));
2025      } catch (Exception e) {      } catch (Exception e) {
2026          result.Error(e);          result.Error(e);
2027      }      }
# Line 2031  String LSCPServer::GetMidiInstrumentMapp Line 2032  String LSCPServer::GetMidiInstrumentMapp
2032  String LSCPServer::GetAllMidiInstrumentMappings() {  String LSCPServer::GetAllMidiInstrumentMappings() {
2033      dmsg(2,("LSCPServer: GetAllMidiInstrumentMappings()\n"));      dmsg(2,("LSCPServer: GetAllMidiInstrumentMappings()\n"));
2034      LSCPResultSet result;      LSCPResultSet result;
2035      std::vector<int> maps = MidiInstrumentMapper::Maps();      try {
2036      int totalMappings = 0;          result.Add(MidiInstrumentMapper::GetInstrumentCount());
2037      for (int i = 0; i < maps.size(); i++) {      } catch (Exception e) {
2038          try {          result.Error(e);
             totalMappings += MidiInstrumentMapper::Entries(maps[i]).size();  
         } catch (Exception e) { /*NOOP*/ }  
2039      }      }
     result.Add(totalMappings);  
2040      return result.Produce();      return result.Produce();
2041  }  }
2042    
# Line 2046  String LSCPServer::GetMidiInstrumentMapp Line 2044  String LSCPServer::GetMidiInstrumentMapp
2044      dmsg(2,("LSCPServer: GetMidiIstrumentMapping()\n"));      dmsg(2,("LSCPServer: GetMidiIstrumentMapping()\n"));
2045      LSCPResultSet result;      LSCPResultSet result;
2046      try {      try {
2047          midi_prog_index_t idx;          MidiInstrumentMapper::entry_t entry = MidiInstrumentMapper::GetEntry(MidiMapID, MidiBank, MidiProg);
2048          idx.midi_bank_msb = (MidiBank >> 7) & 0x7f;          // convert the filename into the correct encoding as defined for LSCP
2049          idx.midi_bank_lsb = MidiBank & 0x7f;          // (especially in terms of special characters -> escape sequences)
         idx.midi_prog     = MidiProg;  
   
         std::map<midi_prog_index_t,MidiInstrumentMapper::entry_t> mappings = MidiInstrumentMapper::Entries(MidiMapID);  
         std::map<midi_prog_index_t,MidiInstrumentMapper::entry_t>::iterator iter = mappings.find(idx);  
         if (iter == mappings.end()) result.Error("there is no map entry with that index");  
         else { // found  
   
             // convert the filename into the correct encoding as defined for LSCP  
             // (especially in terms of special characters -> escape sequences)  
2050  #if WIN32  #if WIN32
2051              const String instrumentFileName = Path::fromWindows(iter->second.InstrumentFile).toLscp();          const String instrumentFileName = Path::fromWindows(entry.InstrumentFile).toLscp();
2052  #else  #else
2053              // assuming POSIX          // assuming POSIX
2054              const String instrumentFileName = Path::fromPosix(iter->second.InstrumentFile).toLscp();          const String instrumentFileName = Path::fromPosix(entry.InstrumentFile).toLscp();
2055  #endif  #endif
2056    
2057              result.Add("NAME", _escapeLscpResponse(iter->second.Name));          result.Add("NAME", _escapeLscpResponse(entry.Name));
2058              result.Add("ENGINE_NAME", iter->second.EngineName);          result.Add("ENGINE_NAME", entry.EngineName);
2059              result.Add("INSTRUMENT_FILE", instrumentFileName);          result.Add("INSTRUMENT_FILE", instrumentFileName);
2060              result.Add("INSTRUMENT_NR", (int) iter->second.InstrumentIndex);          result.Add("INSTRUMENT_NR", (int) entry.InstrumentIndex);
2061              String instrumentName;          String instrumentName;
2062              Engine* pEngine = EngineFactory::Create(iter->second.EngineName);          Engine* pEngine = EngineFactory::Create(entry.EngineName);
2063              if (pEngine) {          if (pEngine) {
2064                  if (pEngine->GetInstrumentManager()) {              if (pEngine->GetInstrumentManager()) {
2065                      InstrumentManager::instrument_id_t instrID;                  InstrumentManager::instrument_id_t instrID;
2066                      instrID.FileName = iter->second.InstrumentFile;                  instrID.FileName = entry.InstrumentFile;
2067                      instrID.Index    = iter->second.InstrumentIndex;                  instrID.Index    = entry.InstrumentIndex;
2068                      instrumentName = pEngine->GetInstrumentManager()->GetInstrumentName(instrID);                  instrumentName = pEngine->GetInstrumentManager()->GetInstrumentName(instrID);
                 }  
                 EngineFactory::Destroy(pEngine);  
2069              }              }
2070              result.Add("INSTRUMENT_NAME", _escapeLscpResponse(instrumentName));              EngineFactory::Destroy(pEngine);
             switch (iter->second.LoadMode) {  
                 case MidiInstrumentMapper::ON_DEMAND:  
                     result.Add("LOAD_MODE", "ON_DEMAND");  
                     break;  
                 case MidiInstrumentMapper::ON_DEMAND_HOLD:  
                     result.Add("LOAD_MODE", "ON_DEMAND_HOLD");  
                     break;  
                 case MidiInstrumentMapper::PERSISTENT:  
                     result.Add("LOAD_MODE", "PERSISTENT");  
                     break;  
                 default:  
                     throw Exception("entry reflects invalid LOAD_MODE, consider this as a bug!");  
             }  
             result.Add("VOLUME", iter->second.Volume);  
2071          }          }
2072            result.Add("INSTRUMENT_NAME", _escapeLscpResponse(instrumentName));
2073            switch (entry.LoadMode) {
2074                case MidiInstrumentMapper::ON_DEMAND:
2075                    result.Add("LOAD_MODE", "ON_DEMAND");
2076                    break;
2077                case MidiInstrumentMapper::ON_DEMAND_HOLD:
2078                    result.Add("LOAD_MODE", "ON_DEMAND_HOLD");
2079                    break;
2080                case MidiInstrumentMapper::PERSISTENT:
2081                    result.Add("LOAD_MODE", "PERSISTENT");
2082                    break;
2083                default:
2084                    throw Exception("entry reflects invalid LOAD_MODE, consider this as a bug!");
2085            }
2086            result.Add("VOLUME", entry.Volume);
2087      } catch (Exception e) {      } catch (Exception e) {
2088          result.Error(e);          result.Error(e);
2089      }      }
# Line 3272  String LSCPServer::SetEcho(yyparse_param Line 3260  String LSCPServer::SetEcho(yyparse_param
3260      }      }
3261      return result.Produce();      return result.Produce();
3262  }  }
3263    
3264    }

Legend:
Removed from v.1761  
changed lines
  Added in v.1765

  ViewVC Help
Powered by ViewVC