<commit_before>/* 
 *	Trajectory≈
 *	Trajectory generator/wrapper object for Jamoma
 *	Copyright © 2010 by <NAME>
 * 
 * License: This code is licensed under the terms of the "New BSD License"
 * http://creativecommons.org/licenses/BSD/
 */

#ifndef __TT_TRAJECTORY_H__
#define __TT_TRAJECTORY_H__

#include "TTDSP.h"


/**	A Generalized trajectory generator/wrapper object for Jamoma. */
class TTTrajectory : TTAudioObject {
	TTCLASS_SETUP(TTTrajectory)
	
protected:
	TTAudioObjectPtr		mActualTrajectoryObject;	///< The actual trajectory object that this object is currently wrapping
	TTFloat64				mA, mB, mC, mDeltaX, mDeltaY, mDeltaZ;
	TTSymbolPtr				mType;					///< The name of the current trajectory type
	TTSymbolPtr				mMode;
	//TTList					mAnchorPoints;
	TTAudioObjectPtr		mPhasors[1];
	TTAudioSignalArrayPtr	mPhasorOutputSignals;
	TTAudioObjectPtr		mRamps[1];
	TTAudioSignalArrayPtr	mRampOutputSignals;
	
public:
	
	TTErr setType(const TTValue& newValue)
	{	
		TTSymbolPtr newType = newValue;
		TTErr		err = kTTErrNone;
		
		// if the type didn't change, then don't change the trajectory
		if (newType == mType)
			return kTTErrNone;
		
		mType = newType;
		err = TTObjectInstantiate(mType, &mActualTrajectoryObject, 2);			
		if (!err) {
			// Now that we have our new trajectory type, update it with the current state of the wrapper:
			mActualTrajectoryObject->setAttributeValue(TT("a"), mA);
			mActualTrajectoryObject->setAttributeValue(TT("b"), mB);
			mActualTrajectoryObject->setAttributeValue(TT("c"), mC);
			mActualTrajectoryObject->setAttributeValue(TT("deltaX"), mDeltaX);
			mActualTrajectoryObject->setAttributeValue(TT("deltaY"), mDeltaY);
			mActualTrajectoryObject->setAttributeValue(TT("deltaZ"), mDeltaZ);
			
			//TODO: I currently update ALL Attributes, regardless whether the types support it or not
			
			//mActualTrajectoryObject->setAttributeValue(kTTSym_sampleRate, sr);
			//mActualFilterObject->setAttributeValue(TT("frequency"), mFrequency);
			//err = mActualFilterObject->setAttributeValue(TT("q"), mQ);
			//if (err == kTTErrInvalidAttribute)
			//	err = mActualFilterObject->setAttributeValue(TT("resonance"), mQ);
			//mActualFilterObject->setAttributeValue(TT("bypass"), this->attrBypass);
			//mActualFilterObject->setAttributeValue(kTTSym_sampleRate, sr);
		}
		return err;
	}
	
	
	TTErr getTypes(const TTValue&, TTValue& listOfTrajectoryTypesToReturn)
	{
		TTValue v;
		v.setSize(2);
		v.set(0, TT("trajectory"));
		v.set(1, TT("audio")); 
		return TTGetRegisteredClassNamesForTags(listOfTrajectoryTypesToReturn, v);
	}
	
	TTErr getCurrentType(const TTValue&, TTValue& CurrentTypeToReturn)

	{
		CurrentTypeToReturn = mType;
		return kTTErrNone;
	}
	
	
	
	TTErr getCurrentAttributeNames(const TTValue&, TTValue& listOfCurrentAttributesToReturn)
	{
		long		n;
		TTValue		names;
		TTSymbol*	aName;
		TTString	nameString;
		
		listOfCurrentAttributesToReturn.clear();
		mActualTrajectoryObject->getAttributeNames(names);
		n = names.getSize();
		for (int i=0; i<n; i++) {
			names.get(i, &aName);
			nameString = aName->getString();
			if (aName == TT("bypass") || aName == TT("mute") || aName == TT("maxNumChannels") || aName == TT("sampleRate"))
				continue;	
			listOfCurrentAttributesToReturn.append(aName);
		}
		if (listOfCurrentAttributesToReturn.getSize()==0)
			listOfCurrentAttributesToReturn.append(TT("NULL")); // in case there is no attribute, send a NULL value out
												   
		return kTTErrNone;
	}
	
