/[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 570 by schoenebeck, Mon May 23 17:37:26 2005 UTC revision 793 by iliev, Wed Oct 26 09:34:38 2005 UTC
# Line 33  Line 33 
33  #endif  #endif
34    
35  #include "../engines/EngineFactory.h"  #include "../engines/EngineFactory.h"
36    #include "../engines/EngineChannelFactory.h"
37  #include "../drivers/audio/AudioOutputDeviceFactory.h"  #include "../drivers/audio/AudioOutputDeviceFactory.h"
38  #include "../drivers/midi/MidiInputDeviceFactory.h"  #include "../drivers/midi/MidiInputDeviceFactory.h"
39    
# Line 60  Mutex LSCPServer::NotifyBufferMutex = Mu Line 61  Mutex LSCPServer::NotifyBufferMutex = Mu
61  Mutex LSCPServer::SubscriptionMutex = Mutex();  Mutex LSCPServer::SubscriptionMutex = Mutex();
62  Mutex LSCPServer::RTNotifyMutex = Mutex();  Mutex LSCPServer::RTNotifyMutex = Mutex();
63    
64  LSCPServer::LSCPServer(Sampler* pSampler) : Thread(true, false, 0, -4) {  LSCPServer::LSCPServer(Sampler* pSampler, long int addr, short int port) : Thread(true, false, 0, -4) {
65        SocketAddress.sin_family      = AF_INET;
66        SocketAddress.sin_addr.s_addr = addr;
67        SocketAddress.sin_port        = port;
68      this->pSampler = pSampler;      this->pSampler = pSampler;
69      LSCPEvent::RegisterEvent(LSCPEvent::event_channel_count, "CHANNEL_COUNT");      LSCPEvent::RegisterEvent(LSCPEvent::event_channel_count, "CHANNEL_COUNT");
70      LSCPEvent::RegisterEvent(LSCPEvent::event_voice_count, "VOICE_COUNT");      LSCPEvent::RegisterEvent(LSCPEvent::event_voice_count, "VOICE_COUNT");
# Line 68  LSCPServer::LSCPServer(Sampler* pSampler Line 72  LSCPServer::LSCPServer(Sampler* pSampler
72      LSCPEvent::RegisterEvent(LSCPEvent::event_buffer_fill, "BUFFER_FILL");      LSCPEvent::RegisterEvent(LSCPEvent::event_buffer_fill, "BUFFER_FILL");
73      LSCPEvent::RegisterEvent(LSCPEvent::event_channel_info, "CHANNEL_INFO");      LSCPEvent::RegisterEvent(LSCPEvent::event_channel_info, "CHANNEL_INFO");
74      LSCPEvent::RegisterEvent(LSCPEvent::event_misc, "MISCELLANEOUS");      LSCPEvent::RegisterEvent(LSCPEvent::event_misc, "MISCELLANEOUS");
75        LSCPEvent::RegisterEvent(LSCPEvent::event_total_voice_count, "TOTAL_VOICE_COUNT");
76      hSocket = -1;      hSocket = -1;
77  }  }
78    
# Line 97  int LSCPServer::Main() { Line 102  int LSCPServer::Main() {
102          exit(EXIT_FAILURE);          exit(EXIT_FAILURE);
103      }      }
104    
     SocketAddress.sin_family      = AF_INET;  
     SocketAddress.sin_port        = htons(LSCP_PORT);  
     SocketAddress.sin_addr.s_addr = htonl(INADDR_ANY);  
   
