Exemplo n.º 1
0
void *hoa_map_new(t_symbol *s, long argc, t_atom *argv)
{
	t_hoa_map *x = NULL;
	int	order = 1;
    int numberOfSources = 1;
    x = (t_hoa_map *)object_alloc(hoa_map_class);
	if (x)
	{		
		if(atom_gettype(argv) == A_LONG)
			order = atom_getlong(argv);
        if(argc > 1 && atom_gettype(argv+1) == A_LONG)
            numberOfSources = atom_getlong(argv+1);

		x->f_map = new Hoa3D::Map(order, numberOfSources);
		if(x->f_map->getNumberOfSources() == 1)
            dsp_setup((t_pxobject *)x, 4);
        else
            dsp_setup((t_pxobject *)x, x->f_map->getNumberOfSources());
		
		for (int i = 0; i < x->f_map->getNumberOfHarmonics(); i++)
			outlet_new(x, "signal");
        
        if(x->f_map->getNumberOfSources() == 1)
            x->f_sig_ins    =  new double[4 * SYS_MAXBLKSIZE];
        else
            x->f_sig_ins    =  new double[x->f_map->getNumberOfSources() * SYS_MAXBLKSIZE];
        x->f_sig_outs   =  new double[x->f_map->getNumberOfHarmonics() * SYS_MAXBLKSIZE];
	}
    
	return (x);
}
Exemplo n.º 2
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
}
Exemplo n.º 3
0
void*
SinkerNew(
	SymbolPtr,
	short		iArgC,
	Atom		iArgV[])
	
	{
	const float kDefVal = 0.0;
	
	short			valCount = (iArgC > 0) ? iArgC : 1;
	objSinker*		me	= NIL;
	tCurPendPair*	vals = (tCurPendPair*) NewPtrClear(valCount * sizeof(tCurPendPair));
	tSampleVector*	inSigs = (tSampleVector*) NewPtrClear(valCount * sizeof(tSampleVector));
	tSampleVector*	outSigs = (tSampleVector*) NewPtrClear(valCount * sizeof(tSampleVector));
	
	if (vals == NIL || inSigs == NIL || outSigs == NIL) {
		// Quick punt before any damage can be done
		if (vals != NIL) DisposePtr((Ptr) vals);
		if (inSigs != NIL) DisposePtr((Ptr) inSigs);
		if (outSigs != NIL) DisposePtr((Ptr) outSigs);
		return NIL;	
		}					
	
	// Let Max/MSP allocate us and inlets
	me = (objSinker*) newobject(gObjectClass);
	
	// Add outlets, right to left, and initialize values
	if (iArgC == 0) {
		// Default to two inlets, one outlet
		dsp_setup(&me->coreObject, 2);
		outlet_new(me, "signal");
		// Don't actually need to initialize as long as kDefVal is zero
		// vals[0].current = vals[0].pending = kDefVal;		
		}
	else {
		dsp_setup(&me->coreObject, iArgC + 1);
		while (--iArgC >= 0) {
			outlet_new(me, "signal");
			vals[iArgC].current = vals[iArgC].pending = AtomGetFloat(&iArgV[iArgC]);
			}
		}
	
	// My own initialization. Do this now before we lose the value of iArgCount
	me->lastSync	= 0.0;
	me->valCount	= valCount;
	me->mode		= trigDef;
	me->vals		= vals;
	me->inSigs		= inSigs;
	me->outSigs		= outSigs;
	
punt:
	return me;
	}
