Beispiel #1
0
static t_pd_err tab_notify(t_tab *x, t_symbol *s, t_symbol *msg, void *sender, void *data)
{
    if (msg == cream_sym_attr_modified)
    {
        if(s == cream_sym_bgcolor ||
                s == cream_sym_bdcolor ||
                s == cream_sym_textcolor ||
                s == cream_sym_hocolor ||
                s == cream_sym_secolor ||
                s == cream_sym_orientation ||
                s == cream_sym_font)
        {
            ebox_invalidate_layer((t_ebox *)x, cream_sym_selection_layer);
            ebox_invalidate_layer((t_ebox *)x, cream_sym_text_layer);
            ebox_invalidate_layer((t_ebox *)x, cream_sym_background_layer);
        }
        else if(s == cream_sym_orientation ||
                s == cream_sym_items)
        {
            ebox_notify((t_ebox *)x, s_cream_size, cream_sym_attr_modified, NULL, NULL);
        }
    }
    else if(msg == cream_sym_value_changed)
    {
        tab_output(x);
        ebox_invalidate_layer((t_ebox *)x, cream_sym_background_layer);
        ebox_redraw((t_ebox *)x);
    }
    return 0;
}
Beispiel #2
0
static void tab_set(t_tab *x, t_symbol *s, int argc, t_atom *argv)
{
    int i;
    t_symbol* item;
    if(argc && argv && atom_gettype(argv) == A_FLOAT)
    {
        ebox_parameter_setvalue((t_ebox *)x, 1, atom_getfloat(argv), 0);
        ebox_invalidate_layer((t_ebox *)x, cream_sym_background_layer);
        ebox_redraw((t_ebox *)x);
    }
    else if(argc && argv && atom_gettype(argv) == A_SYMBOL)
    {
        item = tab_gensym(NULL, argc, argv);
        if(item)
        {
            for(i = 0; i < x->f_nitems; i++)
            {
                if(x->f_items[i] == item)
                {
                    ebox_parameter_setvalue((t_ebox *)x, 1, (float)i, 0);
                    ebox_invalidate_layer((t_ebox *)x, cream_sym_background_layer);
                    ebox_redraw((t_ebox *)x);
                    return;
                }
            }
        }
    }
}
t_pd_err angles_set(t_hoa_meter *x, void *attr, long argc, t_atom *argv)
{
    double angles[MAX_SPEAKER];
    if(argc > MAX_SPEAKER)
        argc = MAX_SPEAKER;
    if(argc && argv)
    {
        for(int i = 0; i < argc; i++)
        {
            if(atom_gettype(argv+i) == A_FLOAT)
            {
                angles[i] = atom_getfloat(argv+i) / 360. * HOA_2PI;
            }
        }
        x->f_meter->setChannelsAzimuth(angles);
        x->f_vector->setChannelsAzimuth(angles);
    }

	ebox_invalidate_layer((t_ebox *)x, hoa_sym_background_layer);
	ebox_invalidate_layer((t_ebox *)x, hoa_sym_leds_layer);
	ebox_invalidate_layer((t_ebox *)x, hoa_sym_vector_layer);
    
	ebox_redraw((t_ebox *)x);
    return 0;
}
Beispiel #4
0
t_pd_err hoa_space_coefficients_set(t_hoa_space *x, t_object *attr, long ac, t_atom *av)
{
    if (ac && av)
    {
        if(atom_gettype(av) == A_FLOAT)
        {
            if(x->f_mode == 0 || x->f_mode == 2)
            {
                for (int i = 0; i < ac && i < x->f_number_of_microphones; i++)
                {
                    if(atom_gettype(av+i) == A_FLOAT)
                        x->f_microphonesValues[i] = Tools::clip((double)atom_getfloat(av + i), 0., 1.);
                }
                
            }
            else
            {
                for (int i = 0; i < ac && i < x->f_number_of_microphones; i++)
                {
                    x->f_microphonesValues[i] = atom_getfloat(av + i);
                }
            }
        }
    } 
    x->f_recomposer->processFixe(x->f_microphonesValues, x->f_harmonicsValues);
    x->f_viewer->processContribAndRep(x->f_harmonicsValues);
    
    ebox_invalidate_layer((t_ebox *)x, gensym("microphones_layer"));
    ebox_invalidate_layer((t_ebox *)x, gensym("harmonics_layer"));
    ebox_invalidate_layer((t_ebox *)x, gensym("center_layer"));
    ebox_redraw((t_ebox *)x);
    return 0;
}
void hoa_meter_tick(t_hoa_meter *x)
{
    if(x->f_vector_type == hoa_sym_both)
        x->f_vector->process(x->f_signals, x->f_vector_coords);
    else if(x->f_vector_type == hoa_sym_velocity)
        x->f_vector->processVelocity(x->f_signals, x->f_vector_coords);
    else if(x->f_vector_type == hoa_sym_energy)
         x->f_vector->processEnergy(x->f_signals, x->f_vector_coords + 2);
    
    double peak;
    for (int i = 0; i < x->f_meter->getNumberOfChannels(); i++)
    {
        peak = x->f_meter->getChannelEnergy(i);
        if(peak >= 0.)
            x->f_over_leds[i] = 1000;
        else
            x->f_over_leds[i] -= x->f_interval;
        
        if(x->f_over_leds[i] < 0)
            x->f_over_leds[i] = 0;
    }
    
	ebox_invalidate_layer((t_ebox *)x, hoa_sym_leds_layer);
	ebox_invalidate_layer((t_ebox *)x, hoa_sym_vector_layer);
  	ebox_redraw((t_ebox *)x);
    
	if (sys_getdspstate())
		clock_delay(x->f_clock, x->f_interval);
}
void breakpoints_mousemove(t_breakpoints *x, t_object *patcherview, t_pt pt, long modifiers)
{
    int i;
    float abs, ord;
    float height = sys_fontheight(ebox_getfontsize((t_ebox *)x)) + 2;
    float distx = (3. / (x->f_size.x - 4.)) * (x->f_range_abscissa[1] - x->f_range_abscissa[0]);
    float disty = (3. / (x->f_size.y - 4. - height)) * (x->f_range_ordinate[1] - x->f_range_ordinate[0]);

    abs = ((pt.x - 3.) / (x->f_size.x - 4.)) * (x->f_range_abscissa[1] - x->f_range_abscissa[0]) + x->f_range_abscissa[0];
    ord = ((x->f_size.y - (pt.y - 4.) - 4.) / (x->f_size.y - 4. - height)) * (x->f_range_ordinate[1] - x->f_range_ordinate[0]) + x->f_range_ordinate[0];
    x->f_point_hover = -1;
    x->f_mouse.x = abs;
    x->f_mouse.y = ord;

    for(i = 0; i < x->f_number_of_points; i++)
    {
        if(abs > x->f_point_abscissa[i] - distx && abs < x->f_point_abscissa[i] + distx && ord > x->f_point_ordinate[i] - disty && ord < x->f_point_ordinate[i] + disty)
        {
            x->f_point_hover = i;
        }
    }
    ebox_invalidate_layer((t_ebox *)x, gensym("points_layer"));
    ebox_invalidate_layer((t_ebox *)x, cream_sym_text_layer);
    ebox_redraw((t_ebox *)x);
}
Beispiel #7
0
void carray_output(t_carray *x, t_symbol* s, long argc, t_atom* argv)
{
    post("Array : %s, Size : %i", x->f_name->s_name, x->f_buffer_size);
    ebox_invalidate_layer((t_ebox*)x, gensym("buffer_layer"));
    ebox_invalidate_layer((t_ebox *)x, gensym("background_layer"));
    ebox_redraw((t_ebox *)x);
}
Beispiel #8
0
static void tab_mouseup(t_tab *x, t_object *patcherview, t_pt pt, long modifiers)
{
    if(!x->f_toggle)
    {
        x->f_off = 1;
        ebox_invalidate_layer((t_ebox *)x, cream_sym_selection_layer);
        ebox_invalidate_layer((t_ebox *)x, cream_sym_text_layer);
        ebox_redraw((t_ebox *)x);
    }
}
Beispiel #9
0
static void knob_mousedrag(t_knob *x, t_object *patcherview, t_pt pt, long modifiers)
{
    t_rect rect;
    ebox_get_rect_for_view((t_ebox *)x, &rect);
    if(x->f_circular)
    {
        const float size  = rect.width * 0.5f;
        const float angle = pd_angle(pt.x - size, -(size - pt.y));
        if(x->f_endless)
        {
            const float value = pd_wrap((angle - EPD_PI2) / EPD_2PI, 0.f, 1.f);
            if(ebox_parameter_isinverted((t_ebox *)x, 1))
            {
                ebox_parameter_setvalue_normalized((t_ebox *)x, 1, 1.f - value, 1);
            }
            else
            {
                ebox_parameter_setvalue_normalized((t_ebox *)x, 1, value, 1);
            }
        }
        else
        {
            const float value = (pd_clip(pd_wrap((angle - EPD_PI2) / EPD_2PI, 0.f, 1.f), 0.125f, 0.875f) - 0.125f) / 0.75f;
            if(ebox_parameter_isinverted((t_ebox *)x, 1))
            {
                ebox_parameter_setvalue_normalized((t_ebox *)x, 1, 1.f - value, 1);
            }
            else
            {
                ebox_parameter_setvalue_normalized((t_ebox *)x, 1, value, 1);
            }
        }
        
        knob_output(x);
        ebox_invalidate_layer((t_ebox *)x, cream_sym_needle_layer);
        ebox_redraw((t_ebox *)x);
    }
    else
    {
        const float current = ebox_parameter_getvalue_normalized((t_ebox *)x, 1);
        const float diff    = (x->f_reference - pt.y) / (rect.width) * (ebox_parameter_isinverted((t_ebox *)x, 1) ? -1.f : 1.f);
        if(x->f_endless)
        {
            ebox_parameter_setvalue_normalized((t_ebox *)x, 1, pd_wrap(current + diff, 0.f, 1.f), 1);
        }
        else
        {
            ebox_parameter_setvalue_normalized((t_ebox *)x, 1, pd_clip(current + diff, 0.f, 1.f), 1);
        }
        x->f_reference      = pt.y;
    }
    knob_output(x);
    ebox_invalidate_layer((t_ebox *)x, cream_sym_needle_layer);
    ebox_redraw((t_ebox *)x);
}
t_pd_err hoa_meter_notify(t_hoa_meter *x, t_symbol *s, t_symbol *msg, void *sender, void *data)
{
	if (msg == gensym("attr_modified"))
	{
		ebox_invalidate_layer((t_ebox *)x, hoa_sym_background_layer);
        ebox_invalidate_layer((t_ebox *)x, hoa_sym_leds_layer);
        ebox_invalidate_layer((t_ebox *)x, hoa_sym_vector_layer);
		ebox_redraw((t_ebox *)x);
	}
	return 0;
}
void breakpoints_mouseleave(t_breakpoints *x, t_object *patcherview, t_pt pt, long modifiers)
{
    x->f_point_selected = -1;
    x->f_point_hover    = -1;
    x->f_mouse.x = -666666;
    x->f_mouse.y = -666666;

    ebox_invalidate_layer((t_ebox *)x, cream_sym_text_layer);
    ebox_invalidate_layer((t_ebox *)x, gensym("points_layer"));
    ebox_redraw((t_ebox *)x);
}
Beispiel #12
0
t_pd_err knob_notify(t_knob *x, t_symbol *s, t_symbol *msg, void *sender, void *data)
{
	if (msg == cream_sym_attr_modified)
	{
		if(s == cream_sym_bgcolor || s == cream_sym_bdcolor || s == gensym("necolor") || s == gensym("endless"))
		{
			ebox_invalidate_layer((t_ebox *)x, gensym("needle_layer"));
            ebox_invalidate_layer((t_ebox *)x, cream_sym_background_layer);
		}
        ebox_redraw((t_ebox *)x);
	}
	return 0;
}
Beispiel #13
0
t_pd_err gain_notify(t_gain *x, t_symbol *s, t_symbol *msg, void *sender, void *data)
{
	if (msg == gensym("attr_modified"))
	{
		if(s == gensym("bgcolor") || s == gensym("bdcolor") || s == gensym("kncolor"))
		{
            ebox_invalidate_layer((t_ebox *)x, gensym("knob_layer"));
			ebox_invalidate_layer((t_ebox *)x, gensym("background_layer"));
		}
        ebox_redraw((t_ebox *)x);
	}
	return 0;
}
Beispiel #14
0
void hoa_space_output(t_hoa_space *x)
{
    for(int i = 0; i < x->f_number_of_microphones; i++)
        atom_setfloat(x->f_tempory_values+i, x->f_microphonesValues[i]);
    
    outlet_list(x->f_out, 0L, x->f_number_of_microphones, x->f_tempory_values);
    ebox_invalidate_layer((t_ebox *)x, gensym("harmonics_layer"));
    ebox_invalidate_layer((t_ebox *)x, gensym("microphones_layer"));
    ebox_invalidate_layer((t_ebox *)x, gensym("center_layer"));
    ebox_redraw((t_ebox *)x);
    if(ebox_getsender((t_ebox *) x))
        pd_list(ebox_getsender((t_ebox *) x), &s_list, x->f_number_of_microphones, x->f_tempory_values);
}
Beispiel #15
0
t_pd_err hoa_space_notify(t_hoa_space *x, t_symbol *s, t_symbol *msg, void *sender, void *data)
{
	if (msg == gensym("attr_modified"))
	{
        if(s == gensym("miccolor"))
        {
            ebox_invalidate_layer((t_ebox *)x, gensym("microphones_layer"));
        }
        else if(s == gensym("harmocolor"))
        {
            ebox_invalidate_layer((t_ebox *)x, gensym("microphones_layer"));
            ebox_invalidate_layer((t_ebox *)x, gensym("harmonics_layer"));
            ebox_invalidate_layer((t_ebox *)x, gensym("center_layer"));
        }
        else if(s == gensym("circolor"))
        {
            ebox_invalidate_layer((t_ebox *)x, gensym("microphones_layer"));
            ebox_invalidate_layer((t_ebox *)x, gensym("harmonics_layer"));
            ebox_invalidate_layer((t_ebox *)x, gensym("background_layer"));
            ebox_invalidate_layer((t_ebox *)x, gensym("center_layer"));
        }
        ebox_redraw((t_ebox *)x);
	}
	return 0;
}
t_pd_err offset_set(t_hoa_meter *x, void *attr, long argc, t_atom *argv)
{
    if(argc && argv && atom_gettype(argv) == A_FLOAT)
    {
        x->f_vector->setChannelsOffset(atom_getfloat(argv) / 360 * HOA_2PI);
        x->f_meter->setChannelsOffset(atom_getfloat(argv) / 360 * HOA_2PI);
    }
    
    ebox_invalidate_layer((t_ebox *)x, hoa_sym_background_layer);
	ebox_invalidate_layer((t_ebox *)x, hoa_sym_leds_layer);
	ebox_invalidate_layer((t_ebox *)x, hoa_sym_vector_layer);
    
	ebox_redraw((t_ebox *)x);
    return 0;
}
Beispiel #17
0
static void plane_float(t_plane *x, float f)
{
    ebox_parameter_setvalue((t_ebox *)x, 1, f, eobj_getproxy(x) + 1);
    plane_output(x);
    ebox_invalidate_layer((t_ebox *)x, cream_sym_points_layer);
    ebox_redraw((t_ebox *)x);
}
Beispiel #18
0
void radio_set(t_radio *x, t_symbol* s, long argc, t_atom* argv)
{
    int i;
    if(argc && argv)
    {
        if(x->f_mode)
        {
            for(i = 0; i < argc && i < x->f_nitems; i++)
            {
                if(atom_gettype(argv+i) == A_FLOAT && atom_getfloat(argv+i) == 0)
                    x->f_items[i] = 0;
                else
                    x->f_items[i] = 1;
            }
        }
        else if(atom_gettype(argv) == A_FLOAT && atom_getfloat(argv) >= 0 && atom_getfloat(argv) < x->f_nitems)
        {
            for(i = 0; i < x->f_nitems; i++)
                x->f_items[(i)] = 0;
            x->f_items[(int)atom_getfloat(argv)] = 1;
        }
        
        ebox_invalidate_layer((t_ebox *)x, gensym("items_layer"));
        ebox_redraw((t_ebox *)x);
    }
}
void breakpoints_remove(t_breakpoints *x, t_symbol* s, int argc, t_atom* argv)
{
    int index, i;
    if(x->f_number_of_points == MAXPOINTS)
        return;

    if(argc && argv)
    {
        if(argc == 1 && atom_gettype(argv) == A_FLOAT)
        {
            index = atom_getfloat(argv);
            if(index >= x->f_number_of_points || index < 0)
                return;

            for(i = index; i < x->f_number_of_points; i++)
            {
                x->f_point_abscissa[i] = x->f_point_abscissa[i+1];
                x->f_point_ordinate[i] = x->f_point_ordinate[i+1];
            }
            x->f_number_of_points--;
            ebox_invalidate_layer((t_ebox *)x, gensym("points_layer"));
            ebox_redraw((t_ebox *)x);
        }
    }
}
Beispiel #20
0
static void tab_float(t_tab *x, t_floatarg f)
{
    ebox_parameter_setvalue((t_ebox *)x, 1, f, 1);
    tab_output(x);
    ebox_invalidate_layer((t_ebox *)x, cream_sym_selection_layer);
    ebox_redraw((t_ebox *)x);
}
Beispiel #21
0
static void incdec_mouseup(t_incdec *x, t_object *patcherview, t_pt pt, long modifiers)
{
    x->f_mouse_down = 0;
    clock_unset(x->f_clock);
    ebox_invalidate_layer((t_ebox *)x, cream_sym_background_layer);
    ebox_redraw((t_ebox *)x);
}
Beispiel #22
0
t_pd_err carray_buffer_set(t_carray *x, t_eattr *attr, long argc, t_atom* argv)
{
    int i;
    x->f_array = NULL;
    if(argc && argv && atom_gettype(argv) == A_SYM)
    {
        x->f_name = atom_getsym(argv);
        if(!(x->f_array  = (t_garray *)pd_findbyclass(x->f_name, garray_class)))
        {
            x->f_array = NULL;
            x->f_name = gensym("(null)");
            x->f_buffer_size = 0;
            x->f_buffer = NULL;
        }
        else if(!garray_getfloatarray(x->f_array, &x->f_buffer_size, &x->f_buffer))
        {
            x->f_array = NULL;
            x->f_name = gensym("(null)");
            x->f_buffer_size = 0;
            x->f_buffer = NULL;
        }
        else
        {
            for(i = 0; i < x->f_buffer_size; i++)
                post("%f", x->f_buffer[i]);
            ebox_invalidate_layer((t_ebox*)x, gensym("buffer_layer"));
            ebox_redraw((t_ebox*)x);
        }
    }

    return 0;
}
void breakpoints_mouseup(t_breakpoints *x, t_object *patcherview, t_pt pt, long modifiers)
{
    float abs, ord;
    float height = sys_fontheight(ebox_getfontsize((t_ebox *)x)) + 2;
    abs = ((pt.x - 3.) / (x->f_size.x - 4.)) * (x->f_range_abscissa[1] - x->f_range_abscissa[0]) + x->f_range_abscissa[0];
    ord = ((x->f_size.y - (pt.y - 4.) - 4.) / (x->f_size.y - 4. - height)) * (x->f_range_ordinate[1] - x->f_range_ordinate[0]) + x->f_range_ordinate[0];


    x->f_mouse.x = abs;
    x->f_mouse.y = ord;
    x->f_point_selected    = -1;

    ebox_invalidate_layer((t_ebox *)x, cream_sym_text_layer);
    ebox_invalidate_layer((t_ebox *)x, gensym("points_layer"));
    ebox_redraw((t_ebox *)x);
}
Beispiel #24
0
static void dsp_tilde_start(t_dsp_tilde *x)
{
    canvas_resume_dsp(1);
    x->f_state = 1;
    ebox_invalidate_layer((t_ebox *)x, cream_sym_background_layer);
    ebox_redraw((t_ebox *)x);
}
Beispiel #25
0
void radio_mousedown(t_radio *x, t_object *patcherview, t_pt pt, long modifiers)
{
    int i, index;
    if(x->f_direction)
    {
        index = (pt.x - 2) / x->j_box.b_rect.width * x->f_nitems;
    }
    else
    {
        index = (pt.y - 2) / x->j_box.b_rect.height * x->f_nitems;
    }
    
    if(index >= 0 && index < x->f_nitems)
    {
        if(x->f_mode)
        {
            if(x->f_items[index] == 0)
                x->f_items[index] = 1;
            else
                x->f_items[index] = 0;
        }
        else
        {
            for(i = 0; i < x->f_nitems; i++)
                x->f_items[i] = 0;
            x->f_items[index] = 1;
        }
    }
    
    ebox_invalidate_layer((t_ebox *)x, gensym("items_layer"));
    ebox_redraw((t_ebox *)x);
    radio_output(x);
}
Beispiel #26
0
static void dsp_tilde_stop(t_dsp_tilde *x)
{
    canvas_suspend_dsp();
    x->f_state = 0;
    ebox_invalidate_layer((t_ebox *)x, cream_sym_background_layer);
    ebox_redraw((t_ebox *)x);
}
t_pd_err vectors_set(t_hoa_meter *x, void *attr, long argc, t_atom *argv)
{
    if(argc && argv)
    {
        if(atom_gettype(argv) == A_SYM)
        {
            if(atom_getsym(argv) == hoa_sym_energy)
                x->f_vector_type = hoa_sym_energy;
            else if(atom_getsym(argv) == hoa_sym_velocity)
                x->f_vector_type = hoa_sym_velocity;
            else if(atom_getsym(argv) == hoa_sym_both)
                x->f_vector_type = hoa_sym_both;
            else
                x->f_vector_type = hoa_sym_none;
        }
        else if(atom_gettype(argv) == A_FLOAT)
        {
            if(atom_getlong(argv) == 1)
                x->f_vector_type = hoa_sym_energy;
            else if(atom_getlong(argv) == 2)
                x->f_vector_type = hoa_sym_velocity;
            else if(atom_getlong(argv) == 3)
                x->f_vector_type = hoa_sym_both;
            else
                x->f_vector_type = hoa_sym_none;
        }
        ebox_invalidate_layer((t_ebox *)x, hoa_sym_vector_layer);
    }
    return 0;
}
Beispiel #28
0
t_pd_err meter_notify(t_meter *x, t_symbol *s, t_symbol *msg, void *sender, void *data)
{
	if (msg == gensym("attr_modified"))
	{
		if(s == gensym("bgcolor") || s == gensym("bdcolor"))
		{
			ebox_invalidate_layer((t_ebox *)x, gensym("background_layer"));
		}
		else if( s == gensym("coldcolor") || s == gensym("tepidcolor") || s == gensym("warmcolor") || s == gensym("hotcolor") || s == gensym("overcolor"))
		{
			ebox_invalidate_layer((t_ebox *)x, gensym("background_layer"));
			ebox_invalidate_layer((t_ebox *)x, gensym("leds_layer"));
		}
		ebox_redraw((t_ebox *)x);
	}
	return 0;
}
Beispiel #29
0
static void tab_prev(t_tab *x)
{
    const float index = ebox_parameter_getvalue((t_ebox *)x, 1);
    ebox_parameter_setvalue((t_ebox *)x, 1, index-1, 1);
    tab_output(x);
    ebox_invalidate_layer((t_ebox *)x, cream_sym_selection_layer);
    ebox_redraw((t_ebox *)x);
}
t_pd_err number_tilde_notify(t_number_tilde *x, t_symbol *s, t_symbol *msg, void *sender, void *data)
{
	if (msg == cream_sym_attr_modified)
	{
		if(s == cream_sym_bgcolor || s == cream_sym_bdcolor || s == gensym("textcolor") || s == gensym("fontsize") || s == gensym("fontname") || s == gensym("fontweight") || s == gensym("fontslant"))
		{
			ebox_invalidate_layer((t_ebox *)x, cream_sym_background_layer);
			ebox_invalidate_layer((t_ebox *)x, gensym("value_layer"));
		}
        if(s == gensym("fontsize"))
        {
            object_attr_setvalueof((t_object *)x, gensym("size"), 0, NULL);
        }
        ebox_redraw((t_ebox *)x);
	}
	return 0;
}