Beispiel #1
0
// Create
void *fade_new(t_symbol *s, long argc, t_atom *argv)
{
	long attrstart = attr_args_offset(argc, argv);		// support normal arguments
	short i;
	
	t_fade *x = (t_fade *)object_alloc(s_fade_class);
	if(x){
		object_obex_store((void *)x, _sym_dumpout, (object *)outlet_new(x, NULL));	// dumpout
		
		x->numChannels = 1;
		if(attrstart && argv){
			int argument = atom_getlong(argv);
			x->numChannels = TTClip(argument, 1, MAX_NUM_CHANNELS);
		}
		
		dsp_setup((t_pxobject *)x, (x->numChannels * 2) + 1);	// Create Object and N Inlets (last argument)
		x->x_obj.z_misc = Z_NO_INPLACE;  					// ESSENTIAL!   		
		for(i=0; i< (x->numChannels); i++)
			outlet_new((t_pxobject *)x, "signal");			// Create a signal Outlet   		
		
		//x->xfade = new TTCrossfade(x->numChannels);			// Constructors
		TTObjectBaseInstantiate(TT("crossfade"),	&x->xfade,			x->numChannels);
		TTObjectBaseInstantiate(kTTSym_audiosignal,	&x->audioIn1,		x->numChannels);
		TTObjectBaseInstantiate(kTTSym_audiosignal,	&x->audioIn2,		x->numChannels);
		TTObjectBaseInstantiate(kTTSym_audiosignal,	&x->audioInControl,	x->numChannels);
		TTObjectBaseInstantiate(kTTSym_audiosignal,	&x->audioOut,		x->numChannels);
		
		x->xfade->setAttributeValue(TT("mode"), TT("lookup"));
		x->xfade->setAttributeValue(TT("shape"), TT("equalPower"));
		x->xfade->setAttributeValue(TT("position"), 0.5);
		
		attr_args_process(x, argc, argv);					// handle attribute args				
	}
	return (x);												// Return the pointer
}
Beispiel #2
0
void* balance_new(t_symbol *msg, short argc, t_atom *argv)
{
    t_balance	*x;
	TTValue		sr(sys_getsr());
 	long		attrstart = attr_args_offset(argc, argv);		// support normal arguments
	short		i;
   
    x = (t_balance *)object_alloc(balance_class);
    if (x) {
		// Default values
		x->attrFrequency = 10;
		x->attrBypass = 0;
		// An initial argument to this object will set the maximum number of channels to process
		// Two input channels are required for each processed channel (source and comperator)
		x->maxNumChannels = 1;		
		if (attrstart && argv)
			x->maxNumChannels = atom_getlong(argv);

		ttEnvironment->setAttributeValue(kTTSym_sampleRate, sr);
		TTObjectBaseInstantiate(TT("balance"), &x->balance, x->maxNumChannels);
		TTObjectBaseInstantiate(TT("audiosignal"), &x->audioIn, x->maxNumChannels*2);
		TTObjectBaseInstantiate(TT("audiosignal"), &x->audioOut, x->maxNumChannels);

		attr_args_process(x,argc,argv);				// handle attribute args	
				
    	object_obex_store((void *)x, _sym_dumpout, (object *)outlet_new(x,NULL));	// dumpout	
	    dsp_setup((t_pxobject *)x, x->maxNumChannels*2);							// inlets
		for (i=0; i < x->maxNumChannels; i++)
			outlet_new((t_pxobject *)x, "signal");									// outlets
		
		x->obj.z_misc = Z_NO_INPLACE;
	}
	return (x);										// Return the pointer
}
Beispiel #3
0
void* op_new(t_symbol *msg, short argc, t_atom *argv)
{
    t_op	*x;
	TTValue		sr(sys_getsr());
 	long		attrstart = attr_args_offset(argc, argv);		// support normal arguments
	short		i;
   
    x = (t_op *)object_alloc(s_op_class);
    if(x){
		x->maxNumChannels = 2;		// An initial argument to this object will set the maximum number of channels
		if(attrstart && argv)
			x->maxNumChannels = atom_getlong(argv);

		ttEnvironment->setAttributeValue(kTTSym_sampleRate, sr);
		TTObjectBaseInstantiate(TT("operator"), &x->op, x->maxNumChannels);
		TTObjectBaseInstantiate(TT("audiosignal"), &x->audioIn, x->maxNumChannels);
		TTObjectBaseInstantiate(TT("audiosignal"), &x->audioOut, x->maxNumChannels);

		attr_args_process(x,argc,argv);				// handle attribute args	
				
    	object_obex_store((void *)x, _sym_dumpout, (object *)outlet_new(x,NULL));	// dumpout	
	    dsp_setup((t_pxobject *)x, x->maxNumChannels);								// inlets
		for(i=0; i < x->maxNumChannels; i++)
			outlet_new((t_pxobject *)x, "signal");									// outlets
		
		x->obj.z_misc = Z_NO_INPLACE;
	}
	return (x);										// Return the pointer
}
Beispiel #4
0
TTInputAudio :: TTInputAudio (const TTValue& arguments) :
TTInput(arguments)
{
	mType = "audio";
	
	TTObjectBaseInstantiate(kTTSym_audiosignal, &mSignalIn, 1);
	TTObjectBaseInstantiate(kTTSym_audiosignal, &mSignalOut, 1);
	TTObjectBaseInstantiate(kTTSym_audiosignal, &mSignalZero, 1);
}
TTErr TukeyWindow::test(TTValue& returnedTestInfo)
{
	int					errorCount = 0;
	int					testAssertionCount = 0;
	int					badSampleCount = 0;
	TTAudioObjectBasePtr	windowObject = NULL;
	TTAudioSignalPtr	input = NULL;
	TTAudioSignalPtr	output = NULL;
	int					N = 128;
	TTValue				v;
	TTFloat64			testAlpha = 0.5;
	
	// setup windowObject
	TTObjectBaseInstantiate(TT("WindowFunction"), &windowObject, TTValue(1));
	windowObject->setAttributeValue(TT("function"), TT("tukey"));
	windowObject->setAttributeValue(TT("mode"), TT("apply"));
	
	// set the value for alpha
	windowObject->setAttributeValue(TT("alpha"), testAlpha);
	TTTestLog("alpha was set to %.10f for test", testAlpha);
	
	// create 1 channel audio signal objects
	TTObjectBaseInstantiate(kTTSym_audiosignal, &input, 1);
	TTObjectBaseInstantiate(kTTSym_audiosignal, &output, 1);
	input->allocWithVectorSize(N);
	output->allocWithVectorSize(N);
									
	// create a signal to be transformed and then process it)
	input->fill(1.0);
	windowObject->process(input, output);
	
	// now test the output
	for (int n=0; n<N; n++)
	{
		TTBoolean result = !TTTestFloatEquivalence(output->mSampleVectors[0][n], sTukeyWindowCoefficients128[n]);
		badSampleCount += result;
		if (result) 
			TTTestLog("BAD SAMPLE @ n=%i ( value=%.10f	expected=%.10f )", n, output->mSampleVectors[0][n], sTukeyWindowCoefficients128[n]);
	}
	
	TTTestAssertion("Produces correct window coefficients", 
					badSampleCount == 0,
					testAssertionCount, 
					errorCount);
	if (badSampleCount)
		TTTestLog("badSampleCount is %i", badSampleCount);
	
	
	TTObjectBaseRelease(&input);
	TTObjectBaseRelease(&output);
	TTObjectBaseRelease(&windowObject);

	
	// wrap up test results and pass back to whoever called test
	return TTTestFinish(testAssertionCount, errorCount, returnedTestInfo);

}
StencilObjectPtr StencilNew(void)
{
	StencilObjectPtr	self = (StencilObjectPtr)jit_object_alloc(sStencilClass);
	TTErr				err;
	
	if (self) {
		err = TTObjectBaseInstantiate(kTTSym_matrix, (TTObjectBasePtr*)&self->x, kTTValNONE);
		err = TTObjectBaseInstantiate(kTTSym_matrix, (TTObjectBasePtr*)&self->y, kTTValNONE);
		err = TTObjectBaseInstantiate(TT("matrix.stencil"), (TTObjectBasePtr*)&self->stencilObject, kTTValNONE);
	} 
	return self;
}
Beispiel #7
0
TTOutputAudio::TTOutputAudio(const TTValue& arguments) :
TTOutput(arguments)
{
	TTValue				args;
	
	mType = "audio";

	// the only argument is the owner, which is used as a baton to hand to the callback
	if (arguments.size())
		mReturnSignalCallback = TTCallbackPtr((TTObjectBasePtr)arguments[0]);
	if (arguments.size() > 1)
		mReturnLinkCallback = TTCallbackPtr((TTObjectBasePtr)arguments[1]);
	
	TTObjectBaseInstantiate(kTTSym_audiosignal, &mSignalIn, 1);
	TTObjectBaseInstantiate(kTTSym_audiosignal, &mSignalOut, 1);
	TTObjectBaseInstantiate(kTTSym_audiosignal, &mSignalTemp, 1);
	TTObjectBaseInstantiate(kTTSym_audiosignal, &mSignalZero, 1);
    
	TTObjectBaseInstantiate(TTSymbol("crossfade"), &mMixUnit, 1);
	if (mMixUnit)
        mMixUnit->setAttributeValue(TTSymbol("position"), 1.0);
	
    TTObjectBaseInstantiate(TTSymbol("gain"), &mGainUnit, 1);
    if (mGainUnit)
        mGainUnit->setAttributeValue(TTSymbol("linearGain"), 1.0);
    
	TTObjectBaseInstantiate(TTSymbol("ramp"), &mRampMixUnit, 1);
	TTObjectBaseInstantiate(TTSymbol("ramp"), &mRampGainUnit, 1);
}
Beispiel #8
0
PackPtr PackNew(t_symbol* msg, long argc, t_atom* argv)
{
    PackPtr	self;
	TTValue	v;
	TTErr	err;

    self = PackPtr(object_alloc(sPackClass));
    if (self) {
    	object_obex_store((void*)self, _sym_dumpout, (t_object*)outlet_new(self, NULL));
		self->graphOutlets[0] = outlet_new(self, "graph.connect");

		v.resize(2);
		v[0] = "graph.input";
		v[1] = 1;
		err = TTObjectBaseInstantiate(TT("graph.object"), (TTObjectBasePtr*)&self->graphObject, v);
		((TTGraphInput*)self->graphObject->mKernel.instance())->setOwner(self->graphObject);

		if (!self->graphObject->mKernel.valid()) {
			object_error(SELF, "cannot load Jamoma object");
			return NULL;
		}

		self->graphDictionary = new TTDictionary;
		self->graphDictionary->setSchema(TT("none"));
		self->graphDictionary->append(TT("outlet"), 0);

		attr_args_process(self, argc, argv);

		self->qelem = qelem_new(self, (method)PackQFn);

		// PackStartTracking(self);
		defer_low(self, (method)PackStartTracking, NULL, 0, NULL);
	}
	return self;
}
Beispiel #9
0
TTErr TTScoreTimeEventStatusCallbackCreate(TTTimeEventPtr timeEvent, TTObjectBasePtr *statusCallback, TTScoreTimeEventStatusCallbackPtr statusCallbackFunction)
{
    TTValue         v, none;
    TTValuePtr      statusAttributeBaton;
    TTAttributePtr  anAttribute;
    TTErr           err;
    
    statusCallback = NULL;
    
    // Create a TTCallback to observe time event status attribute (using internal_TTScoreTimeEventStatusCallback)
    TTObjectBaseInstantiate(TTSymbol("callback"), statusCallback, none);
    
    statusAttributeBaton = new TTValue(TTPtr(timeEvent)); // statusAttributeBaton will be deleted during the callback destruction
    statusAttributeBaton->append(TTPtr(statusCallbackFunction));
    
    (*statusCallback)->setAttributeValue(kTTSym_baton, TTPtr(statusAttributeBaton));
    (*statusCallback)->setAttributeValue(kTTSym_function, TTPtr(&internal_TTScoreTimeEventStatusCallback));
    
    // register for status attribute observation
    err = timeEvent->findAttribute(kTTSym_status, &anAttribute);
    
    if (!err)
        anAttribute->registerObserverForNotifications(**statusCallback);
    
    return err;
}
Beispiel #10
0
TTErr TTScoreTimeProcessEndCallbackCreate(TTTimeProcessPtr timeProcess, TTObjectBasePtr *endCallback, TTScoreTimeProcessEndCallbackPtr endCallbackFunction)
{
    TTValue        v, none;
    TTValuePtr     endMessageBaton;
    TTMessagePtr   aMessage;
    TTErr          err;
    
    *endCallback = NULL;
    
    // create a TTCallback to observe when time process starts (using internal_TTScoreTimeProcessEndCallback)
    TTObjectBaseInstantiate(TTSymbol("callback"), endCallback, none);
    
    // store the function to call and the time process to pass
    endMessageBaton = new TTValue(TTPtr(timeProcess));    // endMessageBaton will be deleted during the callback destruction
    endMessageBaton->append(TTPtr(endCallbackFunction));
    
    (*endCallback)->setAttributeValue(kTTSym_baton, TTPtr(endMessageBaton));
    (*endCallback)->setAttributeValue(kTTSym_function, TTPtr(&internal_TTScoreTimeProcessEndCallback));
    
    // register for ProcessEnd message observation
    err = timeProcess->findMessage(kTTSym_ProcessEnd, &aMessage);
    
    if (!err)
        aMessage->registerObserverForNotifications(**endCallback);
    
    return err;
}
Beispiel #11
0
TTErr TTScoreTimeProcessCreate(TTTimeProcessPtr *timeProcess, const std::string timeProcessClass, TTTimeEventPtr startEvent, TTTimeEventPtr endEvent, TTTimeContainerPtr timeContainer)
{
    TTValue args;
    
    *timeProcess = NULL;
    
    if (timeContainer) {
        
        TTValue out;
        TTErr   err;
        
        args = TTSymbol(timeProcessClass);
        args.append(TTObjectBasePtr(startEvent));
        args.append(TTObjectBasePtr(endEvent));
        
        err = timeContainer->sendMessage(TTSymbol("TimeProcessCreate"), args, out);
        
        if (!err)
           *timeProcess = TTTimeProcessPtr(TTObjectBasePtr(out[0]));
        
        return err;
    }
    else {
        
        args = TTObjectBasePtr(startEvent);
        args.append(TTObjectBasePtr(endEvent));
        
        return TTObjectBaseInstantiate(timeProcessClass.c_str(), TTObjectBaseHandle(timeProcess), args);
    }
}
Beispiel #12
0
AppendPtr AppendNew(t_symbol* msg, long argc, t_atom* argv)
{
    AppendPtr	self;
	TTValue		v;
	TTErr		err;

    self = AppendPtr(object_alloc(sAppendClass));
    if (self) {
    	object_obex_store((void*)self, _sym_dumpout, (t_object*)outlet_new(self, NULL));	// dumpout
		self->graphOutlets[0] = outlet_new(self, "graph.connect");

		v.resize(2);
		v[0] = "dictionary.append";
		v[1] = 1;
		err = TTObjectBaseInstantiate(TT("graph.object"), (TTObjectBasePtr*)&self->graphObject, v);

		if (!self->graphObject->mKernel.valid()) {
			object_error(SELF, "cannot load Jamoma object");
			return NULL;
		}

		attr_args_process(self, argc, argv);
	}
	return self;
}
Beispiel #13
0
PlugOutPtr PlugOutNew(SymbolPtr msg, AtomCount argc, AtomPtr argv)
{
    PlugOutPtr	self = PlugOutPtr(object_alloc(sPlugOutClass));
	TTValue		v;
	TTErr		err;

    if (self) {
		v.setSize(2);
		v.set(0, TT("plugtastic.output"));
		v.set(1, 2);
		err = TTObjectBaseInstantiate(TT("audio.object"), (TTObjectBasePtr*)&self->audioGraphObject, v);

		v = TTPtr(self->audioGraphObject);

		object_obex_store((void*)self, _sym_dumpout, (object*)outlet_new(self, NULL));
		self->audioGraphOutlet = outlet_new(self, "audio.connect");
		self->qelem = qelem_new(self, (method)PlugOutQFn);
		
		object_obex_lookup(self, GENSYM("#P"), &self->patcher);
		self->pluginName = object_attr_getsym(self->patcher, _sym_name);
		self->pluginVersion = GENSYM("1.0");
		self->pluginVersionHex = GENSYM("0x00010000");
		self->pluginManufacturer = GENSYM("Plugtastic");
		self->pluginManufacturerCode = GENSYM("74Ob");
		self->pluginID = GENSYM("ftmp");
		
		attr_args_process(self, argc, argv);
	}
	return self;
}
MidiOutPtr MidiOutNew(SymbolPtr msg, AtomCount argc, AtomPtr argv)
{
    MidiOutPtr	self;
	TTValue		v;
	TTErr		err;
	
    self = MidiOutPtr(object_alloc(sMidiOutClass));
    if (self) {
    	object_obex_store((void*)self, _sym_dumpout, (ObjectPtr)outlet_new(self, NULL));	// dumpout	
		self->graphOutlets[0] = outlet_new(self, "graph.connect");
		
		v.setSize(2);
		v.set(0, TT("midi.out"));
		v.set(1, TTUInt32(1));
		err = TTObjectBaseInstantiate(TT("graph.object"), (TTObjectBasePtr*)&self->graphObject, v);

		if (!self->graphObject->mKernel) {
			object_error(SELF, "cannot load Jamoma object");
			return NULL;
		}
		
		attr_args_process(self, argc, argv);
	}
	return self;
}
Beispiel #15
0
DCBlockPtr DCBlockNew(t_symbol* msg, long argc, t_atom* argv)
{
    DCBlockPtr	self;
	TTValue			v;
	TTErr			err;

    self = (DCBlockPtr)object_alloc(sDCBlockClass);
    if (self) {
    	object_obex_store((void*)self, _sym_dumpout, (t_object*)outlet_new(self, NULL));
		self->audioGraphOutlet = outlet_new(self, "audio.connect");

		// TODO: we need to update objects to work with the correct number of channels when the network is configured
		// Either that, or when we pull we just up the number of channels if when we need to ???
		v.resize(2);
		v[0] = "dcblock";
		v[1] = 1;
		err = TTObjectBaseInstantiate(TT("audio.object"), (TTObjectBasePtr*)&self->audioGraphObject, v);

		if (!self->audioGraphObject->getUnitGenerator().valid()) {
			object_error(SELF, "cannot load JamomaDSP object");
			return NULL;
		}

		attr_args_process(self, argc, argv);
	}
	return self;
}
TTErr TTDataspace::setOutputUnit(TTSymbol& outUnitName)
{
	TTSymbol	newUnitClassName;
	TTErr		err;
	TTValue		v;
	
	if (outUnit && outUnitName == outUnit->name)	// already have this one loaded
		return kTTErrNone;
	else {
		err = unitHash->lookup(outUnitName, v);
        
		if (!err) {
            
            newUnitClassName = v;
            
            if (newUnitClassName) {
			
                v = outUnitName;
                err = TTObjectBaseInstantiate(newUnitClassName, &outUnitTT, v);	// this will free a pre-existing unit
                outUnit = dynamic_cast<TTDataspaceUnitPtr>(outUnitTT);
            }
		}
		return err;
	}
}
Beispiel #17
0
InfoPtr InfoNew(t_symbol* msg, long argc, t_atom* argv)
{
    InfoPtr	self;
	TTValue	v;
	TTErr	err;
   
    self = InfoPtr(object_alloc(sInfoClass));
    if (self) {
    	object_obex_store((TTPtr)self, _sym_dumpout, (t_object*)outlet_new(self, NULL));
		self->outletNumChannels = outlet_new((t_pxobject*)self, 0);
		self->outletVectorSize = outlet_new((t_pxobject*)self, 0);
		self->outletSampleRate = outlet_new((t_pxobject*)self, 0);
		self->outletSmartSignal = outlet_new((t_pxobject*)self, "audio.connect");
		
		self->qelem = qelem_new(self, (method)InfoQfn);
		
		v.resize(2);
		v[0] = "thru";
		v[1] = 1;		// we set it up with 1 inlet, and later modify to 2 inlets if the connection is made
		err = TTObjectBaseInstantiate(TT("audio.object"), (TTObjectBasePtr*)&self->audioGraphObject, v);		
		if (!self->audioGraphObject->getUnitGenerator().valid()) {
			object_error(SELF, "cannot load Jamoma DSP object");
			return NULL;
		}

		attr_args_process(self, argc, argv);
	}
	return self;
}
Beispiel #18
0
UnpackPtr UnpackNew(SymbolPtr msg, AtomCount argc, AtomPtr argv)
{
    UnpackPtr	self;
	TTValue		sr(sys_getsr());
 	long		attrstart = attr_args_offset(argc, argv);		// support normal arguments
	short		i;
	TTValue	v;
	TTErr		err;
   
    self = UnpackPtr(object_alloc(sUnpackClass));
    if (self) {
		self->maxNumChannels = 2;		// An initial argument to this object will set the maximum number of channels
		if(attrstart && argv)
			self->maxNumChannels = atom_getlong(argv);

		ttEnvironment->setAttributeValue(kTTSym_sampleRate, sr);
		
		v.setSize(2);
		v.set(0, TT("thru"));
		v.set(1, 1); // arg is the number of inlets
		err = TTObjectBaseInstantiate(TT("audio.object"), (TTObjectBasePtr*)&self->audioGraphObject, v);
		//self->audioGraphObject->getUnitGenerator()->setAttributeValue(TT("linearGain"), 1.0);
		
		attr_args_process(self, argc, argv);
		
    	object_obex_store((void*)self, _sym_dumpout, (object*)outlet_new(self, NULL));	// dumpout	
	    dsp_setup((t_pxobject*)self, 1);
		for(i=0; i < self->maxNumChannels; i++)
			outlet_new((t_pxobject*)self, "signal");
		
		self->qelem = qelem_new(self, (method)UnpackQFn);
		self->obj.z_misc = Z_NO_INPLACE | Z_PUT_LAST;
	}
	return self;
}
void TTAudioGraphSource::create()
{
	TTObjectBaseInstantiate(TT("callback"), &mCallbackHandler, kTTValNONE);
	
	mCallbackHandler->setAttributeValue(TT("function"), TTPtr(&TTAudioGraphSourceObserverCallback));
	mCallbackHandler->setAttributeValue(TT("baton"), TTPtr(this));	
}
Beispiel #20
0
UnpackPtr UnpackNew(t_symbol *msg, long argc, t_atom* argv)
{
    UnpackPtr	self;
	TTValue		v, none;
	TTErr		err;
	
    self = UnpackPtr(object_alloc(sUnpackClass));
    if (self) {
    	object_obex_store((void*)self, _sym_dumpout, (t_object*)outlet_new(self, NULL));	// dumpout	
		self->graphOutlets[0] = outlet_new(self, NULL);
		
		v.resize(2);
		v[0] = "graph.output";
		v[1] = 1;
		err = TTObjectBaseInstantiate(TT("graph.object"), (TTObjectBasePtr*)&self->graphObject, v);
		
		if (!self->graphObject->mKernel.valid()) {
			object_error(SELF, "cannot load Jamoma object");
			return NULL;
		}
		
		self->callback = new TTObject("callback");
		self->callback->set(TT("function"), TTPtr(&UnpackGraphCallback));
		self->callback->set(TT("baton"), TTPtr(self));
		
		// Dynamically add a message to the callback object so that it can handle the 'dictionaryReceived' notification
		self->callback->instance()->registerMessage(TT("dictionaryReceived"), (TTMethod)&TTCallback::notify, kTTMessagePassValue);
		// Tell the graph object that we want to watch it
		self->graphObject->mKernel.registerObserverForNotifications(*self->callback);
		
		attr_args_process(self, argc, argv);
	}
	return self;
}
void TTGraphDestination::create()
{
	TTObjectBaseInstantiate(TT("callback"), &mCallbackHandler, kTTValNONE);
	
	mCallbackHandler->setAttributeValue(TT("owner"), TT("TTGraphDestination"));
	mCallbackHandler->setAttributeValue(TT("function"), TTPtr(&TTGraphDestinationObserverCallback));
	mCallbackHandler->setAttributeValue(TT("baton"), TTPtr(this));	
}
Beispiel #22
0
t_object* wrappedClass_new(t_symbol* name, long argc, t_atom* argv)
{	
	WrappedClass*		wrappedMaxClass = NULL;
    WrappedInstancePtr	self = NULL;
	TTValue				v;
	TTErr				err = kTTErrNone;
	TTUInt8				numInputs = 1;
	TTUInt8				numOutputs = 1;
 	long				attrstart = attr_args_offset(argc, argv);		// support normal arguments
	
	// Find the WrappedClass
	hashtab_lookup(wrappedMaxClasses, name, (t_object**)&wrappedMaxClass);
	
	// If the WrappedClass has a validity check defined, then call the validity check function.
	// If it returns an error, then we won't instantiate the object.
	if (wrappedMaxClass) {
		if (wrappedMaxClass->validityCheck)
			err = wrappedMaxClass->validityCheck(wrappedMaxClass->validityCheckArgument);
		else
			err = kTTErrNone;
	}
	else
		err = kTTErrGeneric;
	
	if (!err)
		self = (WrappedInstancePtr)object_alloc(wrappedMaxClass->maxClass);
    if (self) {

		if (wrappedMaxClass->options && !wrappedMaxClass->options->lookup(TT("argumentDefinesNumInlets"), v)) {
			int argumentOffsetToDefineTheNumberOfInlets = v;
			if ((attrstart-argumentOffsetToDefineTheNumberOfInlets > 0) && argv+argumentOffsetToDefineTheNumberOfInlets)
				numInputs = atom_getlong(argv+argumentOffsetToDefineTheNumberOfInlets);
		}
		for (TTUInt16 i=numInputs-1; i>0; i--)
			self->inlets[i-1] = proxy_new(self, i, NULL);
		
    	object_obex_store((void*)self, _sym_dumpout, (object*)outlet_new(self, NULL));	// dumpout
		if (wrappedMaxClass->options && !wrappedMaxClass->options->lookup(TT("argumentDefinesNumOutlets"), v)) {
			int argumentOffsetToDefineTheNumberOfOutlets = v;
			if ((attrstart-argumentOffsetToDefineTheNumberOfOutlets > 0) && argv+argumentOffsetToDefineTheNumberOfOutlets)
				numOutputs = atom_getlong(argv+argumentOffsetToDefineTheNumberOfOutlets);
		}
		for (TTInt16 i=numOutputs-1; i>=0; i--)
			self->graphOutlets[i] = outlet_new(self, "audio.connect");

		self->wrappedClassDefinition = wrappedMaxClass;
		v.resize(3);
		v[0] = wrappedMaxClass->ttClassName;
		v[1] = numInputs;
		v[2] = numOutputs;
		err = TTObjectBaseInstantiate(TT("audio.object"), (TTObjectBasePtr*)&self->graphObject, v);
				
		attr_args_process(self, argc, argv);
	}
	return (t_object*)self;
}
Beispiel #23
0
// Create
void *zerox_new(t_symbol *msg, long argc, t_atom *argv)
{
	t_zerox *x = (t_zerox *)object_alloc(zerox_class);;
	
	if (x) {
		object_obex_store((void *)x, _sym_dumpout, (object *)outlet_new(x, NULL));	// dumpout
		dsp_setup((t_pxobject *)x, 1);				// Create Object and 1 Inlet (last argument)
		outlet_new((t_pxobject *)x, "signal");		// Create a signal Outlet
		outlet_new((t_pxobject *)x, "signal");		// Create a signal Outlet
		
		TTObjectBaseInstantiate(TT("zerocross"), &x->zeroxUnit, 1);
		TTObjectBaseInstantiate(TT("audiosignal"), &x->signalIn, 2);
		TTObjectBaseInstantiate(TT("audiosignal"), &x->signalOut, 2);

		x->attr_size = 0;
		attr_args_process(x, argc, argv); 			//handle attribute args			
	}
	return (x);										// Return the pointer
}
Beispiel #24
0
// Create
void* gain_new(t_symbol* s, long argc, t_atom* argv)
{
	long	attrstart = attr_args_offset(argc, argv);		// support normal arguments
	short	i;
	t_gain*	x = (t_gain*)object_alloc(s_gain_class);

	if(x){
		object_obex_store((void*)x, _sym_dumpout, (object*)outlet_new(x, NULL));	// dumpout

		x->numChannels = 1;
		if(attrstart && argv){
			int argument = atom_getlong(argv);
			x->numChannels = TTClip(argument, 1, MAX_NUM_CHANNELS);
		}

		dsp_setup((t_pxobject*)x, x->numChannels * 2);			// Create Object and Inlets
		x->obj.z_misc = Z_NO_INPLACE;							// ESSENTIAL!   		
		for(i=0; i < x->numChannels; i++)
			outlet_new((t_pxobject*)x, "signal");				// Create a signal Outlet   		

		//x->xfade = new TTCrossfade(x->numChannels);				// Constructors
		//x->gain = new TTGain(x->numChannels);
		TTObjectBaseInstantiate(TT("crossfade"), &x->xfade, x->numChannels);
		TTObjectBaseInstantiate(TT("gain"), &x->gain, x->numChannels);
		TTObjectBaseInstantiate(kTTSym_audiosignal, &x->signalTemp, x->numChannels);
		TTObjectBaseInstantiate(kTTSym_audiosignal, &x->signalOut, x->numChannels);
		TTObjectBaseInstantiate(kTTSym_audiosignal, &x->signalIn, x->numChannels*2);
		//x->signalTemp = new TTAudioSignal(x->numChannels);
		//x->signalOut = new TTAudioSignal(x->numChannels);
		//x->signalIn = new TTAudioSignal(x->numChannels*2);
		
		x->xfade->setAttributeValue(TT("position"), 1.0);		// defaults
		x->gain->setAttributeValue(TT("linearGain"), 0.0);
		
		x->attrBypass = 0;
		x->attrGain = 0;

		attr_args_process(x, argc, argv);						// handle attribute args				
	}
	return (x);													// Return the pointer
}
TTErr TTAudioObjectBase::defaultCalculateMethod(const TTFloat64& x, TTFloat64& y, TTPtr data)
{
	TTAudioSignalPtr	in;
	TTAudioSignalPtr	out;
	TTErr				err;
	
	TTObjectBaseInstantiate(kTTSym_audiosignal, &in, 1);
	TTObjectBaseInstantiate(kTTSym_audiosignal, &out, 1);
	
	in->allocWithVectorSize(1);
	out->allocWithVectorSize(1);
	
	in->mSampleVectors[0][0] = x;
	err = process(in, out);
	y = out->mSampleVectors[0][0];
	
	TTObjectBaseRelease(&in);
	TTObjectBaseRelease(&out);

	return err;
}
Beispiel #26
0
TTErr TTScoreTimeEventCreate(TTTimeEventPtr *timeEvent, TTUInt32 date, TTTimeContainerPtr timeContainer)
{
    *timeEvent = NULL;
    
    if (timeContainer) {
        
        TTErr   err;
        TTValue out;
        
        err = timeContainer->sendMessage(TTSymbol("TimeEventCreate"), date, out);
        
        if (!err)
            *timeEvent = TTTimeEventPtr(TTObjectBasePtr(out[0]));
        
        return err;
    }
    else
        return TTObjectBaseInstantiate(kTTSym_TimeEvent, TTObjectBaseHandle(timeEvent), TTValue(date));
}
TTObjectBasePtr OSCSenderManager::add(TTSymbol applicationName, TTSymbol ip, TTUInt16 port)
{
    TTValue     v;
    TTObjectBasePtr anObject = NULL;
    TTErr       err;
    
    err = TTObjectBaseInstantiate(TTSymbol("osc.send"), &anObject, kTTValNONE);
    if (!err) {
        anObject->setAttributeValue(TTSymbol("address"), ip);
        anObject->setAttributeValue(TTSymbol("port"), port);
        
        v.append(anObject);
        v.append(ip);
        v.append(port);
        
        mSenders->append(applicationName, v);
    }
    
    return anObject;
}
Beispiel #28
0
PackPtr PackNew(SymbolPtr msg, AtomCount argc, AtomPtr argv)
{
   PackPtr	self;
	TTValue	sr(sys_getsr());
 	long	attrstart = attr_args_offset(argc, argv);
	TTValue	v;
	TTErr	err;
	
    self =PackPtr(object_alloc(sInClass));
    if (self) {
		self->maxNumChannels = 2;
		if (attrstart && argv)
			self->maxNumChannels = atom_getlong(argv);
		
		ttEnvironment->setAttributeValue(kTTSym_sampleRate, sr);

		v.setSize(3);
		v.set(0, TT("audio.generator"));
		v.set(1, 0); // no audio graph inlets (only msp inlets)
		v.set(2, 1); // one audio graph outlet
		err = TTObjectBaseInstantiate(TT("audio.object"), (TTObjectBasePtr*)&self->audioGraphObject, v);
		self->audioGraphObject->addAudioFlag(kTTAudioGraphGenerator);

		if (!self->audioGraphObject->getUnitGenerator()) {
			object_error(SELF, "cannot load audio.generator");
			return NULL;
		}

		attr_args_process(self, argc, argv);
		
    	object_obex_store((void*)self, _sym_dumpout, (object*)outlet_new(self,NULL));
		self->audioGraphObjectOutlet = outlet_new((t_pxobject*)self, "audio.connect");
	    dsp_setup((t_pxobject*)self, self->maxNumChannels);
		
		self->obj.z_misc = Z_NO_INPLACE | Z_PUT_FIRST;
	}
	return self;
}
Beispiel #29
0
void *dataspace_new(t_symbol *name, long argc, t_atom *argv)
{
	t_dataspace *self;
	TTValue		none;
	
	self = (t_dataspace *)object_alloc(dataspace_class);
	if (self) {
		object_obex_store((void*)self, _sym_dumpout, (object*)outlet_new(self, NULL));

        // Make sure that environment sample rate is set correctly at instantiated,
        // as it is used by time dataspace for conversions to and from sample
        TTValue		sr(sys_getsr());
        ttEnvironment->setAttributeValue(kTTSym_sampleRate, sr);
        
        self->outlet_native = outlet_new(self, 0);
		TTObjectBaseInstantiate(TT("dataspace"), &self->dataspace, none);
		
		attr_args_process(self, argc, argv);
		if (!self->dataspace)
			object_attr_setsym(self, gensym("dataspace"), gensym("temperature"));
	}
	return self;
}
Beispiel #30
0
OutPtr OutNew(SymbolPtr msg, AtomCount argc, AtomPtr argv)
{
    OutPtr		self;
	TTValue		sr(sys_getsr());
 	long		attrstart = attr_args_offset(argc, argv);		// support normal arguments
	//short		i;
	TTValue		v;
	TTErr		err;
   
    self = OutPtr(object_alloc(sOutClass));
    if (self) {
		self->maxNumChannels = 2;		// An initial argument to this object will set the maximum number of channels
		if(attrstart && argv)
			self->maxNumChannels = atom_getlong(argv);

		ttEnvironment->setAttributeValue(kTTSym_sampleRate, sr);
		// setup the output_buffer according to channnel number 
		self->output_buffer = (t_atom *)malloc(self->maxNumChannels * sizeof(t_atom));
		
		v.setSize(2);
		v.set(0, TT("thru"));
		v.set(1, 1); // arg is the number of inlets
		err = TTObjectBaseInstantiate(TT("audio.object"), (TTObjectBasePtr*)&self->audioGraphObject, v);
		//self->audioGraphObject->getUnitGenerator()->setAttributeValue(TT("linearGain"), 1.0);
		
		attr_args_process(self, argc, argv);
		
    	object_obex_store((void*)self, _sym_dumpout, (object*)outlet_new(self, NULL));	// dumpout	
		self->s_out = listout((t_pxobject *)self); // the list outlet
	    dsp_setup((t_pxobject*)self, 1);
		self->clock = clock_new(self, (method)OutTick);
				
		self->qelem = qelem_new(self, (method)OutQFn);
		self->obj.z_misc = Z_NO_INPLACE | Z_PUT_LAST;
	}
	return self;
}