/[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 2137 by schoenebeck, Mon Oct 4 12:20:23 2010 UTC revision 2198 by iliev, Sun Jul 3 18:06:51 2011 UTC
# Line 138  LSCPServer::LSCPServer(Sampler* pSampler Line 138  LSCPServer::LSCPServer(Sampler* pSampler
138      LSCPEvent::RegisterEvent(LSCPEvent::event_global_info, "GLOBAL_INFO");      LSCPEvent::RegisterEvent(LSCPEvent::event_global_info, "GLOBAL_INFO");
139      LSCPEvent::RegisterEvent(LSCPEvent::event_channel_midi, "CHANNEL_MIDI");      LSCPEvent::RegisterEvent(LSCPEvent::event_channel_midi, "CHANNEL_MIDI");
140      LSCPEvent::RegisterEvent(LSCPEvent::event_device_midi, "DEVICE_MIDI");      LSCPEvent::RegisterEvent(LSCPEvent::event_device_midi, "DEVICE_MIDI");
141        LSCPEvent::RegisterEvent(LSCPEvent::event_fx_instance_count, "EFFECT_INSTANCE_COUNT");
142        LSCPEvent::RegisterEvent(LSCPEvent::event_fx_instance_info, "EFFECT_INSTANCE_INFO");
143        LSCPEvent::RegisterEvent(LSCPEvent::event_send_fx_chain_count, "SEND_EFFECT_CHAIN_COUNT");
144        LSCPEvent::RegisterEvent(LSCPEvent::event_send_fx_chain_info, "SEND_EFFECT_CHAIN_INFO");
145      hSocket = -1;      hSocket = -1;
146  }  }
147    
# Line 2393  String LSCPServer::GetFxSendInfo(uint ui Line 2397  String LSCPServer::GetFxSendInfo(uint ui
2397          result.Add("MIDI_CONTROLLER", pFxSend->MidiController());          result.Add("MIDI_CONTROLLER", pFxSend->MidiController());
2398          result.Add("LEVEL", ToString(pFxSend->Level()));          result.Add("LEVEL", ToString(pFxSend->Level()));
2399          result.Add("AUDIO_OUTPUT_ROUTING", AudioRouting);          result.Add("AUDIO_OUTPUT_ROUTING", AudioRouting);
2400          result.Add("SEND_EFFECT", sEffectRouting);          result.Add("EFFECT", sEffectRouting);
2401      } catch (Exception e) {      } catch (Exception e) {
2402          result.Error(e);          result.Error(e);
2403      }      }
# Line 2610  String LSCPServer::SetEffectInstanceInpu Line 2614  String LSCPServer::SetEffectInstanceInpu
2614              );              );
2615    
2616          pEffectControl->SetValue(dValue);          pEffectControl->SetValue(dValue);
2617            LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_fx_instance_info, iEffectInstance));
2618      } catch (Exception e) {      } catch (Exception e) {
2619          result.Error(e);          result.Error(e);
2620      }      }
# Line 2624  String LSCPServer::CreateEffectInstance( Line 2629  String LSCPServer::CreateEffectInstance(
2629          if (!pEffectInfo)          if (!pEffectInfo)
2630              throw Exception("There is no effect with index " + ToString(iEffectIndex));              throw Exception("There is no effect with index " + ToString(iEffectIndex));
2631          Effect* pEffect = EffectFactory::Create(pEffectInfo);          Effect* pEffect = EffectFactory::Create(pEffectInfo);
2632          result.Add(pEffect->ID());          result = pEffect->ID(); // success
2633            LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_fx_instance_count, EffectFactory::EffectInstancesCount()));
2634      } catch (Exception e) {      } catch (Exception e) {
2635          result.Error(e);          result.Error(e);
2636      }      }
# Line 2671  String LSCPServer::CreateEffectInstance( Line 2677  String LSCPServer::CreateEffectInstance(
2677    
2678          Effect* pEffect = EffectFactory::Create(pEffectInfo);          Effect* pEffect = EffectFactory::Create(pEffectInfo);
2679          result = LSCPResultSet(pEffect->ID());          result = LSCPResultSet(pEffect->ID());
2680            LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_fx_instance_count, EffectFactory::EffectInstancesCount()));
2681      } catch (Exception e) {      } catch (Exception e) {
2682          result.Error(e);          result.Error(e);
2683      }      }
# Line 2685  String LSCPServer::DestroyEffectInstance Line 2692  String LSCPServer::DestroyEffectInstance
2692          if (!pEffect)          if (!pEffect)
2693              throw Exception("There is no effect instance with ID " + ToString(iEffectInstance));              throw Exception("There is no effect instance with ID " + ToString(iEffectInstance));
2694          EffectFactory::Destroy(pEffect);          EffectFactory::Destroy(pEffect);
2695            LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_fx_instance_count, EffectFactory::EffectInstancesCount()));
2696      } catch (Exception e) {      } catch (Exception e) {
2697          result.Error(e);          result.Error(e);
2698      }      }
# Line 2768  String LSCPServer::AddSendEffectChain(in Line 2776  String LSCPServer::AddSendEffectChain(in
2776              throw Exception("There is no audio output device with index " + ToString(iAudioOutputDevice) + ".");              throw Exception("There is no audio output device with index " + ToString(iAudioOutputDevice) + ".");
2777          AudioOutputDevice* pDevice = devices[iAudioOutputDevice];          AudioOutputDevice* pDevice = devices[iAudioOutputDevice];
2778          EffectChain* pEffectChain = pDevice->AddSendEffectChain();          EffectChain* pEffectChain = pDevice->AddSendEffectChain();
2779          result.Add(pEffectChain->ID());          result = pEffectChain->ID();
2780            LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_send_fx_chain_count, iAudioOutputDevice, pDevice->SendEffectChainCount()));
2781      } catch (Exception e) {      } catch (Exception e) {
2782          result.Error(e);          result.Error(e);
2783      }      }
# Line 2782  String LSCPServer::RemoveSendEffectChain Line 2791  String LSCPServer::RemoveSendEffectChain
2791          std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices();          std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices();
2792          if (!devices.count(iAudioOutputDevice))          if (!devices.count(iAudioOutputDevice))
2793              throw Exception("There is no audio output device with index " + ToString(iAudioOutputDevice) + ".");              throw Exception("There is no audio output device with index " + ToString(iAudioOutputDevice) + ".");
2794    
2795            std::set<EngineChannel*> engineChannels = EngineChannelFactory::EngineChannelInstances();
2796            std::set<EngineChannel*>::iterator itEngineChannel = engineChannels.begin();
2797            std::set<EngineChannel*>::iterator itEnd           = engineChannels.end();
2798            for (; itEngineChannel != itEnd; ++itEngineChannel) {
2799                AudioOutputDevice* pDev = (*itEngineChannel)->GetAudioOutputDevice();
2800                if (pDev != NULL && pDev->deviceId() == iAudioOutputDevice) {
2801                    for (int i = 0; i < (*itEngineChannel)->GetFxSendCount(); i++) {
2802                        FxSend* fxs = (*itEngineChannel)->GetFxSend(i);
2803                        if(fxs != NULL && fxs->DestinationEffectChain() == iSendEffectChain) {
2804                            throw Exception("The effect chain is still in use by channel " + ToString((*itEngineChannel)->GetSamplerChannel()->Index()));
2805                        }
2806                    }
2807                }
2808            }
2809    
2810          AudioOutputDevice* pDevice = devices[iAudioOutputDevice];          AudioOutputDevice* pDevice = devices[iAudioOutputDevice];
2811          for (int i = 0; i < pDevice->SendEffectChainCount(); i++) {          for (int i = 0; i < pDevice->SendEffectChainCount(); i++) {
2812              EffectChain* pEffectChain = pDevice->SendEffectChain(i);              EffectChain* pEffectChain = pDevice->SendEffectChain(i);
2813              if (pEffectChain->ID() == iSendEffectChain) {              if (pEffectChain->ID() == iSendEffectChain) {
2814                  pDevice->RemoveSendEffectChain(i);                  pDevice->RemoveSendEffectChain(i);
2815                    LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_send_fx_chain_count, iAudioOutputDevice, pDevice->SendEffectChainCount()));
2816                  return result.Produce();                  return result.Produce();
2817              }              }
2818          }          }
# Line 2809  static EffectChain* _getSendEffectChain( Line 2835  static EffectChain* _getSendEffectChain(
2835              ToString(iAudioOutputDevice) + "."              ToString(iAudioOutputDevice) + "."
2836          );          );
2837      AudioOutputDevice* pDevice = devices[iAudioOutputDevice];      AudioOutputDevice* pDevice = devices[iAudioOutputDevice];
2838      for (int i = 0; i < pDevice->SendEffectChainCount(); i++) {      EffectChain* pEffectChain = pDevice->SendEffectChainByID(iSendEffectChain);
2839          EffectChain* pEffectChain = pDevice->SendEffectChain(i);      if(pEffectChain != NULL) return pEffectChain;
         if (pEffectChain->ID() == iSendEffectChain) {  
             return pEffectChain;  
         }  
     }  