Exemplo n.º 4
0
void *bench_new(t_symbol *msg, short argc, t_atom *argv){
	t_bench *x;

	x = (t_bench *)object_alloc(bench_class);
	if(!x){
		return NULL;
	}


	if(!argc){
		object_error((t_object *)x, "bench~: one argument is required, either in or out");
		return NULL;
	}else{
		if(!argv[0].a_type == A_SYM){
			object_error((t_object *)x, "bench~: the first argument to bench must be a symbol (either \"in\" or \"out\")");
			return NULL;
		}else if(!strcmp(argv[0].a_w.w_sym->s_name, "in")){
			dsp_setup((t_pxobject *)x, 1);
			outlet_new((t_object *)x, "signal");
			outlet_new((t_object *)x, "signal");
			x->t_objmode = BENCH_IN;

			if(argc == 1) x->t_mode = BENCH_MODE_ONES;
			else{
				if(!strcmp(argv[1].a_w.w_sym->s_name, "zeros")){
					x->t_mode = BENCH_MODE_ZEROS;
				}else if(!strcmp(argv[1].a_w.w_sym->s_name, "ones")){
					x->t_mode = BENCH_MODE_ONES;
				}else if(!strcmp(argv[1].a_w.w_sym->s_name, "rand")){
					x->t_mode = BENCH_MODE_RAND;
				}else if(!strcmp(argv[1].a_w.w_sym->s_name, "thru")){
					x->t_mode = BENCH_MODE_THRU;
				}else {
					object_error((t_object *)x, "bench~: unrecognized argument %s.  Setting the mode to \"ones\"", argv[1].a_w.w_sym->s_name);
					x->t_mode = BENCH_MODE_ONES;
				}
			}
		}else if(!strcmp(argv[0].a_w.w_sym->s_name, "out")){
			dsp_setup((t_pxobject *)x, 2);
			outlet_new((t_object *)x, "signal");
			x->t_objmode = BENCH_OUT;
		}else {
			object_error((t_object *)x, "bench~: unrecognized argument %s", argv[0].a_w.w_sym->s_name);
			return NULL;
		}
	}
	//x->t_ob.z_misc |= Z_NO_INPLACE;

	return x;
}
Exemplo n.º 5
0
void *freeverb_new(t_symbol *s, long argc, t_atom *argv)
{
	t_freeverb *x = NULL;
	int aSide = 0;
    x = ((t_freeverb *)object_alloc(freeverb_class));
	if (x)
	{	
		if(atom_gettype(argv) == A_LONG)
			aSide = atom_getlong(argv);
		else if(atom_gettype(argv) == A_FLOAT)
			aSide = atom_getfloat(argv);
		else if(atom_gettype(argv) == A_SYM)
		{
			if(atom_getsym(argv) == gensym("right"))
				aSide = 1;
		}

		 if(aSide <= 0)
			 aSide = 0;

		x->f_freeverb = new Freeverb(aSide);
		
		dsp_setup((t_pxobject *)x, 1);	
		outlet_new(x, "signal");
		attr_args_process(x, argc, argv);
	}
	return (x);
}
Exemplo n.º 6
0
void *shoehorn_new(t_symbol *s, int argc, t_atom *argv)
{
	int i;
    double fullFrac, thisFrac, panloc;
    long outIndex;
    t_shoehorn *x = (t_shoehorn *)object_alloc(shoehorn_class);
    x->inChans = (long) atom_getfloatarg(0,argc,argv);
    x->outChans = (long) atom_getfloatarg(1,argc,argv);
    if( x->outChans < 2 || x->inChans < 2){
        object_error((t_object *)x, "%s: illegal channel count: [in = %d] [out = %d]",OBJECT_NAME,x->inChans,x->outChans);
        return NULL;
    }
    dsp_setup((t_pxobject *)x, x->inChans);
    for(i=0; i < x->outChans; i++){
        outlet_new((t_pxobject *)x, "signal");
    }
    x->pio2 = PI / 2.0;
    x->inarr = (double *) malloc(x->inChans * sizeof(double));
    x->pangains1 = (double *) malloc(x->inChans * sizeof(double));
    x->pangains2 = (double *) malloc(x->inChans * sizeof(double));
    x->indexList = (long *) malloc(x->inChans * sizeof(long));
    x->advFrac = (double)(x->outChans - 1)/(double)(x->inChans - 1);
    
    for(i = 1; i < x->inChans - 1; i++){
        fullFrac = i * x->advFrac;
        outIndex = floor(fullFrac);
        thisFrac = fullFrac - outIndex;
        panloc = thisFrac * x->pio2;
        x->indexList[i] = outIndex;
        x->pangains1[i] = cos(panloc);
        x->pangains2[i] = sin(panloc);
    }
    return x;
}
Exemplo n.º 7
0
void *errfilt_new(int order, float interp)
{
	t_errfilt *x = NULL;
	
	if (order == 0)
	{
		error("mbc.errfilt~: must specify filter order (this should match the order of mbc.lpc~ and mbc.allpole~)");
		return NULL;
	}
	
	if (x = (t_errfilt *)object_alloc(errfilt_class)) 
	{
		dsp_setup((t_pxobject *)x,3);
		outlet_new(x, "signal");
		
		if (order < 1) {
			error("mbc.errfilt~: mbc.errfilt~ needs a positive integer value for order");
			order = 1;
		} else if (order > 199) {
			error("mbc.errfilt~: max order is 199");
			order = 199;
		}
		
		x->a_order = order;
		x->a_interp = interp;
		errfilt_init(x);
	}
	
    return (x);
}
Exemplo n.º 8
0
void *pvcompand_new(t_symbol *s, int argc, t_atom *argv)
{
#if MSP
  t_pvcompand *x = (t_pvcompand *)newobject(pvcompand_class);
  dsp_setup((t_pxobject *)x,2);
  outlet_new((t_pxobject *)x, "signal");
#endif

#if PD
    t_pvcompand *x = (t_pvcompand *)pd_new(pvcompand_class);
    inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("signal"), gensym("signal"));
    outlet_new(&x->x_obj, gensym("signal"));
