Skip to content

Commit

Permalink
add print method
Browse files Browse the repository at this point in the history
  • Loading branch information
pierreguillot committed Jul 18, 2018
1 parent df58f17 commit ec40b91
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 4 deletions.
7 changes: 7 additions & 0 deletions src/faust_tilde_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,3 +254,10 @@ char faust_io_manager_is_valid(t_faust_io_manager *x)
{
return x->f_signals && x->f_valid;
}

void faust_io_manager_print(t_faust_io_manager* x, char const log)
{
logpost(x->f_owner, 2+log, " number of inputs: %i", (int)faust_io_manager_get_ninputs(x));
logpost(x->f_owner, 2+log, " number of outputs: %i", (int)faust_io_manager_get_noutputs(x));
logpost(x->f_owner, 2+log, " extra output: %s", faust_io_manager_has_extra_output(x) ? "true" : "false");
}
2 changes: 2 additions & 0 deletions src/faust_tilde_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@ t_sample** faust_io_manager_get_output_signals(t_faust_io_manager *x);

char faust_io_manager_is_valid(t_faust_io_manager *x);

void faust_io_manager_print(t_faust_io_manager* x, char const log);

#endif
9 changes: 9 additions & 0 deletions src/faust_tilde_options.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,3 +212,12 @@ char const* faust_opt_manager_get_full_path(t_faust_opt_manager* x, char const*
pd_error(x->f_owner, "faust~: invalid path or name");
return NULL;
}

void faust_opt_manager_print(t_faust_opt_manager* x, char const log)
{
size_t i;
for(i = 0; i < x->f_noptions; ++i)
{
logpost(x->f_owner, 2+log, " option %i: %s", (int)i, x->f_options[i]);
}
}
2 changes: 2 additions & 0 deletions src/faust_tilde_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ char const** faust_opt_manager_get_options(t_faust_opt_manager* x);

char const* faust_opt_manager_get_full_path(t_faust_opt_manager* x, char const* name);

void faust_opt_manager_print(t_faust_opt_manager* x, char const log);

#endif
41 changes: 41 additions & 0 deletions src/faust_tilde_ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -437,4 +437,45 @@ void faust_ui_manager_restore_default(t_faust_ui_manager *x)
}
}

const char* faust_ui_manager_get_parameter_char(int type)
{
if(type == FAUST_UI_TYPE_BUTTON)
return "button";
else if(type == FAUST_UI_TYPE_TOGGLE)
return "toggle";
else if(type == FAUST_UI_TYPE_NUMBER)
return "number";
else
return "bargraph";
}

void faust_ui_manager_print(t_faust_ui_manager* x, char const log)
{
size_t i;
logpost(x->f_owner, 2+log, " active parameters: %i", (int)x->f_nactive_uis);
for(i = 0; i < x->f_nactive_uis; ++i)
{
logpost(x->f_owner, 2+log, " %i: %s [path:%s - type:%s - init:%g - min:%g - max:%g - current:%g]", (int)i,
x->f_active_uis[i].p_name->s_name,
x->f_active_uis[i].p_longname->s_name,
faust_ui_manager_get_parameter_char(x->f_active_uis[i].p_type),
x->f_active_uis[i].p_default,
x->f_active_uis[i].p_min,
x->f_active_uis[i].p_max,
*x->f_active_uis[i].p_zone);
}
logpost(x->f_owner, 2+log, " passive parameters: %i", (int)x->f_npassive_uis);
for(i = 0; i < x->f_npassive_uis; ++i)
{
logpost(x->f_owner, 2+log, " %i: %s [path:%s - type:%s - init:%g - min:%g - max:%g - current:%g]", (int)i,
x->f_passive_uis[i].p_name->s_name,
x->f_passive_uis[i].p_longname->s_name,
faust_ui_manager_get_parameter_char(x->f_passive_uis[i].p_type),
x->f_passive_uis[i].p_default,
x->f_passive_uis[i].p_min,
x->f_passive_uis[i].p_max,
*x->f_passive_uis[i].p_zone);
}
}


2 changes: 2 additions & 0 deletions src/faust_tilde_ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,6 @@ void faust_ui_manager_save_states(t_faust_ui_manager *x);

void faust_ui_manager_restore_states(t_faust_ui_manager *x);

void faust_ui_manager_print(t_faust_ui_manager* x, char const log);

#endif
15 changes: 11 additions & 4 deletions src/faustgen_tilde.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,9 @@ static void faustgen_tilde_compile(t_faustgen_tilde *x)
const int ninputs = getNumInputsCDSPInstance(x->f_dsp_instance);
const int noutputs = getNumOutputsCDSPInstance(x->f_dsp_instance);
logpost(x, 3, "\nfaustgen~: compilation from source '%s' succeeded", x->f_dsp_name->s_name);
logpost(x, 3, " %s: %i", "number of inputs", ninputs);
logpost(x, 3, " %s: %i", "number of outputs", noutputs);
faust_ui_manager_init(x->f_ui_manager, x->f_dsp_instance);
faust_io_manager_init(x->f_io_manager, ninputs, noutputs, faust_ui_manager_has_passive_ui(x->f_ui_manager));

faust_ui_manager_init(x->f_ui_manager, x->f_dsp_instance);

canvas_resume_dsp(dspstate);
return;
}
Expand Down Expand Up @@ -158,6 +156,14 @@ static void faustgen_tilde_autocompile(t_faustgen_tilde *x, t_symbol* s, int arg
}
}

static void faustgen_tilde_print_parameters(t_faustgen_tilde *x)
{
faust_io_manager_print(x->f_io_manager, 0);
faust_opt_manager_print(x->f_opt_manager, 0);
faust_ui_manager_print(x->f_ui_manager, 0);
}


//////////////////////////////////////////////////////////////////////////////////////////////////
// PURE DATA GENERIC INTERFACE //
//////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -255,6 +261,7 @@ void faustgen_tilde_setup(void)
//class_addmethod(c, (t_method)faustgen_tilde_read, gensym("read"), A_SYMBOL);
class_addmethod(c, (t_method)faustgen_tilde_compile_options, gensym("compileoptions"), A_GIMME);
class_addmethod(c, (t_method)faustgen_tilde_autocompile, gensym("autocompile"), A_GIMME);
class_addmethod(c, (t_method)faustgen_tilde_print_parameters, gensym("print"), A_NULL);
class_addanything(c, (t_method)faustgen_tilde_anything);

CLASS_MAINSIGNALIN(c, t_faustgen_tilde, f_dummy);
Expand Down

0 comments on commit ec40b91

Please sign in to comment.