Esempio n. 1
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;
}
Esempio n. 3
0
void *hoa_rotate_new(t_symbol *s, long argc, t_atom *argv)
{
    t_hoa_rotate *x = NULL;
	int	order = 4;
    
    x = (t_hoa_rotate *)object_alloc(hoa_rotate_class);
    
    order = atom_getint(argv);
    x->f_ambi_rotate = new AmbisonicRotate(order, sys_getblksize());
    dsp_setupjbox((t_jbox *)x, x->f_ambi_rotate->getNumberOfInputs(), x->f_ambi_rotate->getNumberOfOutputs());
    
	x->f_ob.z_misc = Z_NO_INPLACE;
    
	return (x);
}
Esempio n. 4
0
void *hoa_projector_new(t_symbol *s, long argc, t_atom *argv)
{
    t_hoa_projector *x = NULL;
	int	order = 4;
    int microphones = 10;
    
    x = (t_hoa_projector *)object_alloc(hoa_projector_class);
    
    order = atom_getint(argv);
    microphones = atom_getint(argv+1);
    x->f_ambi_projector = new AmbisonicProjector(order, microphones, sys_getblksize());
    dsp_setupjbox((t_jbox *)x, x->f_ambi_projector->getNumberOfInputs(), x->f_ambi_projector->getNumberOfOutputs());
    
	x->f_ob.z_misc = Z_NO_INPLACE;
    
	return (x);
}
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);
}
Esempio n. 6
0
void *hoa_encoder_new(t_symbol *s, long argc, t_atom *argv)
{
    t_hoa_encoder *x = NULL;
	int	order = 4;
    
    x = (t_hoa_encoder *)object_alloc(hoa_encoder_class);
	if (x)
	{
        order = atom_getint(argv);
        
		x->f_ambi_encoder = new AmbisonicEncoder(order, sys_getblksize());
        dsp_setupjbox((t_jbox *)x, x->f_ambi_encoder->getNumberOfInputs(), x->f_ambi_encoder->getNumberOfOutputs());
        
        x->f_ob.z_misc = Z_NO_INPLACE;
	}
	return (x);
}
Esempio n. 7
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);
}
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);
}
Esempio n. 9
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);
}
Esempio n. 10
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;
}
Esempio n. 11
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);
}
Esempio n. 12
0
void *pictmeter_new(t_symbol *s, long argc, t_atom *argv)
{
	t_pictmeter *x = NULL;
	t_dictionary *d=NULL;
	long boxflags;

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

	x = (t_pictmeter *)object_alloc(s_pictmeter_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->p_obj.z_box.b_firstin = (void *)x;
	dsp_setupjbox((t_pxjbox *)x,1);
	x->p_clock = clock_new(x,(method)pictmeter_tick);
	x->p_value = x->p_max = 0;
	x->p_startclock = false;
	jbox_ready((t_jbox *)x);
	return x;
}
Esempio n. 13
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;
}