105      if (bind(hSocket, (sockaddr*) &SocketAddress, sizeof(sockaddr_in)) < 0) {      if (bind(hSocket, (sockaddr*) &SocketAddress, sizeof(sockaddr_in)) < 0) {
106          std::cerr << "LSCPServer: Could not bind server socket, retrying for " << ToString(LSCP_SERVER_BIND_TIMEOUT) << " seconds...";          std::cerr << "LSCPServer: Could not bind server socket, retrying for " << ToString(LSCP_SERVER_BIND_TIMEOUT) << " seconds...";
107          for (int trial = 0; true; trial++) { // retry for LSCP_SERVER_BIND_TIMEOUT seconds          for (int trial = 0; true; trial++) { // retry for LSCP_SERVER_BIND_TIMEOUT seconds
# Line 127  int LSCPServer::Main() { Line 128  int LSCPServer::Main() {
128      FD_SET(hSocket, &fdSet);      FD_SET(hSocket, &fdSet);
129      int maxSessions = hSocket;      int maxSessions = hSocket;
130    
131        timeval timeout;
132    
133      while (true) {      while (true) {
134          fd_set selectSet = fdSet;          // check if some engine channel's parameter / status changed, if so notify the respective LSCP event subscribers
135          int retval = select(maxSessions+1, &selectSet, NULL, NULL, NULL);          {
136                std::set<EngineChannel*> engineChannels = EngineChannelFactory::EngineChannelInstances();
137                std::set<EngineChannel*>::iterator itEngineChannel = engineChannels.begin();
138                std::set<EngineChannel*>::iterator itEnd           = engineChannels.end();
139                for (; itEngineChannel != itEnd; ++itEngineChannel) {
140                    if ((*itEngineChannel)->StatusChanged()) {
141                        SendLSCPNotify(LSCPEvent(LSCPEvent::event_channel_info, (*itEngineChannel)->iSamplerChannelIndex));
142                    }
143                }
144            }
145    
146            //Now let's deliver late notifies (if any)
147            NotifyBufferMutex.Lock();
148            for (std::map<int,String>::iterator iterNotify = bufferedNotifies.begin(); iterNotify != bufferedNotifies.end(); iterNotify++) {
149                    send(iterNotify->first, iterNotify->second.c_str(), iterNotify->second.size(), MSG_NOSIGNAL);
150                    bufferedNotifies.erase(iterNotify);
151            }
152            NotifyBufferMutex.Unlock();
153    
154            fd_set selectSet = fdSet;
155            timeout.tv_sec  = 0;
156            timeout.tv_usec = 100000;
157    
158            int retval = select(maxSessions+1, &selectSet, NULL, NULL, &timeout);
159    
160          if (retval == 0)          if (retval == 0)
161                  continue; //Nothing try again                  continue; //Nothing try again
162          if (retval == -1) {          if (retval == -1) {
# Line 189  int LSCPServer::Main() { Line 216  int LSCPServer::Main() {
216                          break;                          break;
217                  }                  }
218          }          }
   
         //Now let's deliver late notifies (if any)  
         NotifyBufferMutex.Lock();  
         for (std::map<int,String>::iterator iterNotify = bufferedNotifies.begin(); iterNotify != bufferedNotifies.end(); iterNotify++) {  
                 send(iterNotify->first, iterNotify->second.c_str(), iterNotify->second.size(), 0);  
                 bufferedNotifies.erase(iterNotify);  
         }  
         NotifyBufferMutex.Unlock();  
219      }      }
220  }  }
221    
# Line 243  void LSCPServer::SendLSCPNotify( LSCPEve Line 262  void LSCPServer::SendLSCPNotify( LSCPEve
262          while (true) {          while (true) {
263                  if (NotifyMutex.Trylock()) {                  if (NotifyMutex.Trylock()) {
264                          for(;iter != end; iter++)                          for(;iter != end; iter++)
265                                  send(*iter, notify.c_str(), notify.size(), 0);                                  send(*iter, notify.c_str(), notify.size(), MSG_NOSIGNAL);
266                          NotifyMutex.Unlock();                          NotifyMutex.Unlock();
267                          break;                          break;
268                  } else {                  } else {
# Line 352  void LSCPServer::AnswerClient(String Ret Line 371  void LSCPServer::AnswerClient(String Ret
371      dmsg(2,("LSCPServer::AnswerClient(ReturnMessage=%s)", ReturnMessage.c_str()));      dmsg(2,("LSCPServer::AnswerClient(ReturnMessage=%s)", ReturnMessage.c_str()));
372      if (currentSocket != -1) {      if (currentSocket != -1) {
373              NotifyMutex.Lock();              NotifyMutex.Lock();
374              send(currentSocket, ReturnMessage.c_str(), ReturnMessage.size(), 0);              send(currentSocket, ReturnMessage.c_str(), ReturnMessage.size(), MSG_NOSIGNAL);
375              NotifyMutex.Unlock();              NotifyMutex.Unlock();
376      }      }
377  }  }
# Line 485  String LSCPServer::LoadInstrument(String Line 504  String LSCPServer::LoadInstrument(String
504   * sampler channel.   * sampler channel.
505   */   */
506  String LSCPServer::SetEngineType(String EngineName, uint uiSamplerChannel) {  String LSCPServer::SetEngineType(String EngineName, uint uiSamplerChannel) {
507      dmsg(2,("LSCPServer: LoadEngine(EngineName=%s,SamplerChannel=%d)\n", EngineName.c_str(), uiSamplerChannel));      dmsg(2,("LSCPServer: SetEngineType(EngineName=%s,uiSamplerChannel=%d)\n", EngineName.c_str(), uiSamplerChannel));
508      LSCPResultSet result;      LSCPResultSet result;
509      try {      try {
510          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);
511          if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel));          if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel));
512          LockRTNotify();          LockRTNotify();
513          pSamplerChannel->SetEngineType(EngineName);          pSamplerChannel->SetEngineType(EngineName);
514            if(HasSoloChannel()) pSamplerChannel->GetEngineChannel()->SetMute(-1);
515          UnlockRTNotify();          UnlockRTNotify();
516      }      }
517      catch (LinuxSamplerException e) {      catch (LinuxSamplerException e) {
# Line 578  String LSCPServer::GetEngineInfo(String Line 598  String LSCPServer::GetEngineInfo(String
598          Engine* pEngine = EngineFactory::Create(EngineName);          Engine* pEngine = EngineFactory::Create(EngineName);
599          result.Add("DESCRIPTION", pEngine->Description());          result.Add("DESCRIPTION", pEngine->Description());
600          result.Add("VERSION",     pEngine->Version());          result.Add("VERSION",     pEngine->Version());
601          delete pEngine;          EngineFactory::Destroy(pEngine);
602      }      }
603      catch (LinuxSamplerException e) {      catch (LinuxSamplerException e) {
604           result.Error(e);           result.Error(e);
# Line 607  String LSCPServer::GetChannelInfo(uint u Line 627  String LSCPServer::GetChannelInfo(uint u
627          int InstrumentStatus = -1;          int InstrumentStatus = -1;
628          int AudioOutputChannels = 0;          int AudioOutputChannels = 0;
629          String AudioRouting;          String AudioRouting;
630            int Mute = 0;
631            bool Solo = false;
632    
633          if (pEngineChannel) {          if (pEngineChannel) {
634              EngineName          = pEngineChannel->EngineName();              EngineName          = pEngineChannel->EngineName();
# Line 622  String LSCPServer::GetChannelInfo(uint u Line 644  String LSCPServer::GetChannelInfo(uint u
644                  if (AudioRouting != "") AudioRouting += ",";                  if (AudioRouting != "") AudioRouting += ",";
645                  AudioRouting += ToString(pEngineChannel->OutputChannel(chan));                  AudioRouting += ToString(pEngineChannel->OutputChannel(chan));
646              }              }
647                Mute = pEngineChannel->GetMute();
648                Solo = pEngineChannel->GetSolo();
649          }          }
650    
651          result.Add("ENGINE_NAME", EngineName);          result.Add("ENGINE_NAME", EngineName);
# Line 634  String LSCPServer::GetChannelInfo(uint u Line 658  String LSCPServer::GetChannelInfo(uint u
658    
659          result.Add("MIDI_INPUT_DEVICE", GetMidiInputDeviceIndex(pSamplerChannel->GetMidiInputDevice()));          result.Add("MIDI_INPUT_DEVICE", GetMidiInputDeviceIndex(pSamplerChannel->GetMidiInputDevice()));
660          result.Add("MIDI_INPUT_PORT", pSamplerChannel->GetMidiInputPort());          result.Add("MIDI_INPUT_PORT", pSamplerChannel->GetMidiInputPort());
661          if (pSamplerChannel->GetMidiInputChannel() == MidiInputPort::midi_chan_all) result.Add("MIDI_INPUT_CHANNEL", "ALL");          if (pSamplerChannel->GetMidiInputChannel() == midi_chan_all) result.Add("MIDI_INPUT_CHANNEL", "ALL");
662          else result.Add("MIDI_INPUT_CHANNEL", pSamplerChannel->GetMidiInputChannel());          else result.Add("MIDI_INPUT_CHANNEL", pSamplerChannel->GetMidiInputChannel());
663    
664          result.Add("INSTRUMENT_FILE", InstrumentFileName);          result.Add("INSTRUMENT_FILE", InstrumentFileName);
665          result.Add("INSTRUMENT_NR", InstrumentIndex);          result.Add("INSTRUMENT_NR", InstrumentIndex);
666          result.Add("INSTRUMENT_NAME", InstrumentName);          result.Add("INSTRUMENT_NAME", InstrumentName);
667          result.Add("INSTRUMENT_STATUS", InstrumentStatus);          result.Add("INSTRUMENT_STATUS", InstrumentStatus);
668            result.Add("MUTE", Mute == -1 ? "MUTED_BY_SOLO" : (Mute ? "true" : "false"));
669            result.Add("SOLO", Solo);
670      }      }
671      catch (LinuxSamplerException e) {      catch (LinuxSamplerException e) {
672           result.Error(e);           result.Error(e);
# Line 660  String LSCPServer::GetVoiceCount(uint ui Line 686  String LSCPServer::GetVoiceCount(uint ui
686          if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel));          if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel));
687          EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();          EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();
688          if (!pEngineChannel) throw LinuxSamplerException("No engine loaded on sampler channel");          if (!pEngineChannel) throw LinuxSamplerException("No engine loaded on sampler channel");
689            if (!pEngineChannel->GetEngine()) throw LinuxSamplerException("No audio output device connected to sampler channel");
690          result.Add(pEngineChannel->GetEngine()->VoiceCount());          result.Add(pEngineChannel->GetEngine()->VoiceCount());
691      }      }
692      catch (LinuxSamplerException e) {      catch (LinuxSamplerException e) {
# Line 680  String LSCPServer::GetStreamCount(uint u Line 707  String LSCPServer::GetStreamCount(uint u
707          if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel));          if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel));
708          EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();          EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();
709          if (!pEngineChannel) throw LinuxSamplerException("No engine type assigned to sampler channel");          if (!pEngineChannel) throw LinuxSamplerException("No engine type assigned to sampler channel");
710            if (!pEngineChannel->GetEngine()) throw LinuxSamplerException("No audio output device connected to sampler channel");
711          result.Add(pEngineChannel->GetEngine()->DiskStreamCount());          result.Add(pEngineChannel->GetEngine()->DiskStreamCount());
712      }      }
713      catch (LinuxSamplerException e) {      catch (LinuxSamplerException e) {
# Line 700  String LSCPServer::GetBufferFill(fill_re Line 728  String LSCPServer::GetBufferFill(fill_re
728          if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel));          if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel));
729          EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();          EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();
730          if (!pEngineChannel) throw LinuxSamplerException("No engine type assigned to sampler channel");          if (!pEngineChannel) throw LinuxSamplerException("No engine type assigned to sampler channel");
731            if (!pEngineChannel->GetEngine()) throw LinuxSamplerException("No audio output device connected to sampler channel");
732          if (!pEngineChannel->GetEngine()->DiskStreamSupported()) result.Add("NA");          if (!pEngineChannel->GetEngine()->DiskStreamSupported()) result.Add("NA");
733          else {          else {
734              switch (ResponseType) {              switch (ResponseType) {
# Line 1275  String LSCPServer::SetMIDIInputChannel(u Line 1304  String LSCPServer::SetMIDIInputChannel(u
1304      try {      try {
1305          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);
1306          if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel));          if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel));
1307          pSamplerChannel->SetMidiInputChannel((MidiInputPort::midi_chan_t) MIDIChannel);          pSamplerChannel->SetMidiInputChannel((midi_chan_t) MIDIChannel);
1308      }      }
1309      catch (LinuxSamplerException e) {      catch (LinuxSamplerException e) {
1310           result.Error(e);           result.Error(e);
# Line 1352  String LSCPServer::SetMIDIInput(uint MID Line 1381  String LSCPServer::SetMIDIInput(uint MID
1381          std::map<uint, MidiInputDevice*> devices =  pSampler->GetMidiInputDevices();          std::map<uint, MidiInputDevice*> devices =  pSampler->GetMidiInputDevices();
1382          if (!devices.count(MIDIDeviceId)) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(MIDIDeviceId));          if (!devices.count(MIDIDeviceId)) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(MIDIDeviceId));
1383          MidiInputDevice* pDevice = devices[MIDIDeviceId];          MidiInputDevice* pDevice = devices[MIDIDeviceId];
1384          pSamplerChannel->SetMidiInput(pDevice, MIDIPort, (MidiInputPort::midi_chan_t) MIDIChannel);          pSamplerChannel->SetMidiInput(pDevice, MIDIPort, (midi_chan_t) MIDIChannel);
1385      }      }
1386      catch (LinuxSamplerException e) {      catch (LinuxSamplerException e) {
1387           result.Error(e);           result.Error(e);
# Line 1381  String LSCPServer::SetVolume(double dVol Line 1410  String LSCPServer::SetVolume(double dVol
1410  }  }
1411    
1412  /**  /**
1413     * Will be called by the parser to mute/unmute particular sampler channel.
1414     */
1415    String LSCPServer::SetChannelMute(bool bMute, uint uiSamplerChannel) {
1416        dmsg(2,("LSCPServer: SetChannelMute(bMute=%d,uiSamplerChannel=%d)\n",bMute,uiSamplerChannel));
1417        LSCPResultSet result;
1418        try {
1419            SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);
1420            if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel));
1421    
1422            EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();
1423            if (!pEngineChannel) throw LinuxSamplerException("No engine type assigned to sampler channel");
1424    
1425            if(!bMute) pEngineChannel->SetMute((HasSoloChannel() && !pEngineChannel->GetSolo()) ? -1 : 0);
1426            else pEngineChannel->SetMute(1);
1427        } catch (LinuxSamplerException e) {
1428            result.Error(e);
1429        }
1430        return result.Produce();
1431    }
1432    
1433    /**
1434     * Will be called by the parser to solo particular sampler channel.
1435     */
1436    String LSCPServer::SetChannelSolo(bool bSolo, uint uiSamplerChannel) {
1437        dmsg(2,("LSCPServer: SetChannelSolo(bSolo=%d,uiSamplerChannel=%d)\n",bSolo,uiSamplerChannel));
1438        LSCPResultSet result;
1439        try {
1440            SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);
1441            if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel));
1442    
1443            EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();
1444            if (!pEngineChannel) throw LinuxSamplerException("No engine type assigned to sampler channel");
1445    
1446            bool oldSolo = pEngineChannel->GetSolo();
1447            bool hadSoloChannel = HasSoloChannel();
1448            
1449            pEngineChannel->SetSolo(bSolo);
1450            
1451            if(!oldSolo && bSolo) {
1452                if(pEngineChannel->GetMute() == -1) pEngineChannel->SetMute(0);
1453                if(!hadSoloChannel) MuteNonSoloChannels();
1454            }
1455            
1456            if(oldSolo && !bSolo) {
1457                if(!HasSoloChannel()) UnmuteChannels();
1458                else if(!pEngineChannel->GetMute()) pEngineChannel->SetMute(-1);
1459            }
1460        } catch (LinuxSamplerException e) {
1461            result.Error(e);
1462        }
1463        return result.Produce();
1464    }
1465    
1466    /**
1467     * Determines whether there is at least one solo channel in the channel list.
1468     *
1469     * @returns true if there is at least one solo channel in the channel list,
1470     * false otherwise.
1471     */
1472    bool LSCPServer::HasSoloChannel() {
1473        std::map<uint,SamplerChannel*> channels = pSampler->GetSamplerChannels();
1474        std::map<uint,SamplerChannel*>::iterator iter = channels.begin();
1475        for (; iter != channels.end(); iter++) {
1476            EngineChannel* c = iter->second->GetEngineChannel();
1477            if(c && c->GetSolo()) return true;
1478        }
1479    
1480        return false;
1481    }
1482    
1483    /**
1484     * Mutes all unmuted non-solo channels. Notice that the channels are muted
1485     * with -1 which indicates that they are muted because of the presence
1486     * of a solo channel(s). Channels muted with -1 will be automatically unmuted
1487     * when there are no solo channels left.
1488     */
1489    void LSCPServer::MuteNonSoloChannels() {
1490        dmsg(2,("LSCPServer: MuteNonSoloChannels()\n"));
1491        std::map<uint,SamplerChannel*> channels = pSampler->GetSamplerChannels();
1492        std::map<uint,SamplerChannel*>::iterator iter = channels.begin();
1493        for (; iter != channels.end(); iter++) {
1494            EngineChannel* c = iter->second->GetEngineChannel();
1495            if(c && !c->GetSolo() && !c->GetMute()) c->SetMute(-1);
1496        }
1497    }
1498    
1499    /**
1500     * Unmutes all channels that are muted because of the presence
1501     * of a solo channel(s).
1502     */
1503    void  LSCPServer::UnmuteChannels() {
1504        dmsg(2,("LSCPServer: UnmuteChannels()\n"));
1505        std::map<uint,SamplerChannel*> channels = pSampler->GetSamplerChannels();
1506        std::map<uint,SamplerChannel*>::iterator iter = channels.begin();
1507        for (; iter != channels.end(); iter++) {
1508            EngineChannel* c = iter->second->GetEngineChannel();
1509            if(c && c->GetMute() == -1) c->SetMute(0);
1510        }
1511    }
1512    
1513    /**
1514   * Will be called by the parser to reset a particular sampler channel.   * Will be called by the parser to reset a particular sampler channel.
1515   */   */
1516  String LSCPServer::ResetChannel(uint uiSamplerChannel) {  String LSCPServer::ResetChannel(uint uiSamplerChannel) {
# Line 1391  String LSCPServer::ResetChannel(uint uiS Line 1521  String LSCPServer::ResetChannel(uint uiS
1521          if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel));          if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel));
1522          EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();          EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();
1523          if (!pEngineChannel) throw LinuxSamplerException("No engine type assigned to sampler channel");          if (!pEngineChannel) throw LinuxSamplerException("No engine type assigned to sampler channel");
1524          pEngineChannel->GetEngine()->Reset();          pEngineChannel->Reset();
1525      }      }
1526      catch (LinuxSamplerException e) {      catch (LinuxSamplerException e) {
1527           result.Error(e);           result.Error(e);
# Line 1422  String LSCPServer::GetServerInfo() { Line 1552  String LSCPServer::GetServerInfo() {
1552      return result.Produce();      return result.Produce();
1553  }  }
1554    
1555    /**
1556     * Will be called by the parser to return the current number of all active voices.
1557     */
1558    String LSCPServer::GetTotalVoiceCount() {
1559        dmsg(2,("LSCPServer: GetTotalVoiceCount()\n"));
1560        LSCPResultSet result;
1561        result.Add(pSampler->GetVoiceCount());
1562        return result.Produce();
1563    }
1564    
1565    /**
1566     * Will be called by the parser to return the maximum number of voices.
1567     */
1568    String LSCPServer::GetTotalVoiceCountMax() {
1569        dmsg(2,("LSCPServer: GetTotalVoiceCountMax()\n"));
1570        LSCPResultSet result;
1571        result.Add(EngineFactory::EngineInstances().size() * CONFIG_MAX_VOICES);
1572        return result.Produce();
1573    }
1574    
1575  /**  /**
1576   * Will be called by the parser to subscribe a client (frontend) on the   * Will be called by the parser to subscribe a client (frontend) on the
1577   * server for receiving event messages.   * server for receiving event messages.

Legend:
Removed from v.570  
changed lines
  Added in v.793

  ViewVC Help
Powered by ViewVC