Ejemplo n.º 1
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);
}
Ejemplo n.º 2
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_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);
}
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);
}
Ejemplo n.º 5
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);
}
Ejemplo n.º 6
0
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);
}
Ejemplo n.º 7
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);
}
Ejemplo n.º 8
0
void tralala_mouseReleaseLasso(t_tll *x)
{
    long i, n = 0;
    t_symbol **keys = NULL;
    
    TLL_DATA_LOCK
    
    if (!(dictionary_getkeys(x->current, &n, &keys))) {
    //
    long argc;
    t_atom *argv = NULL;
    
    for (i = 0; i < n; i++) {
    //
    long status = 0;
    t_symbol *key = (*(keys + i));
    
    if (!(dictionary_getatoms(x->current, key, &argc, &argv))) { 
        if ((atom_getsym(argv) == TLL_SYM_NOTE) && (!dictionary_getlong(x->status, key, &status))) {
            if (status == TLL_LASSO_UNSELECTED) {
                dictionary_deleteentry(x->status, key);
            } else {
                dictionary_appendlong(x->status, key, TLL_SELECTED);
            }
        }
    }
    //
    }
    
    dictionary_freekeys(x->current, n, keys);
    //
    }
    
    TLL_DATA_UNLOCK
    
    TLL_FLAG_UNSET(TLL_FLAG_LASSO);
}
Ejemplo n.º 9
0
ulong tralala_mouseSelectLasso(t_tll *x)
{
    long i, n = 0;
    t_symbol **keys = NULL;
    ulong dirty = TLL_FLAG_NONE;
    
    TLL_DATA_LOCK
    
    if (!(dictionary_getkeys(x->current, &n, &keys))) {
    //
    long argc;
    t_atom *argv = NULL;
    
    double c[ ] = { TLL_X_OFFSET(MIN(x->origin.x, x->cursor.x)), TLL_Y_OFFSET(MIN(x->origin.y, x->cursor.y)),
                    TLL_X_OFFSET(MAX(x->origin.x, x->cursor.x)), TLL_Y_OFFSET(MAX(x->origin.y, x->cursor.y)) };
    
    for (i = 0; i < n; i++) {
    //
    t_symbol *key = (*(keys + i));
    
    if (!(dictionary_getatoms(x->current, key, &argc, &argv)) && ((atom_getsym(argv) == TLL_SYM_NOTE))) { 
    //
    long status = 0;
    double a = TLL_POSITION_TO_X(atom_getlong(argv + 1));
    double b = TLL_PITCH_TO_Y_UP(atom_getlong(argv + 2));
    double u = TLL_POSITION_TO_X(atom_getlong(argv + 1) + atom_getlong(argv + 4));
    double v = TLL_PITCH_TO_Y_DOWN(atom_getlong(argv + 2));
    bool k = false;
        
    k =  ((a > c[0]) && (a < c[2])) || ((u > c[0]) && (u < c[2]));
    k &= ((b > c[1]) && (b < c[3])) || ((v > c[1]) && (v < c[3]));
    
    if (k) {

        if (!(dictionary_hasentry(x->status, key))) {
            dictionary_appendlong(x->status, key, TLL_LASSO_SELECTED);
            dirty |= TLL_DIRTY_NOTE;
            
        } else if (TLL_FLAG_TRUE(TLL_FLAG_SHIFT)) {
            if (!(dictionary_getlong(x->status, key, &status)) && (status == TLL_SELECTED)) {
                dictionary_appendlong(x->status, key, TLL_LASSO_UNSELECTED);
                dirty |= TLL_DIRTY_NOTE;
            }
        }
        
    } else if (!(dictionary_getlong(x->status, key, &status))) {
    
        if (status == TLL_LASSO_SELECTED) {
            dictionary_deleteentry(x->status, key);
            dirty |= TLL_DIRTY_NOTE;
            
        } else if ((TLL_FLAG_TRUE(TLL_FLAG_SHIFT)) && (status == TLL_LASSO_UNSELECTED)) {
            dictionary_appendlong(x->status, key, TLL_SELECTED);
            dirty |= TLL_DIRTY_NOTE;
        }
    }
    //
    }
    //
    }
    
    dictionary_freekeys(x->current, n, keys);
    //
    }
    
    TLL_DATA_UNLOCK
        
    return dirty;
}
Ejemplo n.º 10
0
void tralala_paintCurrent(t_tll *x, t_object *pv)
{
    long zoneStatus = 0;
    long i, argc, n = 0;
    t_atom *argv = NULL;
    t_symbol *mark = NULL;
    t_symbol **keys = NULL;
    PIZError err = PIZ_GOOD;
    
    char string[TLL_STRING_SIZE] = "";
    
    t_symbol *s[ ] = { 
        TLL_SYM_BPM, 
        TLL_SYM_CHANCE, 
        TLL_SYM_VELOCITY, 
        TLL_SYM_CHANNEL, 
        TLL_SYM_CHORD,
        TLL_SYM_CELL, 
        TLL_SYM_VALUE, 
        TLL_SYM_SCALE
        };
    
    pizArrayClear(x->temp[0]);
    pizArrayClear(x->temp[1]);
    pizArrayClear(x->temp[2]);
    
    TLL_DATA_LOCK
    
    dictionary_getlong(x->status, TLL_SYM_ZONE, &zoneStatus);
    
    for (i = 0; i < 9; i++) {
        if (!(dictionary_getatoms(x->current, s[i], &argc, &argv)) && (argc > 1)) {
            tralala_paintStrncatPanel(string, argc, argv);
        }
    }
    
    if (!(dictionary_getatoms(x->current, TLL_SYM_MUTE, &argc, &argv)) 
        && (argc > 1)
        && (atom_gettype(argv + 1) == A_LONG)
        && (atom_getlong(argv + 1) == 1)) {
        strncat_zero(string, "•\n", TLL_STRING_SIZE);
    } else {
        strncat_zero(string, "\n", TLL_STRING_SIZE);
    }
    
    if (dictionary_hasentry(x->status, TLL_SYM_ZONE)) {
        if (!(dictionary_getatoms(x->current, TLL_SYM_ZONE, &argc, &argv))) {
            tralala_paintStrncatZone(string, argc, argv, zoneStatus);
        } 
    } else if (!(dictionary_getsym(x->status, TLL_SYM_MARK, &mark)) 
        && (!(dictionary_getatoms(x->current, mark, &argc, &argv)))) {
        tralala_paintStrncatNote(string, argc, argv);
    }
    
    if (!(dictionary_getkeys(x->current, &n, &keys))) {
    //
    for (i = 0; i < n; i++) {
    //
    long k, j, p, status = 0; 
    t_symbol *key = (*(keys + i));
    
    if (!(dictionary_getatoms(x->current, key, &argc, &argv)) 
        && (atom_getsym(argv) == TLL_SYM_NOTE)
        && (argc == 6)) { 
        if (k = dictionary_hasentry(x->status, key)) {
           dictionary_getlong(x->status, key, &status);
        }
        if (!k || (status == TLL_LASSO_UNSELECTED)) {
            p = 0;
        } else if (key != mark) {
            p = 1;
        } else {
            p = 2;
        }
        for (j = 1; j < 5; j++) {
            pizArrayAppend(x->temp[p], atom_getlong(argv + j));
        }
    }
    //
    }

    dictionary_freekeys(x->current, n, keys);
    //
    }
    
    err |= (dictionary_getatoms(x->current, TLL_SYM_ZONE, &argc, &argv)) != MAX_ERR_NONE;
    
    TLL_DATA_UNLOCK 
    
    if (!err) {
        if (!zoneStatus) {
            tralala_paintCurrentZone(x, pv, argc, argv, zoneStatus);
            tralala_paintCurrentNote(x, pv);
        } else {
            tralala_paintCurrentNote(x, pv);
            tralala_paintCurrentZone(x, pv, argc, argv, zoneStatus);
        }
        
        if (x->viewText) {
            tralala_paintCurrentText(x, pv, string);
        }
    }
}