/[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 1727 by iliev, Tue Apr 29 15:44:09 2008 UTC revision 1763 by iliev, Wed Sep 3 17:18:51 2008 UTC
# Line 424  int LSCPServer::Main() { Line 424  int LSCPServer::Main() {
424              std::set<EngineChannel*>::iterator itEnd           = engineChannels.end();              std::set<EngineChannel*>::iterator itEnd           = engineChannels.end();
425              for (; itEngineChannel != itEnd; ++itEngineChannel) {              for (; itEngineChannel != itEnd; ++itEngineChannel) {
426                  if ((*itEngineChannel)->StatusChanged()) {                  if ((*itEngineChannel)->StatusChanged()) {
427                      SendLSCPNotify(LSCPEvent(LSCPEvent::event_channel_info, (*itEngineChannel)->iSamplerChannelIndex));                      SendLSCPNotify(LSCPEvent(LSCPEvent::event_channel_info, (*itEngineChannel)->GetSamplerChannel()->Index()));
428                  }                  }
429    
430                  for (int i = 0; i < (*itEngineChannel)->GetFxSendCount(); i++) {                  for (int i = 0; i < (*itEngineChannel)->GetFxSendCount(); i++) {
431                      FxSend* fxs = (*itEngineChannel)->GetFxSend(i);                      FxSend* fxs = (*itEngineChannel)->GetFxSend(i);
432                      if(fxs != NULL && fxs->IsInfoChanged()) {                      if(fxs != NULL && fxs->IsInfoChanged()) {
433                          int chn = (*itEngineChannel)->iSamplerChannelIndex;                          int chn = (*itEngineChannel)->GetSamplerChannel()->Index();
434                          LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_fx_send_info, chn, fxs->Id()));                          LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_fx_send_info, chn, fxs->Id()));
435                          fxs->SetInfoChanged(false);                          fxs->SetInfoChanged(false);
436                      }                      }
# 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);  
2068              }              }
2069              result.Add("INSTRUMENT_NAME", _escapeLscpResponse(instrumentName));              EngineFactory::Destroy(pEngine);
2070              switch (iter->second.LoadMode) {          }
2071                  case MidiInstrumentMapper::ON_DEMAND:          result.Add("INSTRUMENT_NAME", _escapeLscpResponse(instrumentName));
2072                      result.Add("LOAD_MODE", "ON_DEMAND");          switch (entry.LoadMode) {
2073                      break;              case MidiInstrumentMapper::ON_DEMAND:
2074                  case MidiInstrumentMapper::ON_DEMAND_HOLD:                  result.Add("LOAD_MODE", "ON_DEMAND");
2075                      result.Add("LOAD_MODE", "ON_DEMAND_HOLD");                  break;
2076                      break;              case MidiInstrumentMapper::ON_DEMAND_HOLD:
2077                  case MidiInstrumentMapper::PERSISTENT:                  result.Add("LOAD_MODE", "ON_DEMAND_HOLD");
2078                      result.Add("LOAD_MODE", "PERSISTENT");                  break;
2079                      break;              case MidiInstrumentMapper::PERSISTENT:
2080                  default:                  result.Add("LOAD_MODE", "PERSISTENT");
2081                      throw Exception("entry reflects invalid LOAD_MODE, consider this as a bug!");                  break;
2082              }              default:
2083              result.Add("VOLUME", iter->second.Volume);                  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.1727  
changed lines
  Added in v.1763

  ViewVC Help
Powered by ViewVC