#endif

  // INITIALIZATIONS
  x->D  = sys_getblksize();
  x->R = sys_getsr();
  x->max_atten = atom_getfloatarg(0,argc,argv);
  x->overlap = atom_getfloatarg(1,argc,argv);
  x->winfac = atom_getfloatarg(2,argc,argv);
  if(!x->max_atten)
  	x->max_atten = -6;

  if(x->D <= 0)
  	x->D = 256;
  if(x->R <= 0)
  	x->R = 44100;

   pvcompand_init(x,0);
  return (x);
}
Exemplo n.º 9
0
// Create
void *audiosend_new(t_symbol *s, long argc, t_atom *argv)
{
    long			attrstart = attr_args_offset(argc, argv);		// support normal arguments
    t_audiosend 	*x = (t_audiosend *)object_alloc(s_audiosend_class);
    short			i;

    if (x) {
        x->dumpout = outlet_new(x, NULL);
        object_obex_store(x, _sym_dumpout, (t_object *)x->dumpout);

        x->attr_target = _sym_nothing;
        x->num_inputs = 2;		// TODO: make this dynamic from args

        for (i=0; i<attrstart; i++) {
            if (argv[i].a_type == A_LONG)
                x->num_inputs = atom_getlong(argv+i);
            else if (argv[i].a_type == A_SYM)
                x->attr_target = atom_getsym(argv+i);
        }

        dsp_setup((t_pxobject *)x, x->num_inputs);
        x->obj.z_misc = Z_NO_INPLACE;
        attr_args_process(x, argc, argv);					// handle attribute args
    }
    return x;
}
Exemplo n.º 10
0
void *ether_new(t_symbol *s, int argc, t_atom *argv)
{

#if MSP
  t_ether 	*x = (t_ether *) newobject(ether_class);
  dsp_setup((t_pxobject *)x,3);
  outlet_new((t_pxobject *)x, "signal");
#endif
#if PD
  t_ether *x = (t_ether *)pd_new(ether_class);
  /* add two additional signal inlets */
  inlet_new(&x->x_obj, &x->x_obj.ob_pd,gensym("signal"), gensym("signal"));
  inlet_new(&x->x_obj, &x->x_obj.ob_pd,gensym("signal"), gensym("signal"));
  outlet_new(&x->x_obj, gensym("signal"));
#endif

/* optional arguments: overlap winfac */
	
  x->overlap = atom_getfloatarg(0,argc,argv);
  x->winfac = atom_getfloatarg(1,argc,argv);
  if(!power_of_two(x->overlap)){
    x->overlap = 4;
  }
  if(!power_of_two(x->winfac)){
    x->winfac = 1;
  }
  x->vs = sys_getblksize();
  x->R = sys_getsr();
  ether_init(x,0);
  
  return (x);
}
Exemplo n.º 11
0
void *bthresher_new(t_symbol *s, int argc, t_atom *argv)
{
#if MSP
  t_bthresher *x = (t_bthresher *)newobject(bthresher_class);
  x->list_outlet = listout((t_pxobject *)x);
  dsp_setup((t_pxobject *)x,3);
  outlet_new((t_pxobject *)x, "signal");
#endif

#if PD
    t_bthresher *x = (t_bthresher *)pd_new(bthresher_class);
    inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("signal"), gensym("signal"));
    inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("signal"), gensym("signal"));
    outlet_new(&x->x_obj, gensym("signal"));
    x->list_outlet = outlet_new(&x->x_obj,gensym("list"));
