Ejemplo n.º 1
0
String AudioProcessor::getParameterName (int index, int maximumStringLength)
{
    if (AudioProcessorParameter* p = managedParameters[index])
        return p->getName (maximumStringLength);

    return getParameterName (index).substring (0, maximumStringLength);
}
Ejemplo n.º 2
0
void OscController::parameterChanged(ofAbstractParameter & parameter){
    string paramName = getParameterName(parameter);
    string address = getAddressByParamName(paramName);
    
    if(address == ""){
        return;
    }
    
    ofxOscMessage msg;
    msg.setAddress(address);
    
    // NOTE: all parameters are sent as float args
    if(parameter.type()==typeid(ofParameter<int>).name()){
        //msg.addFloatArg(parameter.cast<int>());
        ofParameter<int> & p = parameter.cast<int>();
        msg.addFloatArg( ofMap(p.get(), p.getMin(), p.getMax(), 0.0, 1.0) );
    }else if(parameter.type()==typeid(ofParameter<float>).name()){
        //msg.addFloatArg(parameter.cast<float>());
        ofParameter<float> & p = parameter.cast<float>();
        msg.addFloatArg( ofMap(p.get(), p.getMin(), p.getMax(), 0.0, 1.0) );
    }else if(parameter.type()==typeid(ofParameter<bool>).name()){
        msg.addFloatArg(parameter.cast<bool>());
    }
    
    // send message
//    for (int i = 0; i < oscOut.size(); i++) {
//        oscOut[i]->sendMessage(msg);
//    }
    
    //senderTouchOSC.sendMessage(msg);
    senderVezer.sendMessage(msg);
}
Ejemplo n.º 3
0
//==============================================================================
void SuperSpreadAudioProcessor::getStateInformation (MemoryBlock& destData)
{
    XmlElement xml("STATE");

    for (int i=0; i<getNumParameters(); ++i)
        xml.setAttribute(getParameterName(i), getParameter(i));

    copyXmlToBinary(xml, destData);
}
//==============================================================================
void LuftikusAudioProcessor::getStateInformation (MemoryBlock& destData)
{
	XmlElement xml("LUFTIKUSDATA");

	for (int i=0; i<getNumParameters(); ++i)
		xml.setAttribute(getParameterName(i).replace(" ", "_", false).replace(".", "-", false), getParameter(i));

	xml.setAttribute("tooltips", showTooltips ? 1 : 0);
	copyXmlToBinary(xml, destData);
}
Ejemplo n.º 5
0
void SuperSpreadAudioProcessor::setStateInformation (const void* data, int sizeInBytes)
{
    ScopedPointer<XmlElement> xml(getXmlFromBinary(data, sizeInBytes));

    if (xml != nullptr)
    {
        for (int i=0; i<getNumParameters(); ++i)
            setParameterNotifyingHost(i, static_cast<float> (xml->getDoubleAttribute(getParameterName(i), getParameter(i))));
    }
}
void LuftikusAudioProcessor::setStateInformation (const void* data, int sizeInBytes)
{
	ScopedPointer<XmlElement> xml(getXmlFromBinary(data, sizeInBytes));

	if (xml != nullptr)
	{
		for (int i=0; i<getNumParameters(); ++i)
			setParameterNotifyingHost(i, (float) xml->getDoubleAttribute(getParameterName(i).replace(" ", "_", false).replace(".", "-", false)));

		showTooltips = xml->getBoolAttribute("tooltips", true);
	}
}
Ejemplo n.º 7
0
//==============================================================================
void PitchedDelayAudioProcessor::getStateInformation (MemoryBlock& destData)
{
	XmlElement xml("PitchedDelay");

	for (int i=0; i<getNumParameters(); ++i)
		xml.setAttribute(getParameterName(i), getParameter(i));

	xml.setAttribute("currenttab", jmax(0, currentTab));
	xml.setAttribute("showtooltips", showTooltips ? 1 : 0);

	xml.setAttribute("extended", "1");

	copyXmlToBinary(xml, destData);
}
Ejemplo n.º 8
0
std::set< const CCopasiObject * > CReactionInterface::getDeletedParameters() const
{
  std::set< const CCopasiObject * > ToBeDeleted;

  // We need to compare the current visible local parameter with the one stored
  // in the reaction.
  const CReaction * pReaction
    = dynamic_cast< CReaction *>(CCopasiRootContainer::getKeyFactory()->get(mReactionReferenceKey));

  if (pReaction == NULL)
    return ToBeDeleted;

  if (pReaction->getFunction() == NULL)
    return ToBeDeleted;

  const CFunctionParameters & OriginalParameters
    = pReaction->getFunction()->getVariables();

  size_t j, jmax = size();
  size_t i, imax = OriginalParameters.size();
  const CFunctionParameter * pParameter;

  for (i = 0; i < imax; ++i)
    {
      pParameter = OriginalParameters[i];

      if (pParameter->getUsage() == CFunctionParameter::PARAMETER &&
          pReaction->isLocalParameter(i))
        {
          const std::string & Name = pParameter->getObjectName();

          //find parameter with same name in current parameters
          for (j = 0; j < jmax; ++j)
            if (Name == getParameterName(j)) break;

          if (j < jmax && mIsLocal[j])
            continue;

          // The old parameter is either not found or is no longer local, i.e., it needs to
          // be added to values to be deleted.
          ToBeDeleted.insert(pReaction->getParameters().getParameter(Name));
        }
    }

  return ToBeDeleted;
}
Ejemplo n.º 9
0
//-------------------------------------------------------------------------------------------------------
VstIntPtr AudioEffect::dispatcher (VstInt32 opcode, VstInt32 index, VstIntPtr value, void* ptr, float opt)
{
	VstIntPtr v = 0;
	
	switch (opcode)
	{
		case effOpen:				open ();											break;
		case effClose:				close ();											break;
		case effSetProgram:			if (value < numPrograms) setProgram ((VstInt32)value); break;
		case effGetProgram:			v = getProgram ();									break;
		case effSetProgramName: 	setProgramName ((char*)ptr);						break;
		case effGetProgramName: 	getProgramName ((char*)ptr);						break;
		case effGetParamLabel:		getParameterLabel (index, (char*)ptr);				break;
		case effGetParamDisplay:	getParameterDisplay (index, (char*)ptr);			break;
		case effGetParamName:		getParameterName (index, (char*)ptr);				break;

		case effSetSampleRate:		setSampleRate (opt);								break;
		case effSetBlockSize:		setBlockSize ((VstInt32)value);						break;
		case effMainsChanged:		if (!value) suspend (); else resume ();				break;
	#if !VST_FORCE_DEPRECATED
		case effGetVu:				v = (VstIntPtr)(getVu () * 32767.);					break;
	#endif

		//---Editor------------
		case effEditGetRect:		if (editor) v = editor->getRect ((ERect**)ptr) ? 1 : 0;	break;
		case effEditOpen:			if (editor) v = editor->open (ptr) ? 1 : 0;			break;
		case effEditClose:			if (editor) editor->close ();						break;		
		case effEditIdle:			if (editor) editor->idle ();						break;
		
	#if (TARGET_API_MAC_CARBON && !VST_FORCE_DEPRECATED)
		case effEditDraw:			if (editor) editor->draw ((ERect*)ptr);				break;
		case effEditMouse:			if (editor) v = editor->mouse (index, value);		break;
		case effEditKey:			if (editor) v = editor->key (value);				break;
		case effEditTop:			if (editor) editor->top ();							break;
		case effEditSleep:			if (editor) editor->sleep ();						break;
	#endif
		
		case DECLARE_VST_DEPRECATED (effIdentify):	v = CCONST ('N', 'v', 'E', 'f');	break;

		//---Persistence-------
		case effGetChunk:			v = getChunk ((void**)ptr, index ? true : false);	break;
		case effSetChunk:			v = setChunk (ptr, (VstInt32)value, index ? true : false);	break;
	}
	return v;
}
Ejemplo n.º 10
0
//-----------------------------------------------------------------------------
long AudioEffect::dispatcher(long opCode, long index, long value, void *ptr, float opt)
{
	long v = 0;

	switch(opCode)
	{
		case effOpen:				open();												break;
		case effClose:				close();											break;
		case effSetProgram:			if(value < numPrograms)	setProgram(value);			break;
		case effGetProgram:			v = getProgram();									break;
		case effSetProgramName: 	setProgramName((char *)ptr);						break;
		case effGetProgramName: 	getProgramName((char *)ptr);						break;
		case effGetParamLabel:		getParameterLabel(index, (char *)ptr);				break;
		case effGetParamDisplay:	getParameterDisplay(index, (char *)ptr);			break;
		case effGetParamName:		getParameterName(index, (char *)ptr);				break;

		case effSetSampleRate:		setSampleRate(opt);									break;
		case effSetBlockSize:		setBlockSize(value);								break;
		case effMainsChanged:		if(!value) suspend(); else resume();				break;
		case effGetVu:				v = (long)(getVu() * 32767.);						break;

	// editor
	
		case effEditGetRect:		if(editor) v = editor->getRect((ERect **)ptr);		break;
		case effEditOpen:			if(editor) v = editor->open(ptr);					break;
		case effEditClose:			if(editor) editor->close();							break;		
		case effEditIdle:			if(editor) editor->idle();							break;
		
		#if MAC
		case effEditDraw:			if(editor) editor->draw((ERect *)ptr);				break;
		case effEditMouse:			if(editor) v = editor->mouse(index, value);			break;
		case effEditKey:			if(editor) v = editor->key(value);					break;
		case effEditTop:			if(editor) editor->top();							break;
		case effEditSleep:			if(editor) editor->sleep();							break;
		#endif
		
	// new

		case effIdentify:			v = 'NvEf';											break;
		case effGetChunk:			v = getChunk((void**)ptr, index ? true : false); break;
		case effSetChunk:			v = setChunk(ptr, value, index ? true : false); break;
	}
	return v;
}
Ejemplo n.º 11
0
void OscController::enableParameterSync(){
    if(bParamenterSyncEnabled){
        return;
    }
    bParamenterSyncEnabled = true;
    
    // we need this because a group can only have one parent
    // because the parent of this parameter might not be
    // the panel group, we need to find the current parent.
    // with multiple parents we could just have added the listener to the panel.
    
    // iterate through the stored controls
    for(map<string,ofxBaseGui*>::iterator it=controls.begin(); it!=controls.end(); ++it){
        string controlName = it->first;
        ofxBaseGui* control = it->second;
        string oscAddress = getAddressByControlName(controlName);
        ofAbstractParameter& parameter = control->getParameter();
        
        // if this control is mapped to an address, create a link between
        // the parameter name and the osc address
        if(oscAddress != ""){
            string paramName = getParameterName(parameter);
            paramNameToAddress[paramName] = oscAddress;
        }
        
        // what is the last parent of this param?
        ofParameterGroup* lastParent = parameter.getParent();
        while(lastParent->getParent()){
            lastParent = lastParent->getParent();
        }
        lastParents[ lastParent->getName() ] = lastParent; // use a map to store the lastParent of the parameter
    }
    
    // add listerner
    for(map<string,ofParameterGroup*>::iterator it=lastParents.begin(); it!=lastParents.end(); ++it){
        ofParameterGroup* lastParent = it->second;
        cout << lastParent->getName() << endl;
        ofAddListener(lastParent->parameterChangedE, this, &OscController::parameterChanged);
    }
}
Ejemplo n.º 12
0
void CReactionInterface::printDebug() const
{
  std::cout << "Reaction interface   " << std::endl;
  std::cout << "  Function: " << getFunctionName() << std::endl;
  std::cout << "  ChemEq:   " << getChemEqString() << std::endl;

  size_t i, imax = size();

  for (i = 0; i < imax; ++i)
    {
      std::cout << "    ---  " << i << ": " << getParameterName(i)
                << ", vector: " << isVector(i) << " local: " << isLocalValue(i)
                << ", value: " << mValues[i] << std::endl;

      size_t j, jmax = mNameMap[i].size();

      for (j = 0; j < jmax; ++j)
        std::cout << "            " << mNameMap[i][j] << std::endl;
    }

  std::cout << std::endl;
}
Ejemplo n.º 13
0
void CParameterObject::parametersChanged()
{
	std::list<paramPair>::iterator it = parameterObjects->begin();

	for (;it != parameterObjects->end(); it ++)
	{
		string prefix = (*it).second;
		for (int i = 0; i < getNumParameters(); i++)
		{
			string paramName = getParameterName(i);
			double value = getParameter(paramName);

			if (prefix == paramName.substr(0, prefix.length()))
			{
				paramName = paramName.substr(prefix.length());
				if ((*it).first->getParameterIndex(paramName) >= 0 && fabs((*it).first->getParameter(paramName) - value) > 0.00001)
				{
					(*it).first->setParameter(paramName, value);
				}
			}
		}
	}
	onParametersChanged();
}
Ejemplo n.º 14
0
String AudioProcessor::getParameterName (int parameterIndex, int maximumStringLength)
{
    return getParameterName (parameterIndex).substring (0, maximumStringLength);
}
Ejemplo n.º 15
0
   plugMainUnion plugMain(DWORD functionCode, DWORD inputValue, DWORD instanceID)