2840      throw Exception(      throw Exception(
2841          "There is no send effect chain with ID " +          "There is no send effect chain with ID " +
2842          ToString(iSendEffectChain) + " for audio output device " +          ToString(iSendEffectChain) + " for audio output device " +
# Line 2851  String LSCPServer::AppendSendEffectChain Line 2873  String LSCPServer::AppendSendEffectChain
2873          if (!pEffect)          if (!pEffect)
2874              throw Exception("There is no effect instance with ID " + ToString(iEffectInstance));              throw Exception("There is no effect instance with ID " + ToString(iEffectInstance));
2875          pEffectChain->AppendEffect(pEffect);          pEffectChain->AppendEffect(pEffect);
2876            LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_send_fx_chain_info, iAudioOutputDevice, iSendEffectChain, pEffectChain->EffectCount()));
2877      } catch (Exception e) {      } catch (Exception e) {
2878          result.Error(e);          result.Error(e);
2879      }      }
# Line 2867  String LSCPServer::InsertSendEffectChain Line 2890  String LSCPServer::InsertSendEffectChain
2890          if (!pEffect)          if (!pEffect)
2891              throw Exception("There is no effect instance with index " + ToString(iEffectInstance));              throw Exception("There is no effect instance with index " + ToString(iEffectInstance));
2892          pEffectChain->InsertEffect(pEffect, iEffectChainPosition);          pEffectChain->InsertEffect(pEffect, iEffectChainPosition);
2893            LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_send_fx_chain_info, iAudioOutputDevice, iSendEffectChain, pEffectChain->EffectCount()));
2894      } catch (Exception e) {      } catch (Exception e) {
2895          result.Error(e);          result.Error(e);
2896      }      }
# Line 2879  String LSCPServer::RemoveSendEffectChain Line 2903  String LSCPServer::RemoveSendEffectChain
2903      try {      try {
2904          EffectChain* pEffectChain =          EffectChain* pEffectChain =
2905              _getSendEffectChain(pSampler, iAudioOutputDevice, iSendEffectChain);              _getSendEffectChain(pSampler, iAudioOutputDevice, iSendEffectChain);
2906    
2907            std::set<EngineChannel*> engineChannels = EngineChannelFactory::EngineChannelInstances();
2908            std::set<EngineChannel*>::iterator itEngineChannel = engineChannels.begin();
2909            std::set<EngineChannel*>::iterator itEnd           = engineChannels.end();
2910            for (; itEngineChannel != itEnd; ++itEngineChannel) {
2911                AudioOutputDevice* pDev = (*itEngineChannel)->GetAudioOutputDevice();
2912                if (pDev != NULL && pDev->deviceId() == iAudioOutputDevice) {
2913                    for (int i = 0; i < (*itEngineChannel)->GetFxSendCount(); i++) {
2914                        FxSend* fxs = (*itEngineChannel)->GetFxSend(i);
2915                        if(fxs != NULL && fxs->DestinationEffectChain() == iSendEffectChain && fxs->DestinationEffectChainPosition() == iEffectChainPosition) {
2916                            throw Exception("The effect instance is still in use by channel " + ToString((*itEngineChannel)->GetSamplerChannel()->Index()));
2917                        }
2918                    }
2919                }
2920            }
2921    
2922          pEffectChain->RemoveEffect(iEffectChainPosition);          pEffectChain->RemoveEffect(iEffectChainPosition);
2923            LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_send_fx_chain_info, iAudioOutputDevice, iSendEffectChain, pEffectChain->EffectCount()));
2924      } catch (Exception e) {      } catch (Exception e) {
2925          result.Error(e);          result.Error(e);
2926      }      }

Legend:
Removed from v.2137  
changed lines
  Added in v.2198

  ViewVC Help
Powered by ViewVC