#endif


  x->D = sys_getblksize();
  x->R = sys_getsr();
  
  x->init_thresh = atom_getfloatarg(0,argc,argv);
  x->init_damping = atom_getfloatarg(1,argc,argv);
  x->overlap = atom_getintarg(2,argc,argv);
  x->winfac = atom_getintarg(3,argc,argv);
  
  bthresher_init(x,0);
  


  return (x);
}
Exemplo n.º 12
0
/* an entry point for an address book or the like */
void dialer_dial( char * number )
{
    int x = 0;
    int ret;
    dsp_st dspz;

    if( !number ) return;

#ifdef __linux__
    ret = dsp_open(&dspz, DSP_LINEOUT);
    if( ret < 0 ) {
        pz_error( "/dev/dsp" );
        return;
    }
    ret = dsp_setup(&dspz, 1, 44100);
#else
    ret = ret;
#endif

    while ( number[x] != '\0' )
    {
        dtmf_play( &dspz, number[x++] );
    }

#ifdef __linux__
    dsp_close(&dspz);
#endif
}
Exemplo n.º 13
0
void *shapee_new(t_symbol *s, int argc, t_atom *argv)
{
			
#if MSP
  t_shapee 	*x = (t_shapee *) newobject(shapee_class);
  dsp_setup((t_pxobject *)x, 3);
  outlet_new((t_pxobject *)x, "signal");
#endif
#if PD
  t_shapee *x = (t_shapee *)pd_new(shapee_class);
  inlet_new(&x->x_obj, &x->x_obj.ob_pd,gensym("signal"), gensym("signal"));
  inlet_new(&x->x_obj, &x->x_obj.ob_pd,gensym("signal"), gensym("signal"));
  outlet_new(&x->x_obj, gensym("signal"));
#endif

/* INITIALIZATIONS */
  x->overlap = atom_getfloatarg(0,argc,argv);
  x->winfac = atom_getfloatarg(1,argc,argv);
  if(!x->winfac)	
	x->winfac = 1;
  if(!x->overlap)
	x->overlap = 4;
  x->vs = sys_getblksize();
  x->R = sys_getsr();
  shapee_init(x,0); 

  return (x);
}
Exemplo n.º 14
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);
		TTObjectInstantiate(TT("balance"), &x->balance, x->maxNumChannels);
		TTObjectInstantiate(TT("audiosignal"), &x->audioIn, x->maxNumChannels*2);
		TTObjectInstantiate(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
}
Exemplo n.º 15
0
void *leaker_new(t_symbol *msg, short argc, t_atom *argv)
{
#if MSP
  t_leaker *x = (t_leaker *)newobject(leaker_class);
  dsp_setup((t_pxobject *)x,3);
  outlet_new((t_pxobject *)x, "signal");
#endif

#if PD
  t_leaker *x = (t_leaker *)pd_new(leaker_class);
  inlet_new(&x->x_obj, &x->x_obj.ob_pd,gensym("signal"), gensym("signal"));
  inlet_new(&x->x_obj, &x->x_obj.ob_pd,gensym("signal"), gensym("signal"));
  outlet_new(&x->x_obj, gensym("signal"));
#endif

  x->D = sys_getblksize();
  x->R = sys_getsr();
  if(!x->D)
    x->D = 256;
  if(!x->R)
    x->R = 44100;

  x->overlap = atom_getfloatarg(0,argc,argv);
  x->winfac = atom_getfloatarg(1,argc,argv);
  if(!x->overlap)
    x->overlap = 4;
  if(!x->winfac)
    x->winfac = 1;

  leaker_init(x,0);	
  return (x);
}
Exemplo n.º 16
0
/********************************************************************************
void *grainstream_new(double initial_pos)

inputs:			*snd		-- name of buffer holding sound
				*win		-- name of buffer holding window
description:	called for each new instance of object in the MAX environment;
		defines inlets and outlets; sets variables and buffers
returns:		nothing
********************************************************************************/
void *grainstream_new(t_symbol *snd, t_symbol *win)
{
	t_grainstream *x = (t_grainstream *) object_alloc((t_class*) grainstream_class);
	dsp_setup((t_pxobject *)x, 4);					// four inlets
    outlet_new((t_pxobject *)x, "signal");          // sample count outlet
    outlet_new((t_pxobject *)x, "signal");			// signal ch2 outlet
    outlet_new((t_pxobject *)x, "signal");			// signal ch1 outlet
	
	/* set buffer names */
	x->snd_sym = snd;
	x->win_sym = win;
	
	/* zero pointers */
	x->snd_buf_ptr = x->next_snd_buf_ptr = NULL;
	x->win_buf_ptr = x->next_win_buf_ptr = NULL;
	
	/* setup variables */
	x->grain_freq = x->next_grain_freq = 20.0;
	x->grain_pos_start = x->next_grain_pos_start = 0.0;
    x->grain_pitch = x->next_grain_pitch = 1.0;
    x->grain_gain = x->next_grain_gain = 1.0;
	x->win_step_size = x->snd_step_size = 0.0;
	x->curr_win_pos = x->curr_snd_pos = 0.0;
	
	/* set flags to defaults */
	x->snd_interp = INTERP_ON;
	x->win_interp = INTERP_ON;
	x->grain_direction = x->next_grain_direction = FORWARD_GRAINS;
	
	x->x_obj.z_misc = Z_NO_INPLACE;
	
	/* return a pointer to the new object */
	return (x);
}
Exemplo n.º 17
0
/********************************************************************************
void *gverb_new(double d)

inputs:			void
description:	called for each new instance of object in the MAX environment;
		defines inlets and outlets; 
returns:		nothing
********************************************************************************/
void *gverb_new(double d)
{
	t_gverb *x = (t_gverb *)object_alloc((t_class*) gverb_class);
	
	dsp_setup((t_pxobject *)x, 2);					// two inlets
	outlet_new((t_pxobject *)x, "signal");			// left outlet
	outlet_new((t_pxobject *)x, "signal");			// right outlet
	
	/* setup variables */
	x->verb_decay = d > 0.0 ? d : 1000.0;
	x->verb_decay_1over = d > 0.0 ? 1.0 / d : 0.001;
	
	// get sample rate info
	x->output_sr = sys_getsr();
	x->output_msr = x->output_sr * 0.001;
	x->output_1overmsr = 1.0 / x->output_msr;
	
	// initialize square injection value
	x->sqinject_val = TINY_DC;
	
	x->verb_decay_coeff = 
			pow(10.0, (-16416.0 * x->verb_decay_1over * x->output_1overmsr));
	
	gverb_init(x);
	
	x->x_obj.z_misc = Z_NO_INPLACE;
    
    #ifdef DEBUG
        post("%s: new function was called", OBJECT_NAME);
    #endif /* DEBUG */
	
	/* return a pointer to the new object */
	return (x);
}
Exemplo n.º 18
0
void *HoaSevenDotOne_new(t_symbol *s, long argc, t_atom *argv)
{
	t_HoaSevenDotOne *x = NULL;
	int order = 4;
	double anAngle1 = 30.;
	double anAngle2 = 110.;
	if (x = (t_HoaSevenDotOne *)object_alloc((t_class*)HoaSevenDotOne_class)) 
	{
		if(atom_gettype(argv) == A_LONG)
			order	= atom_getlong(argv);
		if(atom_gettype(argv+1) == A_LONG)
			anAngle1	= atom_getlong(argv+1);
		else if(atom_gettype(argv+1) == A_FLOAT)
			anAngle1	= atom_getfloat(argv+1);
		if(atom_gettype(argv+2) == A_LONG)
			anAngle2	= atom_getlong(argv+2);
		else if(atom_gettype(argv+2) == A_FLOAT)
			anAngle2	= atom_getfloat(argv+2);

		x->f_AmbisonicSixDotOne	= new AmbisonicSixDotOne(order, anAngle1, anAngle2, sys_getblksize());
		
		dsp_setup((t_pxobject *)x, x->f_AmbisonicSixDotOne->getNumberOfInputs());
		for (int i = 0; i < x->f_AmbisonicSixDotOne->getNumberOfOutputs(); i++) 
			outlet_new(x, "signal");
		
	
	}
	return (x);
}
void *ibufconcatenate_new (t_symbol *buffer_name, long max_mode)
{
    t_ibufconcatenate *x = (t_ibufconcatenate *)object_alloc (this_class);
	
	x->last_added_out = listout(x);

	if (!max_mode)
	{
		dsp_setup((t_pxobject *)x, 1);
		outlet_new((t_object *)x, "signal");
		outlet_new((t_object *)x, "signal");
		outlet_new((t_object *)x, "signal");
		outlet_new((t_object *)x, "signal");
	}
	else
	{
		x->data_out = listout(x);
	}
	
	x->attachment = new_ibufconcatenate_info(buffer_name);
	
	if (!x->attachment)
		return 0;
	
	x->max_mode = max_mode;
	
	return(x);
}
Exemplo n.º 20
0
void *HoaRecomposer_new(t_symbol *s, long argc, t_atom *argv)
{
	t_HoaRecomposer *x = NULL;
    t_dictionary *d;
	int order = 4, inputs = 10;
    x = (t_HoaRecomposer *)object_alloc((t_class*)HoaRecomposer_class);
	if (x)
	{
		if(atom_gettype(argv) == A_LONG)
			order	= atom_getlong(argv);
		if(atom_gettype(argv+1) == A_LONG)
			inputs	= atom_getlong(argv+1);
        
        /* Base Attributes */
        
		x->f_ambiRecomposer	= new AmbisonicRecomposer(order, inputs, Hoa_Fixe, sys_getblksize(), sys_getsr());
        x->f_ambiRecomposer->setRampInMs(20.);
        
        x->f_ramp_time = x->f_ambiRecomposer->getRampInMs();
        x->f_mode = gensym("fixe");
        
		dsp_setup((t_pxobject *)x, x->f_ambiRecomposer->getNumberOfInputs());
		for (int i = 0; i < x->f_ambiRecomposer->getNumberOfOutputs(); i++)
			outlet_new(x, "signal");
        
		x->f_ob.z_misc = Z_NO_INPLACE;
        
        attr_args_process(x, argc, argv);
        d = (t_dictionary *)gensym("#D")->s_thing;
        if (d) attr_dictionary_process(x, d);
        object_attr_setdisabled((t_object *)x, gensym("ramp"), (x->f_mode == gensym("fixe")) ? 1 : 0);
	}
	return (x);
}
Exemplo n.º 21
0
void *radians_new(t_symbol *msg, short argc, t_atom *argv)
{
	t_atom_long myArg = 0;
	long attrstart;	
	t_radians *x;
	
	attrstart = attr_args_offset(argc, argv);
	if(attrstart && argv)
		atom_arg_getlong(&myArg, 0, attrstart, argv);	// support a normal int argument for bwc	
	
	x = (t_radians *)object_alloc(radians_class);;
	if(x){
		object_obex_store((void *)x, _sym_dumpout, (object *)outlet_new(x,NULL));	// dumpout
		dsp_setup((t_pxobject *)x,1);
		x->radians_out = floatout(x);					// Create a floating-point Outlet
		outlet_new((t_object *)x, "signal");
		
		x->tt = new tt_audio_base;				// Create object for performing radian conversions
		x->tt->set_sr(sys_getsr());
		
		x->radians_mode = myArg;					// default mode

		attr_args_process(x, argc, argv); 			//handle attribute args			
		
	}
	return (x);
}
Exemplo n.º 22
0
void *cabasa_new(double initial_coeff)
{
	int i;
	
	    //user controlled vars	    
	float coeffs[2];

    t_cabasa *x = (t_cabasa *)newobject(cabasa_class);
    //zero out the struct, to be careful (takk to jkclayton)
    if (x) { 
        for(i=sizeof(t_pxobject);i<sizeof(t_cabasa);i++)  
                ((char *)x)[i]=0; 
	} 
    dsp_setup((t_pxobject *)x,4);
    outlet_new((t_object *)x, "signal");
    
    x->srate = sys_getsr();
    x->one_over_srate = 1./x->srate;

	x->shakeEnergy = 0.0;
	for(i=0; i<2; i++) {
		x->output[i] = 0.;
	}
	x->input = 0.0;
	x->sndLevel = 0.0;
    
    cabasa_setup(x);
    
    srand(0.54);
    
    return (x);
}
void *hoa_projector_new(t_symbol *s, long argc, t_atom *argv)
{
	// @arg 0 @name ambisonic-order @optional 0 @type int @digest The ambisonic order of decomposition
	// @description First argument is the ambisonic order of decomposition.
	
	// @arg 1 @name number-of-channels @optional 0 @type int @digest The number of channels
	// @description Second argument sets the number of channels.
    
	t_hoa_projector *x = NULL;
    x = (t_hoa_projector *)object_alloc(hoa_projector_class);
	if (x)
	{
        ulong order = 1;
        ulong numberOfPlanewaves = 4;
        
		if(argc && atom_gettype(argv) == A_LONG)
			order = max<long>(atom_getlong(argv), 1);
        
        if(argc > 1 && atom_gettype(argv+1) == A_LONG)
			numberOfPlanewaves = max<long>(atom_getlong(argv+1), order * 2 + 1);
		
		x->f_projector = new Projector<Hoa2d, t_sample>(order, numberOfPlanewaves);
		
		dsp_setup((t_pxobject *)x, x->f_projector->getNumberOfHarmonics());
		for (int i = 0; i < x->f_projector->getNumberOfPlanewaves(); i++)
			outlet_new(x, "signal");
        
        x->f_ins = new t_sample[x->f_projector->getNumberOfHarmonics() * HOA_MAXBLKSIZE];
        x->f_outs = new t_sample[x->f_projector->getNumberOfPlanewaves() * HOA_MAXBLKSIZE];
	}

	return (x);
}
Exemplo n.º 24
0
void *thresher_new(t_symbol *s, int argc, t_atom *argv)
{
#if MSP
	t_thresher *x = (t_thresher *)newobject(thresher_class);
	dsp_setup((t_pxobject *)x,3);
	outlet_new((t_pxobject *)x, "signal");
#endif
	
#if PD
    t_thresher *x = (t_thresher *)pd_new(thresher_class);
    inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("signal"), gensym("signal"));
    inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("signal"), gensym("signal"));
    outlet_new(&x->x_obj, gensym("signal"));