#endif	

{
	plugMainUnion retval;

	// declare pPlugObj - pointer to this instance
	CFreeFrameGLPlugin* pPlugObj;

	// typecast DWORD into pointer to a CFreeFrameGLPlugin
	pPlugObj = (CFreeFrameGLPlugin*) instanceID;

	switch (functionCode) {

	case FF_GETINFO:
		retval.PISvalue = (PluginInfoStruct*)getInfo();
		break;

	case FF_INITIALISE:
		retval.ivalue = initialise();
		break;

	case FF_DEINITIALISE:
		retval.ivalue = deInitialise();	
		break;

	case FF_GETNUMPARAMETERS:
		retval.ivalue = getNumParameters();
		break;

	case FF_GETPARAMETERNAME:
		retval.svalue = getParameterName(inputValue);
		break;
	
	case FF_GETPARAMETERDEFAULT:
		retval.ivalue = getParameterDefault(inputValue);
		break;

	case FF_GETPLUGINCAPS:
		retval.ivalue = getPluginCaps(inputValue);
		break;

	case FF_GETEXTENDEDINFO: 
		retval.ivalue = (DWORD) getExtendedInfo();
		break;

	case FF_GETPARAMETERTYPE:		
		retval.ivalue = getParameterType(inputValue);
		break;

	case FF_GETPARAMETERDISPLAY:
		if (pPlugObj != NULL) 
			retval.svalue = pPlugObj->GetParameterDisplay(inputValue);
		else
			retval.svalue = (char*)FF_FAIL;
		break;
		
	case FF_SETPARAMETER:
		if (pPlugObj != NULL)
			retval.ivalue = pPlugObj->SetParameter((const SetParameterStruct*) inputValue);
		else
			retval.ivalue = FF_FAIL;
		break;
	
	case FF_GETPARAMETER:
		if (pPlugObj != NULL) 
			retval.ivalue = pPlugObj->GetParameter(inputValue);
		else 
			retval.ivalue = FF_FAIL;
		break;
		
  case FF_INSTANTIATEGL:
    retval.ivalue = (DWORD)instantiateGL((const FFGLViewportStruct *)inputValue);
    break;

  case FF_DEINSTANTIATEGL:
    if (pPlugObj != NULL)
			retval.ivalue = deInstantiateGL(pPlugObj);
		else
			retval.ivalue = FF_FAIL;
    break;
	
	case FF_GETIPUTSTATUS:
		if (pPlugObj != NULL)
			retval.ivalue = pPlugObj->GetInputStatus(inputValue);
		else
			retval.ivalue = FF_FAIL;
		break;

  case FF_PROCESSOPENGL:
    if (pPlugObj != NULL)
    {
      ProcessOpenGLStruct *pogls = (ProcessOpenGLStruct *)inputValue;
      if (pogls!=NULL)
        retval.ivalue = pPlugObj->ProcessOpenGL(pogls);
      else
        retval.ivalue = FF_FAIL;
    }
		else
			retval.ivalue = FF_FAIL;
		break;

  case FF_SETTIME:
    if (pPlugObj != NULL)
    {
      double *inputTime = (double *)inputValue;
      if (inputTime!=NULL)
        retval.ivalue = pPlugObj->SetTime(*inputTime);
      else
        retval.ivalue = FF_FAIL;
    }
		else
			retval.ivalue = FF_FAIL;
		break;

  //these old FF functions must always fail for FFGL plugins
	case FF_INSTANTIATE:
  case FF_DEINSTANTIATE:
	case FF_PROCESSFRAME:
  case FF_PROCESSFRAMECOPY:
	default:
		retval.ivalue = FF_FAIL;
		break;
	}
	
	return retval;
}
void QFFCSMaxEntEvaluationItem::doFit(QFRawDataRecord* record, int index, int model, int defaultMinDatarange, int defaultMaxDatarange, int runAvgWidth, int residualHistogramBins) {
    bool doEmit=record->isEmitResultsChangedEnabled();
    bool thisDoEmitResults=get_doEmitResultsChanged();
    bool thisDoEmitProps=get_doEmitResultsChanged();
    set_doEmitResultsChanged(false);
    set_doEmitPropertiesChanged(false);
    record->disableEmitResultsChanged();

    //qDebug() << "START DEBUGGING 0: We enter the do fit Method with MODEL = " << model;



    /* IMPLEMENT THIS

      Ergebnisse koennen einfach mit einer der setFitResult... Methoden gespeichert werden:

        //                                          PARAMETERNAME           WERT
        setFitResultValueBool(record, index, model, "evaluation_completed", true);
        //                                      PARAMETERNAME   WERT   FEHLER und EINHEIT (z.B. "ms") dazu
        setFitResultValue(record, index, model, "my_parameter", value, error, unit);

    */

    // HERE IS A DUMMY IMPLEMENTATION THAT OUTPUTS A SIMPLE GAUSSIAN
    QFRDRFCSDataInterface* data=qobject_cast<QFRDRFCSDataInterface*>(record);
    if (data) {
        getProject()->getServices()->log_text(tr("running MaxEnt fit with model '%1' on raw data record '%2', run %3 ... \n").arg(getModelName(model)).arg(record->getName()).arg(index));
        // which datapoints should we actually use?
        int rangeMinDatarange=0;
        int rangeMaxDatarange=data->getCorrelationN();
        if (defaultMinDatarange>=0) rangeMinDatarange=defaultMinDatarange;
        if (defaultMaxDatarange>=0) rangeMaxDatarange=defaultMaxDatarange;
        getProject()->getServices()->log_text(tr("   - fit data range: %1...%2 (%3 datapoints)\n").arg(defaultMinDatarange).arg(defaultMaxDatarange).arg(defaultMaxDatarange-defaultMinDatarange));




        uint32_t N=data->getCorrelationN();
        double* taus=data->getCorrelationT();
        double* distTaus=NULL;//(double*)qfCalloc(Ndist,sizeof(double));
        double* distDs=NULL;//(double*)qfCalloc(Ndist,sizeof(double));
        double* dist=NULL;//(double*)qfCalloc(Ndist,sizeof(double));
        double* modelEval=(double*)qfMalloc(N*sizeof(double));
        bool weightsOK=false;
        double* corrdata=data->getCorrelationMean();
        if (index>=0) corrdata=data->getCorrelationRun(index);
        double* weights=allocWeights(&weightsOK, record, index);
        if (!weightsOK) getProject()->getServices()->log_warning(tr("   - weights have invalid values => setting all weights to 1\n"));

        //////////Load Algorithm Parameters ////////////////////////////////////////////////
        double alpha=getFitValue(record,index,model,"maxent_alpha");
        int NumIter=getFitValue(record,index,model,"maxent_numiter");
        uint32_t Ndist=getFitValue(record,index,model,"maxent_Ndist");
        ////////////////////////////////////////////////////////////////////////////////////
        bool fitSuccess=false;


        //qDebug() << "DEBUG #1: alpha = " << alpha << " NumIter = " << NumIter << "Ndist =" << Ndist ;

        //////////Load Model Parameters//////////////////////////////////////////////////////
        //int parameter_count=getParameterCount(model);
        QVector<double> param_vector(getParameterCount(model));
        switch(model)
            {
                // FCS 3D diffusion with triplet
                case 0: param_vector[0]=getFitValue(record,index,model,"trip_tau")*1e-6;
                        param_vector[1]=getFitValue(record,index,model,"trip_theta");
                        param_vector[2]=getFitValue(record,index,model,"focus_struct_fac");
                        param_vector[3]=getFitValue(record,index,model,"offset");
                        break;
                // FCS 3D diffusion with 2 blinking components
                case 1:
                        param_vector[0]=getFitValue(record,index,model,"trip_tau")*1e-6;
                        param_vector[1]=getFitValue(record,index,model,"trip_theta");
                        param_vector[2]=getFitValue(record,index,model,"focus_struct_fac");
                        param_vector[3]=getFitValue(record,index,model,"dark_tau")*1e-6;
                        param_vector[4]=getFitValue(record,index,model,"dark_theta");
                        param_vector[5]=getFitValue(record,index,model,"offset");
                        break;
                // FCS 2D diffusion with 2 blinking components
                case 2:
                        param_vector[0]=getFitValue(record,index,model,"trip_tau")*1e-6;
                        param_vector[1]=getFitValue(record,index,model,"trip_theta");
                        param_vector[2]=getFitValue(record,index,model,"dark_tau")*1e-6;
                        param_vector[3]=getFitValue(record,index,model,"dark_theta");
                        param_vector[4]=getFitValue(record,index,model,"offset");
                        break;
                case 3: param_vector[0]=getFitValue(record,index,model,"A");
                        break;
                case 4: param_vector[0]=getFitValue(record,index,model,"tau_1")*1e-6;
                        param_vector[1]=getFitValue(record,index,model,"tau_2")*1e-6;
                        param_vector[2]=getFitValue(record,index,model,"focus_struct_fac");
                        param_vector[3]=getFitValue(record,index,model,"fraction");
                        param_vector[4]=getFitValue(record,index,model,"particle_number");
                        param_vector[5]=getFitValue(record,index,model,"offset");
                        break;
                case 5: //param_vector[0]=getFitValue(record,index,model,"maxent_wxy")*1e-3;
                        param_vector[0]=getFitValue(record,index,model,"focus_height")*1e-3;
                        param_vector[1]=getFitValue(record,index,model,"pixel_size")*1e-3;
                        param_vector[2]=getFitValue(record,index,model,"offset");
                        break;
                case 6: param_vector[0]=getFitValue(record,index,model,"pixel_size")*1e-3;
                        param_vector[1]=getFitValue(record,index,model,"offset");
                        break;



             }

        double *param_list=param_vector.data();
        //////////////////////////////////////////////////////////////////////////////////////////////////

        /*
        double kappa=getFitValue(record,index,model,"focus_struct_fac");
        double tripTau=getFitValue(record,index,model,"trip_tau")*1e-6;
        double tripTheta=getFitValue(record,index,model,"trip_theta");
        */

        QVector<double> init_tau=getFitValueNumberArray(record, index, model, "maxent_tau");
        QVector<double> init_dist=getFitValueNumberArray(record, index, model, "maxent_distribution");

        //qDebug()<<init_tau;

        bool old_distribution=false; // default value
        if (init_tau.size()>0 && init_dist.size()>0)
            {
                Ndist=qMin(init_tau.size(), init_dist.size());
                distTaus=(double*)qfCalloc(Ndist,sizeof(double));
                dist=(double*)qfCalloc(Ndist,sizeof(double));
                for (uint32_t i=0; i<Ndist; i++)
                    {
                        distTaus[i]=init_tau[i];
                        dist[i]=init_dist[i];
                    }
                old_distribution=true;
                //qDebug()<< "OLDDIST TRUE";
            }
        else
            {
                distTaus=NULL;
                dist=NULL;
                old_distribution=false;
                //qDebug()<< "OLDDIST FALSE";
                if (int64_t(Ndist)>(rangeMaxDatarange-rangeMinDatarange))
                    {
                        Ndist=(rangeMaxDatarange-rangeMinDatarange);
                    }

            }



        QElapsedTimer time;
        time.start();

        /////////////////////////////////////////////////////////
        /// MaxEnt Implementation ///////////////////////////////
        /////////////////////////////////////////////////////////
        double tau_min=getFitValue(record,index,model,"maxent_taumin");
        double tau_max=getFitValue(record,index,model,"maxent_taumax");
        MaxEntB040::TauMode tau_mode= (MaxEntB040::TauMode)getFitValue(record,index,model,"maxent_taumode");

        MaxEntB040 mem;
        mem.setData(taus,corrdata,weights,N,rangeMinDatarange,rangeMaxDatarange,Ndist,dist,distTaus, model,getParameterCount(model),param_list, getFitValue(record,index,model,"maxent_wxy")*1e-3, tau_mode, tau_min, tau_max);
        mem.run(alpha,NumIter,param_list,model,getParameterCount(model));
        fitSuccess=true;
        if (old_distribution==false)
            {
                distTaus=(double*)qfCalloc(Ndist,sizeof(double));
                dist=(double*)qfCalloc(Ndist,sizeof(double));
            }
        mem.writeDistTaus(distTaus);
        mem.writeDistribution(dist);
        /////////////////////////////////////////////////////////
        /////////////////////////////////////////////////////////
        /////////////////////////////////////////////////////////


        // reset all NAN to 0
        for (unsigned int i=0; i<Ndist; i++) {
            double d=dist[i];
            if (!QFFloatIsOK(dist[i])) dist[i]=0;
            //qDebug()<<distTaus[i]<<" ,\t"<<d<<" ,\t"<<dist[i];
        }

        //////////////////////////////////////////////////////////
        //////////////////////////////////////////////////////////
/*
        // REPLACE THIS WITH THE ACTUAL MAXENT FIT!!!
        double T0=1e-4;
        double sigma=2e-5;
        double dSum=0;
        for (int i=rangeMinDatarange; i<rangeMaxDatarange; i++) {
            const double t=taus[i];
            dist[i]=exp(-0.5*sqr(t-T0)/sqr(sigma));
            dSum=dSum+dist[i];
        }
        for (int i=rangeMinDatarange; i<rangeMaxDatarange; i++) {
            dist[i]=dist[i]/dSum;
        }
        fitSuccess=true;
        // FIT CODE COMPLETE
*/

        // duration measurement
        double duration=double(time.elapsed())/1000.0;

        getProject()->getServices()->log_text(tr("   - fit completed after %1 msecs with result %2\n").arg(duration).arg(fitSuccess?tr("success"):tr("no convergence")));

        distDs=(double*)qfCalloc(Ndist, sizeof(double));
        if (model!=3) {
            const double wxy=getWXY();
            for (uint32_t i=0; i<Ndist; i++) {
                distDs[i]=wxy*wxy/1000000.0/(4.0*distTaus[i]);
            }
        } else if (model==3) {
            const double q2=qfSqr(getDLSQ());
            //qDebug()<<"q2="<<q2;
            for (uint32_t i=0; i<Ndist; i++) {
                distDs[i]=1.0/(q2*distTaus[i]);
            }
        }

        // now store the results:
        QString param,paramtau,paramD,parammem;
        setFitResultValueNumberArray(record, index, model, paramtau=param="maxent_tau", distTaus, Ndist, QString("seconds"));
        setFitResultGroup(record, index, model, param, tr("fit results"));
        setFitResultLabel(record, index, model, param, tr("MaxEnt distribution: lag times"), QString("MaxEnt distribution: lag times <i>&tau;</i>"));
        setFitResultSortPriority(record, index, model, param, true);

        setFitResultValueNumberArray(record, index, model, paramD=param="maxent_D", distDs, Ndist, QString("seconds"));
        setFitResultGroup(record, index, model, param, tr("fit results"));
        setFitResultLabel(record, index, model, param, tr("MaxEnt distribution: diffusion coefficients"), QString("MaxEnt distribution: diffusion coefficients <i>D</i>"));
        setFitResultSortPriority(record, index, model, param, true);

        setFitResultValueNumberArray(record, index, model, parammem=param="maxent_distribution", dist, Ndist);
        setFitResultGroup(record, index, model, param, tr("fit results"));
        setFitResultLabel(record, index, model, param, tr("MaxEnt distribution"), QString("MaxEnt distribution: <i>p(&tau;)</i>"));
        setFitResultSortPriority(record, index, model, param, true);

        setFitResultValueInt(record, index, model, param="maxent_taumode", tau_mode);
        setFitResultGroup(record, index, model, param, tr("fit results"));
        setFitResultLabel(record, index, model, param, tr("MaxEnt distribution: tau mode"), tr("MaxEnt distribution: tau mode"));
        setFitResultSortPriority(record, index, model, param, true);

        QFRawDataRecord::evaluationCompoundResult comp;
        comp.type=QFRawDataRecord::qfrdrctGraph1D;
        comp.metadata["logX"]=true;
        comp.metadata["logY"]=false;
        comp.metadata["labelX"]=tr("correlation time \\tau_D [s]");
        comp.metadata["labelY"]=tr("MaxEnt distribution");
        comp.label=tr("MaxEnt(tauD)");
        comp.referencedResults<<paramtau<<parammem;
        record->resultsCompoundSet(getEvaluationResultID(index, model), "maxent_tau_curve", comp);

        comp.metadata["labelX"]=tr("diffusion coefficient D [{\\mu}m^2/s]");
        comp.label=tr("MaxEnt(D)");
        comp.referencedResults.clear();
        comp.referencedResults<<paramD<<parammem;
        record->resultsCompoundSet(getEvaluationResultID(index, model), "maxent_d_curve", comp);

        if (tau_mode>2) {

            double wxy=getFitValue(record,index,model,"maxent_wxy")*1e-3;

            setFitResultValue(record, index, model, param="maxent_taumax", wxy*wxy/(4.0*distTaus[0]), QString("seconds"));
            setFitResultGroup(record, index, model, param, tr("fit results"));
            setFitResultLabel(record, index, model, param, tr("MaxEnt distribution: minimum distribution times"), QString("MaxEnt distribution: minimum distribution times <i>&tau;<sub>min</sub></i>"));
            setFitResultSortPriority(record, index, model, param, true);

            setFitResultValue(record, index, model, param="maxent_taumin", wxy*wxy/(4.0*distTaus[Ndist-1]), QString("seconds"));
            setFitResultGroup(record, index, model, param, tr("fit results"));
            setFitResultLabel(record, index, model, param, tr("MaxEnt distribution: maximum distribution times"), QString("MaxEnt distribution: maximum distribution times <i>&tau;<sub>max</sub></i>"));
            setFitResultSortPriority(record, index, model, param, true);
        } else {
            setFitResultValue(record, index, model, param="maxent_taumin", distTaus[0], QString("seconds"));
            setFitResultGroup(record, index, model, param, tr("fit results"));
            setFitResultLabel(record, index, model, param, tr("MaxEnt distribution: minimum distribution times"), QString("MaxEnt distribution: minimum distribution times <i>&tau;<sub>min</sub></i>"));
            setFitResultSortPriority(record, index, model, param, true);

            setFitResultValue(record, index, model, param="maxent_taumax", distTaus[Ndist-1], QString("seconds"));
            setFitResultGroup(record, index, model, param, tr("fit results"));
            setFitResultLabel(record, index, model, param, tr("MaxEnt distribution: maximum distribution times"), QString("MaxEnt distribution: maximum distribution times <i>&tau;<sub>max</sub></i>"));
            setFitResultSortPriority(record, index, model, param, true);

        }


        // save all the default values for all fit parameters as results.
        for (int i=0; i<getParameterCount(model); i++) {
            param=getParameterID(model, i);
            double value=getFitValue(record, index, model, param);
            //qDebug()<<"model param "<<i<<": "<<param<<" = "<<value;
            setFitResultValue(record, index, model, param, value, getParameterUnit(model, i, false));
            setFitResultGroup(record, index, model, param, tr("fit results"));
            setFitResultLabel(record, index, model, param, getParameterName(model, i, false), getParameterName(model, i, true));
            setFitResultSortPriority(record, index, model, param, true);
            //qDebug()<<"model param "<<i<<": "<<param<<" = "<< getFitValue(record, index, model, param)<<getParameterUnit(model, i, false);
        }

        // you can overwrite certain of these parameters using code like this:
        /*setFitResultValue(record, index, model, param="focus_struct_fac", getFitValue(record, index, model, param));
        setFitResultGroup(record, index, model, param, tr("fit results"));
        setFitResultLabel(record, index, model, param, tr("focus structure factor"), QString("focus structure factor <i>&gamma;</i>"));
        setFitResultSortPriority(record, index, model, param, true);*/




        // store number of iterations ... you may also store more fit algorithm properties like this
        setFitResultValue(record, index, model, param="maxent_alpha", alpha);
        setFitResultGroup(record, index, model, param, tr("fit properties"));
        setFitResultLabel(record, index, model, param, tr("MaxEnt scaling parameter alpha"), tr("scaling parameter &alpha;"));

        setFitResultValueInt(record, index, model, param="maxent_iterations", ceil(getFitValue(record, index, model, param)+NumIter));
        setFitResultGroup(record, index, model, param, tr("fit properties"));
        setFitResultLabel(record, index, model, param, tr("number of MaxEnt iterations"), tr("number of MaxEnt iterations"));

        setFitResultValueInt(record, index, model, param="maxent_numiter", NumIter);
        setFitResultGroup(record, index, model, param, tr("fit properties"));
        setFitResultLabel(record, index, model, param, tr("number of MaxEnt iterations in last run of algorithm"), tr("last MaxEnt iterations"));

        setFitResultValueString(record, index, model, param="used_model", getModelName(model));
        setFitResultGroup(record, index, model, param, tr("fit properties"));
        setFitResultLabel(record, index, model, param, tr("used model name"), tr("used model name"));

        setFitResultValueInt(record, index, model, param="maxent_Ndist",Ndist);
        setFitResultGroup(record, index, model, param, tr("fit properties"));
        setFitResultLabel(record, index, model, param, tr("MaxEnt number of distribution points"), tr("MaxEnt number of distribution points"));

        setFitResultValueInt(record, index, model, param="used_model_id", model);
        setFitResultGroup(record, index, model, param, tr("fit properties"));
        setFitResultLabel(record, index, model, param, tr("used model id"), tr("used model id"));

        setFitResultValueInt(record, index, model, param="used_run", index);
        setFitResultGroup(record, index, model, param, tr("fit properties"));
        setFitResultLabel(record, index, model, param, tr("used run"), tr("used run"));

        setFitResultValue(record, index, model, param="runtime", duration, tr("seconds"));
        setFitResultGroup(record, index, model, param, tr("fit properties"));
        setFitResultLabel(record, index, model, param, tr("fit runtime"), tr("fit runtime"));

        setFitResultValueString(record, index, model, param="fitalg_message", tr("MaxEnt finished successfully after %1 iterations with alpha=%2").arg(NumIter).arg(alpha));
        setFitResultGroup(record, index, model, param, tr("fit properties"));
        setFitResultLabel(record, index, model, param, tr("MaxEnt message"), tr("MaxEnt message"));

        setFitResultValueString(record, index, model, param="fitalg_messageHTML", tr("<b>MaxEnt finished successfully</b><br>after %1 iterations with &alpha;=%2").arg(NumIter).arg(alpha));
        setFitResultGroup(record, index, model, param, tr("fit properties"));
        setFitResultLabel(record, index, model, param, tr("MaxEnt message"), tr("MaxEnt message"));

        // CALCULATE FIT STATISTICS
        //   now we evaluate the model for the given distribution
        /////////////////////////
        /////////////////////////
        // I changed the 7th argument in the evaluateModel call from &(taus[rangeMindatarange]) to &(distTaus[rangeMinDatarange])
        // this is what the 7th and 8th argument used to be like: &(distTaus[rangeMinDatarange]), &(dist[rangeMinDatarange])
        // this was the last argument:  rangeMaxDatarange-rangeMinDatarange, now changed to Ndist
        ////////////////////////

        evaluateModel(record, index, model, taus, modelEval, N, distTaus,dist,Ndist);
        //   then we can call calcFitStatistics()
        QFFitStatistics fit_stat=calcFitStatistics(record, index, model, taus, corrdata, N,Ndist, rangeMinDatarange, rangeMaxDatarange, runAvgWidth, residualHistogramBins);
        //   finally we have to free the memory allocated in the calcFitStatistics() result.
        fit_stat.free();

        qfFree(dist);
        qfFree(weights);
        qfFree(modelEval);
        qfFree(distTaus);
        qfFree(distDs);


    }

    if (doEmit) record->enableEmitResultsChanged(true);
    set_doEmitResultsChanged(thisDoEmitResults);
    set_doEmitPropertiesChanged(thisDoEmitProps);
}
Ejemplo n.º 17
0
   plugMainUnion plugMain( DWORD functionCode, LPVOID pParam, LPVOID instanceID )
