Example #1
0
/**
 * Ties a parameter to other parameters
 * @param parName :: The name of the parameter to tie.
 * @param expr :: A math expression
 * @param isDefault :: Flag to mark as default the value of an object associated with this reference: a tie or a constraint.
 * @return newly ties parameters
 */
ParameterTie* IFunction::tie(const std::string& parName,const std::string& expr, bool isDefault)
{
  ParameterTie* ti = new ParameterTie(this,parName,expr,isDefault);
  addTie(ti);
  this->fix(getParameterIndex(*ti));
  return ti;
}
bool CLuaScriptParameters::removeParameterValue(const char* paramName)
{
	int ind=getParameterIndex(paramName);
	if (ind<0)
		return(false);
	return(removeParameterValue(ind));
}
Example #3
0
void MLPluginProcessor::doPropertyChangeAction(MLSymbol property, const MLProperty& newVal)
{
	int propertyType = newVal.getType();
	int paramIdx = getParameterIndex(property);
	float f = newVal.getFloatValue();
	
	switch(propertyType)
	{
		case MLProperty::kFloatProperty:
			setParameterWithoutProperty (property, f);
			if (paramIdx < 0) return;
			
			// convert to host units for VST
			f = newVal.getFloatValue();
			if (wrapperType == AudioProcessor::wrapperType_VST)
			{
				MLPublishedParamPtr p = mEngine.getParamPtr(paramIdx);
				if(p)
				{
					f = p->getValueAsLinearProportion();
				}
			}
			// send to wrapper in host units
			AudioProcessor::sendParamChangeMessageToListeners (paramIdx, f);
			
			break;
		case MLProperty::kStringProperty:
			break;
		case MLProperty::kSignalProperty:
			break;
		default:
			break;
	}
}
Example #4
0
void CParameters::loadParametersXML(FILE *stream)
{
	char buffer1[256];
	char paramName[256];
	double value = 0.0;

	fscanf(stream, "<Parameters>\n");

	std::map<string, double>::iterator it;

	fscanf(stream, "%s", buffer1);
	while (strcmp(buffer1, "</Parameters>") != 0)
	{
		if (fscanf(stream, " %lf </%s>\n", &value, paramName) != 2)
		{
			break;
		}
		paramName[strlen(paramName) - 1] = '\0';
		if (getParameterIndex(paramName) >= 0)
		{
			setParameter(paramName, value);
		}
		else
		{
			addParameter(paramName,value);
		}fscanf(stream, "%s", buffer1);
	}
	fscanf(stream, "\n");
}
Example #5
0
void CParameters::loadParameters(FILE *stream)
{
	char description[50];
	int numParams;

	char buffer[80];
	//fscanf(stream, "%s %d\n", buffer, &numParams);

	int result = fscanf(stream, "%s %d\n", buffer, &numParams);

	double value = 0.0;
	
	if (result == 2)
	{
		for (int i = 0; i < numParams; i ++)
		{
			fscanf(stream, "%s : %lf\n", description, &value);
			
			if (getParameterIndex(description) >= 0)
			{
				setParameter(description, value);
			}
			else
			{
				addParameter(description,value);
			}
		}
	}
}
/** Remove all ties
 */
void ParamFunction::clearTies() {
  for (auto &tie : m_ties) {
    size_t i = getParameterIndex(*tie);
    unfix(i);
    delete tie;
  }
  m_ties.clear();
}
// set string plugin parameter by name without setting property. Typically called from internal code.
//
void MLPluginProcessor::setStringParameterWithoutProperty (MLSymbol paramName, const std::string& newValue)
{
	int index = getParameterIndex(paramName);
	if (index < 0) return;
	
	mEngine.setPublishedParam(index, MLProperty(newValue));
	mHasParametersSet = true;
}
Example #8
0
// set plugin parameter by name without setting property. Typically called from internal code.
//
void MLPluginProcessor::setParameterWithoutProperty (MLSymbol paramName, float newValue)
{
	int index = getParameterIndex(paramName);
	if (index < 0) return;	

	mEngine.setPublishedParam(index, newValue);	
	mHasParametersSet = true;
}
Example #9
0
/** Remove all ties
 */