#endif
	
	
	x->move_threshold = atom_getfloatarg(0, argc, argv);
	x->damping_factor = atom_getfloatarg(1, argc, argv);
	x->overlap = atom_getfloatarg( 2, argc, argv );
	x->winfac = atom_getfloatarg( 3, argc, argv );
	
//	post("thresh %f damper %f overlap %d winfac %d", x->move_threshold, x->damping_factor, x->overlap, x->winfac);

	/* if overlap is zero we crash so should protect against bad input parameters*/

	x->D = sys_getblksize();
	x->R = sys_getsr();
	
	thresher_init(x,0);
	return (x);
}
Exemplo n.º 25
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;
}
Exemplo n.º 26
0
// instantiate the object
void *jitter_new(double flag, double a)
{
    post("flag: %f; a-flag: %f", flag, a);
    
    t_jitter *x = (t_jitter *)object_alloc(jitter_class);
    if (x) {
        dsp_setup((t_pxobject *)x,1);
        outlet_new((t_pxobject *)x, "signal");
        x->range = 0.0; // initialize argument
        x->jitter = 0.0;
        
        // if the arguments are there check them and set them
        if (flag) x->range = flag;
        if (x->range<=0.0) x->range=0.0;
        if (x->range>65535) x->range=65535;

        if (a) {
            x->aflag = (long)a;
        } else {
            x->aflag = 0;
        }
        
        if (x->aflag<0) x->aflag = 0;
        if (x->aflag>1) x->aflag = 1;
    }

    return (x);
}
Exemplo n.º 27
0
void *crossx_new(t_symbol *s, int argc, t_atom *argv)
{
#if MSP
  t_crossx *x = (t_crossx *)newobject(crossx_class);
  dsp_setup((t_pxobject *)x,3);
  outlet_new((t_pxobject *)x, "signal");
#endif
#if PD
  t_crossx *x = (t_crossx *)pd_new(crossx_class);
  inlet_new(&x->x_obj, &x->x_obj.ob_pd,gensym("signal"), gensym("signal"));
  inlet_new(&x->x_obj, &x->x_obj.ob_pd,gensym("signal"), gensym("signal"));
  outlet_new(&x->x_obj, gensym("signal"));
#endif


  x->overlap = atom_getfloatarg(0,argc,argv);
  x->winfac = atom_getfloatarg(1,argc,argv);
  if(x->overlap <= 0)
    x->overlap = 4;

  x->winfac = 1;
    
  x->R = sys_getsr();
  x->vs = sys_getblksize();

  crossx_init(x,0);
  return (x);
}
Exemplo n.º 28
0
static void *teabox_new(t_symbol *s, long ac, t_atom *at)
{
    t_teabox *x;
    short i;

#ifdef PD
    if ((x = (t_teabox *)pd_new(teabox_class)))
    {
        for(i=0; i<9; i++) {
            outlet_new(&x->obj, gensym("signal"));	// Create new signal outlet
            x->data[i] = 0;							// Init this element of the data array
        }
        x->outlet = outlet_new(&x->obj, gensym("anything"));	// create the status/version outlet

        x->counter = 0;								// init member values
        x->hw_version = 0;
    }
#else
    if ((x = (t_teabox *)object_alloc(teabox_class)))
    {
        dsp_setup((t_pxobject *)x,1);

        x->outlet = outlet_new(x, 0L);				// create the status/version outlet
        for(i=0; i<9; i++) {
            outlet_new((t_object *)x, "signal");	// Create new signal outlet
            x->data[i] = 0;							// Init this element of the data array
        }

        x->counter = 0;								// init member values
        x->hw_version = 0;
    }
#endif
    return(x);									// return the pointer to our instance
}
Exemplo n.º 29
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
}
Exemplo n.º 30
0
void *hoa_optim_new(t_symbol *s, long argc, t_atom *argv)
{
	t_hoa_optim *x = NULL;
	int	order = 1;
    x = (t_hoa_optim *)object_alloc(hoa_optim_class);
	if (x)
	{		
		if(atom_gettype(argv) == A_LONG)
			order = atom_getlong(argv);
        
        x->f_optim = new Hoa3D::Optim(order, Hoa3D::Optim::InPhase);
        
        if(argc > 1 && atom_gettype(argv+1) == A_SYM)
        {
            if(atom_getsym(argv+1) == gensym("maxRe"))
                x->f_optim->setMode(Hoa3D::Optim::MaxRe);
            else if(atom_getsym(argv+1) == gensym("basic"))
                x->f_optim->setMode(Hoa3D::Optim::Basic);
        }
		
		dsp_setup((t_pxobject *)x, x->f_optim->getNumberOfHarmonics());
		for (int i = 0; i < x->f_optim->getNumberOfHarmonics(); i++)
			outlet_new(x, "signal");
        
        x->f_signals =  new double[x->f_optim->getNumberOfHarmonics() * SYS_MAXBLKSIZE];
	}
	return (x);
}