/[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 1763 by iliev, Wed Sep 3 17:18:51 2008 UTC
# Line 2020  String LSCPServer::GetMidiInstrumentMapp Line 2020  String LSCPServer::GetMidiInstrumentMapp
2020      dmsg(2,("LSCPServer: GetMidiInstrumentMappings()\n"));      dmsg(2,("LSCPServer: GetMidiInstrumentMappings()\n"));
2021      LSCPResultSet result;      LSCPResultSet result;
2022      try {      try {
2023          result.Add(MidiInstrumentMapper::Entries(MidiMapID).size());          result.Add(MidiInstrumentMapper::GetInstrumentCount(MidiMapID));
2024      } catch (Exception e) {      } catch (Exception e) {
2025          result.Error(e);          result.Error(e);
2026      }      }
# Line 2031  String LSCPServer::GetMidiInstrumentMapp Line 2031  String LSCPServer::GetMidiInstrumentMapp
2031  String LSCPServer::GetAllMidiInstrumentMappings() {  String LSCPServer::GetAllMidiInstrumentMappings() {
2032      dmsg(2,("LSCPServer: GetAllMidiInstrumentMappings()\n"));      dmsg(2,("LSCPServer: GetAllMidiInstrumentMappings()\n"));
2033      LSCPResultSet result;      LSCPResultSet result;
2034      std::vector<int> maps = MidiInstrumentMapper::Maps();      try {
2035      int totalMappings = 0;          result.Add(MidiInstrumentMapper::GetInstrumentCount());
2036      for (int i = 0; i < maps.size(); i++) {      } catch (Exception e) {
2037          try {          result.Error(e);
             totalMappings += MidiInstrumentMapper::Entries(maps[i]).size();  
         } catch (Exception e) { /*NOOP*/ }  
2038      }      }
     result.Add(totalMappings);  
2039      return result.Produce();      return result.Produce();
2040  }  }
2041    
# Line 2046  String LSCPServer::GetMidiInstrumentMapp Line 2043  String LSCPServer::GetMidiInstrumentMapp
2043      dmsg(2,("LSCPServer: GetMidiIstrumentMapping()\n"));      dmsg(2,("LSCPServer: GetMidiIstrumentMapping()\n"));
2044      LSCPResultSet result;      LSCPResultSet result;
2045      try {      try {
2046          midi_prog_index_t idx;          MidiInstrumentMapper::entry_t entry = MidiInstrumentMapper::GetEntry(MidiMapID, MidiBank, MidiProg);
2047          idx.midi_bank_msb = (MidiBank >> 7) & 0x7f;          // convert the filename into the correct encoding as defined for LSCP
2048          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)  
2049  #if WIN32  #if WIN32
2050              const String instrumentFileName = Path::fromWindows(iter->second.InstrumentFile).toLscp();          const String instrumentFileName = Path::fromWindows(entry.InstrumentFile).toLscp();
2051  #else  #else
2052              // assuming POSIX          // assuming POSIX
2053              const String instrumentFileName = Path::fromPosix(iter->second.InstrumentFile).toLscp();          const String instrumentFileName = Path::fromPosix(entry.InstrumentFile).toLscp();
2054  #endif  #endif
2055    
2056              result.Add("NAME", _escapeLscpResponse(iter->second.Name));          result.Add("NAME", _escapeLscpResponse(entry.Name));
2057              result.Add("ENGINE_NAME", iter->second.EngineName);          result.Add("ENGINE_NAME", entry.EngineName);
2058              result.Add("INSTRUMENT_FILE", instrumentFileName);          result.Add("INSTRUMENT_FILE", instrumentFileName);
2059              result.Add("INSTRUMENT_NR", (int) iter->second.InstrumentIndex);          result.Add("INSTRUMENT_NR", (int) entry.InstrumentIndex);
2060              String instrumentName;          String instrumentName;
2061              Engine* pEngine = EngineFactory::Create(iter->second.EngineName);          Engine* pEngine = EngineFactory::Create(entry.EngineName);
2062              if (pEngine) {          if (pEngine) {
2063                  if (pEngine->GetInstrumentManager()) {              if (pEngine->GetInstrumentManager()) {
2064                      InstrumentManager::instrument_id_t instrID;                  InstrumentManager::instrument_id_t instrID;
2065                      instrID.FileName = iter->second.InstrumentFile;                  instrID.FileName = entry.InstrumentFile;
2066                      instrID.Index    = iter->second.InstrumentIndex;                  instrID.Index    = entry.InstrumentIndex;
2067                      instrumentName = pEngine->GetInstrumentManager()->GetInstrumentName(instrID);                  instrumentName = pEngine->GetInstrumentManager()->GetInstrumentName(instrID);
                 }  
                 EngineFactory::Destroy(pEngine);  
             }  
             result.Add("INSTRUMENT_NAME", _escapeLscpResponse(instrumentName));  
             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!");  
2068              }              }
2069              result.Add("VOLUME", iter->second.Volume);              EngineFactory::Destroy(pEngine);
2070            }
2071            result.Add("INSTRUMENT_NAME", _escapeLscpResponse(instrumentName));
2072            switch (entry.LoadMode) {
2073                case MidiInstrumentMapper::ON_DEMAND:
2074                    result.Add("LOAD_MODE", "ON_DEMAND");
2075                    break;
2076                case MidiInstrumentMapper::ON_DEMAND_HOLD:
2077                    result.Add("LOAD_MODE", "ON_DEMAND_HOLD");
2078                    break;
2079                case MidiInstrumentMapper::PERSISTENT:
2080                    result.Add("LOAD_MODE", "PERSISTENT");
2081                    break;
2082                default:
2083                    throw Exception("entry reflects invalid LOAD_MODE, consider this as a bug!");
2084          }          }
2085            result.Add("VOLUME", entry.Volume);
2086      } catch (Exception e) {      } catch (Exception e) {
2087          result.Error(e);          result.Error(e);
2088      }      }

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

  ViewVC Help
Powered by ViewVC