Exemple #1
0
void *HoaOptim_new(t_symbol *s, long argc, t_atom *argv)
{
	t_HoaOptim *x = NULL;
    t_dictionary *d = NULL;
	int order = 4;
    
    x = (t_HoaOptim *)object_alloc(HoaOptim_class);
	if (x)
	{
		if(atom_gettype(argv) == A_LONG)
			order	= atom_getlong(argv);
        
        x->f_optim_mode = gensym("inPhase");
		x->f_AmbisonicsOptim	= new AmbisonicOptim(order, Hoa_InPhase_Optim, sys_getblksize());
		
		dsp_setup((t_pxobject *)x, x->f_AmbisonicsOptim->getNumberOfInputs());
		for (int i = 0; i < x->f_AmbisonicsOptim->getNumberOfOutputs(); i++) 
			outlet_new(x, "signal");
		
		x->f_ob.z_misc = Z_NO_INPLACE;
        
        d = (t_dictionary *)gensym("#D")->s_thing;
        if (d) attr_dictionary_process(x, d);
        attr_args_process(x, argc, argv);
	}
	return (x);
}
Exemple #2
0
void *space_new(t_symbol *s, int argc, t_atom *argv)
{
	t_space *x =  NULL; 
	t_dictionary *d;
	long flags;
	
	if (!(d = object_dictionaryarg(argc,argv)))
		return NULL;

	x = (t_space *)object_alloc(space_class);
	flags = 0 
			| JBOX_DRAWFIRSTIN 
			| JBOX_DRAWINLAST
			| JBOX_TRANSPARENT	
			| JBOX_GROWY
			;
    
	x->f_viewer				= new AmbisonicViewer(1);
    x->f_recomposer         = new ambisonicRecomposer(1, 3);
    
	jbox_new((t_jbox *)x, flags, argc, argv);
	x->j_box.b_firstin = (t_object *)x;

    x->f_out        = listout(x);

	attr_dictionary_process(x, d);
	jbox_ready((t_jbox *)x);

	return (x);
}			
Exemple #3
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);
}
Exemple #4
0
t_uisimp* uisimp_new(t_symbol *s, long argc, t_atom *argv)
{
	t_uisimp* x = NULL;
	t_max_err err = MAX_ERR_GENERIC;
	t_dictionary *d;
	long flags;
	
	if (!(d=object_dictionaryarg(argc,argv)))
		return NULL;

	x = (t_uisimp*) object_alloc(s_uisimp_class);
	flags = 0 
			| JBOX_DRAWFIRSTIN 
	//		| JBOX_NODRAWBOX
			| JBOX_DRAWINLAST
			| JBOX_TRANSPARENT	
	//		| JBOX_NOGROW
	//		| JBOX_GROWY
			| JBOX_GROWBOTH
	//		| JBOX_HILITE
	//		| JBOX_BACKGROUND
	//		| JBOX_TEXTFIELD
			| JBOX_DRAWBACKGROUND
			;

	err = jbox_new(&x->j_box, flags, argc, argv); 

	x->j_box.b_firstin = (t_object*) x;

	attr_dictionary_process(x, d);
	jbox_ready(&x->j_box);

	return x;
}
Exemple #5
0
void *uisimp_new(t_symbol *s, long argc, t_atom *argv)
{
	t_uisimp *x = NULL;
	t_dictionary *d = NULL;
	long boxflags;

	if (!(d = object_dictionaryarg(argc,argv)))
		return NULL;

	x = (t_uisimp *)object_alloc(s_uisimp_class);
	boxflags = 0
			   | JBOX_DRAWFIRSTIN
			   | JBOX_NODRAWBOX
			   | JBOX_DRAWINLAST
			   | JBOX_TRANSPARENT
			   //		| JBOX_NOGROW
			   | JBOX_GROWY
			   //		| JBOX_GROWBOTH
			   //		| JBOX_HILITE
			   //		| JBOX_BACKGROUND
			   | JBOX_DRAWBACKGROUND
			   //		| JBOX_NOFLOATINSPECTOR
			   //		| JBOX_TEXTFIELD
			   //		| JBOX_MOUSEDRAGDELTA
			   //		| JBOX_TEXTFIELD
			   ;

	jbox_new((t_jbox *)x, boxflags, argc, argv);
	x->u_box.b_firstin = (void *)x;
	x->u_mousedowninside = x->u_mouseover = x->u_state = 0;
	x->u_out = intout((t_object *)x);
	attr_dictionary_process(x,d);
	jbox_ready((t_jbox *)x);
	return x;
}
Exemple #6
0
void *space_new(t_symbol *s, int argc, t_atom *argv)
{
	t_space *x =  NULL; 
	t_dictionary *d;
	long flags;
	
	if (!(d = object_dictionaryarg(argc,argv)))
		return NULL;

	x = (t_space *)object_alloc(space_class);
	flags = 0 
			| JBOX_DRAWFIRSTIN 
			| JBOX_DRAWINLAST
			| JBOX_TRANSPARENT	
			| JBOX_GROWY
			;
    x->f_number_of_microphones_initialized = false;

	x->f_viewer				= new AmbisonicViewer(1);
    x->f_recomposer         = new ambisonicRecomposer(1, 3);
    
	jbox_new((t_jbox *)x, flags, argc, argv);
	x->j_box.b_firstin = (t_object *)x;

	x->f_outInfos	= outlet_new(x, NULL);
    x->f_out        = listout(x);
    dictionary_getfloat(d, gensym("coeffs"), x->f_microphonesValues);
	attr_dictionary_process(x, d);
	jbox_ready((t_jbox *)x);

	return (x);
}			
Exemple #7
0
void *hoa_space_new(t_symbol *s, int argc, t_atom *argv)
{
    t_hoa_space *x = NULL;
    t_dictionary *d;
	long flags;
    long defc;
    t_atom *defv;
    x = (t_hoa_space *)object_alloc(hoa_space_class);
    if (x)
    {
        if (!(d = object_dictionaryarg(argc,argv)))
            return NULL;
        flags = 0
            | JBOX_DRAWFIRSTIN
            | JBOX_DRAWINLAST
            | JBOX_TRANSPARENT
            | JBOX_GROWY
            | JBOX_DRAWBACKGROUND
        ;
        
        jbox_new((t_jbox *)x, 1, argc, argv);
        
        x->j_box.b_firstin = (t_object *)x;
        
        
        
        x->f_viewer                 = new AmbisonicViewer(1);
        x->f_recomposer             = new AmbisonicRecomposer(1, 4);
        x->f_out                    = listout(x);
        x->f_number_of_microphones  = 4;
        x->f_new_number             = 4;
        
        x->f_defer             = clock_new(x, (t_method)hoa_space_do_channels_set);
        
        attr_dictionary_process(x, d);
        
        binbuf_copy_atoms(d, gensym("@channels"), &defc, &defv);
        if(defc && defv)
        {
            x->f_new_number = Tools::clip(long(atom_getlong(defv)), (long)3, (long)MAX_CHANNELS);
            hoa_space_do_channels_set(x);
            defc = 0;
            free(defv);
            defv = NULL;
        }
        binbuf_copy_atoms(d, gensym("@coeffs"), &defc, &defv);
        if(defc && defv)
        {
            hoa_space_coefficients_set(x, NULL, defc, defv);
            defc = 0;
            free(defv);
            defv = NULL;
        }
        
        jbox_ready((t_jbox *)x);
    }
    return (x);
}
Exemple #8
0
void *hoa_meter_new(t_symbol *s, long argc, t_atom *argv)
{
	t_hoa_meter *x    = NULL;
 	t_dictionary *d = NULL;
	long flags;
    
	if (!(d = object_dictionaryarg(argc,argv)))
		return NULL;
    
	x = (t_hoa_meter *)object_alloc(hoa_meter_class);
	flags = 0
    | JBOX_DRAWFIRSTIN
    | JBOX_NODRAWBOX
    | JBOX_DRAWINLAST
    | JBOX_TRANSPARENT
    | JBOX_GROWY
    | JBOX_DRAWBACKGROUND
    ;
    
	jbox_new((t_jbox *)x, flags, argc, argv);
    x->j_box.j_box.z_box.b_firstin = (t_object *)x;
    
    dictionary_getlong(d, gensym("loudspeakers"), (t_atom_long *)&x->f_number_of_loudspeakers);
    x->f_meter      = new Hoa3D::Meter(x->f_number_of_loudspeakers, 100, 199);
    x->f_number_of_loudspeakers      = x->f_meter->getNumberOfLoudspeakers();
    x->f_signals    = new double[x->f_meter->getNumberOfLoudspeakers() * SYS_MAXBLKSIZE];
    x->f_clock      = clock_new((void *)x, (method)hoa_meter_tick);
    x->f_startclock = 0;
    x->f_number_of_leds = 13;
    x->f_leds_coordinates = new double***[100];

    double azimuth, elevation, radius;
    for(int i = 0; i < 100; i++)
    {
        elevation = (double)i / 100. * CICM_PI - CICM_PI2;
        x->f_leds_coordinates[i] = new double**[199];
        for(int j = 0; j < 199; j++)
        {
            azimuth = (double)j / 199. * CICM_2PI;
            x->f_leds_coordinates[i][j] = new double*[x->f_number_of_leds];
            for(int k = 0; k < x->f_number_of_leds; k++)
            {
                radius = (k + 1) / (double)x->f_number_of_leds;
                x->f_leds_coordinates[i][j][k] = new double[3];
                x->f_leds_coordinates[i][j][k][0] = Hoa3D::abscissa(radius, azimuth, elevation);
                x->f_leds_coordinates[i][j][k][1] = Hoa3D::ordinate(radius, azimuth, elevation);
                x->f_leds_coordinates[i][j][k][2] = Hoa3D::height(radius, azimuth, elevation);
            }
        }
    }
    
    dsp_setupjbox((t_pxjbox *)x, x->f_meter->getNumberOfLoudspeakers());
	jucebox_new((t_jucebox *) x);
    
	attr_dictionary_process(x,d);
	jbox_ready((t_jbox *)x);
	return x;
}
void *hoa_gain_new(t_symbol *s, short argc, t_atom *argv)
{
    t_hoa_gain *x = NULL;
    t_dictionary *d = NULL;
    
    x = (t_hoa_gain *) object_alloc(s_hoa_gain_class);
    d = object_dictionaryarg(argc, argv);
    
    if (x && d)
    {
        long flags = 0
        | JBOX_DRAWFIRSTIN
        | JBOX_NODRAWBOX
        | JBOX_DRAWINLAST
        | JBOX_GROWBOTH
        | JBOX_DRAWBACKGROUND
        | JBOX_MOUSEDRAGDELTA
        ;
        
        x->j_val = 0;
        x->j_defaultValuedB = 0;
        x->j_valdB = x->j_defaultValuedB;
        x->f_interp = 20;
        x->f_number_of_channels = 8;
        
        jbox_new((t_jbox *)x, flags, argc, argv);
        x->j_box.z_box.b_firstin = (t_object *)x;
        
        x->f_amp = new Line<t_sample>();
        x->f_amp->setRamp((const ulong)(0.1 * sys_getsr()));
        x->f_amp->setValueDirect(1.f);
        
        // inputs
        dsp_setupjbox((t_pxjbox *)x, x->f_number_of_channels + 1);
        
        // outputs
        x->f_outlet_infos = outlet_new(x, NULL);
        for (int i=0; i < x->f_number_of_channels; i++)
            outlet_new(x,"signal");
        
        x->j_box.z_misc = Z_NO_INPLACE;
        
        attr_dictionary_process(x,d); // handle attribute args
        
        hoa_gain_set_dB(x, x->j_defaultValuedB);
        
        jbox_ready((t_jbox *)x);
    }
    
    return x;
}
Exemple #10
0
void *hoa_decoder_new(t_symbol *s, long argc, t_atom *argv)
{
	t_hoa_decoder *x = NULL;
    t_dictionary *d = NULL;
    t_dictionary *attr = NULL;
    t_atom_long channels;
    t_symbol*   mode;
	int	order = 1;
    x = (t_hoa_decoder *)object_alloc(hoa_decoder_class);
	if (x)
	{
		if(atom_gettype(argv) == A_LONG)
			order = atom_getlong(argv);
		if(order < 1)
            order = 1;
    
        x->f_decoder    = new Hoa2D::DecoderMulti(order);
        x->f_decoder->setSampleRate(sys_getsr());
        x->f_decoder->setVectorSize(sys_getblksize());
        
        d = (t_dictionary *)gensym("#D")->s_thing;
        if(d && dictionary_getdictionary(d, gensym("saved_object_attributes"), (t_object **)&attr) == MAX_ERR_NONE)
        {
            if(dictionary_getsym(attr, gensym("mode"), &mode) == MAX_ERR_NONE)
            {
                if(mode == gensym("irregular"))
                    x->f_decoder->setDecodingMode(Hoa2D::DecoderMulti::Irregular);
                else if(mode == gensym("binaural"))
                    x->f_decoder->setDecodingMode(Hoa2D::DecoderMulti::Binaural);
                else
                    x->f_decoder->setDecodingMode(Hoa2D::DecoderMulti::Regular);
            }
            if(dictionary_getlong(attr, gensym("channels"), &channels) == MAX_ERR_NONE)
                x->f_decoder->setNumberOfChannels(channels);
            dictionary_getlong(attr, gensym("autoconnect"), &x->f_send_config);
        }
       
		dsp_setup((t_pxobject *)x, x->f_decoder->getNumberOfHarmonics());
        for(int i = 0; i < x->f_decoder->getNumberOfChannels(); i++)
            outlet_new(x, "signal");
        
        x->f_ob.z_misc = Z_NO_INPLACE;
        x->f_ins = new double[x->f_decoder->getNumberOfHarmonics() * SYS_MAXBLKSIZE];
        x->f_outs= new double[MAX_CHANNELS * SYS_MAXBLKSIZE];
        
        if(d)
            attr_dictionary_process(x, d);
	}

	return (x);
}
Exemple #11
0
void *rd_new(t_symbol *msg, int argc, t_atom *argv){
	t_rd *x;
    
 	t_dictionary *d = NULL; 
 	long boxflags; 
    
	// box setup 
	if(!(d = object_dictionaryarg(argc, argv))){ 
		return NULL; 
	} 
    
	boxflags = 0 
		| JBOX_DRAWFIRSTIN 
		//| JBOX_NODRAWBOX
		| JBOX_DRAWINLAST
		//| JBOX_TRANSPARENT  
		//      | JBOX_NOGROW
		//| JBOX_GROWY
		| JBOX_GROWBOTH
		//      | JBOX_HILITE
		| JBOX_BACKGROUND
		| JBOX_DRAWBACKGROUND
		//      | JBOX_NOFLOATINSPECTOR
		//      | JBOX_MOUSEDRAGDELTA
		//      | JBOX_TEXTFIELD
		;

	if((x = (t_rd *)object_alloc(rd_class))){
		jbox_new((t_jbox *)x, boxflags, argc, argv); 
 		x->ob.b_firstin = (void *)x; 

		x->outlet = outlet_new(x, NULL);

		critical_new(&(x->lock));

		x->buffer_size = 1024 * 3;
		x->n = 0;
		x->buffer = (double *)calloc(x->buffer_size, sizeof(double));
		x->num_partials_selected = 0;
        
		attr_dictionary_process(x, d); 
		x->selection = (t_range){x->freqmin, x->freqmax};
 		jbox_ready((t_jbox *)x); 
        
		return x;
	}
	return NULL;
}
void *hoa_3d_scope_new(t_symbol *s, int argc, t_atom *argv)
{
    t_hoa_3d_scope *x =  NULL;
    t_dictionary *d;
    long flags;
    
    if(!(d = object_dictionaryarg(argc,argv)))
        return NULL;
    
    x = (t_hoa_3d_scope *)object_alloc(hoa_3d_scope_class);
    if (x && d)
    {
        flags = 0
        | JBOX_DRAWFIRSTIN
        | JBOX_DRAWINLAST
        | JBOX_NODRAWBOX
        | JBOX_DRAWBACKGROUND
        | JBOX_TRANSPARENT
        | JBOX_GROWY
        ;
        
        jbox_new((t_jbox *)x, flags, argc, argv);
        x->j_box.z_box.b_firstin = (t_object *)x;
        
        dictionary_getlong(d, gensym("order"), (t_atom_long *)&x->f_order);
        if(x->f_order < 1)
            x->f_order = 1;
        
        x->f_order      = 1;
        x->f_startclock = 0;
        x->f_scope      = new Scope<Hoa3d, t_sample>(x->f_order, (ulong)(HOA_DISPLAY_NPOINTS * 0.25), (ulong)(HOA_DISPLAY_NPOINTS * 0.5));
        x->f_order      = x->f_scope->getDecompositionOrder();
        x->f_signals    = new t_sample[x->f_scope->getNumberOfHarmonics() * HOA_MAXBLKSIZE];
        x->f_view[0] = x->f_view[1] = x->f_view[2] = 0.;
        
        dsp_setupjbox((t_pxjbox *)x, x->f_scope->getNumberOfHarmonics());
        
        x->f_clock = (t_clock*)clock_new(x,(method)hoa_3d_scope_tick);
        x->f_startclock = 0;
        
        attr_dictionary_process(x, d);
        jbox_ready((t_jbox *)x);
    }
    
    return (x);
}
Exemple #13
0
void *polywave_new(t_symbol *s, long argc, t_atom *argv)
{
    t_polywave *x = (t_polywave *)object_alloc(polywave_class);
    if(x)
    {
    	   
        x->buf_proxy = (t_buffer_proxy **)sysmem_newptr(POLYWAVE_MAX_BUFFERS * sizeof(t_buffer_proxy *));
        
        critical_new(&x->lock);
        
        int n = POLYWAVE_MAX_BUFFERS;
        while (--n) {
            x->buf_proxy[n] = NULL;
        }
        
        x->dims = ONE_D;
        x->interp_type = LINEAR;
        x->backup = x->interp_type;
        x->numbufs = 0;
        
        t_dictionary *d = NULL;
        d = dictionary_new();
        
        if (d) {
            attr_args_dictionary(d, argc, argv);
            attr_dictionary_process(x, d); //calls appropriate class_attr_accessors
            object_free(d);
        }
        
        int numlets = 0;
        switch (x->dims) {
            case ONE_D: numlets = 2; break;
            case TWO_D: numlets = 5; break;
            default:
                object_error((t_object *)x, "dimention attribute set to unknown value, cannont create inlets");
                break;
        }
        
        dsp_setup((t_pxobject *)x, numlets);
        outlet_new((t_object *)x, "signal");
    }
    return x;
}
void *meter_new(t_symbol *s, int argc, t_atom *argv)
{
    t_meter *x =  NULL;
    t_dictionary *d;
    long flags;
    
    if(!(d = object_dictionaryarg(argc, argv)))
        return NULL;
    
    x = (t_meter *)object_alloc(meter_class);
    flags = 0
    | JBOX_DRAWFIRSTIN
    | JBOX_NODRAWBOX
    | JBOX_DRAWINLAST
    | JBOX_TRANSPARENT
    | JBOX_DRAWBACKGROUND
    | JBOX_GROWY
    ;
    
    jbox_new((t_jbox *)x, flags, argc, argv);
    x->j_box.z_box.b_firstin = (t_object *)x;
    
    ulong channels = 4;
    dictionary_getlong(d, hoa_sym_channels, (t_atom_long *)&channels);
    if(channels < 1)
        channels = 1;
    
    x->f_meter  = new Meter<Hoa2d, t_sample>(channels);
    x->f_vector = new Vector<Hoa2d, t_sample>(channels);
    
    x->f_signals  = new t_sample[MAX_UI_CHANNELS * HOA_MAXBLKSIZE];
    x->f_meter->computeRendering();
    x->f_vector->computeRendering();
    
    dsp_setupjbox((t_pxjbox *)x, x->f_meter->getNumberOfPlanewaves());
    x->f_clock = (t_clock*)clock_new(x,(method)meter_tick);
    x->f_startclock = 0;
    
    attr_dictionary_process(x, d);
    jbox_ready((t_jbox *)x);
    
    return (x);
}
Exemple #15
0
void *scope_new(t_symbol *s, int argc, t_atom *argv)
{
	t_scope *x =  NULL; 
	t_dictionary *d;
	long flags;
	
	if (!(d = object_dictionaryarg(argc,argv)))
		return NULL;

	x = (t_scope *)object_alloc(scope_class);
	flags = 0 
			| JBOX_DRAWFIRSTIN 
			| JBOX_DRAWINLAST
            | JBOX_DRAWBACKGROUND
			| JBOX_TRANSPARENT	
			| JBOX_GROWY
			;
	jbox_new((t_jbox *)x, flags, argc, argv);
    
    x->f_order = 1;
    x->f_sampleCounter = 0;
    x->f_normalize = 1.;
	x->j_box.b_firstin = (t_object *)x;

	dsp_setupjbox((t_jbox *)x, x->f_order * 2 + 1, 0);
    
	x->f_clock              = clock_new(x, (t_method)scope_tick);
	x->f_startclock         = 0;
    
	x->f_viewer             = new AmbisonicViewer(x->f_order);
	x->f_harmonicsValues    = new double[x->f_order * 2 + 1];
    x->f_averageHarmo       = new double[x->f_order * 2 + 1];
    for (int i = 0; i < x->f_order * 2 + 1; i++)
    {
        x->f_harmonicsValues[i] = 0.;
        x->f_averageHarmo[i]    = 0.;
    }

    attr_dictionary_process(x, d);
	jbox_ready((t_jbox *)x);
	
	return (x);
}
Exemple #16
0
void *fton_new(t_symbol *s, long argc, t_atom *argv)
{
	t_fton *x = NULL;
    	
	t_dictionary *d = NULL;
	
	if(!(d = object_dictionaryarg(argc, argv))){
		 return NULL;
	 }
	
	if (x = (t_fton *)object_alloc(fton_class)) {
		x->outlet = outlet_new((t_object *)x,NULL);
	}

	critical_new(&x->lock);

	attr_dictionary_process(x, d);
	return (x);
}
Exemple #17
0
void *dbviewer_new(t_symbol *s, short argc, t_atom *argv)
{
	t_dbviewer		*x;
	long			flags;
	t_dictionary	*d = NULL;

	if (!(d=object_dictionaryarg(argc, argv)))
		return NULL;

	x = (t_dbviewer*)object_alloc(s_dbviewer_class);
	if(x){
		flags = 0 
		| JBOX_DRAWFIRSTIN		
		| JBOX_NODRAWBOX
		| JBOX_DRAWINLAST
		//		| JBOX_TRANSPARENT	
		//		| JBOX_NOGROW
		//		| JBOX_GROWY
		| JBOX_GROWBOTH
		//		| JBOX_IGNORELOCKCLICK
		| JBOX_HILITE				
		//		| JBOX_BACKGROUND
		//		| JBOX_NOFLOATINSPECTOR
		//		| JBOX_TEXTFIELD
		;
		
		jbox_new(&x->d_box, flags, argc, argv);
		x->d_box.b_firstin = (t_object*)x;
		object_obex_store((void *)x, _sym_dumpout, (t_object*)outlet_new(x, NULL));

		x->d_columns = hashtab_new(13);
		hashtab_flags(x->d_columns, OBJ_FLAG_DATA);
		x->d_query = _sym_nothing;

		dbviewer_initdataview(x);
		attr_dictionary_process(x, d);

		jbox_ready(&x->d_box);
//		object_notify(x->d_view, ps_dbview_update, NULL);
	}
	return(x);
}
Exemple #18
0
void *meter_new(t_symbol *s, int argc, t_atom *argv)
{
	t_meter *x =  NULL;
	t_dictionary *d;
	long flags;
	if (!(d = object_dictionaryarg(argc,argv)))
		return NULL;
    
	x = (t_meter *)object_alloc(meter_class);
	flags = 0
    | JBOX_DRAWFIRSTIN
    | JBOX_DRAWINLAST
    | JBOX_TRANSPARENT
    | JBOX_DRAWBACKGROUND
    | JBOX_GROWY
    ;
    
    x->f_number_of_channels = 8;
	jbox_new((t_jbox *)x, flags, argc, argv);
	x->j_box.z_box.b_firstin = (t_object *)x;
    
    dictionary_getlong(d, gensym("channels"), (t_atom_long *)&x->f_number_of_channels);
	if(x->f_number_of_channels < 1)
        x->f_number_of_channels = 1;
    
    x->f_angles_of_channels = new double[MAX_SPEAKER];
    x->f_peaks              = new t_atom[MAX_SPEAKER];
    x->f_overled            = new long[MAX_SPEAKER];
    x->f_signals            = new double[MAX_SPEAKER* SYS_MAXBLKSIZE];
    x->f_meter  = new Hoa2D::Meter(x->f_number_of_channels);
    x->f_vector = new Hoa2D::Vector(x->f_number_of_channels);
    dsp_setupjbox((t_pxjbox *)x, x->f_number_of_channels);
    x->f_outlet = listout(x);
    
    x->f_clock = clock_new(x,(method)meter_tick);
	x->f_startclock = 0;
    
	attr_dictionary_process(x, d);
	jbox_ready((t_jbox *)x);
	
	return (x);
}
Exemple #19
0
void *HoaDelay_new(t_symbol *s, long argc, t_atom *argv)
{
	t_HoaDelay *x = NULL;
    t_dictionary *d = NULL;
    
	int order = 4;
    bool mode = 1;
    double maxdelay = 5000.;
	x = (t_HoaDelay *)object_alloc(HoaDelay_class);
	if (x)
	{
		if(atom_gettype(argv) == A_LONG)
			order	= atom_getlong(argv);
        if(atom_gettype(argv+1) == A_SYM && atom_getsym(argv+1) == gensym("no"))
            mode = 0;
        if(atom_gettype(argv+2) == A_LONG || atom_gettype(argv+2) == A_FLOAT)
            maxdelay = atom_getfloat(argv+2);
			
		x->f_AmbiDelay	= new AmbisonicsDelay(order, mode, maxdelay, sys_getblksize(), sys_getsr());
		
		dsp_setup((t_pxobject *)x, x->f_AmbiDelay->getNumberOfInputs());
		for (int i = 0; i < x->f_AmbiDelay->getNumberOfOutputs(); i++) 
			outlet_new(x, "signal");
        
		x->f_ramp_time = x->f_AmbiDelay->getRampInMs();
        x->f_diffuse_factor = x->f_AmbiDelay->getDiffuseFactor();
        x->f_encoding_compensation = x->f_AmbiDelay->getEncodingCompensation();
        x->f_delay = x->f_AmbiDelay->getDelayTimeInMs();
        
        if(x->f_AmbiDelay->getMode() == Hoa_No_Encoding)
        {
            object_attr_setdisabled((t_object*)x, gensym("diffusion"), 1);
            object_attr_setdisabled((t_object*)x, gensym("compensation"), 1);
        }
        
        x->f_ob.z_misc = Z_NO_INPLACE;
        d = (t_dictionary *)gensym("#D")->s_thing;
        if (d) attr_dictionary_process(x, d);
        attr_args_process(x, argc, argv);
	}
	return (x);
}
Exemple #20
0
void *meter_new(t_symbol *s, long argc, t_atom *argv)
{
	t_meter*	x;
	t_jbox*		box;
	long		flags;
	
	t_dictionary *d=NULL;
	
	if (!(d=object_dictionaryarg(argc,argv)))
		return NULL;
	
	x = (t_meter *)object_alloc(s_meter_class);
	
	flags = 0 
		| JBOX_DRAWFIRSTIN 
		| JBOX_NODRAWBOX
		| JBOX_DRAWINLAST
	//	| JBOX_TRANSPARENT	
	//	| JBOX_NOGROW
	//	| JBOX_GROWY
		| JBOX_GROWBOTH
	//	| JBOX_HILITE
	//	| JBOX_BACKGROUND
	//	| JBOX_DRAWBACKGROUND
	//	| JBOX_NOFLOATINSPECTOR
	//	| JBOX_TEXTFIELD
	//	| JBOX_MOUSEDRAGDELTA
	//	| JBOX_TEXTFIELD
	;
	
	box = (t_jbox *)x;
	jbox_new(box, flags, argc, argv);
	x->obj.z_box.b_firstin = (t_object*)x;
	dsp_setupjbox((t_pxjbox *)x, 1);
	x->clock = clock_new(x, (method)meter_clock);
	meterEffectOrientation(x);
	x->outlet = outlet_new(x, 0); //adding a outlet 		
	attr_dictionary_process(x,d);
	jbox_ready((t_jbox *)x);
	return x;
}
Exemple #21
0
void *hoa_scope_new(t_symbol *s, int argc, t_atom *argv)
{
	t_hoa_scope *x =  NULL; 
	t_dictionary *d;
	long flags;
	
	if(!(d = object_dictionaryarg(argc,argv)))
		return NULL;

	x = (t_hoa_scope *)object_alloc(hoa_scope_class);
	flags = 0 
			| JBOX_DRAWFIRSTIN 
			| JBOX_DRAWINLAST
            | JBOX_DRAWBACKGROUND
			| JBOX_TRANSPARENT	
			| JBOX_GROWY
			;
    
	jbox_new((t_jbox *)x, flags, argc, argv);
	x->j_box.z_box.b_firstin = (t_object *)x;
    
    dictionary_getlong(d, gensym("order"), (t_atom_long *)&x->f_order);
    if(x->f_order < 1)
        x->f_order = 1;
    
	x->f_scope = new Hoa2D::Scope(x->f_order, NUMBEROFCIRCLEPOINTS_UI);
    x->f_order      = x->f_scope->getOrder();
    x->f_signals    = new double[x->f_scope->getNumberOfHarmonics() * SYS_MAXBLKSIZE];
    x->f_index      = 0;
    
    dsp_setupjbox((t_pxjbox *)x, x->f_scope->getNumberOfHarmonics());
    
    x->f_clock = clock_new(x,(method)hoa_scope_tick);
	x->f_startclock = 0;
    
    attr_dictionary_process(x, d);
	jbox_ready((t_jbox *)x);
	
	return (x);
}
void *hoa_vector_new(t_symbol *s, long argc, t_atom *argv)
{
	// @arg 0 @name number-of-channels @optional 0 @type int @digest The number of channels
	// @description First argument sets the number of channels.
	
	t_hoa_vector *x = NULL;
    t_dictionary *d = NULL;
    t_dictionary *attr = NULL;
    t_atom_long nchannels = 0;
    x = (t_hoa_vector *)object_alloc(hoa_vector_class);
    
	if(x)
	{
        d = (t_dictionary *)gensym("#D")->s_thing;
        if(d && dictionary_getdictionary(d, gensym("saved_object_attributes"), (t_object **)&attr) == MAX_ERR_NONE)
        {
            if(dictionary_getlong(attr, gensym("channels"), &nchannels) != MAX_ERR_NONE)
                nchannels = 4;
        }
        else
            nchannels = 4;
       
        if(nchannels < 1)
            nchannels = 1;
        
		x->f_vector = new Hoa2D::Vector(nchannels);
		
		dsp_setup((t_pxobject *)x, x->f_vector->getNumberOfChannels());
		for (int i = 0; i < 4; i++)
			outlet_new(x, "signal");
        
		x->f_ins = new double[x->f_vector->getNumberOfChannels() * SYS_MAXBLKSIZE];
        x->f_outs = new double[4 * SYS_MAXBLKSIZE];
        
        if(d)
            attr_dictionary_process(x, d);
	}

	return (x);
}
Exemple #23
0
void *cc_new(t_symbol *msg, short argc, t_atom *argv){
	t_cc *x;

	if(x = (t_cc *)object_alloc(cc_class)){
#if defined(CC_JBOX)
		t_dictionary *d = NULL; 
		long boxflags; 

		if(!(d = object_dictionaryarg(argc, argv))){ 
			return NULL; 
		} 
    
		boxflags = 0 
			| JBOX_DRAWFIRSTIN 
			//| JBOX_NODRAWBOX
			| JBOX_DRAWINLAST
			//| JBOX_TRANSPARENT  
			//      | JBOX_NOGROW
			//| JBOX_GROWY
			| JBOX_GROWBOTH
			//      | JBOX_HILITE
			| JBOX_BACKGROUND
			| JBOX_DRAWBACKGROUND
			//      | JBOX_NOFLOATINSPECTOR
			//      | JBOX_MOUSEDRAGDELTA
			//      | JBOX_TEXTFIELD
			;
		jbox_new((t_jbox *)x, boxflags, argc, argv); 
#if defined(CC_MSP)
		x->ob.z_box.b_firstin = (void *)x;
#else
 		x->ob.b_firstin = (void *)x; 
#endif
#endif
		x->ht = (t_hashtab *)hashtab_new(0);
		hashtab_flags(x->ht, OBJ_FLAG_DATA);

		x->ok_to_compile = 1;
		x->compiling = 0;
		x->have_valid_filename = 0;

		x->build_path_is_tmp = 1;

		x->ed = NULL;
		x->code_buf_len = BUFSIZE;
		x->code_buf = (char *)calloc(BUFSIZE, sizeof(char));

		x->cfile_path = (char *)calloc(MAX_FILENAME_CHARS, sizeof(char));
		x->build_path = (char *)calloc(MAX_FILENAME_CHARS, sizeof(char));
		x->basename = (char *)calloc(MAX_FILENAME_CHARS, sizeof(char));

		x->cfile_fullpath = (char *)calloc(MAX_PATH_CHARS, sizeof(char));
		x->ofile_fullpath = (char *)calloc(MAX_PATH_CHARS, sizeof(char));
		x->dfile_fullpath = (char *)calloc(MAX_PATH_CHARS, sizeof(char));
		x->logfile_fullpath = (char *)calloc(MAX_PATH_CHARS, sizeof(char));

		x->path_to_maxsdk = gensym("");
		x->user_obj = (char *)calloc(OBJSIZE, sizeof(char));

		x->verbose = 0;

		long ic = (long)(ps_cc_instance_count->s_thing);
		ic += 1;
		ps_cc_instance_count->s_thing = (void *)ic;

#if defined(CC_MSP) && defined(CC_JBOX)
		sprintf(x->basename, "cc_jbox~_%ld", (long)ps_cc_instance_count->s_thing);
#elif defined(CC_MSP)
		sprintf(x->basename, "cc~_%ld", (long)ps_cc_instance_count->s_thing);
#elif defined(CC_JBOX)
		sprintf(x->basename, "cc_jbox_%ld", (long)ps_cc_instance_count->s_thing);
#else
		sprintf(x->basename, "cc_%ld", (long)ps_cc_instance_count->s_thing);
#endif

		short tmpdir;
		sprintf(x->build_path, "/private/var/tmp");
		char fn[512];
		path_frompathname(x->build_path, &tmpdir, fn);
		x->build_path_id = tmpdir;

		//sprintf(x->cfile_fullpath, "%s/%s.c", x->build_path, x->basename);
		sprintf(x->ofile_fullpath, "%s/%s.o", x->build_path, x->basename);
		sprintf(x->dfile_fullpath, "%s/%s.dylib", x->build_path, x->basename);
		sprintf(x->logfile_fullpath, "%s/%s.log", x->build_path, x->basename);

		x->code_len = cc_write_template(x, x->code_buf);

		x->function_names = (t_symbol **)calloc(128, sizeof(t_symbol *));

		x->ninlets = 1;
		x->noutlets = 1;

		x->def_cflags = (char *)calloc(4096, sizeof(char));
		x->def_ldflags = (char *)calloc(4096, sizeof(char));

		char *sdk = x->path_to_maxsdk->s_name;

#if defined(CC_MSP)
		sprintf(x->def_cflags, CFLAGS, sdk, sdk, sdk, sdk, sdk);
		sprintf(x->def_ldflags, LDFLAGS, sdk, sdk);
#else
		sprintf(x->def_cflags, CFLAGS, sdk, sdk, sdk);
		sprintf(x->def_ldflags, LDFLAGS, sdk);
#endif

		x->user_cflags = gensym("");
		x->user_ldflags = gensym("");

#ifdef CC_JBOX
		x->user_paint = NULL;
#endif

#if !defined(CC_JBOX)
		attr_args_process(x, argc, argv);
#else
		attr_dictionary_process(x, d);
#endif

		int i;
#if defined(CC_MSP)
#if defined(CC_JBOX)
		dsp_setupjbox((t_pxjbox *)x, x->nsiginlets);
#else
		dsp_setup((t_pxobject *)x, x->nsiginlets);
#endif
		for(i = 0; i < x->nsigoutlets; i++){
			outlet_new((t_object *)x, "signal");
		}
		x->svin = (t_float **)calloc(x->nsiginlets, sizeof(t_float *));
		x->svout = (t_float **)calloc(x->nsigoutlets, sizeof(t_float *));
#endif
		x->proxies = (void **)calloc(x->ninlets - 1, sizeof(void *));
		for(i = 0; i < x->ninlets - 1; i++){
			x->proxies[0] = proxy_new((t_object *)x, x->ninlets - (i + 1), &(x->inlet));
		}
#if !defined(CC_MSP)
		x->outlets = (void **)calloc(x->noutlets, sizeof(void *));
		for(i = x->noutlets - 1; i >= 0; i--){
			x->outlets[i] = outlet_new((t_object *)x, NULL);
		}
#endif

		x->handle = NULL;

		object_attach_byptr_register(x, x, CLASS_BOX);

#ifdef CC_JBOX
		jbox_ready((t_jbox *)x);
#endif
		return x;
	}
	return NULL;
}
Exemple #24
0
void *grans_new(t_symbol *s, long argc, t_atom *argv)
{
    int n;
	t_grans *x = (t_grans *)object_alloc(grans_class);

	if (x) {
		dsp_setup((t_pxobject *)x, 8);

        x->maxoscillators = DEFAULTMAXOSCILLATORS;
        
        if( argc > 0)
        {
            int i;
            t_atom *ap;
            for (i = 0, ap = argv; i < argc; i++, ap++) {
                if(atom_gettype(ap) == A_LONG)
                {
                    switch(i){
                        case 0:
                            n = atom_getlong(ap);
                            x->maxoscillators = n;
                           // object_post((t_object *)x, "%d oscillators initialized", n);
                            break;
                        case 1:
                            n = atom_getlong(ap);
                            x->numoutlets = n;
                           // object_post((t_object *)x, "%d outlets?", n);

                            while(n--){
                                outlet_new(x, "signal");
                            }
                        default:
                        break;       
                    }
                }
            }
            
        }
        else
        {
            x->numoutlets = 1;
            outlet_new(x, "signal");
           // outlet_new(x, "signal");
            
        }
		
        x->ob.z_misc |= Z_NO_INPLACE;

        
		x->base = (t_osc *)calloc(x->maxoscillators, sizeof(t_osc));
//		x->modbase = (t_osc *)calloc(x->maxoscillators, sizeof(t_osc));

        x->sinetab = (double *)calloc(STABSZ, sizeof(double));
        x->wind_costab = (double *)calloc(STABSZ, sizeof(double));
        x->expdecaytab = (double *)calloc(STABSZ, sizeof(double));
        x->dampedsinetab = (double *)calloc(STABSZ, sizeof(double));
        x->sincwindow = (double *)calloc(STABSZ, sizeof(double));

        double coefshape[NSHAPINGTABS];
        
        PowTableFunction(NSHAPINGTABS, coefshape, 1, 0.0001, 1.0, 2.0);
        
        
        x->exptab = (double **)calloc(NSHAPINGTABS, sizeof(double *));
        
        long i;
        for(i = 0; i < NSHAPINGTABS; i++){
            x->exptab[i] = (double *)calloc(STABSZ, sizeof(double));
            if(x->exptab[i])
            {
                PowTableFunction(STABSZ, x->exptab[i], 1, 0.0001, 1.0, coefshape[i] * 10.0);
            } else {
                object_error((t_object *)x, "could not allocate memory for lookup table");
            }
        }
        
        x->samplerate =  sys_getsr();
        if(x->samplerate<=0)
            x->samplerate = 44100;
      
        
        x->sampleinterval = 1.0 / x->samplerate;
        x->pkw = ( STABSZ * x->sampleinterval ) ;

        x->maxhz = (x->samplerate / 2) * x->pkw;
        x->nosc = x->next_nosc = 0;
        
        x->prev_in1 = 0.0;
        
        x->sincripples = 5; //could make this an attribute, or maybe compute sinc in realtime...
        
        Makeoscsinetable(x);
        MakeCosWindow(x);
        MakeExpDecaytable(x);
        MakeDampedSineWindow(x);
        MakeSincWindow(x);
        
        grans_clear(x);
        
        x->always_on = 0;
        
        t_dictionary *d = NULL;
        d = dictionary_new();
        
        if (d) {
            attr_args_dictionary(d, argc, argv);
            attr_dictionary_process(x, d);
            object_free(d);
        }
        

        
    } else {
        object_post((t_object *)x, "this is potentially bad!");
    }
    
	return (x);
}
t_paramui* paramui_new(t_symbol *s, long argc, t_atom *argv)
{
	t_paramui		*x = NULL;
	t_dictionary 	*d = NULL;
	long 			flags;
	t_atom			a[LISTSIZE+34];
	long			argLen;
	//t_max_err		err = MAX_ERR_NONE;

	if(!(d=object_dictionaryarg(argc, argv)))
		return NULL;	

	if(x = (t_paramui*)object_alloc(s_ui_class)){
		flags = 0 
				| JBOX_DRAWFIRSTIN
				| JBOX_NODRAWBOX
		//		| JBOX_DRAWINLAST
				| JBOX_TRANSPARENT	
		//		| JBOX_NOGROW
		//		| JBOX_GROWY
		//		| JBOX_GROWBOTH
		//		| JBOX_IGNORELOCKCLICK
				| JBOX_HILITE
		//		| JBOX_BACKGROUND
		//		| JBOX_NOFLOATINSPECTOR
				| JBOX_TEXTFIELD
				;

		jbox_new(&x->box, flags, argc, argv);
		x->box.b_firstin = (t_object *)x;
		x->outlet = outlet_new(x, 0L);
		x->menu_items = NULL;
				
		attr_dictionary_process(x, d); 					// handle attribute args
		
		// a textlayout is used for the displaying the value and the unit
		x->layout_value = jtextlayout_create();
		x->layout_unit = jtextlayout_create();

		jbox_ready(&x->box);

		x = (t_paramui *)object_register(CLASS_BOX, symbol_unique(), x);

		x->menu_items = (t_linklist *)linklist_new();
		paramui_menu_build(x);
		x->menu_qelem = qelem_new(x, (method)paramui_menu_qfn);
		
		// here we create our internal instance of jcom.parameter
		atom_setsym(a+0, x->attr_name);
		atom_setsym(a+1, gensym("@type"));
		atom_setsym(a+2, x->attr_type);
		atom_setsym(a+3, gensym("@ramp/drive"));
		atom_setsym(a+4, x->attr_rampDrive);
		atom_setsym(a+5, gensym("@ramp/function"));
		atom_setsym(a+6, x->attr_rampFunction);
		atom_setsym(a+7, gensym("@view/freeze"));
		atom_setlong(a+8, x->attr_uiFreeze);
		atom_setsym(a+9, gensym("@value/stepsize"));
		atom_setfloat(a+10, x->attr_stepsize);
		atom_setsym(a+11, gensym("@priority"));
		atom_setlong(a+12, x->attr_priority);
		atom_setsym(a+13, gensym("@range/bounds"));
		atom_setfloat(a+14, x->attr_range[0]);
		atom_setfloat(a+15, x->attr_range[1]);
		atom_setsym(a+16, gensym("@repetitions/allow"));
		atom_setlong(a+17, x->attr_repetitions);
		atom_setsym(a+18, gensym("@range/clipmode"));
		atom_setsym(a+19, x->attr_clipmode);
		atom_setsym(a+20, gensym("@description"));
		atom_setsym(a+21, x->attr_description);
		atom_setsym(a+22, gensym("@dataspace"));
		atom_setsym(a+23, x->attr_dataspace);
		atom_setsym(a+24, gensym("@dataspace/unit/active"));
		atom_setsym(a+25, x->attr_unitActive);
		atom_setsym(a+26, gensym("@dataspace/unit/native"));
		atom_setsym(a+27, x->attr_unitNative);
		if(x->attr_defaultSize){
			atom_setsym(a+28, gensym("@value/default"));
			sysmem_copyptr(x->attr_default, a+29, sizeof(t_atom) * x->attr_defaultSize);
			argLen = 29 + x->attr_defaultSize;
		}
		else
			argLen = 28;

		jcom_core_loadextern(gensym("jcom.parameter"), argLen, a, &x->obj_parameter);
	}
	return x;
}
Exemple #26
0
void *odisplay_new(t_symbol *msg, short argc, t_atom *argv){
	t_odisplay *x;
    
	t_dictionary *d = NULL;
 	long boxflags;
    
	// box setup
	if(!(d = object_dictionaryarg(argc, argv))){
		return NULL;
	}
    
	boxflags = 0
    | JBOX_DRAWFIRSTIN
    | JBOX_NODRAWBOX
    | JBOX_DRAWINLAST
    | JBOX_TRANSPARENT
    //| JBOX_NOGROW
    //| JBOX_GROWY
    //| JBOX_GROWBOTH
    //| JBOX_HILITE
    //| JBOX_BACKGROUND
    //| JBOX_DRAWBACKGROUND
    //| JBOX_NOFLOATINSPECTOR
    //| JBOX_MOUSEDRAGDELTA
    | JBOX_TEXTFIELD
    ;
    
	if((x = (t_odisplay *)object_alloc(odisplay_class))){
		jbox_new((t_jbox *)x, boxflags, argc, argv);
 		x->ob.b_firstin = (void *)x;
		x->outlet = outlet_new(x, NULL);
		//x->proxy = proxy_new(x, 1, &(x->inlet));
		x->bndl_u = NULL;
		x->bndl_s = NULL;
		x->newbndl = 0;
		x->textlen = 0;
		x->text = NULL;
		//x->bndl_has_been_checked_for_subs = 0;
		//x->bndl_has_subs = 0;
		critical_new(&(x->lock));
		x->qelem = qelem_new((t_object *)x, (method)odisplay_refresh);
		x->new_data_indicator_clock = clock_new((t_object *)x, (method)odisplay_refresh);
		x->have_new_data = 1;
		x->draw_new_data_indicator = 0;
		attr_dictionary_process(x, d);
        
		t_object *textfield = jbox_get_textfield((t_object *)x);
		if(textfield){
			object_attr_setchar(textfield, gensym("editwhenunlocked"), 0);
            textfield_set_readonly(textfield, '1');
            textfield_set_selectallonedit(textfield, '1');
			textfield_set_textmargins(textfield, 5, 5, 5, 15);
			textfield_set_textcolor(textfield, &(x->text_color));
		}
        
 		jbox_ready((t_jbox *)x);
		//odisplay_gettext(x);
        odisplay_clear(x);
		return x;
	}
	return NULL;
}