Example #1
0
// Create
void *out_new(t_symbol *s, long argc, t_atom *argv)
{
	long 		attrstart = attr_args_offset(argc, argv);		// support normal arguments
	t_out 		*x = (t_out *)object_alloc(out_class);
	short 		i;

	if(x){
		x->dumpout = outlet_new(x, NULL);
		object_obex_store((void *)x, jps_dumpout, (object *)x->dumpout);		// setup the dumpout

		x->numOutputs =  1;
		x->attr_preview = 0;
		x->preview_object = NULL;
		x->attr_bypass = 0;
		x->attr_mute = 0;
		x->attr_mix = 100;										// Assume 100%, so that processed signal is passed through if @has_mix is false
		if(attrstart > 0){
			int argument = atom_getlong(argv);
			x->numOutputs = TTClip(argument, 1, MAX_NUM_CHANNELS);
		}
#ifdef JCOM_OUT_TILDE
		if(x->numOutputs > 0)
			dsp_setup((t_pxobject *)x, x->numOutputs);		// Create Object and Inlets
		else
			dsp_setup((t_pxobject *)x, 1);					// Create Object and Inlets
			
		x->common.ob.z_misc = Z_NO_INPLACE | Z_PUT_LAST;	// Z_PUT_LAST so that thispoly~ gets it's message properly?  		
		for(i=0; i < (x->numOutputs); i++)
			outlet_new((t_pxobject *)x, "signal");			// Create a signal Outlet   		

		x->clock = clock_new(x, (method)update_meters);
		x->clock_is_set = 0;
		TTObjectInstantiate(kTTSym_audiosignal, &x->audioIn, x->numOutputs);
		TTObjectInstantiate(kTTSym_audiosignal, &x->audioOut, x->numOutputs);
		TTObjectInstantiate(kTTSym_audiosignal, &x->audioTemp, x->numOutputs);
		TTObjectInstantiate(kTTSym_audiosignal, &x->zeroSignal, x->numOutputs);
		
		TTObjectInstantiate(TT("crossfade"), &x->xfade, x->numOutputs);
		x->xfade->setAttributeValue(TT("position"), 1.0);
		TTObjectInstantiate(TT("gain"), &x->gain, x->numOutputs);
		TTObjectInstantiate(TT("ramp"), &x->ramp_gain, x->numOutputs);
		TTObjectInstantiate(TT("ramp"), &x->ramp_xfade, x->numOutputs);

//		out_alloc(x, sys_getblksize());						// allocates the vectors for the audio signals
		x->gain->setAttributeValue(TT("linearGain"), 1.0);
#else
		for(i=x->numOutputs-1; i >= 1; i--)
			x->inlet[i] = proxy_new(x, i, 0L);
		for(i=x->numOutputs-1; i >= 0; i--)
			x->outlet[i] = outlet_new(x, 0L);
#endif		
		jcom_core_subscriber_new_common(&x->common, jps__jcom_out__, jps_subscribe_out);
		jcom_core_subscriber_setcustomsubscribe_method(&x->common, &out_subscribe);
		
		attr_args_process(x, argc, argv);					// handle attribute args				
		jcom_core_subscriber_subscribe((t_jcom_core_subscriber_common*)x);
	}
	return (x);												// Return the pointer
}
void jcom_core_subscriber_new_extended(t_jcom_core_subscriber_extended *x, t_symbol *name, t_symbol *subscriber_type)
{
	jcom_core_subscriber_new_common((t_jcom_core_subscriber_common *)x, name, subscriber_type);
	
	x->attr_range[0] = 0.0;
	x->attr_range[1] = 1.0;
	x->attr_clipmode = jps_none;
	x->attr_description = _sym_nothing;
	x->attr_type = jps_generic;
	x->attr_repetitions = 0;	// this should default to the most efficient and common way of working, so repetitions are filtered [TAP]
}