void TiesFunction::clearTies()
{
  for(std::vector<ParameterTie*>::iterator it = m_ties.begin();it != m_ties.end(); ++it)
  {
    size_t i = getParameterIndex(**it);
    unfix(i);
    delete *it;
  }
  m_ties.clear();
}
bool CLuaScriptParameters::getParameterValue(const char* paramName,std::string& paramValue)
{
	int ind=getParameterIndex(paramName);
	if (ind>=0)
	{
		paramValue=parameterValues[ind];
		return(true);
	}
	return(false);
}
Example #11
0
void MLPluginProcessor::doPropertyChangeAction(MLSymbol propName, const MLProperty& newVal)
{
	int propertyType = newVal.getType();
	int paramIdx = getParameterIndex(propName);
	if (paramIdx < 0) return;
	float f = newVal.getFloatValue();
	
	switch(propertyType)
	{
		case MLProperty::kFloatProperty:
		{
			// update DSP engine parameters
			MLPublishedParamPtr p = mEngine.getParamPtr(paramIdx);
			if(p)
			{
				// set published float parameter in DSP engine.
				setParameterWithoutProperty (propName, f);
				
				// convert to host units for VST
				f = newVal.getFloatValue();
				if (wrapperType == AudioProcessor::wrapperType_VST)
				{
					f = p->getValueAsLinearProportion();
				}
				
				// either enqueue change, or send change immediately to host wrapper
				if(p->getNeedsQueue())
				{
					p->pushValue(f);
				}
				else
				{
					AudioProcessor::sendParamChangeMessageToListeners (paramIdx, f);
				}
			}
		}
		break;
		case MLProperty::kStringProperty:
		{
			// set published string parameter in DSP engine.
			const std::string& sigVal = newVal.getStringValue();
			setStringParameterWithoutProperty (propName, sigVal);
		}
		break;
		case MLProperty::kSignalProperty:
		{
			// set published signal parameter in DSP engine.
			const MLSignal& sigVal = newVal.getSignalValue();
			setSignalParameterWithoutProperty (propName, sigVal);
		}
		break;
		default:
		break;
	}
}
//inNormValue expected to be normalized
void ZenDecibelParameter::setValueNotifyingHost(float inNormValue)
{
	float clampedValue = getClamped(inNormValue, 0.0f, 1.0f);
	//clampedValue = DecibelConversions::mapDecibelsToProperNormalizedValue(clampedValue, range.start, range.end, midValue);
	
	//DBG("In ZenDecibelParameter::setValueNotifyingHost(inValue) of " << this->paramID << " with invalue: " << inNormValue << " and setParameterNotifyingHost with: " << clampedValue);
	processor->setParameterNotifyingHost(getParameterIndex(), clampedValue);
	if (shouldBeSmoothed) setTargetValue(clampedValue);

	listeners.call(&ZenAudioProcessorValueTreeState::Listener::parameterChanged, paramID, clampedValue);
	listenersNeedCalling = false;
	setValueInGainFromNormalised(value.load());
	needsUpdate.set(1);

}
Example #13
0
KalmanParameters KalmanFilter::update(float iBias, int iTimeStep, const KalmanParameters& iParameters) {
   std::vector<float> x = iParameters.x;
   std::vector<float> k = iParameters.k;
   vec2 P = iParameters.P;

   const vec2& W = getW();

   // Compute Pt|t-1. This increases the covariance.
   for(int i = 0; i < mDim; i++) {
      for(int j = 0; j < mDim; j++) {
         P[i][j] += W[i][j];
      }
   }
   if(Util::isValid(iBias)) {
      float y = iBias;
      int dindex = getParameterIndex(iTimeStep);
      assert(dindex < k.size());
      assert(dindex < P.size());

      // Compute Kt
      for(int i = 0; i < mDim; i++) {
         k[i] = P[dindex][i] / (P[dindex][dindex] + mV);
      }
      // Compute Pt|t
      for(int i = 0; i < mDim; i++) {
         for(int j = 0; j < mDim; j++) {
            P[i][j] = (1 - k[dindex])*P[i][j]; // ? i or j for k?
         }
      }
      // Compute xt|t
      float x_dindex = x[dindex];
      for(int i = 0; i < mDim; i++) {
         x[i] = x[i] + k[i]*(y - x_dindex);
      }
   }
   else {
      // Missing obs or forecast. P has already been increased, do not update x.
      // TODO: Does the kalman gain need to be updated?
   }

   // Store the new parameters
   KalmanParameters parNew = iParameters;
   parNew.x = x;
   parNew.k = k;
   parNew.P = P;

   return parNew;
}
Example #14
0
QStringList CMDLineRegistryUtils::getParameterValues( const QString & paramName, int startWith ) {
    QList<StringPair> params;
    setCMDLineParams( params );
    QStringList res;
    int sz = params.size();
    int paramIdx = getParameterIndex( paramName, startWith );
    if( -1 == paramIdx ) { // no such parameter
        return res;
    }
    for( int i = paramIdx; i < sz; ++i ) {
        res << params[i].second;
        if( i + 1 < sz && !params[i + 1].first.isEmpty() ) {
            break;
        }
    }
    return res;
}
Example #15
0
void InstanceProcessor::setStateInformation (const void* data, int sizeInBytes)
{
    ScopedPointer<XmlElement> xml(getXmlFromBinary(data, sizeInBytes));
    if(xml != nullptr)
    {
        if(xml->hasTagName("CamomileSettings"))
        {
            String name = xml->getStringAttribute("name");
            String path = xml->getStringAttribute("path");
            if(File::isAbsolutePath(path))
            {
                File file(path + File::separatorString + name);
                if(!file.exists())
                {
                    file = File(m_path + File::separatorString + name);
                    if(!file.exists())
                    {
                        file = File(File::getCurrentWorkingDirectory().getFullPathName() + File::separatorString + name);
                        if(!file.exists())
                        {
                            file = File(File::getSpecialLocation(juce::File::SpecialLocationType::userDocumentsDirectory).getFullPathName() + File::separatorString + name);
                            if(!file.exists())
                            {
                                file = File(path + File::separatorString + name);
                            }
                        }
                    }
                }
                loadPatch(name.toStdString(), path.toStdString());
            }
            
            XmlElement* params = xml->getChildByName(juce::StringRef("params"));
            if(params)
            {
                for(int i = 0; i < params->getNumAttributes(); i++)
                {
                    int index = getParameterIndex(params->getAttributeName(i));
                    if(index >= 0)
                    {
                        setParameterNotifyingHost(index, params->getAttributeValue(i).getDoubleValue());
                    }
                }
            }
        }
    }
}
bool CLuaScriptParameters::setParameterValue(const char* paramName,const char* paramValue,int paramValueLength)
{
	int ind=getParameterIndex(paramName);
	if (ind>=0)
	{
		parameterValues[ind].assign(paramValue,paramValueLength);
		for (int i=0;i<paramValueLength;i++)
		{
			if (paramValue[i]==0)
			{
				parameterProperties[ind]|=4; // Indicates that string contains embedded 0's
				break;
			}
		}
		return(true);
	}
	return(false);
}
void CLuaScriptParameters::addParameterValue(const char* paramName,const char* unitText,const char* paramValue,int paramValueLength)
{
	int ind=getParameterIndex(paramName);
	if (ind<0)
	{ // parameter not yet present!
		parameterNames.push_back(paramName);	
		parameterUnits.push_back("");	
		parameterValues.push_back("");
		parameterProperties.push_back(0);
		ind=parameterNames.size()-1;
	}
	parameterUnits[ind]=unitText;
	parameterValues[ind].assign(paramValue,paramValueLength);
	for (int i=0;i<paramValueLength;i++)
	{
		if (paramValue[i]==0)
		{
			parameterProperties[ind]|=4; // Indicates that string contains embedded 0's
			break;
		}
	}
}
Example #18
0
bool CParameters::containsParameters(CParameters *parametersObject)
{

	if (parametersObject->getNumParameters() > getNumParameters())
	{
		return false;
	}

	for (int i = 0 ;i < parametersObject->getNumParameters(); i++)
	{
		string name =  parametersObject->getParameterName(i);
		
		if (getParameterIndex(name) < 0)
		{
			return false;
		}
		if (fabs(getParameter(name) - parametersObject->getParameter(name)) > 0.00001)
		{
			//printf("Different Param Values for Parameter %s, %f %f\n", (*it).first.c_str(), (*it).second, parameterObject.getParameter((*it).first));
			return false;
		}
	}
	return true;
}
Example #19
0
void CMMLNodeAttrList::setMapTag2Attr()
{
	HKMap<long,int> mstyleAttr;

	static const int commonAttrsLength = 5;
	static QString commonAttrs[ commonAttrsLength ] =
		{FBL_ATTR_class, FBL_ATTR_style, FBL_ATTR_id, FBL_ATTR_xref, FBL_ATTR_xlink_href};

	long i, j;
	long idx = 0;
	QString tagName;

	static const int nPToken_cb = 7;
	static const QString namePToken[ nPToken_cb ] =
	{ FBL_TAG_mi, FBL_TAG_mn, FBL_TAG_mo, FBL_TAG_mtext, FBL_TAG_mspace, FBL_TAG_ms, FBL_TAG_mglyph };
	//
	static const int commonAttrsLength_P = 9;
	static QString commonAttrs_P[ commonAttrsLength_P ] = 
		{FBL_ATTR_mathvariant, FBL_ATTR_mathsize, FBL_ATTR_mathcolor, FBL_ATTR_mathbackground, 
		 FBL_ATTR_fontsize, FBL_ATTR_fontweight, FBL_ATTR_fontstyle, FBL_ATTR_fontfamily, FBL_ATTR_color};
	//
	static const int commonAttrsLength_Mo = 12;
	static QString commonAttrs_Mo[ commonAttrsLength_Mo ] = 
		{FBL_ATTR_form, FBL_ATTR_fence, FBL_ATTR_separator, FBL_ATTR_lspace, FBL_ATTR_rspace,
		 FBL_ATTR_stretchy, FBL_ATTR_symmetric, FBL_ATTR_maxsize, FBL_ATTR_minsize, 
		 FBL_ATTR_largeop, FBL_ATTR_movablelimits, FBL_ATTR_accent};
	//
	static const int commonAttrsLength_Mspace = 4;
	static QString commonAttrs_Mspace[ commonAttrsLength_Mspace ] = 
		{FBL_ATTR_width, FBL_ATTR_height, FBL_ATTR_depth, FBL_ATTR_linebreak};
	//
	static const int commonAttrsLength_Ms = 2;
	static QString commonAttrs_Ms[ commonAttrsLength_Ms ] = 
		{FBL_ATTR_lquote, FBL_ATTR_rquote};
	//
	static const int commonAttrsLength_Mglyph = 2;
	static QString commonAttrs_Mglyph[ commonAttrsLength_Mglyph ] = 
		{FBL_ATTR_alt, FBL_ATTR_index};

	for( j = 0; j < commonAttrsLength_P; j++ )
	{
		if( (idx = getParameterIndex( commonAttrs_P[ j ] )) == -1 )
			continue;
		for( i = 0; i < nPToken_cb; i++ )
		{
			m_tag2attrno.insert( std::pair<QString, long>(namePToken[ i ], idx) );
			::addAttr2MStyle( mstyleAttr, m_tag2attrno, idx );
		}
	}
	//
	// Presentation: mo
	for( j = 0; j < commonAttrsLength_Mo; j++ )
	{
		if( (idx = getParameterIndex( commonAttrs_Mo[ j ] )) != -1 )
		{
			m_tag2attrno.insert( std::pair<QString, long>(QString(FBL_TAG_mo), idx) );
			::addAttr2MStyle( mstyleAttr, m_tag2attrno, idx );
		}
	}
	//
	// Presentation: mspace
	for( j = 0; j < commonAttrsLength_Mspace; j++ )
	{
		if( (idx = getParameterIndex( commonAttrs_Mspace[ j ] )) != -1 )
		{
			m_tag2attrno.insert( std::pair<QString, long>(QString(FBL_TAG_mspace), idx) );
			::addAttr2MStyle( mstyleAttr, m_tag2attrno, idx );
		}
	}
	//
	// Presentation: ms
	for( j = 0; j < commonAttrsLength_Ms; j++ )
	{
		if( (idx = getParameterIndex( commonAttrs_Ms[ j ] )) != -1 )
		{
			m_tag2attrno.insert( std::pair<QString, long>(QString(FBL_TAG_ms), idx) );
			::addAttr2MStyle( mstyleAttr, m_tag2attrno, idx );
		}
	}
	//
	// Presentation: mglyph
	for( j = 0; j < commonAttrsLength_Mglyph; j++ )
	{
		if( (idx = getParameterIndex( commonAttrs_Mglyph[ j ] )) != -1 )
			m_tag2attrno.insert( std::pair<QString, long>(QString(FBL_TAG_mglyph), idx) );
	}
    ///////////////////////////////////////////////////////////////////////////

    ///////////////////////////////////////////////////////////////////////////
	// Presentation: layout schema
	//
	static const int nPElem_cb = 24;
	static const QString namePElem[ nPElem_cb ] =
	{ FBL_TAG_math, FBL_TAG_mrow, FBL_TAG_mfrac, FBL_TAG_msqrt, FBL_TAG_mroot, FBL_TAG_mstyle,
	  FBL_TAG_merror, FBL_TAG_mpadded, FBL_TAG_mphantom, FBL_TAG_mfenced, FBL_TAG_menclose,
	  FBL_TAG_msub, FBL_TAG_msup, FBL_TAG_msubsup, FBL_TAG_munder, FBL_TAG_mover,
	  FBL_TAG_munderover, FBL_TAG_mmultiscripts, FBL_TAG_mtable, FBL_TAG_mtr, FBL_TAG_mtd,
	  FBL_TAG_malignmark, FBL_TAG_maligngroup, FBL_TAG_maction };

	//
	// Element: mfrac
	//
	static const int commonAttrsLength_Mfrac = 5;
	static QString commonAttrs_Mfrac[ commonAttrsLength_Mfrac ] = 
		{FBL_ATTR_linethickness, FBL_ATTR_numalign, FBL_ATTR_denomalign, FBL_ATTR_bevelled, FBL_ATTR_color};
	//
	for( j = 0; j < commonAttrsLength_Mfrac; j++ )
	{
		if( (idx = getParameterIndex( commonAttrs_Mfrac[ j ] )) != -1 )
		{
			m_tag2attrno.insert( std::pair<QString, long>(QString(FBL_TAG_mfrac), idx) );
			//m_tag2attrno.insert( std::pair<QString, long>(QString(FBL_TAG_mstyle), idx) );
			::addAttr2MStyle( mstyleAttr, m_tag2attrno, idx );
		}
	}
	//

	//
	// Element: math
	//
	static const int commonAttrsLength_Math = 6;
	static QString commonAttrs_Math[ commonAttrsLength_Math ] = 
		{FBL_ATTR_macros, FBL_ATTR_mode, FBL_ATTR_display, FBL_ATTR_overflow, FBL_ATTR_altimg, FBL_ATTR_alttext};
	//
	for( j = 0; j < commonAttrsLength_Math; j++ )
	{
		if( (idx = getParameterIndex( commonAttrs_Math[ j ] )) != -1 )
			m_tag2attrno.insert( std::pair<QString, long>(QString(FBL_TAG_math), idx) );
	}
	//

	//
	// Element: mstyle
	//
	static const int commonAttrsLength_Mstyle = 13;
	static QString commonAttrs_Mstyle[ commonAttrsLength_Mstyle ] = 
		{FBL_ATTR_scriptlevel, FBL_ATTR_displaystyle, FBL_ATTR_scriptsizemultiplier, 
		 FBL_ATTR_scriptminsize, FBL_ATTR_background, FBL_ATTR_veryverythinmathspace, 
		 FBL_ATTR_verythinmathspace, FBL_ATTR_thinmathspace, FBL_ATTR_mediummathspace, 
		 FBL_ATTR_thickmathspace, FBL_ATTR_verythickmathspace, FBL_ATTR_veryverythickmathspace, FBL_ATTR_color};
	//
	for( j = 0; j < commonAttrsLength_Mstyle; j++ )
	{
		if( (idx = getParameterIndex( commonAttrs_Mstyle[ j ] )) != -1 )
			::addAttr2MStyle( mstyleAttr, m_tag2attrno, idx );
	}
	//

	//
	// Element: mpadded
	//
	static const int commonAttrsLength_Mpadded = 4;
	static QString commonAttrs_Mpadded[ commonAttrsLength_Mpadded ] = 
		{FBL_ATTR_width, FBL_ATTR_lspace, FBL_ATTR_height, FBL_ATTR_depth};
	//
	for( j = 0; j < commonAttrsLength_Mpadded; j++ )
	{
		if( (idx = getParameterIndex( commonAttrs_Mpadded[ j ] )) != -1 )
		{
			m_tag2attrno.insert( std::pair<QString, long>(QString(FBL_TAG_mpadded), idx) );
			::addAttr2MStyle( mstyleAttr, m_tag2attrno, idx );
		}
	}
	//

	//
	// Element: mfenced
	//
	static const int commonAttrsLength_Mfenced = 4;
	static QString commonAttrs_Mfenced[ commonAttrsLength_Mfenced ] = 
		{FBL_ATTR_open, FBL_ATTR_close, FBL_ATTR_separators, FBL_ATTR_color};
	//
	for( j = 0; j < commonAttrsLength_Mfenced; j++ )
	{
		if( (idx = getParameterIndex( commonAttrs_Mfenced[ j ] )) != -1 )
		{
			m_tag2attrno.insert( std::pair<QString, long>(QString(FBL_TAG_mfenced), idx) );
			::addAttr2MStyle( mstyleAttr, m_tag2attrno, idx );
		}
	}
	//

	//
	// Element: msqrt, mroot
	//
	if( (idx = getParameterIndex( FBL_ATTR_color )) != -1 )
		m_tag2attrno.insert( std::pair<QString, long>(QString(FBL_TAG_msqrt), idx) );
	if( (idx = getParameterIndex( FBL_ATTR_color )) != -1 )
		m_tag2attrno.insert( std::pair<QString, long>(QString(FBL_TAG_mroot), idx) );
	//

	//
	// Element: menclose
	//
	if( (idx = getParameterIndex( FBL_ATTR_notation )) != -1 )
	{
		m_tag2attrno.insert( std::pair<QString, long>(QString(FBL_TAG_menclose), idx) );
		::addAttr2MStyle( mstyleAttr, m_tag2attrno, idx );
	}
	if( (idx = getParameterIndex( FBL_ATTR_color )) != -1 )
		m_tag2attrno.insert( std::pair<QString, long>(QString(FBL_TAG_menclose), idx) );
	//

	//
	// Element: msub
	//
	if( (idx = getParameterIndex( FBL_ATTR_subscriptshift )) != -1 )
	{
		m_tag2attrno.insert( std::pair<QString, long>(QString(FBL_TAG_msub), idx) );
		::addAttr2MStyle( mstyleAttr, m_tag2attrno, idx );
	}
	//

	//
	// Element: msup
	//
	if( (idx = getParameterIndex( FBL_ATTR_superscriptshift )) != -1 )
	{
		m_tag2attrno.insert( std::pair<QString, long>(QString(FBL_TAG_msup), idx) );
		::addAttr2MStyle( mstyleAttr, m_tag2attrno, idx );
	}
	//

	//
	// Element: msubsup
	//
	if( (idx = getParameterIndex( FBL_ATTR_subscriptshift )) != -1 )
		m_tag2attrno.insert( std::pair<QString, long>(QString(FBL_TAG_msubsup), idx) );
	if( (idx = getParameterIndex( FBL_ATTR_superscriptshift )) != -1 )
		m_tag2attrno.insert( std::pair<QString, long>(QString(FBL_TAG_msubsup), idx) );
	//

	//
	// Element: munder
	//
	if( (idx = getParameterIndex( FBL_ATTR_accentunder )) != -1 )
	{
		m_tag2attrno.insert( std::pair<QString, long>(QString(FBL_TAG_munder), idx) );
		::addAttr2MStyle( mstyleAttr, m_tag2attrno, idx );
	}
	//

	//
	// Element: mover
	//
	if( (idx = getParameterIndex( FBL_ATTR_accent )) != -1 )
	{
		m_tag2attrno.insert( std::pair<QString, long>(QString(FBL_TAG_mover), idx) );
		::addAttr2MStyle( mstyleAttr, m_tag2attrno, idx );
	}
	//

	//
	// Element: munderover
	//
	if( (idx = getParameterIndex( FBL_ATTR_accentunder )) != -1 )
		m_tag2attrno.insert( std::pair<QString, long>(QString(FBL_TAG_munderover), idx) );
	if( (idx = getParameterIndex( FBL_ATTR_accent )) != -1 )
		m_tag2attrno.insert( std::pair<QString, long>(QString(FBL_TAG_munderover), idx) );
	//

	//
	// Element: mtable
	//
	static const int commonAttrsLength_Mtable = 19;
	static QString commonAttrs_Mtable[ commonAttrsLength_Mtable ] = 
		{FBL_ATTR_align, FBL_ATTR_rowalign, FBL_ATTR_columnalign,
		 FBL_ATTR_groupalign, FBL_ATTR_alignmentscope, FBL_ATTR_columnwidth,
		 FBL_ATTR_rowspacing, FBL_ATTR_columnspacing, FBL_ATTR_rowlines,
		 FBL_ATTR_columnlines, FBL_ATTR_frame, FBL_ATTR_framespacing,
		 FBL_ATTR_equalrows, FBL_ATTR_equalcolumns, FBL_ATTR_side,
		 FBL_ATTR_minlabelspacing, _T("table.width"), _T("table.displaystyle"), FBL_ATTR_color};
	//
	for( j = 0; j < commonAttrsLength_Mtable; j++ )
	{
		if( (idx = getParameterIndex( commonAttrs_Mtable[ j ] )) != -1 )
		{
			m_tag2attrno.insert( std::pair<QString, long>(QString(FBL_TAG_mtable), idx) );
			if( commonAttrs_Mtable[ j ] != _T("table.width") )
				::addAttr2MStyle( mstyleAttr, m_tag2attrno, idx );
		}
	}
	//

	//
	// Element: mtr
	//
	static const int commonAttrsLength_Mtr = 3;
	static QString commonAttrs_Mtr[ commonAttrsLength_Mtr ] = 
		{FBL_ATTR_rowalign, FBL_ATTR_columnalign, FBL_ATTR_groupalign};
	//
	for( j = 0; j < commonAttrsLength_Mtr; j++ )
	{
		if( (idx = getParameterIndex( commonAttrs_Mtr[ j ] )) != -1 )
		{
			m_tag2attrno.insert( std::pair<QString, long>(QString(FBL_TAG_mtr), idx) );
			::addAttr2MStyle( mstyleAttr, m_tag2attrno, idx );
		}
	}
	//

	//
	// Element: mtd
	//
	static const int commonAttrsLength_Mtd = 5;
	static QString commonAttrs_Mtd[ commonAttrsLength_Mtd ] = 
		{FBL_ATTR_rowspan, FBL_ATTR_columnspan, FBL_ATTR_rowalign, FBL_ATTR_columnalign, FBL_ATTR_groupalign};
	//
	for( j = 0; j < commonAttrsLength_Mtd; j++ )
	{
		if( (idx = getParameterIndex( commonAttrs_Mtd[ j ] )) != -1 )
		{
			m_tag2attrno.insert( std::pair<QString, long>(QString(FBL_TAG_mtd), idx) );
			::addAttr2MStyle( mstyleAttr, m_tag2attrno, idx );
		}
	}
	//

	//
	// Element: malignmark
	//
	if( (idx = getParameterIndex( FBL_ATTR_edge )) != -1 )
		m_tag2attrno.insert( std::pair<QString, long>(QString(FBL_TAG_malignmark), idx) );
	//

	//
	// Element: maligngroup
	//
	if( (idx = getParameterIndex( FBL_ATTR_groupalign )) != -1 )
		m_tag2attrno.insert( std::pair<QString, long>(QString(FBL_TAG_maligngroup), idx) );
	//

	//
	// Element: maction
	//
	if( (idx = getParameterIndex( FBL_ATTR_actiontype )) != -1 )
		m_tag2attrno.insert( std::pair<QString, long>(QString(FBL_TAG_maction), idx) );
	if( (idx = getParameterIndex( FBL_ATTR_selection )) != -1 )
		m_tag2attrno.insert( std::pair<QString, long>(QString(FBL_TAG_maction), idx) );
	//
    ///////////////////////////////////////////////////////////////////////////


    ///////////////////////////////////////////////////////////////////////////
	// Content
	//
	static const int nCElem_cb = TAG2MML_infinity - TAG2MML_cn + 1;
	QString nameCElem[ nCElem_cb ];
	for( i = 0; i < nCElem_cb; i++ )
		nameCElem[ i ] = ::mml_getTagID2TagName( (enum TAG2MML)(i + TAG2MML_cn) );
	//
	static const int commonAttrsLength_C = 2;
	static QString commonAttrs_C[ commonAttrsLength_C ] = {FBL_ATTR_encoding, FBL_ATTR_definitionURL};
	//
	for( j = 0; j < commonAttrsLength_C; j++ )
	{
		if( (idx = getParameterIndex( commonAttrs_C[ j ] )) == -1 )
			continue;
		for( i = 0; i < nCElem_cb; i++ )
			m_tag2attrno.insert( std::pair<QString, long>(nameCElem[ i ], idx) );
	}
	//

	//
	// Element: cn
	//
	if( (idx = getParameterIndex( _T("cn.type") )) != -1 )
		m_tag2attrno.insert( std::pair<QString, long>(QString(FBL_TAG_cn), idx) );
	if( (idx = getParameterIndex( FBL_ATTR_base )) != -1 )
		m_tag2attrno.insert( std::pair<QString, long>(QString(FBL_TAG_cn), idx) );
	//

	//
	// Element: ci
	//
	if( (idx = getParameterIndex( _T("ci.type") )) != -1 )
		m_tag2attrno.insert( std::pair<QString, long>(QString(FBL_TAG_ci), idx) );
	//

	//
	// Element: set
	//
	if( (idx = getParameterIndex( _T("set.type") )) != -1 )
		m_tag2attrno.insert( std::pair<QString, long>(QString(FBL_TAG_set), idx) );
	//

	//
	// Element: tendsto
	//
	if( (idx = getParameterIndex( _T("tendsto.type") )) != -1 )
		m_tag2attrno.insert( std::pair<QString, long>(QString(FBL_TAG_tendsto), idx) );
	//

	//
	// Element: declare
	//
	static const int commonAttrsLength_Mdeclare = 4;
	static QString commonAttrs_Mdeclare[ commonAttrsLength_Mdeclare ] = 
		{ _T("declare.type"), FBL_ATTR_nargs, FBL_ATTR_occurrence, FBL_ATTR_scope };
	//
	for( j = 0; j < commonAttrsLength_Mdeclare; j++ )
	{
		if( (idx = getParameterIndex( commonAttrs_Mdeclare[ j ] )) != -1 )
			m_tag2attrno.insert( std::pair<QString, long>(QString(FBL_TAG_declare), idx) );
	}
	//

	//
	// Element: interval
	//
	if( (idx = getParameterIndex( FBL_ATTR_closure )) != -1 )
		m_tag2attrno.insert( std::pair<QString, long>(QString(FBL_TAG_interval), idx) );
	//

	//
	// Element: list
	//
	if( (idx = getParameterIndex( FBL_ATTR_order )) != -1 )
		m_tag2attrno.insert( std::pair<QString, long>(QString(FBL_TAG_list), idx) );
	//
    ///////////////////////////////////////////////////////////////////////////


    ///////////////////////////////////////////////////////////////////////////
	// Common attributes
	//
	for( j = 0; j < commonAttrsLength; j++ )
	{
		if( (idx = getParameterIndex( commonAttrs[ j ] )) == -1 )
			continue;
		for( i = 0; i < nPToken_cb; i++ )
			m_tag2attrno.insert( std::pair<QString, long>(namePToken[ i ], idx) );
		for( i = 0; i < nPElem_cb; i++ )
			m_tag2attrno.insert( std::pair<QString, long>(namePElem[ i ], idx) );
		for( i = 0; i < nCElem_cb; i++ )
			m_tag2attrno.insert( std::pair<QString, long>(nameCElem[ i ], idx) );
	}
	//
    ///////////////////////////////////////////////////////////////////////////
}
Example #20
0
double CParameters::getDouble(char* parameterName)
{
	int index= getParameterIndex(parameterName);

	return *getDoublePtr(index);
}
Example #21
0
char *CParameters::getStringPtr(char* parameterName)
{
	int index= getParameterIndex(parameterName);

	return getStringPtr(index);
}
Example #22
0
void MLPluginProcessor::setStateFromXML(const XmlElement& xmlState, bool setViewAttributes)
{
	if (!(xmlState.hasTagName (JucePlugin_Name))) return;
	if (!(mEngine.getCompileStatus() == MLProc::OK)) return; // TODO revisit need to compile first

	// getCallbackLock() is in juce_AudioProcessor
	// process lock is a quick fix.  it is here to prevent doParams() from getting called in 
	// process() methods and thereby setting mParamsChanged to false before the real changes take place.
	// A better alternative would be a lock-free queue of parameter changes.
	const ScopedLock sl (getCallbackLock()); 
		
	// only the differences between default parameters and the program state are saved in a program,
	// so the first step is to set the default parameters.
	setDefaultParameters();
	
	// get program version of saved state
	unsigned blobVersion = xmlState.getIntAttribute ("pluginVersion");
	unsigned pluginVersion = JucePlugin_VersionCode;
	
	if (blobVersion > pluginVersion)
	{
		// TODO show error to user
		MLError() << "MLPluginProcessor::setStateFromXML: saved program version is newer than plugin version!\n";
		return;
	}
    
	// try to load scale if a scale attribute exists
    // TODO auto save all state including this
 	const String scaleDir = xmlState.getStringAttribute ("scaleDir"); // look for old-style dir attribute   
	const String scaleName = xmlState.getStringAttribute ("scaleName");
    String fullName;
    if(scaleName != String::empty)
    {
        fullName = scaleName;
        if(scaleDir != String::empty)
        {
            fullName = scaleDir + String("/") + fullName + ".scl";
        }
    }
    else
    {
        fullName = "12-equal";
    }
    std::string fullScaleName(fullName.toUTF8());
	setProperty("key_scale", fullScaleName);
    bool loaded = false;
    // look for scale under full name with path
    if(fullScaleName != std::string())
    {
        const MLFilePtr f = mScaleFiles->getFileByName(fullScaleName);
        if(f != MLFilePtr())
        {
            loadScale(f->mFile);
            loaded = true;
        }
    }
    if(!loaded)
    {
        loadDefaultScale();
    }
    
	// get preset name saved in blob.  when saving from AU host, name will also be set from RestoreState().
	const String presetName = xmlState.getStringAttribute ("presetName");
	setProperty("preset", std::string(presetName.toUTF8()));
    
	/*
     debug() << "MLPluginProcessor: setStateFromXML: loading program " << presetName << ", version " << std::hex << blobVersion << std::dec << "\n";
     MemoryOutputStream myStream;
     xmlState->writeToStream (myStream, "");
     debug() << myStream.toString();
     */
	
    /*
     setCurrentPresetName(presetName.toUTF8());
     setCurrentPresetDir(presetDir.toUTF8());
     */
    
	// get plugin-specific translation table for updating older versions of data
	std::map<MLSymbol, MLSymbol> translationTable;

	// TODO move this into Aalto! 
	// make translation tables based on program version. 
	//
	if (blobVersion <= 0x00010120)
	{
		// translate seq parameters
		for(unsigned n=0; n<16; ++n)
		{
			std::stringstream pName;
			std::stringstream pName2;
			pName << "seq_value" << n;
			pName2 << "seq_pulse" << n;
			MLSymbol oldSym(pName.str());
			MLSymbol newSym = MLSymbol("seq_value#").withFinalNumber(n);
			MLSymbol oldSym2(pName2.str());
			MLSymbol newSym2 = MLSymbol("seq_pulse#").withFinalNumber(n);
			translationTable[oldSym] = newSym;
			translationTable[oldSym2] = newSym2;	
		}
	}

	if (blobVersion <= 0x00010200)
	{
		MLSymbol oldSym = MLSymbol("seq_value");
		MLSymbol newSym = MLSymbol("seq_value").withFinalNumber(0);
		MLSymbol oldSym2 = MLSymbol("seq_pulse");
		MLSymbol newSym2 = MLSymbol("seq_pulse").withFinalNumber(0);
		translationTable[oldSym] = newSym;
		translationTable[oldSym2] = newSym2;
		
		// translate seq parameters
		for(unsigned n=1; n<16; ++n)
		{
			oldSym = MLSymbol("seq_value#").withFinalNumber(n);
			newSym = MLSymbol("seq_value").withFinalNumber(n);
			oldSym2 = MLSymbol("seq_pulse#").withFinalNumber(n);
			newSym2 = MLSymbol("seq_pulse").withFinalNumber(n);
			translationTable[oldSym] = newSym;
			translationTable[oldSym2] = newSym2;	
		}		
	}
	
	// get params from xml
	const unsigned numAttrs = xmlState.getNumAttributes();
	String patcherInputStr ("patcher_input_");

	for(unsigned i=0; i<numAttrs; ++i)
	{
		// get name / value pair.
		const String& attrName = xmlState.getAttributeName(i);
		const MLParamValue paramVal = xmlState.getDoubleAttribute(attrName);
		
		// if not a patcher input setting,
		if (!attrName.contains(patcherInputStr))
		{					
			// see if we have this named parameter in our engine. 
			MLSymbol paramSym = XMLAttrToSymbol(attrName);
			const int pIdx = getParameterIndex(paramSym);
			
			if (pIdx >= 0)
			{
				// debug() << "setStateFromXML: <" << paramSym << " = " << paramVal << ">\n";
				setPropertyImmediate(paramSym, paramVal);
			}
			else // try finding a match through translation table. 
			{
				//debug() << "Looking for parameter " << paramSym << " in table...\n";
				std::map<MLSymbol, MLSymbol>::iterator it;
				it = translationTable.find(paramSym);
				if (it != translationTable.end())
				{
					const MLSymbol newSym = translationTable[paramSym];
					const int pNewIdx = getParameterIndex(newSym);
					if (pNewIdx >= 0)
					{
						//debug() << "translated parameter to " << newSym << " .\n";
						setPropertyImmediate(newSym, paramVal);
					}
					else
					{
						MLError() << "MLPluginProcessor::setStateFromXML: no such parameter! \n";
					}
				}
				else
				{
					// fail silently on unfound params, because we have deprecated some but they may still 
					// be around in old presets. 
					//debug() << "MLPluginProcessor::setStateFromXML: parameter " << paramSym << " not found!\n";
				}
			}
		}
	}
	
	// get editor state from XML
    if(setViewAttributes)
	{
		int x = xmlState.getIntAttribute("editor_x");
		int y = xmlState.getIntAttribute("editor_y");
		int width = xmlState.getIntAttribute("editor_width");
		int height = xmlState.getIntAttribute("editor_height");
		mEditorRect = MLRect(x, y, width, height);
		mEditorNumbersOn = xmlState.getIntAttribute("editor_num", 1);
		mEditorAnimationsOn = xmlState.getIntAttribute("editor_anim", 1);
	}
}
Example #23
0
/**
 * Attaches a tie to this function. The attached tie is owned by the function.
 * @param tie :: A pointer to a new tie
 */
void CompositeFunction::addTie(ParameterTie *tie) {
  size_t i = getParameterIndex(*tie);
  size_t iFun = functionIndex(i);
  m_functions[iFun]->addTie(tie);
}
Example #24
0
/** Add a constraint
 *  @param ic :: Pointer to a constraint.
 */
void CompositeFunction::addConstraint(IConstraint *ic) {
  size_t i = getParameterIndex(*ic);
  size_t iFun = functionIndex(i);
  getFunction(iFun)->addConstraint(ic);
}