#endif	
{
	plugMainUnion retval;

	// declare pPlugObj - pointer to this instance
	WhorldPlug *pPlugObj;

	// typecast LPVOID into pointer to a WhorldPlug
	pPlugObj = (WhorldPlug*) instanceID;

	switch(functionCode) {

	case FF_GETINFO:
		retval.PISvalue = getInfo();
		break;
	case FF_INITIALISE:
		retval.ivalue = initialise();
		break;
	case FF_DEINITIALISE:
		retval.ivalue = deInitialise();			// todo: pass on instance IDs etc
		break;
	case FF_GETNUMPARAMETERS:
		retval.ivalue = getNumParameters();
		break;
	case FF_GETPARAMETERNAME:
		retval.svalue =  getParameterName( (DWORD) pParam );
		break;
	case FF_GETPARAMETERDEFAULT:
		retval.fvalue =  getParameterDefault( (DWORD) pParam );
		break;
	case FF_GETPARAMETERDISPLAY:
		retval.svalue =  pPlugObj->getParameterDisplay( (DWORD) pParam );
		break;	
	// parameters are passed in here as a packed struct of two DWORDS:
	// index and value
	case FF_SETPARAMETER:
		retval.ivalue=  pPlugObj->setParameter( (SetParameterStruct*) pParam );
		break;
	case FF_PROCESSFRAME:
		retval.ivalue = pPlugObj->processFrame(pParam);
		break;
	case FF_GETPARAMETER:
		retval.fvalue =  pPlugObj->getParameter((DWORD) pParam);
		break;
	case FF_GETPLUGINCAPS:
		retval.ivalue = getPluginCaps( (DWORD) pParam);
		break;

// Russell - FF 1.0 upgrade in progress ...

	case FF_INSTANTIATE:
		retval.ivalue = (DWORD) instantiate( (VideoInfoStruct*) pParam);
		break;
	case FF_DEINSTANTIATE:
		retval.ivalue = deInstantiate(pPlugObj);
		break;
	case FF_GETEXTENDEDINFO: 
		retval.ivalue = (DWORD) getExtendedInfo();
		break;
	case FF_PROCESSFRAMECOPY:
		retval.ivalue = pPlugObj->processFrameCopy((ProcessFrameCopyStruct*)pParam);
		break;
	case FF_GETPARAMETERTYPE:		
		// not implemented yet
		retval.ivalue = FF_FAIL;
		break;

// ....................................

	default:
		retval.ivalue = FF_FAIL;
		break;
	}
	return retval;
}
int getOptModelParameterName(emb_optimizer optim, int name_idx, char par_name[], size_t maxlen, size_t *reqlen)
{
	return getParameterName(myModel, name_idx, par_name, maxlen, reqlen);
}
Ejemplo n.º 19
0
void CReactionInterface::copyMapping()
{
  if (!mpParameters) //nothing to copy
    {
      initMapping();
      return;
    }

  // save the old information
  CFunctionParameters *oldParameters = mpParameters;
  std::vector<std::vector<std::string> > oldMap = mNameMap;
  std::vector<C_FLOAT64> oldValues = mValues;
  std::vector<bool> oldIsLocal = mIsLocal;

  //create new mapping
  initMapping();

  //try to preserve as much information from the old mapping as possible
  size_t j, jmax = oldParameters->size();
  size_t i, imax = size();

  for (i = 0; i < imax; ++i)
    {
      //find parameter with same name in old parameters
      for (j = 0; j < jmax; ++j)
        if ((*oldParameters)[j]->getObjectName() == getParameterName(i)) break;

      if (j == jmax) continue;

      //see if usage matches
      if (getUsage(i) != (*oldParameters)[j]->getUsage()) continue;

      //see if vector property matches
      if (isVector(i) != ((*oldParameters)[j]->getType() == CFunctionParameter::VFLOAT64))
        continue;

      mIsLocal[i] = oldIsLocal[j];
      mValues[i] = oldValues[j];

      switch (getUsage(i))
        {
          case CFunctionParameter::SUBSTRATE:
          case CFunctionParameter::PRODUCT:
            //TODO: check with chemeq
            mNameMap[i] = oldMap[j];
            break;

          case CFunctionParameter::MODIFIER:
            //TODO: check existence?
            mNameMap[i] = oldMap[j];
            //TODO: add to chemeq
            break;

          case CFunctionParameter::PARAMETER:
          case CFunctionParameter::VOLUME:
          case CFunctionParameter::TIME:
            //TODO: check existence?
            mNameMap[i] = oldMap[j];
            break;

          default:
            break;
        }
    }

  pdelete(oldParameters);
}
Ejemplo n.º 20
0
double CParameters::getParameterFromIndex(unsigned int index)
{
	return getParameter(getParameterName(index));
}
Ejemplo n.º 21
0
bool CReactionInterface::writeBackToReaction(CReaction * rea)
{
  bool success = true;

  //CReaction *rea;
  if (rea == NULL)
    rea = dynamic_cast< CReaction *>(CCopasiRootContainer::getKeyFactory()->get(mReactionReferenceKey));

  if (rea == NULL) return false;

  // Now we can safely write to the equation as we are sure that only unique metabolites
  // may have the empty string as compartments
  mChemEqI.writeToChemEq(rea->getChemEq());

  if (!isValid()) return false; // do nothing

  if (mpFunction == NULL) return false;

  if (mpFunction->getObjectName() == "undefined") return false;

  if (mpParameters == NULL) return false;

  if (!(*mpParameters == mpFunction->getVariables())) return false; // do nothing

  // TODO. check if function has changed since it was set in the R.I.
  rea->setFunction(mpFunction->getObjectName());

  size_t j, jmax;
  size_t i, imax = size();
  std::pair< std::string, std::string > Names;

  for (i = 0; i < imax; ++i)
    {
      switch (getUsage(i))
        {
          case CFunctionParameter::PARAMETER:

            if (mIsLocal[i])
              rea->setParameterValue(getParameterName(i), mValues[i]);
            else
              {
                rea->setParameterValue(getParameterName(i), mValues[i], false);
                rea->setParameterMapping(i, mpModel->getModelValues()[mNameMap[i][0]]->getKey());
              }

            break;

          case CFunctionParameter::VOLUME:
            rea->setParameterMapping(i, mpModel->getCompartments()[mNameMap[i][0]]->getKey());
            break;

          case CFunctionParameter::TIME:
            rea->setParameterMapping(i, mpModel->getKey()); //time is the value of the model
            break;

          case CFunctionParameter::SUBSTRATE:
          case CFunctionParameter::PRODUCT:
          case CFunctionParameter::MODIFIER:

            if (isVector(i))
              {
                rea->clearParameterMapping(i);
                jmax = mNameMap[i].size();

                for (j = 0; j < jmax; ++j)
                  {
                    Names = CMetabNameInterface::splitDisplayName(mNameMap[i][j]);
                    rea->addParameterMapping(i, CMetabNameInterface::getMetaboliteKey(mpModel, Names.first, Names.second));
                  }
              }
            else
              {
                Names = CMetabNameInterface::splitDisplayName(mNameMap[i][0]);
                rea->setParameterMapping(i, CMetabNameInterface::getMetaboliteKey(mpModel, Names.first, Names.second));
              }

            break;

          default:
            break;
        }
    }

  rea->compile();
  mpModel->setCompileFlag(); //TODO: check if really necessary

  return success;
}
Ejemplo n.º 22
0
bool CReactionInterface::loadMappingAndValues(const CReaction & rea)
{
  bool success = true;
  std::vector< std::vector<std::string> >::const_iterator it;
  std::vector< std::vector<std::string> >::const_iterator iEnd;
  std::vector<std::string>::const_iterator jt;
  std::vector<std::string>::const_iterator jEnd;
  size_t i;

  std::string metabName;
  const CModelEntity* pObj;

  std::vector<std::string> SubList;
  SubList.resize(1);
  SubList[0] = "unknown";

  mNameMap.resize(size());

  for (i = 0; i != size(); ++i)
    {
      mNameMap[i] = SubList;
    }

  mValues.resize(size(), 0.1);
  mIsLocal.resize(size(), false);

  it = rea.getParameterMappings().begin();
  iEnd = rea.getParameterMappings().end();

  for (i = 0; it != iEnd; ++it, ++i)
    {

      if (isVector(i))
        {
          assert((getUsage(i) == CFunctionParameter::SUBSTRATE)
                 || (getUsage(i) == CFunctionParameter::PRODUCT)
                 || (getUsage(i) == CFunctionParameter::MODIFIER));

          SubList.clear();

          for (jt = it->begin(), jEnd = it->end(); jt != jEnd; ++jt)
            {
              metabName = CMetabNameInterface::getDisplayName(mpModel, *jt, true);
              assert(metabName != "");
              SubList.push_back(metabName);
            }
        }
      else
        {
          assert(it->size() == 1);
          SubList.resize(1); SubList[0] = "unknown";

          switch (getUsage(i))
            {
              case CFunctionParameter::SUBSTRATE:
              case CFunctionParameter::PRODUCT:
              case CFunctionParameter::MODIFIER:
                metabName = CMetabNameInterface::getDisplayName(mpModel, *(it->begin()), true);
                // assert(metabName != "");
                SubList[0] = metabName;
                //TODO: check if the metabolite is in the chemical equation with the correct rule
                break;

              case CFunctionParameter::VOLUME:
                pObj = dynamic_cast<const CCompartment*>(CCopasiRootContainer::getKeyFactory()->get(*(it->begin())));
                assert(pObj);
                SubList[0] = pObj->getObjectName();
                break;

              case CFunctionParameter::TIME:
                pObj = dynamic_cast<const CModel*>(CCopasiRootContainer::getKeyFactory()->get(*(it->begin())));
                assert(pObj);
                SubList[0] = pObj->getObjectName();
                break;

              case CFunctionParameter::PARAMETER:
              {
                const CCopasiParameter * pParameter = rea.getParameters().getParameter(getParameterName(i));

                if (pParameter != NULL)
                  {
                    mValues[i] = * pParameter->getValue().pDOUBLE;
                  }
                else
                  {
                    mValues[i] = std::numeric_limits< C_FLOAT64 >::quiet_NaN();
                  }

                mIsLocal[i] = rea.isLocalParameter(i);

                if (!mIsLocal[i])
                  {
                    pObj = dynamic_cast<const CModelValue*>(CCopasiRootContainer::getKeyFactory()->get(*(it->begin())));

                    if (pObj)
                      {
                        SubList[0] = pObj->getObjectName();
                        mValues[i] = pObj->getInitialValue();
                      }
                  }
              }
              break;

              default:
                break;
            }
        }

      mNameMap[i] = SubList;
    }

  return success;
}
Ejemplo n.º 23
0
void
RemotePluginServer::dispatchControlEvents()
{    
    RemotePluginOpcode opcode = RemotePluginNoOpcode;
    static float *parameterBuffer = 0;

    tryRead(m_controlRequestFd, &opcode, sizeof(RemotePluginOpcode));

    switch (opcode) {

    case RemotePluginGetVersion:
	writeFloat(m_controlResponseFd, getVersion());
	break;

    case RemotePluginGetName:
	writeString(m_controlResponseFd, getName());
	break;

    case RemotePluginGetMaker:
	writeString(m_controlResponseFd, getMaker());
	break;
    
    case RemotePluginTerminate:
	terminate();
	break;
    
    case RemotePluginGetInputCount:
	m_numInputs = getInputCount();
	writeInt(m_controlResponseFd, m_numInputs);
	break;

    case RemotePluginGetOutputCount:
	m_numOutputs = getOutputCount();
	writeInt(m_controlResponseFd, m_numOutputs);
	break;

    case RemotePluginGetParameterCount:
	writeInt(m_controlResponseFd, getParameterCount());
	break;
	
    case RemotePluginGetParameterName:
	writeString(m_controlResponseFd, getParameterName(readInt(m_controlRequestFd)));
	break;
    
    case RemotePluginGetParameter:
	writeFloat(m_controlResponseFd, getParameter(readInt(m_controlRequestFd)));
	break;
    
    case RemotePluginGetParameterDefault:
	writeFloat(m_controlResponseFd, getParameterDefault(readInt(m_controlRequestFd)));
	break;

    case RemotePluginGetParameters:
    {
	if (!parameterBuffer) {
	    parameterBuffer = new float[getParameterCount()];
	}
	int p0 = readInt(m_controlRequestFd);
	int pn = readInt(m_controlRequestFd);
	getParameters(p0, pn, parameterBuffer);
	tryWrite(m_controlResponseFd, parameterBuffer, (pn - p0 + 1) * sizeof(float));
	break;
    }

    case RemotePluginHasMIDIInput:
    {
	bool m = hasMIDIInput();
	tryWrite(m_controlResponseFd, &m, sizeof(bool));
	break;
    }
       
    case RemotePluginGetProgramCount:
	writeInt(m_controlResponseFd, getProgramCount());
	break;

    case RemotePluginGetProgramName:
	writeString(m_controlResponseFd, getProgramName(readInt(m_controlRequestFd)));
	break;

    case RemotePluginIsReady:
    {
	if (!m_shm) sizeShm();
	bool b(isReady());
	std::cerr << "isReady: returning " << b << std::endl;
	tryWrite(m_controlResponseFd, &b, sizeof(bool));
    }

    case RemotePluginSetDebugLevel:
    {
	RemotePluginDebugLevel newLevel = m_debugLevel;
	tryRead(m_controlRequestFd, &newLevel, sizeof(RemotePluginDebugLevel));
	setDebugLevel(newLevel);
	m_debugLevel = newLevel;
	break;
    }

    case RemotePluginWarn:
    {
	bool b = warn(readString(m_controlRequestFd));
	tryWrite(m_controlResponseFd, &b, sizeof(bool));
	break;
    }

    case RemotePluginShowGUI:
    {
	showGUI(readString(m_controlRequestFd));
	break;
    }

    case RemotePluginHideGUI:
    {
	hideGUI();
	break;
    }

    //Deryabin Andrew: vst chunks support
    case RemotePluginGetVSTChunk:
    {
        std::vector<char> chunk = getVSTChunk();
        writeRaw(m_controlResponseFd, chunk);
        break;
    }

    case RemotePluginSetVSTChunk:
    {
        std::vector<char> chunk = readRaw(m_controlRequestFd);
        setVSTChunk(chunk);
        break;
    }
    //Deryabin Andrew: vst chunks support: end code

    case RemotePluginNoOpcode:
	break;

    case RemotePluginReset:
	reset();
	break;

    default:
	std::cerr << "WARNING: RemotePluginServer::dispatchControlEvents: unexpected opcode "
		  << opcode << std::endl;
    }
}
const String DemoJuceFilter::getParameterXMLName (int index)
{
   String name = getParameterName(index);
   name = name.replace(T(" "), T("_"));
   return name;
}