	TTErr ramp(const TTValue& arguments, TTValue&)
	{
		/*
		 ramp <startValue|double> <stopValue|double> <time|double> <type|string>
		 ramp <stopValue|double> <time|double> <type|string>
		 ramp <startValue|double> <stopValue|double> <time|double> 
		 ramp <stopValue|double> <time|double> 
		*/
		long		n;
		TTSymbolPtr	attrType;
		TTFloat64   x;
		TTErr		err = kTTErrNone;
		
		if (mMode == TT("ramp")){
			if (ttDataTypeInfo[arguments.getType(0)]->isNumerical and ttDataTypeInfo[arguments.getType(1)]->isNumerical) {
				n = arguments.getSize();
				switch(n)
				{
					case 4:<commit_msg>TrajectoryLib: replacing getString() with getCString() - project builds now again<commit_after>/* 
 *	Trajectory≈
 *	Trajectory generator/wrapper object for Jamoma
 *	Copyright © 2010 by <NAME>
 * 
 * License: This code is licensed under the terms of the "New BSD License"
 * http://creativecommons.org/licenses/BSD/
 */

#ifndef __TT_TRAJECTORY_H__
#define __TT_TRAJECTORY_H__

#include "TTDSP.h"


/**	A Generalized trajectory generator/wrapper object for Jamoma. */
class TTTrajectory : TTAudioObject {
	TTCLASS_SETUP(TTTrajectory)
	
protected:
	TTAudioObjectPtr		mActualTrajectoryObject;	///< The actual trajectory object that this object is currently wrapping
	TTFloat64				mA, mB, mC, mDeltaX, mDeltaY, mDeltaZ;
	TTSymbolPtr				mType;					///< The name of the current trajectory type
	TTSymbolPtr				mMode;
	//TTList					mAnchorPoints;
	TTAudioObjectPtr		mPhasors[1];
	TTAudioSignalArrayPtr	mPhasorOutputSignals;
	TTAudioObjectPtr		mRamps[1];
	TTAudioSignalArrayPtr	mRampOutputSignals;
	
public:
	
	TTErr setType(const TTValue& newValue)
	{	
		TTSymbolPtr newType = newValue;
		TTErr		err = kTTErrNone;
		
		// if the type didn't change, then don't change the trajectory
		if (newType == mType)
			return kTTErrNone;
		
		mType = newType;
		err = TTObjectInstantiate(mType, &mActualTrajectoryObject, 2);			
		if (!err) {
			// Now that we have our new trajectory type, update it with the current state of the wrapper:
			mActualTrajectoryObject->setAttributeValue(TT("a"), mA);
			mActualTrajectoryObject->setAttributeValue(TT("b"), mB);
			mActualTrajectoryObject->setAttributeValue(TT("c"), mC);
			mActualTrajectoryObject->setAttributeValue(TT("deltaX"), mDeltaX);
			mActualTrajectoryObject->setAttributeValue(TT("deltaY"), mDeltaY);
			mActualTrajectoryObject->setAttributeValue(TT("deltaZ"), mDeltaZ);
			
			//TODO: I currently update ALL Attributes, regardless whether the types support it or not
			
			//mActualTrajectoryObject->setAttributeValue(kTTSym_sampleRate, sr);
			//mActualFilterObject->setAttributeValue(TT("frequency"), mFrequency);
			//err = mActualFilterObject->setAttributeValue(TT("q"), mQ);
			//if (err == kTTErrInvalidAttribute)
			//	err = mActualFilterObject->setAttributeValue(TT("resonance"), mQ);
			//mActualFilterObject->setAttributeValue(TT("bypass"), this->attrBypass);
			//mActualFilterObject->setAttributeValue(kTTSym_sampleRate, sr);
		}
		return err;
	}
	
	
	TTErr getTypes(const TTValue&, TTValue& listOfTrajectoryTypesToReturn)
	{
		TTValue v;
		v.setSize(2);
		v.set(0, TT("trajectory"));
		v.set(1, TT("audio")); 
		return TTGetRegisteredClassNamesForTags(listOfTrajectoryTypesToReturn, v);
	}
	
	TTErr getCurrentType(const TTValue&, TTValue& CurrentTypeToReturn)

	{
		CurrentTypeToReturn = mType;
		return kTTErrNone;
	}
	
	
	
	TTErr getCurrentAttributeNames(const TTValue&, TTValue& listOfCurrentAttributesToReturn)
	{
		long		n;
		TTValue		names;
		TTSymbol*	aName;
		TTString	nameString;
		
		listOfCurrentAttributesToReturn.clear();
		mActualTrajectoryObject->getAttributeNames(names);
		n = names.getSize();
		for (int i=0; i<n; i++) {
			names.get(i, &aName);
			nameString = aName->getCString();
			if (aName == TT("bypass") || aName == TT("mute") || aName == TT("maxNumChannels") || aName == TT("sampleRate"))
				continue;	
			listOfCurrentAttributesToReturn.append(aName);
		}
		if (listOfCurrentAttributesToReturn.getSize()==0)
			listOfCurrentAttributesToReturn.append(TT("NULL")); // in case there is no attribute, send a NULL value out
												   
		return kTTErrNone;
	}
	
	TTErr ramp(const TTValue& arguments, TTValue&)
	{
		/*
		 ramp <startValue|double> <stopValue|double> <time|double> <type|string>
		 ramp <stopValue|double> <time|double> <type|string>
		 ramp <startValue|double> <stopValue|double> <time|double> 
		 ramp <stopValue|double> <time|double> 
		*/
		long		n;
		TTSymbolPtr	attrType;
		TTFloat64   x;
		TTErr		err = kTTErrNone;
		
		if (mMode == TT("ramp")){
			if (ttDataTypeInfo[arguments.getType(0)]->isNumerical and ttDataTypeInfo[arguments.getType(1)]->isNumerical) {
				n = arguments.getSize();
				switch(n)
				{
					case 4:
{'fraction_non_alphanumeric': 0.11921338707707341, 'fraction_numerical': 0.004641504824722121, 'mean_word_length': 4.61206305688828, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 63, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3733473', 'n_tokens_mistral': 3192, 'n_tokens_neox': 2792, 'n_words': 605}