From 1a9f373e4f80c8c7009943eacad43acb34c6f29c Mon Sep 17 00:00:00 2001 From: Pierre Date: Tue, 21 Aug 2018 17:12:18 +0200 Subject: [PATCH 01/40] fix output value --- src/faustgen_tilde.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/faustgen_tilde.c b/src/faustgen_tilde.c index fe5d1a2..4032fc1 100644 --- a/src/faustgen_tilde.c +++ b/src/faustgen_tilde.c @@ -188,7 +188,7 @@ static void faustgen_tilde_anything(t_faustgen_tilde *x, t_symbol* s, int argc, { t_atom av; SETFLOAT(&av, value); - outlet_anything(faust_io_manager_get_extra_output(x->f_io_manager), s, 0, &av); + outlet_anything(faust_io_manager_get_extra_output(x->f_io_manager), s, 1, &av); return; } pd_error(x, "faustgen~: passive parameter '%s' not defined", s->s_name); From df5202e06ccab03fe91e413d72bc7c35a3d75fb1 Mon Sep 17 00:00:00 2001 From: Pierre Date: Wed, 22 Aug 2018 08:03:49 +0200 Subject: [PATCH 02/40] Improve parameters support --- src/faust_tilde_io.c | 32 ++--- src/faust_tilde_io.h | 4 +- src/faust_tilde_ui.c | 291 ++++++++++++++++++++----------------------- src/faust_tilde_ui.h | 8 +- src/faustgen_tilde.c | 45 ++++--- 5 files changed, 175 insertions(+), 205 deletions(-) diff --git a/src/faust_tilde_io.c b/src/faust_tilde_io.c index eeb35ca..7ca63f8 100644 --- a/src/faust_tilde_io.c +++ b/src/faust_tilde_io.c @@ -119,7 +119,7 @@ static char faust_io_manager_resize_inputs(t_faust_io_manager *x, size_t const n return 2; } -static char faust_io_manager_resize_outputs(t_faust_io_manager *x, size_t const nouts, char const extraout) +static char faust_io_manager_resize_outputs(t_faust_io_manager *x, size_t const nouts) { t_outlet** noutlets; size_t i; @@ -128,13 +128,7 @@ static char faust_io_manager_resize_outputs(t_faust_io_manager *x, size_t const if(rnouts == couts) { - if(faust_io_manager_has_extra_output(x) && !extraout) - { - outlet_free(x->f_extra_outlet); - x->f_extra_outlet = NULL; - return 0; - } - else if(!faust_io_manager_has_extra_output(x) && extraout) + if(!faust_io_manager_has_extra_output(x)) { x->f_extra_outlet = outlet_new((t_object *)x->f_owner, NULL); if(x->f_extra_outlet) @@ -170,17 +164,14 @@ static char faust_io_manager_resize_outputs(t_faust_io_manager *x, size_t const } x->f_outlets = noutlets; x->f_noutlets = rnouts; - if(extraout) + + x->f_extra_outlet = outlet_new((t_object *)x->f_owner, NULL); + if(x->f_extra_outlet) { - x->f_extra_outlet = outlet_new((t_object *)x->f_owner, NULL); - if(x->f_extra_outlet) - { - return 0; - } - pd_error(x->f_owner, "faustgen~: memory allocation failed - extra output"); - return 1; + return 0; } - return 0; + pd_error(x->f_owner, "faustgen~: memory allocation failed - extra output"); + return 1; } pd_error(x->f_owner, "faustgen~: memory allocation failed - output"); return 1; @@ -237,7 +228,7 @@ t_outlet* faust_io_manager_get_extra_output(t_faust_io_manager *x) return x->f_extra_outlet; } -char faust_io_manager_init(t_faust_io_manager *x, int const nins, int const nouts, char const extraout) +char faust_io_manager_init(t_faust_io_manager *x, int const nins, int const nouts) { char valid = 0; char const redraw = x->f_owner->te_binbuf && gobj_shouldvis((t_gobj *)x->f_owner, x->f_canvas) && glist_isvisible(x->f_canvas); @@ -247,7 +238,7 @@ char faust_io_manager_init(t_faust_io_manager *x, int const nins, int const nout } size_t const rnins = nins > 1 ? nins : 1; valid += faust_io_manager_resize_inputs(x, (size_t)rnins); - valid += faust_io_manager_resize_outputs(x, (size_t)nouts, extraout); + valid += faust_io_manager_resize_outputs(x, (size_t)nouts); valid += faust_io_manager_resize_signals(x, (size_t)rnins + (size_t)nouts); if(redraw) { @@ -319,9 +310,8 @@ t_sample** faust_io_manager_get_output_signals(t_faust_io_manager *x) return x->f_signals+x->f_ninlets; } -void faust_io_manager_print(t_faust_io_manager* x, char const log) +void faust_io_manager_print(t_faust_io_manager const* 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"); } diff --git a/src/faust_tilde_io.h b/src/faust_tilde_io.h index 1f606a3..4d0f992 100644 --- a/src/faust_tilde_io.h +++ b/src/faust_tilde_io.h @@ -24,7 +24,7 @@ char faust_io_manager_has_extra_output(t_faust_io_manager *x); t_outlet* faust_io_manager_get_extra_output(t_faust_io_manager *x); -char faust_io_manager_init(t_faust_io_manager *x, int const nins, int const nouts, char const extraout); +char faust_io_manager_init(t_faust_io_manager *x, int const nins, int const nouts); char faust_io_manager_prepare(t_faust_io_manager *x, t_signal **sp); @@ -32,6 +32,6 @@ t_sample** faust_io_manager_get_input_signals(t_faust_io_manager *x); t_sample** faust_io_manager_get_output_signals(t_faust_io_manager *x); -void faust_io_manager_print(t_faust_io_manager* x, char const log); +void faust_io_manager_print(t_faust_io_manager const* x, char const log); #endif diff --git a/src/faust_tilde_ui.c b/src/faust_tilde_ui.c index ef75d7a..2dbc219 100644 --- a/src/faust_tilde_ui.c +++ b/src/faust_tilde_ui.c @@ -18,89 +18,102 @@ typedef struct _faust_ui { - t_symbol* p_name; - t_symbol* p_longname; - int p_type; - FAUSTFLOAT* p_zone; - FAUSTFLOAT p_min; - FAUSTFLOAT p_max; - FAUSTFLOAT p_step; - FAUSTFLOAT p_default; - FAUSTFLOAT p_saved; + t_symbol* p_name; + t_symbol* p_longname; + int p_type; + FAUSTFLOAT* p_zone; + FAUSTFLOAT p_min; + FAUSTFLOAT p_max; + FAUSTFLOAT p_step; + FAUSTFLOAT p_default; + FAUSTFLOAT p_saved; + char p_kept; + FAUSTFLOAT p_tempv; + struct _faust_ui* p_next; }t_faust_ui; typedef struct _faust_ui_manager { UIGlue f_glue; t_object* f_owner; - t_clock* f_clock; - t_faust_ui* f_active_uis; - size_t f_nactive_uis; - t_faust_ui* f_temp_ui; - t_faust_ui* f_passive_uis; - size_t f_npassive_uis; + t_faust_ui* f_uis; t_symbol** f_names; size_t f_nnames; MetaGlue f_meta_glue; }t_faust_ui_manager; - -static void faust_ui_manager_clear_active_uis(t_faust_ui_manager *x) +static void faust_ui_manager_free_uis(t_faust_ui_manager *x) { - if(x->f_active_uis && x->f_nactive_uis) + t_faust_ui *c = x->f_uis; + while(c) { - freebytes(x->f_active_uis, x->f_nactive_uis * sizeof(t_faust_ui)); + x->f_uis = c->p_next; + freebytes(c, sizeof(*c)); + c = x->f_uis; } - x->f_active_uis = NULL; - x->f_nactive_uis = 0; } -static void faust_ui_manager_clear_passive_uis(t_faust_ui_manager *x) +static t_faust_ui* faust_ui_manager_get(t_faust_ui_manager const *x, t_symbol const *name) { - if(x->f_passive_uis && x->f_npassive_uis) + t_faust_ui *c = x->f_uis; + while(c) { - freebytes(x->f_passive_uis, x->f_npassive_uis * sizeof(t_faust_ui)); + if(c->p_name == name || c->p_longname == name) + { + return c; + } + c = c->p_next; } - x->f_passive_uis = NULL; - x->f_npassive_uis = 0; + return NULL; } -static void faust_ui_manager_clear_names(t_faust_ui_manager *x) +static void faust_ui_manager_prepare_changes(t_faust_ui_manager *x) { - if(x->f_names && x->f_nnames) + t_faust_ui *c = x->f_uis; + while(c) { - freebytes(x->f_names, x->f_nnames * sizeof(t_symbol *)); + c->p_kept = 0; + c->p_tempv = *(c->p_zone); + c = c->p_next; } - x->f_names = NULL; - x->f_nnames = 0; } -static t_faust_ui* faust_ui_manager_get_active_uis(t_faust_ui_manager *x, t_symbol* name) +static void faust_ui_manager_finish_changes(t_faust_ui_manager *x) { - size_t i; - for(i = 0; i < x->f_nactive_uis; ++i) + t_faust_ui *c = x->f_uis; + if(c) { - if(x->f_active_uis[i].p_name == name || - x->f_active_uis[i].p_longname == name) + t_faust_ui *n = c->p_next; + while(n) { - return x->f_active_uis+i; + if(!n->p_kept) + { + c->p_next = n->p_next; + freebytes(n, sizeof(*n)); + n = c->p_next; + } + else + { + c = n; + n = c->p_next; + } + } + if(!x->f_uis->p_kept) + { + x->f_uis = x->f_uis->p_next; + freebytes(x->f_uis, sizeof(*x->f_uis)); } } - return NULL; } -static t_faust_ui* faust_ui_manager_get_passive_uis(t_faust_ui_manager *x, t_symbol* name) +static void faust_ui_manager_free_names(t_faust_ui_manager *x) { - size_t i; - for(i = 0; i < x->f_npassive_uis; ++i) + if(x->f_names && x->f_nnames) { - if(x->f_passive_uis[i].p_name == name || - x->f_passive_uis[i].p_longname == name) - { - return x->f_passive_uis+i; - } + freebytes(x->f_names, x->f_nnames * sizeof(t_symbol *)); } - return NULL; + x->f_names = NULL; + x->f_nnames = 0; } static t_symbol* faust_ui_manager_get_long_name(t_faust_ui_manager *x, const char* label) @@ -117,52 +130,42 @@ static t_symbol* faust_ui_manager_get_long_name(t_faust_ui_manager *x, const cha return gensym(name); } -static void faust_ui_manager_add_params(t_faust_ui_manager *x, const char* label, int const type, FAUSTFLOAT* zone, +static void faust_ui_manager_add_param(t_faust_ui_manager *x, const char* label, int const type, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step) { - t_faust_ui *newmemory = NULL; - t_faust_ui *oldmemory = (type == FAUST_UI_TYPE_BARGRAPH) ? x->f_passive_uis : x->f_active_uis; - size_t size = (type == FAUST_UI_TYPE_BARGRAPH) ? x->f_npassive_uis : x->f_nactive_uis; - if(oldmemory) + FAUSTFLOAT saved, current; + t_symbol* name = gensym(label); + t_symbol* lname = faust_ui_manager_get_long_name(x, label); + t_faust_ui *c = faust_ui_manager_get(x, name); + if(c) { - newmemory = (t_faust_ui *)resizebytes(oldmemory, size * sizeof(t_faust_ui), (size + 1) * sizeof(t_faust_ui)); - if(!newmemory) - { - pd_error(x->f_owner, "faustgen~: memory allocation failed - ui glue"); - return; - } + saved = c->p_saved; + current = c->p_tempv; } else { - newmemory = (t_faust_ui *)getbytes(sizeof(t_faust_ui)); - if(!newmemory) + c = (t_faust_ui *)getbytes(sizeof(*c)); + if(!c) { pd_error(x->f_owner, "faustgen~: memory allocation failed - ui glue"); return; } + c->p_name = name; + c->p_next = x->f_uis; + x->f_uis = c; + saved = init; + current = init; } - - newmemory[size].p_name = gensym(label); - newmemory[size].p_longname = faust_ui_manager_get_long_name(x, label); - newmemory[size].p_type = type; - newmemory[size].p_zone = zone; - newmemory[size].p_min = min; - newmemory[size].p_max = max; - newmemory[size].p_step = step; - newmemory[size].p_default = init; - newmemory[size].p_saved = init; - *(newmemory[size].p_zone) = init; - if(type == FAUST_UI_TYPE_BARGRAPH) - { - x->f_passive_uis = (t_faust_ui *)newmemory; - x->f_npassive_uis = size + 1; - } - else - { - x->f_active_uis = (t_faust_ui *)newmemory; - x->f_nactive_uis = size + 1; - } - + c->p_longname = lname; + c->p_type = type; + c->p_zone = zone; + c->p_min = min; + c->p_max = max; + c->p_step = step; + c->p_default = init; + c->p_saved = saved; + c->p_kept = 1; + *(c->p_zone) = current; } ////////////////////////////////////////////////////////////////////////////////////////////////// @@ -238,18 +241,18 @@ static void faust_ui_manager_ui_close_box(t_faust_ui_manager* x) static void faust_ui_manager_ui_add_button(t_faust_ui_manager* x, const char* label, FAUSTFLOAT* zone) { - faust_ui_manager_add_params(x, label, FAUST_UI_TYPE_BUTTON, zone, 0, 0, 0, 0); + faust_ui_manager_add_param(x, label, FAUST_UI_TYPE_BUTTON, zone, 0, 0, 0, 0); } static void faust_ui_manager_ui_add_toggle(t_faust_ui_manager* x, const char* label, FAUSTFLOAT* zone) { - faust_ui_manager_add_params(x, label, FAUST_UI_TYPE_TOGGLE, zone, 0, 0, 1, 1); + faust_ui_manager_add_param(x, label, FAUST_UI_TYPE_TOGGLE, zone, 0, 0, 1, 1); } static void faust_ui_manager_ui_add_number(t_faust_ui_manager* x, const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step) { - faust_ui_manager_add_params(x, label, FAUST_UI_TYPE_NUMBER, zone, init, min, max, step); + faust_ui_manager_add_param(x, label, FAUST_UI_TYPE_NUMBER, zone, init, min, max, step); } // PASSIVE UIS @@ -258,7 +261,7 @@ static void faust_ui_manager_ui_add_number(t_faust_ui_manager* x, const char* la static void faust_ui_manager_ui_add_bargraph(t_faust_ui_manager* x, const char* label, FAUSTFLOAT* zone, FAUSTFLOAT min, FAUSTFLOAT max) { - faust_ui_manager_add_params(x, label, FAUST_UI_TYPE_BARGRAPH, zone, 0, min, max, 0); + faust_ui_manager_add_param(x, label, FAUST_UI_TYPE_BARGRAPH, zone, 0, min, max, 0); } static void faust_ui_manager_ui_add_sound_file(t_faust_ui_manager* x, const char* label, const char* filename, struct Soundfile** sf_zone) @@ -287,8 +290,6 @@ static void faust_ui_manager_meta_declare(t_faust_ui_manager* x, const char* key // PUBLIC INTERFACE // ////////////////////////////////////////////////////////////////////////////////////////////////// -static void faust_ui_manager_tick(t_faust_ui_manager* x); - t_faust_ui_manager* faust_ui_manager_new(t_object* owner) { t_faust_ui_manager* ui_manager = (t_faust_ui_manager*)getbytes(sizeof(t_faust_ui_manager)); @@ -311,14 +312,10 @@ t_faust_ui_manager* faust_ui_manager_new(t_object* owner) ui_manager->f_glue.addSoundFile = (addSoundFileFun)faust_ui_manager_ui_add_sound_file; ui_manager->f_glue.declare = (declareFun)faust_ui_manager_ui_declare; - ui_manager->f_owner = owner; - ui_manager->f_clock = clock_new(ui_manager, (t_method)faust_ui_manager_tick); - ui_manager->f_active_uis = NULL; - ui_manager->f_nactive_uis = 0; - ui_manager->f_passive_uis = NULL; - ui_manager->f_npassive_uis = 0; - ui_manager->f_names = NULL; - ui_manager->f_nnames = 0; + ui_manager->f_owner = owner; + ui_manager->f_uis = NULL; + ui_manager->f_names = NULL; + ui_manager->f_nnames = 0; ui_manager->f_meta_glue.metaInterface = ui_manager; ui_manager->f_meta_glue.declare = (metaDeclareFun)faust_ui_manager_meta_declare; @@ -329,49 +326,40 @@ t_faust_ui_manager* faust_ui_manager_new(t_object* owner) void faust_ui_manager_free(t_faust_ui_manager *x) { faust_ui_manager_clear(x); - freebytes(x, sizeof(t_faust_ui_manager)); + freebytes(x, sizeof(*x)); } void faust_ui_manager_init(t_faust_ui_manager *x, void* dspinstance) { - faust_ui_manager_clear(x); + faust_ui_manager_prepare_changes(x); buildUserInterfaceCDSPInstance((llvm_dsp *)dspinstance, (UIGlue *)&(x->f_glue)); - faust_ui_manager_clear_names(x); + faust_ui_manager_finish_changes(x); + faust_ui_manager_free_names(x); metadataCDSPInstance((llvm_dsp *)dspinstance, &x->f_meta_glue); } void faust_ui_manager_clear(t_faust_ui_manager *x) { - faust_ui_manager_clear_active_uis(x); - faust_ui_manager_clear_passive_uis(x); - faust_ui_manager_clear_names(x); -} - -static void faust_ui_manager_tick(t_faust_ui_manager* x) -{ - if(x->f_temp_ui) - { - *(x->f_temp_ui->p_zone) = 0; - } - x->f_temp_ui = NULL; + faust_ui_manager_free_uis(x); + faust_ui_manager_free_names(x); } -char faust_ui_manager_has_passive_ui(t_faust_ui_manager *x) +char faust_ui_manager_set_value(t_faust_ui_manager *x, t_symbol const *name, t_float const f) { - return x->f_npassive_uis > 0; -} - -char faust_ui_manager_set(t_faust_ui_manager *x, t_symbol* name, t_float f) -{ - t_faust_ui* ui = faust_ui_manager_get_active_uis(x, name); + t_faust_ui* ui = faust_ui_manager_get(x, name); if(ui) { if(ui->p_type == FAUST_UI_TYPE_BUTTON) { - *(ui->p_zone) = 0; - *(ui->p_zone) = 1; - x->f_temp_ui = ui; - clock_delay(x->f_clock, 1.5); + if(f > FLT_EPSILON) + { + *(ui->p_zone) = 0; + *(ui->p_zone) = 1; + } + else + { + *(ui->p_zone) = 0; + } return 0; } else if(ui->p_type == FAUST_UI_TYPE_TOGGLE) @@ -399,9 +387,9 @@ char faust_ui_manager_set(t_faust_ui_manager *x, t_symbol* name, t_float f) return 1; } -char faust_ui_manager_get(t_faust_ui_manager *x, t_symbol* name, t_float* f) +char faust_ui_manager_get_value(t_faust_ui_manager const *x, t_symbol const *name, t_float* f) { - t_faust_ui* ui = faust_ui_manager_get_passive_uis(x, name); + t_faust_ui* ui = faust_ui_manager_get(x, name); if(ui) { *f = (t_float)(*(ui->p_zone)); @@ -412,32 +400,35 @@ char faust_ui_manager_get(t_faust_ui_manager *x, t_symbol* name, t_float* f) void faust_ui_manager_save_states(t_faust_ui_manager *x) { - size_t i; - for(i = 0; i < x->f_nactive_uis; ++i) + t_faust_ui *c = x->f_uis; + while(c) { - x->f_active_uis[i].p_saved = *(x->f_active_uis[i].p_zone); + c->p_saved = *(c->p_zone); + c = c->p_next; } } void faust_ui_manager_restore_states(t_faust_ui_manager *x) { - size_t i; - for(i = 0; i < x->f_nactive_uis; ++i) + t_faust_ui *c = x->f_uis; + while(c) { - *(x->f_active_uis[i].p_zone) = x->f_active_uis[i].p_saved; + *(c->p_zone) = c->p_saved; + c = c->p_next; } } void faust_ui_manager_restore_default(t_faust_ui_manager *x) { - size_t i; - for(i = 0; i < x->f_nactive_uis; ++i) + t_faust_ui *c = x->f_uis; + while(c) { - *(x->f_active_uis[i].p_zone) = x->f_active_uis[i].p_default; + *(c->p_zone) = c->p_default; + c = c->p_next; } } -const char* faust_ui_manager_get_parameter_char(int type) +static const char* faust_ui_manager_get_parameter_char(int const type) { if(type == FAUST_UI_TYPE_BUTTON) return "button"; @@ -449,32 +440,16 @@ const char* faust_ui_manager_get_parameter_char(int type) return "bargraph"; } -void faust_ui_manager_print(t_faust_ui_manager* x, char const log) +void faust_ui_manager_print(t_faust_ui_manager const *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) + t_faust_ui *c = x->f_uis; + while(c) { - 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); + logpost(x->f_owner, 2+log, " parameter: %s [path:%s - type:%s - init:%g - min:%g - max:%g - current:%g]", + c->p_name->s_name, c->p_longname->s_name, + faust_ui_manager_get_parameter_char(c->p_type), + c->p_default, c->p_min, c->p_max, *c->p_zone); + c = c->p_next; } } diff --git a/src/faust_tilde_ui.h b/src/faust_tilde_ui.h index 3806e98..5ad4552 100644 --- a/src/faust_tilde_ui.h +++ b/src/faust_tilde_ui.h @@ -20,16 +20,14 @@ void faust_ui_manager_free(t_faust_ui_manager *x); void faust_ui_manager_clear(t_faust_ui_manager *x); -char faust_ui_manager_has_passive_ui(t_faust_ui_manager *x); +char faust_ui_manager_set_value(t_faust_ui_manager *x, t_symbol const *name, t_float const f); -char faust_ui_manager_set(t_faust_ui_manager *x, t_symbol* name, t_float f); - -char faust_ui_manager_get(t_faust_ui_manager *x, t_symbol* name, t_float* f); +char faust_ui_manager_get_value(t_faust_ui_manager const *x, t_symbol const *name, t_float* f); 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); +void faust_ui_manager_print(t_faust_ui_manager const *x, char const log); #endif diff --git a/src/faustgen_tilde.c b/src/faustgen_tilde.c index 4032fc1..e5bbcb8 100644 --- a/src/faustgen_tilde.c +++ b/src/faustgen_tilde.c @@ -78,37 +78,44 @@ static void faustgen_tilde_compile(t_faustgen_tilde *x) filepath = faust_opt_manager_get_full_path(x->f_opt_manager, x->f_dsp_name->s_name); if(filepath) { + llvm_dsp* instance; + llvm_dsp_factory* factory; char errors[MAXFAUSTSTRING]; int noptions = (int)faust_opt_manager_get_noptions(x->f_opt_manager); char const** options = faust_opt_manager_get_options(x->f_opt_manager); - faustgen_tilde_delete_instance(x); - faustgen_tilde_delete_factory(x); - faust_ui_manager_clear(x->f_ui_manager); - x->f_dsp_factory = createCDSPFactoryFromFile(filepath, noptions, options, "", errors, -1); + factory = createCDSPFactoryFromFile(filepath, noptions, options, "", errors, -1); if(strnlen(errors, MAXFAUSTSTRING)) { pd_error(x, "faustgen~: try to load %s", filepath); pd_error(x, "faustgen~: %s", errors); - x->f_dsp_factory = NULL; - + faustgen_tilde_delete_instance(x); + faustgen_tilde_delete_factory(x); canvas_resume_dsp(dspstate); return; } - - x->f_dsp_instance = createCDSPInstance(x->f_dsp_factory); - if(x->f_dsp_instance) + + + instance = createCDSPInstance(factory); + if(instance) { - const int ninputs = getNumInputsCDSPInstance(x->f_dsp_instance); - const int noutputs = getNumOutputsCDSPInstance(x->f_dsp_instance); + const int ninputs = getNumInputsCDSPInstance(instance); + const int noutputs = getNumOutputsCDSPInstance(instance); logpost(x, 3, "\nfaustgen~: compilation from source '%s' succeeded", x->f_dsp_name->s_name); - 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, instance); + faust_io_manager_init(x->f_io_manager, ninputs, noutputs); + + faustgen_tilde_delete_instance(x); + faustgen_tilde_delete_factory(x); + x->f_dsp_factory = factory; + x->f_dsp_instance = instance; canvas_resume_dsp(dspstate); return; } + faustgen_tilde_delete_instance(x); + faustgen_tilde_delete_factory(x); pd_error(x, "faustgen~: memory allocation failed - instance"); canvas_resume_dsp(dspstate); return; @@ -184,28 +191,28 @@ static void faustgen_tilde_anything(t_faustgen_tilde *x, t_symbol* s, int argc, if(!argc) { t_float value; - if(!faust_ui_manager_get(x->f_ui_manager, s, &value)) + if(!faust_ui_manager_get_value(x->f_ui_manager, s, &value)) { t_atom av; SETFLOAT(&av, value); outlet_anything(faust_io_manager_get_extra_output(x->f_io_manager), s, 1, &av); return; } - pd_error(x, "faustgen~: passive parameter '%s' not defined", s->s_name); + pd_error(x, "faustgen~: parameter '%s' not defined", s->s_name); return; } else if(argc == 1) { if(argv[0].a_type != A_FLOAT) { - pd_error(x, "faustgen~: active parameter requires a float value"); + pd_error(x, "faustgen~: parameter requires a float value"); return; } - if(!faust_ui_manager_set(x->f_ui_manager, s, argv[0].a_w.w_float)) + if(!faust_ui_manager_set_value(x->f_ui_manager, s, argv[0].a_w.w_float)) { return; } - pd_error(x, "faustgen~: active parameter '%s' not defined", s->s_name); + pd_error(x, "faustgen~: parameter '%s' not defined", s->s_name); return; } else @@ -236,7 +243,7 @@ static void faustgen_tilde_anything(t_faustgen_tilde *x, t_symbol* s, int argc, { pd_error(x, "faustgen~: active parameter requires a float value"); } - if(faust_ui_manager_set(x->f_ui_manager, gensym(name), argv[i+1].a_w.w_float)) + if(faust_ui_manager_set_value(x->f_ui_manager, gensym(name), argv[i+1].a_w.w_float)) { pd_error(x, "faustgen~: active parameter '%s' not defined", name); return; From 208b7511994a1c047718b004a8493d2cf667e096 Mon Sep 17 00:00:00 2001 From: Pierre Date: Wed, 22 Aug 2018 08:11:43 +0200 Subject: [PATCH 03/40] add tests and update changelog --- ChangeLog.md | 3 +++ tests/recompile.dsp | 11 +++++++++++ tests/recompile.pd | 30 ++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 tests/recompile.dsp create mode 100644 tests/recompile.pd diff --git a/ChangeLog.md b/ChangeLog.md index f52c4af..61dfc89 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,3 +1,6 @@ +### v0.0.6 +- Preserve parameters values during recompilation + ### v0.0.5 - Fix when no arguments - Update deken script diff --git a/tests/recompile.dsp b/tests/recompile.dsp new file mode 100644 index 0000000..07aeb93 --- /dev/null +++ b/tests/recompile.dsp @@ -0,0 +1,11 @@ +declare name "Dummy"; +declare version "1.0"; +declare author "Heu... me..."; + + +process =_ <: _ * gain1, _ * gain2 +with +{ + gain1 = vslider("gain1 [unit:linear]", 0.2, 0 , 1, 0.001); + gain2 = vslider("gain2 [unit:linear]", 0.2, 0 , 1, 0.001); +}; diff --git a/tests/recompile.pd b/tests/recompile.pd new file mode 100644 index 0000000..812f3bb --- /dev/null +++ b/tests/recompile.pd @@ -0,0 +1,30 @@ +#N canvas 229 134 455 400 10; +#X obj 286 115 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 1 +1; +#X msg 286 135 \; pd dsp \$1; +#X obj 32 308 dac~ 1 2; +#X obj 51 129 nbx 5 14 0 1 0 0 empty empty empty 0 -8 0 10 -262144 +-1 -1 0.95 256; +#X obj 31 242 ../external/faustgen~ recompile, f 16; +#X obj 199 40 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 1 +1; +#X msg 199 69 autocompile \$1 100; +#X obj 199 19 loadbang; +#X obj 31 47 osc~ 220; +#X msg 51 148 gain1 \$1; +#X obj 122 169 nbx 5 14 0 1 0 0 empty empty empty 0 -8 0 10 -262144 +-1 -1 0.7 256; +#X msg 122 188 gain2 \$1; +#X msg 200 136 compile; +#X connect 0 0 1 0; +#X connect 3 0 9 0; +#X connect 4 0 2 0; +#X connect 4 1 2 1; +#X connect 5 0 6 0; +#X connect 6 0 4 0; +#X connect 7 0 5 0; +#X connect 8 0 4 0; +#X connect 9 0 4 0; +#X connect 10 0 11 0; +#X connect 11 0 4 0; +#X connect 12 0 4 0; From c2ed1b641844a8d2f9e70dc6d6f0c3b7d2dba4da Mon Sep 17 00:00:00 2001 From: Pierre Date: Wed, 22 Aug 2018 08:15:16 +0200 Subject: [PATCH 04/40] fix get time when instance not valid --- src/faustgen_tilde.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/faustgen_tilde.c b/src/faustgen_tilde.c index e5bbcb8..b7b4a2b 100644 --- a/src/faustgen_tilde.c +++ b/src/faustgen_tilde.c @@ -140,9 +140,13 @@ static void faustgen_tilde_read(t_faustgen_tilde *x, t_symbol* s) static long faustgen_tilde_get_time(t_faustgen_tilde *x) { - struct stat attrib; - stat(faust_opt_manager_get_full_path(x->f_opt_manager, x->f_dsp_name->s_name), &attrib); - return attrib.st_ctime; + if(x->f_dsp_instance) + { + struct stat attrib; + stat(faust_opt_manager_get_full_path(x->f_opt_manager, x->f_dsp_name->s_name), &attrib); + return attrib.st_ctime; + } + return 0; } static void faustgen_tilde_autocompile_tick(t_faustgen_tilde *x) From aa18e3b904f38e1ca182f74230c78ed491145f57 Mon Sep 17 00:00:00 2001 From: Pierre Date: Wed, 22 Aug 2018 08:22:17 +0200 Subject: [PATCH 05/40] add test for passive parameters --- tests/passive.dsp | 13 +++++++++++++ tests/passive.pd | 25 +++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 tests/passive.dsp create mode 100644 tests/passive.pd diff --git a/tests/passive.dsp b/tests/passive.dsp new file mode 100644 index 0000000..9424b5b --- /dev/null +++ b/tests/passive.dsp @@ -0,0 +1,13 @@ +declare name "Dummy"; +declare version "1.0"; +declare author "Heu... me..."; + + +process = _ * gain1 * gain2 * gain3 * gain4 +with +{ + gain1 = vslider("gain1 [unit:linear]", 0.1, 0 , 1, 0.001); + gain2 = vslider("gain2 [unit:linear]", 0.2, 0 , 1, 0.001); + gain3 = vslider("gain3 [unit:linear]", 0.3, 0 , 1, 0.001); + gain4 = vslider("gain4 [unit:linear]", 0.4, 0 , 1, 0.001); +}; diff --git a/tests/passive.pd b/tests/passive.pd new file mode 100644 index 0000000..934bda7 --- /dev/null +++ b/tests/passive.pd @@ -0,0 +1,25 @@ +#N canvas 229 134 455 400 10; +#X obj 286 115 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 +1; +#X msg 286 135 \; pd dsp \$1; +#X obj 32 308 dac~ 1 2; +#X obj 31 47 osc~ 220; +#X msg 200 136 compile; +#X obj 31 242 ../external/faustgen~ passive, f 16; +#X msg 51 148 gain1; +#X msg 122 188 gain2; +#X obj 124 282 print; +#X msg 206 166 print; +#X msg 51 118 gain3; +#X msg 121 158 gain4; +#X connect 0 0 1 0; +#X connect 3 0 5 0; +#X connect 4 0 5 0; +#X connect 5 0 2 0; +#X connect 5 0 2 1; +#X connect 5 1 8 0; +#X connect 6 0 5 0; +#X connect 7 0 5 0; +#X connect 9 0 5 0; +#X connect 10 0 5 0; +#X connect 11 0 5 0; From 646c7104b651663bb84560698db8329a794b687b Mon Sep 17 00:00:00 2001 From: Pierre Date: Wed, 22 Aug 2018 18:07:20 +0200 Subject: [PATCH 06/40] updated ToDoList --- ToDoList.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ToDoList.md b/ToDoList.md index 715bafd..7fb3477 100644 --- a/ToDoList.md +++ b/ToDoList.md @@ -4,4 +4,4 @@ - Check why FAUST double option crashes - Add method to open the FAUST file in the default text editor - Add a default temporary FAUST file when no argument -- Add support for saving parameters states +- Look for the DSP file in all Pd's search paths From f32205001bddb2752932821ae44f2361ae129673 Mon Sep 17 00:00:00 2001 From: Pierre Date: Wed, 22 Aug 2018 18:07:38 +0200 Subject: [PATCH 07/40] update change log --- ChangeLog.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ChangeLog.md b/ChangeLog.md index 61dfc89..38ab8a3 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,8 +1,9 @@ ### v0.0.6 - Preserve parameters values during recompilation +- Fix autocompilation when DSP instance not initialized ### v0.0.5 -- Fix when no arguments +- Fix when no argument is provided - Update deken script - Fix sources distribution From 0fdd4bc0b6f5cc1a13375536553d88fef7681d5f Mon Sep 17 00:00:00 2001 From: Pierre Date: Wed, 22 Aug 2018 18:19:33 +0200 Subject: [PATCH 08/40] fix default FAUSTFLOAT using Pd t_sample for future double precision compatibility --- src/faustgen_tilde.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/faustgen_tilde.c b/src/faustgen_tilde.c index b7b4a2b..3d004a5 100644 --- a/src/faustgen_tilde.c +++ b/src/faustgen_tilde.c @@ -11,6 +11,7 @@ #include #include +#define FAUSTFLOAT t_sample #include #include "faust_tilde_ui.h" From 575a5094aa30486e6246eb71986f10d4084ddf69 Mon Sep 17 00:00:00 2001 From: Pierre Date: Wed, 22 Aug 2018 18:20:40 +0200 Subject: [PATCH 09/40] improve option manager function prototype --- src/faust_tilde_options.c | 2 +- src/faust_tilde_options.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/faust_tilde_options.c b/src/faust_tilde_options.c index f77a63b..e6692b0 100644 --- a/src/faust_tilde_options.c +++ b/src/faust_tilde_options.c @@ -216,7 +216,7 @@ char const* faust_opt_manager_get_full_path(t_faust_opt_manager* x, char const* return NULL; } -void faust_opt_manager_print(t_faust_opt_manager* x, char const log) +void faust_opt_manager_print(t_faust_opt_manager const *x, char const log) { size_t i; for(i = 0; i < x->f_noptions; ++i) diff --git a/src/faust_tilde_options.h b/src/faust_tilde_options.h index a984cff..60e3aa8 100644 --- a/src/faust_tilde_options.h +++ b/src/faust_tilde_options.h @@ -24,6 +24,7 @@ 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); +void faust_opt_manager_print(t_faust_opt_manager const *x, char const log); + #endif From cd4f38316150ed17370074fab6e2e7289865d530 Mon Sep 17 00:00:00 2001 From: Pierre Date: Wed, 22 Aug 2018 18:21:29 +0200 Subject: [PATCH 10/40] add double precision function to options manager --- src/faust_tilde_options.c | 15 ++++++++++++++- src/faust_tilde_options.h | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/faust_tilde_options.c b/src/faust_tilde_options.c index e6692b0..eae24ea 100644 --- a/src/faust_tilde_options.c +++ b/src/faust_tilde_options.c @@ -193,7 +193,20 @@ char const** faust_opt_manager_get_options(t_faust_opt_manager* x) return (char const**)x->f_options; } -char const* faust_opt_manager_get_full_path(t_faust_opt_manager* x, char const* name) +char faust_opt_has_double_precision(t_faust_opt_manager const *x) +{ + size_t i; + for(i = 0; i < x->f_noptions; ++i) + { + if(strncmp(x->f_options[i], "-double", 7)) + { + return 1; + } + } + return 0; +} + +char const* faust_opt_manager_get_full_path(t_faust_opt_manager *x, char const* name) { if(sys_isabsolutepath(name)) { diff --git a/src/faust_tilde_options.h b/src/faust_tilde_options.h index 60e3aa8..9c657f6 100644 --- a/src/faust_tilde_options.h +++ b/src/faust_tilde_options.h @@ -26,5 +26,6 @@ char const* faust_opt_manager_get_full_path(t_faust_opt_manager* x, char const* void faust_opt_manager_print(t_faust_opt_manager const *x, char const log); +char faust_opt_has_double_precision(t_faust_opt_manager const *x); #endif From 73f3b41bf5ad122dce68baf458c6588fc1fb5f8e Mon Sep 17 00:00:00 2001 From: Pierre Date: Wed, 22 Aug 2018 18:21:57 +0200 Subject: [PATCH 11/40] add internal check to avoid multiple precision conflicts --- src/faust_tilde_options.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/faust_tilde_options.c b/src/faust_tilde_options.c index eae24ea..5020cc0 100644 --- a/src/faust_tilde_options.c +++ b/src/faust_tilde_options.c @@ -78,6 +78,7 @@ static void faust_opt_manager_free_compile_options(t_faust_opt_manager *x) char faust_opt_manager_parse_compile_options(t_faust_opt_manager *x, size_t const argc, const t_atom* argv) { char has_include = 0; + char has_precision = 0; faust_opt_manager_free_compile_options(x); if(argc && argv) { @@ -101,6 +102,17 @@ char faust_opt_manager_parse_compile_options(t_faust_opt_manager *x, size_t cons { has_include = 1; } + else if(!strncmp(x->f_options[i], "-double", 7) || + !strncmp(x->f_options[i], "-single", 7) || + !strncmp(x->f_options[i], "-quad", 5)) + { + if(has_precision) + { + pd_error(x->f_owner, "faustgen~: floating-point format already defined"); + memset(x->f_options[i], 0, MAXFAUSTSTRING); + } + has_precision = 1; + } } else { From ea09b4f1c2591af4533a468985c698c9776a166c Mon Sep 17 00:00:00 2001 From: Pierre Date: Wed, 22 Aug 2018 19:07:16 +0200 Subject: [PATCH 12/40] fix previous commit --- src/faust_tilde_options.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/faust_tilde_options.c b/src/faust_tilde_options.c index 5020cc0..8f55ce6 100644 --- a/src/faust_tilde_options.c +++ b/src/faust_tilde_options.c @@ -210,7 +210,7 @@ char faust_opt_has_double_precision(t_faust_opt_manager const *x) size_t i; for(i = 0; i < x->f_noptions; ++i) { - if(strncmp(x->f_options[i], "-double", 7)) + if(!strncmp(x->f_options[i], "-double", 7)) { return 1; } From 97c3a29a701c7187213c0cd7dc43f5d46f580916 Mon Sep 17 00:00:00 2001 From: Pierre Date: Wed, 22 Aug 2018 19:07:37 +0200 Subject: [PATCH 13/40] add support for -double and -single options --- src/faustgen_tilde.c | 156 +++++++++++++++++++++++++++++++++---------- 1 file changed, 120 insertions(+), 36 deletions(-) diff --git a/src/faustgen_tilde.c b/src/faustgen_tilde.c index 3d004a5..5a5f490 100644 --- a/src/faustgen_tilde.c +++ b/src/faustgen_tilde.c @@ -27,9 +27,11 @@ typedef struct _faustgen_tilde llvm_dsp_factory* f_dsp_factory; llvm_dsp* f_dsp_instance; - FAUSTFLOAT** f_signal_matrix; - FAUSTFLOAT* f_signal_aligned; - size_t f_signal_aligned_size; + float** f_signal_matrix_single; + float* f_signal_aligned_single; + + double** f_signal_matrix_double; + double* f_signal_aligned_double; t_faust_ui_manager* f_ui_manager; t_faust_io_manager* f_io_manager; @@ -260,14 +262,14 @@ static void faustgen_tilde_anything(t_faustgen_tilde *x, t_symbol* s, int argc, pd_error(x, "faustgen~: no dsp instance"); } -static t_int *faustgen_tilde_perform(t_int *w) +static t_int *faustgen_tilde_perform_single(t_int *w) { int i, j; llvm_dsp *dsp = (llvm_dsp *)w[1]; int const nsamples = (int)w[2]; int const ninputs = (int)w[3]; int const noutputs = (int)w[4]; - FAUSTFLOAT** faustsigs = (FAUSTFLOAT **)w[5]; + float** faustsigs = (float **)w[5]; t_sample const** realinputs = (t_sample const**)w[6]; t_sample** realoutputs = (t_sample **)w[7]; for(i = 0; i < ninputs; ++i) @@ -277,7 +279,7 @@ static t_int *faustgen_tilde_perform(t_int *w) faustsigs[i][j] = (FAUSTFLOAT)realinputs[i][j]; } } - computeCDSPInstance(dsp, nsamples, faustsigs, faustsigs+ninputs); + computeCDSPInstance(dsp, nsamples, (FAUSTFLOAT**)faustsigs, (FAUSTFLOAT**)(faustsigs+ninputs)); for(i = 0; i < noutputs; ++i) { for(j = 0; j < nsamples; ++j) @@ -288,18 +290,101 @@ static t_int *faustgen_tilde_perform(t_int *w) return (w+8); } -static void faustgen_tilde_free_signal(t_faustgen_tilde *x) +static t_int *faustgen_tilde_perform_double(t_int *w) { - if(x->f_signal_aligned) + int i, j; + llvm_dsp *dsp = (llvm_dsp *)w[1]; + int const nsamples = (int)w[2]; + int const ninputs = (int)w[3]; + int const noutputs = (int)w[4]; + double** faustsigs = (double **)w[5]; + t_sample const** realinputs = (t_sample const**)w[6]; + t_sample** realoutputs = (t_sample **)w[7]; + for(i = 0; i < ninputs; ++i) { - free(x->f_signal_aligned); + for(j = 0; j < nsamples; ++j) + { + faustsigs[i][j] = (FAUSTFLOAT)realinputs[i][j]; + } } - x->f_signal_aligned = NULL; - if(x->f_signal_matrix) + computeCDSPInstance(dsp, nsamples, (FAUSTFLOAT**)faustsigs, (FAUSTFLOAT**)(faustsigs+ninputs)); + for(i = 0; i < noutputs; ++i) { - free(x->f_signal_matrix); + for(j = 0; j < nsamples; ++j) + { + realoutputs[i][j] = (t_sample)faustsigs[ninputs+i][j]; + } + } + return (w+8); +} + +static void faustgen_tilde_free_signals(t_faustgen_tilde *x) +{ + if(x->f_signal_aligned_single) + { + free(x->f_signal_aligned_single); + } + x->f_signal_aligned_single = NULL; + if(x->f_signal_matrix_single) + { + free(x->f_signal_matrix_single); + } + x->f_signal_matrix_single = NULL; + + if(x->f_signal_aligned_double) + { + free(x->f_signal_aligned_double); + } + x->f_signal_aligned_double = NULL; + if(x->f_signal_matrix_double) + { + free(x->f_signal_matrix_double); + } + x->f_signal_matrix_double = NULL; +} + +static void faustgen_tilde_alloc_signals_single(t_faustgen_tilde *x, size_t const ninputs, size_t const noutputs, size_t const nsamples) +{ + size_t i; + faustgen_tilde_free_signals(x); + x->f_signal_aligned_single = (float *)malloc((ninputs + noutputs) * nsamples * sizeof(float)); + if(!x->f_signal_aligned_single) + { + pd_error(x, "memory allocation failed"); + return; + } + x->f_signal_matrix_single = (float **)malloc((ninputs + noutputs) * sizeof(float *)); + if(!x->f_signal_matrix_single) + { + pd_error(x, "memory allocation failed"); + return; + } + for(i = 0; i < (ninputs + noutputs); ++i) + { + x->f_signal_matrix_single[i] = (x->f_signal_aligned_single+(i*nsamples)); + } +} + +static void faustgen_tilde_alloc_signals_double(t_faustgen_tilde *x, size_t const ninputs, size_t const noutputs, size_t const nsamples) +{ + size_t i; + faustgen_tilde_free_signals(x); + x->f_signal_aligned_double = (double *)malloc((ninputs + noutputs) * nsamples * sizeof(double)); + if(!x->f_signal_aligned_double) + { + pd_error(x, "memory allocation failed"); + return; + } + x->f_signal_matrix_double = (double **)malloc((ninputs + noutputs) * sizeof(double *)); + if(!x->f_signal_matrix_double) + { + pd_error(x, "memory allocation failed"); + return; + } + for(i = 0; i < (ninputs + noutputs); ++i) + { + x->f_signal_matrix_double[i] = (x->f_signal_aligned_double+(i*nsamples)); } - x->f_signal_matrix = NULL; } static void faustgen_tilde_dsp(t_faustgen_tilde *x, t_signal **sp) @@ -314,33 +399,30 @@ static void faustgen_tilde_dsp(t_faustgen_tilde *x, t_signal **sp) } if(!faust_io_manager_prepare(x->f_io_manager, sp)) { - size_t i; size_t const ninputs = faust_io_manager_get_ninputs(x->f_io_manager); size_t const noutputs = faust_io_manager_get_noutputs(x->f_io_manager); size_t const nsamples = (size_t)sp[0]->s_n; - - faustgen_tilde_free_signal(x); - x->f_signal_aligned = (t_sample *)malloc((ninputs + noutputs) * nsamples * sizeof(FAUSTFLOAT)); - if(!x->f_signal_aligned) - { - pd_error(x, "memory allocation failed"); - return; - } - x->f_signal_matrix = (FAUSTFLOAT **)malloc((ninputs + noutputs) * sizeof(FAUSTFLOAT *)); - if(!x->f_signal_matrix) + + if(faust_opt_has_double_precision(x->f_opt_manager)) { - pd_error(x, "memory allocation failed"); - return; + post("double precision"); + faustgen_tilde_alloc_signals_double(x, ninputs, noutputs, nsamples); + dsp_add((t_perfroutine)faustgen_tilde_perform_double, 7, + (t_int)x->f_dsp_instance, (t_int)nsamples, (t_int)ninputs, (t_int)noutputs, + (t_int)x->f_signal_matrix_double, + (t_int)faust_io_manager_get_input_signals(x->f_io_manager), + (t_int)faust_io_manager_get_output_signals(x->f_io_manager)); } - for(i = 0; i < (ninputs + noutputs); ++i) + else { - x->f_signal_matrix[i] = (x->f_signal_aligned+(i*nsamples)); + post("single precision"); + faustgen_tilde_alloc_signals_single(x, ninputs, noutputs, nsamples); + dsp_add((t_perfroutine)faustgen_tilde_perform_single, 7, + (t_int)x->f_dsp_instance, (t_int)nsamples, (t_int)ninputs, (t_int)noutputs, + (t_int)x->f_signal_matrix_single, + (t_int)faust_io_manager_get_input_signals(x->f_io_manager), + (t_int)faust_io_manager_get_output_signals(x->f_io_manager)); } - dsp_add((t_perfroutine)faustgen_tilde_perform, 7, - (t_int)x->f_dsp_instance, (t_int)nsamples, (t_int)ninputs, (t_int)noutputs, - (t_int)x->f_signal_matrix, - (t_int)faust_io_manager_get_input_signals(x->f_io_manager), - (t_int)faust_io_manager_get_output_signals(x->f_io_manager)); } if(initialized) { @@ -356,6 +438,7 @@ static void faustgen_tilde_free(t_faustgen_tilde *x) faust_ui_manager_free(x->f_ui_manager); faust_io_manager_free(x->f_io_manager); faust_opt_manager_free(x->f_opt_manager); + faustgen_tilde_free_signals(x); } static void *faustgen_tilde_new(t_symbol* s, int argc, t_atom* argv) @@ -366,9 +449,10 @@ static void *faustgen_tilde_new(t_symbol* s, int argc, t_atom* argv) x->f_dsp_factory = NULL; x->f_dsp_instance = NULL; - x->f_signal_matrix = NULL; - x->f_signal_aligned = NULL; - x->f_signal_aligned_size = 0; + x->f_signal_matrix_single = NULL; + x->f_signal_aligned_single = NULL; + x->f_signal_matrix_double = NULL; + x->f_signal_aligned_double = NULL; x->f_ui_manager = faust_ui_manager_new((t_object *)x); x->f_io_manager = faust_io_manager_new((t_object *)x, canvas_getcurrent()); From 2707ad57b59d4f408a7170d15a2fb748f39048ba Mon Sep 17 00:00:00 2001 From: Pierre Date: Wed, 22 Aug 2018 19:07:52 +0200 Subject: [PATCH 14/40] add tests for double/single options --- tests/double.dsp | 6 ++++++ tests/double.pd | 21 +++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 tests/double.dsp create mode 100644 tests/double.pd diff --git a/tests/double.dsp b/tests/double.dsp new file mode 100644 index 0000000..7616f1a --- /dev/null +++ b/tests/double.dsp @@ -0,0 +1,6 @@ +declare name "Dummy"; +declare version "1.0"; +declare author "Heu... me..."; + + +process = _ * 0.01; diff --git a/tests/double.pd b/tests/double.pd new file mode 100644 index 0000000..9eca909 --- /dev/null +++ b/tests/double.pd @@ -0,0 +1,21 @@ +#N canvas 229 134 455 400 10; +#X obj 286 115 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 +1; +#X msg 286 135 \; pd dsp \$1; +#X obj 32 308 dac~ 1 2; +#X obj 31 47 osc~ 220; +#X msg 49 71 compile; +#X obj 124 282 print; +#X obj 31 242 ../external/faustgen~ double, f 16; +#X msg 70 95 compileoptions -single; +#X msg 70 125 compileoptions -double; +#X msg 70 155 compileoptions -single -double; +#X connect 0 0 1 0; +#X connect 3 0 6 0; +#X connect 4 0 6 0; +#X connect 6 0 2 0; +#X connect 6 0 2 1; +#X connect 6 1 5 0; +#X connect 7 0 6 0; +#X connect 8 0 6 0; +#X connect 9 0 6 0; From f204cbf66b515280065ab3cb84566df90a5cbf93 Mon Sep 17 00:00:00 2001 From: Pierre Date: Wed, 22 Aug 2018 19:08:50 +0200 Subject: [PATCH 15/40] updated change log and todo list --- ChangeLog.md | 1 + ToDoList.md | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog.md b/ChangeLog.md index 38ab8a3..c1c7989 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,6 +1,7 @@ ### v0.0.6 - Preserve parameters values during recompilation - Fix autocompilation when DSP instance not initialized +- Fix support for the double-float-precision option ### v0.0.5 - Fix when no argument is provided diff --git a/ToDoList.md b/ToDoList.md index 7fb3477..7654d30 100644 --- a/ToDoList.md +++ b/ToDoList.md @@ -1,7 +1,6 @@ - Mesure DSP time of the code - Use automatic optimizations with compile options - Check if FAUST supports in-place processing -- Check why FAUST double option crashes - Add method to open the FAUST file in the default text editor - Add a default temporary FAUST file when no argument - Look for the DSP file in all Pd's search paths From 86fc9a6cbd17711ae2638590aec0e448e5c90ee4 Mon Sep 17 00:00:00 2001 From: Pierre Date: Thu, 23 Aug 2018 09:19:10 +0200 Subject: [PATCH 16/40] update faust (float precision) --- faust | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/faust b/faust index 83bf8b2..5ef1f5e 160000 --- a/faust +++ b/faust @@ -1 +1 @@ -Subproject commit 83bf8b29e0850ac801e20bba4ce2b952a36a3e6c +Subproject commit 5ef1f5e325b9a7c0dec66107a7ede0531a02346f From 41aaa25e124c39aed0514ede3c06eeabbc65c2a6 Mon Sep 17 00:00:00 2001 From: Pierre Date: Thu, 23 Aug 2018 09:22:15 +0200 Subject: [PATCH 17/40] remove float precision warning (fixed by faust) --- src/faust_tilde_options.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/faust_tilde_options.c b/src/faust_tilde_options.c index 8f55ce6..ba8eff8 100644 --- a/src/faust_tilde_options.c +++ b/src/faust_tilde_options.c @@ -78,7 +78,6 @@ static void faust_opt_manager_free_compile_options(t_faust_opt_manager *x) char faust_opt_manager_parse_compile_options(t_faust_opt_manager *x, size_t const argc, const t_atom* argv) { char has_include = 0; - char has_precision = 0; faust_opt_manager_free_compile_options(x); if(argc && argv) { @@ -102,17 +101,6 @@ char faust_opt_manager_parse_compile_options(t_faust_opt_manager *x, size_t cons { has_include = 1; } - else if(!strncmp(x->f_options[i], "-double", 7) || - !strncmp(x->f_options[i], "-single", 7) || - !strncmp(x->f_options[i], "-quad", 5)) - { - if(has_precision) - { - pd_error(x->f_owner, "faustgen~: floating-point format already defined"); - memset(x->f_options[i], 0, MAXFAUSTSTRING); - } - has_precision = 1; - } } else { From 2f998060912a5ddaf3fd9f4fa90a11f8e5c04f44 Mon Sep 17 00:00:00 2001 From: Pierre Date: Thu, 23 Aug 2018 09:57:17 +0200 Subject: [PATCH 18/40] look for the DSP file in all Pd's search paths --- src/faust_tilde_options.c | 34 +++++++++++++++++++++------------- tests/location.pd | 23 +++++++++++++++++++++++ 2 files changed, 44 insertions(+), 13 deletions(-) create mode 100644 tests/location.pd diff --git a/src/faust_tilde_options.c b/src/faust_tilde_options.c index ba8eff8..6995e24 100644 --- a/src/faust_tilde_options.c +++ b/src/faust_tilde_options.c @@ -8,6 +8,12 @@ #include "faust_tilde_options.h" #include +#ifdef _WIN32 +#include +#else +#include +#endif + #define MAXFAUSTSTRING 4096 typedef struct _faust_opt_manager @@ -208,22 +214,24 @@ char faust_opt_has_double_precision(t_faust_opt_manager const *x) char const* faust_opt_manager_get_full_path(t_faust_opt_manager *x, char const* name) { - if(sys_isabsolutepath(name)) - { - return name; - } - else if(x->f_directory && x->f_directory->s_name && name) + if(x->f_directory && x->f_directory->s_name && name) { - char* file = (char *)getbytes(MAXFAUSTSTRING * sizeof(char)); - if(file) + char patht[MAXFAUSTSTRING], path[MAXFAUSTSTRING], realdir[MAXPDSTRING], *bufptr; + int filedesc = open_via_path(x->f_directory->s_name, name, ".dsp", realdir, &bufptr, MAXPDSTRING, 0); + if(filedesc < 0) + { + pd_error(x->f_owner, "faustgen~: can't find the FAUST DSP file %s.dsp", name); + return NULL; + } + else { - sprintf(file, "%s/%s.dsp", x->f_directory->s_name, name); - x->f_temp_path = gensym(file); - freebytes(file, MAXFAUSTSTRING * sizeof(char)); - return x->f_temp_path->s_name; + close(filedesc); } - pd_error(x->f_owner, "faustgen~: memory allocation failed - path"); - return NULL; + + sprintf(patht, "%s/%s.dsp", realdir, name); + sys_unbashfilename(patht, path); + x->f_temp_path = gensym(path); + return x->f_temp_path->s_name; } pd_error(x->f_owner, "faustgen~: invalid path or name"); return NULL; diff --git a/tests/location.pd b/tests/location.pd new file mode 100644 index 0000000..8e26c6f --- /dev/null +++ b/tests/location.pd @@ -0,0 +1,23 @@ +#N canvas 471 124 627 394 10; +#X obj 286 115 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 +1; +#X msg 286 135 \; pd dsp \$1; +#X obj 32 308 dac~ 1 2; +#X obj 31 47 osc~ 220; +#X msg 49 71 compile; +#X obj 124 282 print; +#X msg 70 95 compileoptions -single; +#X msg 70 125 compileoptions -double; +#X msg 70 155 compileoptions -single -double; +#X obj 31 241 ../external/faustgen~ location, f 16; +#X text 172 222 location.dsp must be located in the Pd search path +, f 23; +#X connect 0 0 1 0; +#X connect 3 0 9 0; +#X connect 4 0 9 0; +#X connect 6 0 9 0; +#X connect 7 0 9 0; +#X connect 8 0 9 0; +#X connect 9 0 2 0; +#X connect 9 0 2 1; +#X connect 9 1 5 0; From 8d3aee25c61b2ff06b2e5d9010e142102b1c2281 Mon Sep 17 00:00:00 2001 From: Pierre Date: Thu, 23 Aug 2018 09:58:38 +0200 Subject: [PATCH 19/40] updated to do list --- ChangeLog.md | 3 ++- ToDoList.md | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index c1c7989..21214e9 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,7 +1,8 @@ ### v0.0.6 -- Preserve parameters values during recompilation +- Add support to preserve parameters values during recompilation - Fix autocompilation when DSP instance not initialized - Fix support for the double-float-precision option +- Add support to look for the DSP file in all Pd's search paths ### v0.0.5 - Fix when no argument is provided diff --git a/ToDoList.md b/ToDoList.md index 7654d30..b53cb5e 100644 --- a/ToDoList.md +++ b/ToDoList.md @@ -3,4 +3,3 @@ - Check if FAUST supports in-place processing - Add method to open the FAUST file in the default text editor - Add a default temporary FAUST file when no argument -- Look for the DSP file in all Pd's search paths From 3a9b374068318774ee1bf215ab63335f89e470b7 Mon Sep 17 00:00:00 2001 From: Pierre Date: Thu, 23 Aug 2018 10:09:29 +0200 Subject: [PATCH 20/40] fix dip file location with subdirectories in name --- src/faust_tilde_options.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/faust_tilde_options.c b/src/faust_tilde_options.c index 6995e24..4797bab 100644 --- a/src/faust_tilde_options.c +++ b/src/faust_tilde_options.c @@ -22,7 +22,7 @@ typedef struct _faust_opt_manager char* f_default_include; size_t f_noptions; char** f_options; - t_symbol* f_directory; + t_canvas* f_canvas; t_symbol* f_temp_path; char f_use_default_include; }t_faust_opt_manager; @@ -177,7 +177,7 @@ t_faust_opt_manager* faust_opt_manager_new(t_object* owner, t_canvas* canvas) x->f_options = NULL; x->f_noptions = 0; x->f_use_default_include = 0; - x->f_directory = canvas_getdir(canvas); + x->f_canvas = canvas; faust_opt_manager_get_default_include_path(x); } return x; @@ -214,10 +214,10 @@ char faust_opt_has_double_precision(t_faust_opt_manager const *x) char const* faust_opt_manager_get_full_path(t_faust_opt_manager *x, char const* name) { - if(x->f_directory && x->f_directory->s_name && name) + if(x->f_canvas && name) { - char patht[MAXFAUSTSTRING], path[MAXFAUSTSTRING], realdir[MAXPDSTRING], *bufptr; - int filedesc = open_via_path(x->f_directory->s_name, name, ".dsp", realdir, &bufptr, MAXPDSTRING, 0); + char patht[MAXFAUSTSTRING], path[MAXFAUSTSTRING], realdir[MAXPDSTRING], *realname; + int filedesc = canvas_open(x->f_canvas, name, ".dsp", realdir, &realname, MAXPDSTRING, 0); if(filedesc < 0) { pd_error(x->f_owner, "faustgen~: can't find the FAUST DSP file %s.dsp", name); @@ -227,10 +227,11 @@ char const* faust_opt_manager_get_full_path(t_faust_opt_manager *x, char const* { close(filedesc); } - - sprintf(patht, "%s/%s.dsp", realdir, name); + + sprintf(patht, "%s/%s", realdir, realname); sys_unbashfilename(patht, path); x->f_temp_path = gensym(path); + post("path: %s", path); return x->f_temp_path->s_name; } pd_error(x->f_owner, "faustgen~: invalid path or name"); From 1de78306b3adb8729cfc46fb3955edf1d52f5deb Mon Sep 17 00:00:00 2001 From: Pierre Date: Thu, 23 Aug 2018 10:10:30 +0200 Subject: [PATCH 21/40] updated help file --- external/faustgen~-help.pd | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/external/faustgen~-help.pd b/external/faustgen~-help.pd index a0ad7d9..561d7de 100644 --- a/external/faustgen~-help.pd +++ b/external/faustgen~-help.pd @@ -9,11 +9,6 @@ -1 -1 0 256; #X obj 62 149 loadbang; #X msg 62 171 0; -#X text 10 36 The first argument is the name of the file FAUST DSP -file to read. The path is relative to the patch. Extra arguments can -be used to define compilation options \, see the FAUST documentation -for further information. Use the debug level 3 to displays information -about the code in the Pd console.; #X text 26 351 FAUST institution: GRAME; #X text 26 365 FAUST website: faust.grame.fr; #X text 132 380 Yann Orlarey \, Stéphane Letz \, Dominique Fober \, @@ -29,7 +24,7 @@ using the programming language "Pure" : https://github.com/agraef/pure-lang. #X text 26 399 faustgen~ institutions: CICM - ANR MUSICOLL; #X text 26 427 faustgen~ developer: Pierre Guillot; #X msg 62 211 gain \$1; -#X obj 31 118 osc~ 220; +#X obj 31 128 osc~ 220; #N canvas 766 136 471 246 options 0; #X text 16 70 Change the compile options and recompile; #X msg 17 91 compileoptions -vec -vs 64; @@ -166,17 +161,23 @@ the index 2, f 36; #X obj 103 284 metro 100; #X obj 103 264 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 1; -#X obj 31 242 faustgen~ examples/gain; #X text 26 413 faustgen~ website: github.com/CICM/pd-faustgen; +#X obj 31 242 faustgen~ examples/gain; +#X text 10 36 The first argument is the name of the FAUST DSP file +to read. The path of the FAUST DSP file can be relative to the patch +or must be located in the Pd search paths. Extra arguments can be used +to define compilation options \, see the FAUST documentation for further +information. Use the debug level 3 to displays information about the +code in the Pd console., f 72; #X connect 1 0 2 0; -#X connect 4 0 18 0; +#X connect 4 0 17 0; #X connect 5 0 6 0; #X connect 6 0 4 0; +#X connect 17 0 27 0; #X connect 18 0 27 0; -#X connect 19 0 27 0; -#X connect 23 0 24 0; -#X connect 25 0 23 0; -#X connect 26 0 25 0; +#X connect 22 0 23 0; +#X connect 24 0 22 0; +#X connect 25 0 24 0; #X connect 27 0 3 0; #X connect 27 0 3 1; -#X connect 27 0 23 0; +#X connect 27 0 22 0; From b3cb3919b7b072d98ee49355c81e15097d8d8996 Mon Sep 17 00:00:00 2001 From: Pierre Date: Thu, 23 Aug 2018 10:49:34 +0200 Subject: [PATCH 22/40] updated help file --- external/faustgen~-help.pd | 63 +++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/external/faustgen~-help.pd b/external/faustgen~-help.pd index 561d7de..714fab8 100644 --- a/external/faustgen~-help.pd +++ b/external/faustgen~-help.pd @@ -1,30 +1,30 @@ -#N canvas 428 137 481 548 10; +#N canvas 428 137 483 556 10; #X obj 12 15 cnv 15 360 17 empty empty faustgen~ 2 9 0 14 -233017 -66577 0; -#X obj 286 115 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 +#X obj 336 115 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 1; -#X msg 286 135 \; pd dsp \$1; -#X obj 32 308 dac~ 1 2; -#X obj 62 192 nbx 5 14 0 1 0 0 empty empty empty 0 -8 0 10 -262144 +#X msg 336 135 \; pd dsp \$1; +#X obj 32 318 dac~ 1 2; +#X obj 62 172 nbx 5 14 0 1 0 0 empty empty empty 0 -8 0 10 -262144 -1 -1 0 256; -#X obj 62 149 loadbang; -#X msg 62 171 0; -#X text 26 351 FAUST institution: GRAME; -#X text 26 365 FAUST website: faust.grame.fr; -#X text 132 380 Yann Orlarey \, Stéphane Letz \, Dominique Fober \, +#X obj 62 129 loadbang; +#X msg 62 151 0; +#X text 26 361 FAUST institution: GRAME; +#X text 26 375 FAUST website: faust.grame.fr; +#X text 132 390 Yann Orlarey \, Stéphane Letz \, Dominique Fober \, ...; -#X text 26 379 FAUST developers:; -#X text 26 449 This object is inspired by faustgen~ for Max developed +#X text 26 389 FAUST developers:; +#X text 26 459 This object is inspired by faustgen~ for Max developed by Martin Di Rollo and Stéphane Letz., f 50; #X text 95 16 the FAUST compiler embedded in a Pd external; -#X text 26 479 Another faust~ object has been developed by Albert Graef +#X text 26 489 Another faust~ object has been developed by Albert Graef using the programming language "Pure" : https://github.com/agraef/pure-lang. , f 67; -#X text 125 189 Control the parameters with their names, f 15; -#X text 26 399 faustgen~ institutions: CICM - ANR MUSICOLL; -#X text 26 427 faustgen~ developer: Pierre Guillot; -#X msg 62 211 gain \$1; -#X obj 31 128 osc~ 220; +#X text 125 169 Control the parameters with their names, f 15; +#X text 26 409 faustgen~ institutions: CICM - ANR MUSICOLL; +#X text 26 437 faustgen~ developer: Pierre Guillot; +#X msg 62 191 gain \$1; +#X obj 31 108 osc~ 220; #N canvas 766 136 471 246 options 0; #X text 16 70 Change the compile options and recompile; #X msg 17 91 compileoptions -vec -vs 64; @@ -42,12 +42,12 @@ the redering, f 55; #X connect 1 0 9 0; #X connect 5 0 9 0; #X connect 8 0 7 0; -#X restore 287 185 pd options; -#N canvas 287 129 524 202 recompilation 0; +#X restore 337 185 pd options; +#N canvas 287 129 410 324 recompilation 0; #X obj 17 75 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 1 ; #X msg 17 134 autocompile \$1 100; -#X obj 17 166 faustgen~ examples/dummy; +#X obj 17 246 faustgen~ examples/dummy; #X text 14 11 The automatic compilation can be used during the Faust code edition to recompile the code each time the file has been modified. ; @@ -55,14 +55,13 @@ code edition to recompile the code each time the file has been modified. changed., f 37; #X text 50 92 The second argument is the time between each check., f 37; -#X msg 155 134 compile; -#X text 214 128 Reload and recompile the FAUST file manually, f 23 +#X msg 55 194 compile; +#X text 114 188 Reload and recompile the FAUST file manually, f 23 ; -#X obj 339 90 switch~; #X connect 0 0 1 0; #X connect 1 0 2 0; #X connect 6 0 2 0; -#X restore 287 214 pd recompilation; +#X restore 337 214 pd recompilation; #N canvas 575 109 646 630 control 0; #X obj 30 598 dac~ 1 2; #X msg 45 195 print; @@ -154,14 +153,14 @@ the index 2, f 36; #X connect 28 0 29 0; #X connect 29 0 24 0; #X connect 33 0 35 0; -#X restore 287 243 pd control lists; -#X obj 103 305 snapshot~; -#X obj 103 326 nbx 5 14 -1e+37 1e+37 0 0 empty empty empty 0 -8 0 10 +#X restore 337 243 pd control lists; +#X obj 103 315 snapshot~; +#X obj 103 336 nbx 5 14 -1e+37 1e+37 0 0 empty empty empty 0 -8 0 10 -262144 -1 -1 0 256; -#X obj 103 284 metro 100; -#X obj 103 264 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 +#X obj 103 294 metro 100; +#X obj 103 274 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 1; -#X text 26 413 faustgen~ website: github.com/CICM/pd-faustgen; +#X text 26 423 faustgen~ website: github.com/CICM/pd-faustgen; #X obj 31 242 faustgen~ examples/gain; #X text 10 36 The first argument is the name of the FAUST DSP file to read. The path of the FAUST DSP file can be relative to the patch @@ -169,6 +168,8 @@ or must be located in the Pd search paths. Extra arguments can be used to define compilation options \, see the FAUST documentation for further information. Use the debug level 3 to displays information about the code in the Pd console., f 72; +#X text 177 233 Click on the object to open the code in your default +text editor, f 22; #X connect 1 0 2 0; #X connect 4 0 17 0; #X connect 5 0 6 0; From 0656042ab97334dcb8d8d5a1de166af2a97b8881 Mon Sep 17 00:00:00 2001 From: Pierre Date: Thu, 23 Aug 2018 10:49:55 +0200 Subject: [PATCH 23/40] start support to open the file in the text editor --- src/faustgen_tilde.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/faustgen_tilde.c b/src/faustgen_tilde.c index 5a5f490..985bd81 100644 --- a/src/faustgen_tilde.c +++ b/src/faustgen_tilde.c @@ -133,6 +133,20 @@ static void faustgen_tilde_compile_options(t_faustgen_tilde *x, t_symbol* s, int faustgen_tilde_compile(x); } +static void faustgen_tilde_open_texteditor(t_faustgen_tilde *x) +{ + char message[MAXPDSTRING]; +#ifdef _WIN32 +#elif __APPLE__ + sprintf(message, "open -t %s", faust_opt_manager_get_full_path(x->f_opt_manager, x->f_dsp_name->s_name)); + system(message); +#else + sprintf(message, "xdg-open %s", faust_opt_manager_get_full_path(x->f_opt_manager, x->f_dsp_name->s_name)); + system(message); +#endif + +} + /* static void faustgen_tilde_read(t_faustgen_tilde *x, t_symbol* s) { @@ -482,14 +496,15 @@ void faustgen_tilde_setup(void) if(c) { - class_addmethod(c, (t_method)faustgen_tilde_dsp, gensym("dsp"), A_CANT); - class_addmethod(c, (t_method)faustgen_tilde_compile, gensym("compile"), A_NULL); - 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_addmethod(c, (t_method)faustgen_tilde_dsp, gensym("dsp"), A_CANT, 0); + class_addmethod(c, (t_method)faustgen_tilde_compile, gensym("compile"), A_NULL, 0); + class_addmethod(c, (t_method)faustgen_tilde_compile_options, gensym("compileoptions"), A_GIMME, 0); + class_addmethod(c, (t_method)faustgen_tilde_autocompile, gensym("autocompile"), A_GIMME, 0); + class_addmethod(c, (t_method)faustgen_tilde_print_parameters, gensym("print"), A_NULL, 0); + class_addmethod(c, (t_method)faustgen_tilde_open_texteditor, gensym("click"), A_NULL, 0); //class_addmethod(c, (t_method)faustgen_tilde_read, gensym("read"), A_SYMBOL); - class_addanything(c, (t_method)faustgen_tilde_anything); + class_addanything(c, (t_method)faustgen_tilde_anything); CLASS_MAINSIGNALIN(c, t_faustgen_tilde, f_dummy); logpost(NULL, 3, "Faust website: faust.grame.fr"); From 6c1a8dfd0acd685c43d7547bee00d4ad9d3bd078 Mon Sep 17 00:00:00 2001 From: Pierre Date: Thu, 23 Aug 2018 10:53:43 +0200 Subject: [PATCH 24/40] continue text editor feature --- src/faustgen_tilde.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/faustgen_tilde.c b/src/faustgen_tilde.c index 985bd81..5521f12 100644 --- a/src/faustgen_tilde.c +++ b/src/faustgen_tilde.c @@ -135,16 +135,20 @@ static void faustgen_tilde_compile_options(t_faustgen_tilde *x, t_symbol* s, int static void faustgen_tilde_open_texteditor(t_faustgen_tilde *x) { - char message[MAXPDSTRING]; + if(x->f_dsp_instance) + { + char message[MAXPDSTRING]; #ifdef _WIN32 + sys_bashfilename(faust_opt_manager_get_full_path(x->f_opt_manager, x->f_dsp_name->s_name), message); #elif __APPLE__ - sprintf(message, "open -t %s", faust_opt_manager_get_full_path(x->f_opt_manager, x->f_dsp_name->s_name)); - system(message); + sprintf(message, "open -t %s", faust_opt_manager_get_full_path(x->f_opt_manager, x->f_dsp_name->s_name)); #else - sprintf(message, "xdg-open %s", faust_opt_manager_get_full_path(x->f_opt_manager, x->f_dsp_name->s_name)); - system(message); + sprintf(message, "xdg-open %s", faust_opt_manager_get_full_path(x->f_opt_manager, x->f_dsp_name->s_name)); #endif - + system(message); + return; + } + pd_error(x, "faustgen~: no FAUST DSP file defined"); } /* From 8e2b75a06b03d84e527cbcc77196fa4165233a24 Mon Sep 17 00:00:00 2001 From: Pierre Date: Thu, 23 Aug 2018 11:08:38 +0200 Subject: [PATCH 25/40] remove debug posts --- src/faustgen_tilde.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/faustgen_tilde.c b/src/faustgen_tilde.c index 5521f12..417cef2 100644 --- a/src/faustgen_tilde.c +++ b/src/faustgen_tilde.c @@ -423,7 +423,6 @@ static void faustgen_tilde_dsp(t_faustgen_tilde *x, t_signal **sp) if(faust_opt_has_double_precision(x->f_opt_manager)) { - post("double precision"); faustgen_tilde_alloc_signals_double(x, ninputs, noutputs, nsamples); dsp_add((t_perfroutine)faustgen_tilde_perform_double, 7, (t_int)x->f_dsp_instance, (t_int)nsamples, (t_int)ninputs, (t_int)noutputs, @@ -433,7 +432,6 @@ static void faustgen_tilde_dsp(t_faustgen_tilde *x, t_signal **sp) } else { - post("single precision"); faustgen_tilde_alloc_signals_single(x, ninputs, noutputs, nsamples); dsp_add((t_perfroutine)faustgen_tilde_perform_single, 7, (t_int)x->f_dsp_instance, (t_int)nsamples, (t_int)ninputs, (t_int)noutputs, From 340b2241f80e8dd16cba0db6dd2cb1b66eed7763 Mon Sep 17 00:00:00 2001 From: Pierre Date: Thu, 23 Aug 2018 14:44:31 +0200 Subject: [PATCH 26/40] remove debug post --- src/faust_tilde_options.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/faust_tilde_options.c b/src/faust_tilde_options.c index 4797bab..1e90bee 100644 --- a/src/faust_tilde_options.c +++ b/src/faust_tilde_options.c @@ -231,7 +231,6 @@ char const* faust_opt_manager_get_full_path(t_faust_opt_manager *x, char const* sprintf(patht, "%s/%s", realdir, realname); sys_unbashfilename(patht, path); x->f_temp_path = gensym(path); - post("path: %s", path); return x->f_temp_path->s_name; } pd_error(x->f_owner, "faustgen~: invalid path or name"); From 20725334c0e6d7da073ec98c340b051da35cea11 Mon Sep 17 00:00:00 2001 From: Pierre Date: Thu, 23 Aug 2018 14:45:48 +0200 Subject: [PATCH 27/40] updated change log and todo list --- ChangeLog.md | 1 + ToDoList.md | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog.md b/ChangeLog.md index 21214e9..7ac5209 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -3,6 +3,7 @@ - Fix autocompilation when DSP instance not initialized - Fix support for the double-float-precision option - Add support to look for the DSP file in all Pd's search paths +- Add support to open the FAUST file in the default text editor when object is clicked ### v0.0.5 - Fix when no argument is provided diff --git a/ToDoList.md b/ToDoList.md index b53cb5e..f75d012 100644 --- a/ToDoList.md +++ b/ToDoList.md @@ -1,5 +1,4 @@ - Mesure DSP time of the code - Use automatic optimizations with compile options - Check if FAUST supports in-place processing -- Add method to open the FAUST file in the default text editor - Add a default temporary FAUST file when no argument From 0092b27795d23cd26457862e25ff3a8007b1d80b Mon Sep 17 00:00:00 2001 From: Pierre Date: Thu, 23 Aug 2018 14:53:59 +0200 Subject: [PATCH 28/40] updated print method --- src/faustgen_tilde.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/faustgen_tilde.c b/src/faustgen_tilde.c index 417cef2..5e7a633 100644 --- a/src/faustgen_tilde.c +++ b/src/faustgen_tilde.c @@ -197,11 +197,19 @@ static void faustgen_tilde_autocompile(t_faustgen_tilde *x, t_symbol* s, int arg } } -static void faustgen_tilde_print_parameters(t_faustgen_tilde *x) +static void faustgen_tilde_print(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); + if(x->f_dsp_factory) + { + post("faustgen~: %s", faust_opt_manager_get_full_path(x->f_opt_manager, x->f_dsp_name->s_name)); + 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); + } + else + { + pd_error(x, "faustgen~: no FAUST DSP file defined"); + } } @@ -502,7 +510,7 @@ void faustgen_tilde_setup(void) class_addmethod(c, (t_method)faustgen_tilde_compile, gensym("compile"), A_NULL, 0); class_addmethod(c, (t_method)faustgen_tilde_compile_options, gensym("compileoptions"), A_GIMME, 0); class_addmethod(c, (t_method)faustgen_tilde_autocompile, gensym("autocompile"), A_GIMME, 0); - class_addmethod(c, (t_method)faustgen_tilde_print_parameters, gensym("print"), A_NULL, 0); + class_addmethod(c, (t_method)faustgen_tilde_print, gensym("print"), A_NULL, 0); class_addmethod(c, (t_method)faustgen_tilde_open_texteditor, gensym("click"), A_NULL, 0); //class_addmethod(c, (t_method)faustgen_tilde_read, gensym("read"), A_SYMBOL); From 8ae19a5ee7b98fb295596963d367ae8deffe6368 Mon Sep 17 00:00:00 2001 From: Pierre Date: Thu, 23 Aug 2018 15:57:37 +0200 Subject: [PATCH 29/40] fix white space --- src/faustgen_tilde.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/faustgen_tilde.c b/src/faustgen_tilde.c index 5e7a633..4204dbf 100644 --- a/src/faustgen_tilde.c +++ b/src/faustgen_tilde.c @@ -506,12 +506,12 @@ void faustgen_tilde_setup(void) if(c) { - class_addmethod(c, (t_method)faustgen_tilde_dsp, gensym("dsp"), A_CANT, 0); - class_addmethod(c, (t_method)faustgen_tilde_compile, gensym("compile"), A_NULL, 0); - class_addmethod(c, (t_method)faustgen_tilde_compile_options, gensym("compileoptions"), A_GIMME, 0); - class_addmethod(c, (t_method)faustgen_tilde_autocompile, gensym("autocompile"), A_GIMME, 0); - class_addmethod(c, (t_method)faustgen_tilde_print, gensym("print"), A_NULL, 0); - class_addmethod(c, (t_method)faustgen_tilde_open_texteditor, gensym("click"), A_NULL, 0); + class_addmethod(c, (t_method)faustgen_tilde_dsp, gensym("dsp"), A_CANT, 0); + class_addmethod(c, (t_method)faustgen_tilde_compile, gensym("compile"), A_NULL, 0); + class_addmethod(c, (t_method)faustgen_tilde_compile_options, gensym("compileoptions"), A_GIMME, 0); + class_addmethod(c, (t_method)faustgen_tilde_autocompile, gensym("autocompile"), A_GIMME, 0); + class_addmethod(c, (t_method)faustgen_tilde_print, gensym("print"), A_NULL, 0); + class_addmethod(c, (t_method)faustgen_tilde_open_texteditor, gensym("click"), A_NULL, 0); //class_addmethod(c, (t_method)faustgen_tilde_read, gensym("read"), A_SYMBOL); class_addanything(c, (t_method)faustgen_tilde_anything); From 60ab3b6fad75d855265bbc5f50649c3c2d78f806 Mon Sep 17 00:00:00 2001 From: Pierre Date: Thu, 23 Aug 2018 16:23:27 +0200 Subject: [PATCH 30/40] update help --- external/examples/parameters.dsp | 13 ++ external/faustgen~-help.pd | 250 +++++++++++++++++++++++-------- 2 files changed, 198 insertions(+), 65 deletions(-) create mode 100644 external/examples/parameters.dsp diff --git a/external/examples/parameters.dsp b/external/examples/parameters.dsp new file mode 100644 index 0000000..e2ad878 --- /dev/null +++ b/external/examples/parameters.dsp @@ -0,0 +1,13 @@ +declare name "Dummy"; +declare version "1.0"; +declare author "Heu... me..."; + + +process = _ * param1 * param2 * (param3 / 3) * (param4 /4) +with +{ + param1 = button("button"); + param2 = checkbox("checkbox"); + param3 = vslider("slider", 3, 0 , 3, 0.001); + param4 = nentry("number", 4, 0 , 4, 1); +}; diff --git a/external/faustgen~-help.pd b/external/faustgen~-help.pd index 714fab8..0e089fb 100644 --- a/external/faustgen~-help.pd +++ b/external/faustgen~-help.pd @@ -1,7 +1,7 @@ -#N canvas 428 137 483 556 10; +#N canvas 917 216 509 556 10; #X obj 12 15 cnv 15 360 17 empty empty faustgen~ 2 9 0 14 -233017 -66577 0; -#X obj 336 115 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 +#X obj 336 115 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 1 1; #X msg 336 135 \; pd dsp \$1; #X obj 32 318 dac~ 1 2; @@ -26,23 +26,19 @@ using the programming language "Pure" : https://github.com/agraef/pure-lang. #X msg 62 191 gain \$1; #X obj 31 108 osc~ 220; #N canvas 766 136 471 246 options 0; -#X text 16 70 Change the compile options and recompile; -#X msg 17 91 compileoptions -vec -vs 64; +#X text 16 50 Change the compile options and recompile; +#X msg 17 71 compileoptions -vec -vs 64; #X text 56 141 Use the compile options as default arguments; #X text 19 196 All the compile options are listed page 54 and page 55 of the PDF file faust-quick-reference, f 46; -#X text 21 27 Use the compile options to optimize the CPU or improve +#X text 11 8 Use the compile options to optimize the CPU or improve the redering, f 55; #X msg 41 115 print; #X text 84 116 Print faustgen~ informations; -#X obj 405 65 switch~; -#X obj 405 43 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 -1; #X obj 17 165 faustgen~ examples/gain -vec -lv 1; -#X connect 1 0 9 0; -#X connect 5 0 9 0; -#X connect 8 0 7 0; -#X restore 337 185 pd options; +#X connect 1 0 7 0; +#X connect 5 0 7 0; +#X restore 327 272 pd options; #N canvas 287 129 410 324 recompilation 0; #X obj 17 75 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 1 ; @@ -55,35 +51,180 @@ code edition to recompile the code each time the file has been modified. changed., f 37; #X text 50 92 The second argument is the time between each check., f 37; -#X msg 55 194 compile; -#X text 114 188 Reload and recompile the FAUST file manually, f 23 +#X msg 55 174 compile; +#X text 114 168 Reload and recompile the FAUST file manually, f 23 ; +#X text 59 205 Click on the object to open the code in your default +text editor \, then recompile to listen to the changes, f 47; #X connect 0 0 1 0; #X connect 1 0 2 0; #X connect 6 0 2 0; -#X restore 337 214 pd recompilation; -#N canvas 575 109 646 630 control 0; +#X restore 327 301 pd recompilation; +#X obj 103 315 snapshot~; +#X obj 103 336 nbx 5 14 -1e+37 1e+37 0 0 empty empty empty 0 -8 0 10 +-262144 -1 -1 0 256; +#X obj 103 294 metro 100; +#X obj 103 274 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 +1; +#X text 26 423 faustgen~ website: github.com/CICM/pd-faustgen; +#X obj 31 242 faustgen~ examples/gain; +#X text 10 36 The first argument is the name of the FAUST DSP file +to read. The path of the FAUST DSP file can be relative to the patch +or must be located in the Pd search paths. Extra arguments can be used +to define compilation options \, see the FAUST documentation for further +information. Use the debug level 3 to displays information about the +code in the Pd console., f 72; +#X text 177 233 Click on the object to open the code in your default +text editor, f 22; +#N canvas 332 276 618 466 get.parameters.values 0; +#X obj 193 396 nbx 5 14 -1e+37 1e+37 0 0 empty empty empty 0 -8 0 10 +-262144 -1 -1 0 256; +#X obj 249 396 nbx 5 14 -1e+37 1e+37 0 0 empty empty empty 0 -8 0 10 +-262144 -1 -1 1 256; +#X obj 305 396 nbx 5 14 -1e+37 1e+37 0 0 empty empty empty 0 -8 0 10 +-262144 -1 -1 2.23 256; +#X obj 361 396 nbx 5 14 -1e+37 1e+37 0 0 empty empty empty 0 -8 0 10 +-262144 -1 -1 2.95 256; +#X obj 22 352 faustgen~ examples/parameters; +#X text 20 9 You can use the name of the parameters without any arguments +to output their current values via the extra control outlet.; +#X msg 189 134 print; +#X msg 22 104 button; +#X msg 72 104 checkbox; +#X msg 132 104 slider; +#X msg 181 104 number; +#X obj 193 375 route button checkbox slider number, f 38; +#X obj 288 261 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 1 +1; +#X obj 375 262 nbx 5 14 0 3 0 0 empty empty empty 0 -8 0 10 -262144 +-1 -1 2.23 256; +#X obj 448 260 nbx 5 14 0 4 0 0 empty empty empty 0 -8 0 10 -262144 +-1 -1 2.95 256; +#X obj 209 200 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 +-1 -1; +#X obj 209 220 t b b, f 9; +#X obj 209 241 del 200; +#X obj 260 241 f 1; +#X obj 209 262 f 0; +#X msg 375 237 3; +#X msg 448 237 4; +#X msg 288 237 1; +#X obj 375 196 loadbang; +#X msg 209 283 button \$1 \, button, f 10; +#X msg 288 283 checkbox \$1 \, checkbox, f 12; +#X msg 375 283 slider \$1 \, slider, f 10; +#X msg 448 283 number \$1 \, number, f 10; +#X text 20 57 Click on the name of the parameter to output its current +value, f 23; +#X text 205 176 Set and output the value; +#X text 233 129 Print the informations of the FAUST code, f 22; +#X connect 4 1 11 0; +#X connect 6 0 4 0; +#X connect 7 0 4 0; +#X connect 8 0 4 0; +#X connect 9 0 4 0; +#X connect 10 0 4 0; +#X connect 11 0 0 0; +#X connect 11 1 1 0; +#X connect 11 2 2 0; +#X connect 11 3 3 0; +#X connect 12 0 25 0; +#X connect 13 0 26 0; +#X connect 14 0 27 0; +#X connect 15 0 16 0; +#X connect 16 0 17 0; +#X connect 16 1 18 0; +#X connect 17 0 19 0; +#X connect 18 0 24 0; +#X connect 19 0 24 0; +#X connect 20 0 13 0; +#X connect 21 0 14 0; +#X connect 22 0 12 0; +#X connect 23 0 20 0; +#X connect 23 0 21 0; +#X connect 23 0 22 0; +#X connect 24 0 4 0; +#X connect 25 0 4 0; +#X connect 26 0 4 0; +#X connect 27 0 4 0; +#X restore 327 219 pd get.parameters.values; +#N canvas 253 455 614 360 set.parameters.values 0; +#X obj 22 252 faustgen~ examples/parameters; +#X obj 22 84 noise~; +#X obj 22 303 dac~ 1 2; +#X msg 282 204 print; +#X obj 162 139 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 1 +1; +#X msg 162 161 checkbox \$1; +#X obj 245 140 nbx 5 14 0 3 0 0 empty empty empty 0 -8 0 10 -262144 +-1 -1 3 256; +#X msg 245 161 slider \$1; +#X obj 322 138 nbx 5 14 0 4 0 0 empty empty empty 0 -8 0 10 -262144 +-1 -1 4 256; +#X obj 73 88 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 +-1; +#X msg 73 171 button \$1; +#X obj 73 108 t b b, f 9; +#X obj 73 129 del 200; +#X obj 124 129 f 1; +#X obj 73 150 f 0; +#X msg 322 161 number \$1; +#X msg 245 115 3; +#X msg 322 115 4; +#X msg 162 115 1; +#X text 71 69 Generate sounds; +#X obj 245 84 loadbang; +#X text 20 9 You can use the name of the parameters without any arguments +to output their current values via the extra control outlet. In this +example \, all the parameters are used to control the gain of the output +signal.; +#X text 324 198 Print the informations of the FAUST code, f 22; +#X connect 0 0 2 0; +#X connect 0 0 2 1; +#X connect 1 0 0 0; +#X connect 3 0 0 0; +#X connect 4 0 5 0; +#X connect 5 0 0 0; +#X connect 6 0 7 0; +#X connect 7 0 0 0; +#X connect 8 0 15 0; +#X connect 9 0 11 0; +#X connect 10 0 0 0; +#X connect 11 0 12 0; +#X connect 11 1 13 0; +#X connect 12 0 14 0; +#X connect 13 0 10 0; +#X connect 14 0 10 0; +#X connect 15 0 0 0; +#X connect 16 0 6 0; +#X connect 17 0 8 0; +#X connect 18 0 4 0; +#X connect 20 0 16 0; +#X connect 20 0 17 0; +#X connect 20 0 18 0; +#X restore 327 191 pd set.parameters.values; +#N canvas 575 109 646 630 set.parameters.lists 0; #X obj 30 598 dac~ 1 2; #X msg 45 195 print; #N canvas 0 22 450 278 (subpatch) 0; #X array \$0-gains 20 float 3; -#A 0 0.706521 0.597826 0.521739 0.521739 0.521739 0.378572 0.442858 -0.528573 0.621431 0.685717 0.792861 0.921433 0.950004 0.950004 0.950004 -0.871432 0.792861 0.607145 0.578574 0.3; +#A 0 0.619565 0.782608 0.75 0.717391 0.717391 0.717391 0.195654 0.195654 +0.163046 0.119568 0.108698 0.0652174 0.0652174 0.0597826 0.0543479 +0.0326089 -0.0108691 -0.0434777 -0.0706514 -0.20652; #X coords 0 1 20 0 199 92 1 0 0; #X restore 397 74 graph; #N canvas 0 22 450 278 (subpatch) 0; #X array \$0-decays 20 float 3; -#A 0 0.0652173 0.0978258 0.119565 0.152173 0.206521 0.260868 0.326085 -0.402172 0.456519 0.521736 0.65217 0.706518 0.771735 0.804344 0.804344 -0.804344 0.771735 0.749996 0.66304 0.608692; +#A 0 0.11956 0.228258 0.282606 0.347825 0.402173 0.434783 0.434786 +0.402176 0.347828 0.315218 0.298914 0.282609 0.25 0.25 0.25 0.25 0.25 +0.25 0.66304 0.608692; #X coords 0 1 20 0 199 92 1 0 0; #X restore 397 198 graph; #N canvas 0 22 450 278 (subpatch) 0; #X array \$0-freq 20 float 3; -#A 0 0.0652173 6956.52 6956.52 8260.87 9347.82 10434.8 11956.5 13478.2 -15000 16521.7 17608.7 18478.2 19130.4 18913 18260.8 14782.6 11304.3 -9347.82 8695.65 0.608692; +#A 0 -0.0351562 217.363 434.762 652.16 652.16 652.16 869.559 7391.3 +7391.3 7826.1 8260.9 8695.7 8913.09 9782.69 5217.38 3912.99 3260.8 +2608.6 2391.2 1086.81; #X coords 0 20000 20 0 199 92 1 0 0; #X restore 397 328 graph; #X obj 30 107 noise~; @@ -107,7 +248,6 @@ arguments are the list., f 44; #X obj 203 320 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 -1; #X msg 203 362 freq 4 \$1; -#X obj 203 341 array get \$0-decays 3 1; #X text 395 10 Change the value of the arrays and use the bangs to send them to the faustgen~ object, f 33; #X text 116 84 Set the values of all the "gain" parameters, f 23; @@ -126,10 +266,7 @@ the index 2, f 36; #X text 199 388 Dynamic approach, f 9; #X text 254 398 Index; #X text 312 398 Size; -#X obj 303 107 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 -1; -#X text 301 86 Turn DSP on; -#X obj 303 128 switch~; +#X obj 203 341 array get \$0-freq 3 1; #X connect 1 0 6 0; #X connect 5 0 6 0; #X connect 6 0 0 0; @@ -142,43 +279,26 @@ the index 2, f 36; #X connect 13 0 14 0; #X connect 14 0 15 0; #X connect 15 0 12 0; -#X connect 17 0 19 0; +#X connect 17 0 32 0; #X connect 18 0 6 0; -#X connect 19 0 18 0; -#X connect 24 0 6 0; -#X connect 25 0 28 0; -#X connect 26 0 28 1; -#X connect 26 0 29 1; -#X connect 27 0 28 2; -#X connect 28 0 29 0; -#X connect 29 0 24 0; -#X connect 33 0 35 0; -#X restore 337 243 pd control lists; -#X obj 103 315 snapshot~; -#X obj 103 336 nbx 5 14 -1e+37 1e+37 0 0 empty empty empty 0 -8 0 10 --262144 -1 -1 0 256; -#X obj 103 294 metro 100; -#X obj 103 274 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 -1; -#X text 26 423 faustgen~ website: github.com/CICM/pd-faustgen; -#X obj 31 242 faustgen~ examples/gain; -#X text 10 36 The first argument is the name of the FAUST DSP file -to read. The path of the FAUST DSP file can be relative to the patch -or must be located in the Pd search paths. Extra arguments can be used -to define compilation options \, see the FAUST documentation for further -information. Use the debug level 3 to displays information about the -code in the Pd console., f 72; -#X text 177 233 Click on the object to open the code in your default -text editor, f 22; +#X connect 23 0 6 0; +#X connect 24 0 27 0; +#X connect 25 0 27 1; +#X connect 25 0 28 1; +#X connect 26 0 27 2; +#X connect 27 0 28 0; +#X connect 28 0 23 0; +#X connect 32 0 18 0; +#X restore 327 246 pd set.parameters.lists; #X connect 1 0 2 0; #X connect 4 0 17 0; #X connect 5 0 6 0; #X connect 6 0 4 0; -#X connect 17 0 27 0; -#X connect 18 0 27 0; -#X connect 22 0 23 0; -#X connect 24 0 22 0; -#X connect 25 0 24 0; -#X connect 27 0 3 0; -#X connect 27 0 3 1; -#X connect 27 0 22 0; +#X connect 17 0 26 0; +#X connect 18 0 26 0; +#X connect 21 0 22 0; +#X connect 23 0 21 0; +#X connect 24 0 23 0; +#X connect 26 0 3 0; +#X connect 26 0 3 1; +#X connect 26 0 21 0; From f1e56261034b9b6ec4e2e75af41beaddffeefb5d Mon Sep 17 00:00:00 2001 From: Pierre Date: Thu, 23 Aug 2018 17:04:02 +0200 Subject: [PATCH 31/40] fix constantness --- src/faust_tilde_io.c | 6 +++--- src/faust_tilde_io.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/faust_tilde_io.c b/src/faust_tilde_io.c index 7ca63f8..cc2a8de 100644 --- a/src/faust_tilde_io.c +++ b/src/faust_tilde_io.c @@ -208,17 +208,17 @@ void faust_io_manager_free(t_faust_io_manager* x) freebytes(x, sizeof(t_faust_io_manager)); } -size_t faust_io_manager_get_ninputs(t_faust_io_manager *x) +size_t faust_io_manager_get_ninputs(t_faust_io_manager const *x) { return x->f_ninlets; } -size_t faust_io_manager_get_noutputs(t_faust_io_manager *x) +size_t faust_io_manager_get_noutputs(t_faust_io_manager const *x) { return x->f_noutlets; } -char faust_io_manager_has_extra_output(t_faust_io_manager *x) +char faust_io_manager_has_extra_output(t_faust_io_manager const *x) { return x->f_extra_outlet != NULL; } diff --git a/src/faust_tilde_io.h b/src/faust_tilde_io.h index 4d0f992..1e6b23a 100644 --- a/src/faust_tilde_io.h +++ b/src/faust_tilde_io.h @@ -16,11 +16,11 @@ t_faust_io_manager* faust_io_manager_new(t_object* owner, t_canvas* canvas); void faust_io_manager_free(t_faust_io_manager* x); -size_t faust_io_manager_get_ninputs(t_faust_io_manager *x); +size_t faust_io_manager_get_ninputs(t_faust_io_manager const *x); -size_t faust_io_manager_get_noutputs(t_faust_io_manager *x); +size_t faust_io_manager_get_noutputs(t_faust_io_manager const *x); -char faust_io_manager_has_extra_output(t_faust_io_manager *x); +char faust_io_manager_has_extra_output(t_faust_io_manager const *x); t_outlet* faust_io_manager_get_extra_output(t_faust_io_manager *x); From af14690186bdaeff0498ebb31e73435ec984b303 Mon Sep 17 00:00:00 2001 From: Pierre Date: Thu, 23 Aug 2018 17:04:31 +0200 Subject: [PATCH 32/40] updated help --- external/faustgen~-help.pd | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/external/faustgen~-help.pd b/external/faustgen~-help.pd index 0e089fb..97ab8e3 100644 --- a/external/faustgen~-help.pd +++ b/external/faustgen~-help.pd @@ -1,7 +1,7 @@ #N canvas 917 216 509 556 10; #X obj 12 15 cnv 15 360 17 empty empty faustgen~ 2 9 0 14 -233017 -66577 0; -#X obj 336 115 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 1 +#X obj 336 115 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 1; #X msg 336 135 \; pd dsp \$1; #X obj 32 318 dac~ 1 2; @@ -59,7 +59,7 @@ text editor \, then recompile to listen to the changes, f 47; #X connect 0 0 1 0; #X connect 1 0 2 0; #X connect 6 0 2 0; -#X restore 327 301 pd recompilation; +#X restore 327 298 pd recompilation; #X obj 103 315 snapshot~; #X obj 103 336 nbx 5 14 -1e+37 1e+37 0 0 empty empty empty 0 -8 0 10 -262144 -1 -1 0 256; @@ -82,9 +82,9 @@ text editor, f 22; #X obj 249 396 nbx 5 14 -1e+37 1e+37 0 0 empty empty empty 0 -8 0 10 -262144 -1 -1 1 256; #X obj 305 396 nbx 5 14 -1e+37 1e+37 0 0 empty empty empty 0 -8 0 10 --262144 -1 -1 2.23 256; +-262144 -1 -1 3 256; #X obj 361 396 nbx 5 14 -1e+37 1e+37 0 0 empty empty empty 0 -8 0 10 --262144 -1 -1 2.95 256; +-262144 -1 -1 4 256; #X obj 22 352 faustgen~ examples/parameters; #X text 20 9 You can use the name of the parameters without any arguments to output their current values via the extra control outlet.; @@ -97,9 +97,9 @@ to output their current values via the extra control outlet.; #X obj 288 261 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 1 1; #X obj 375 262 nbx 5 14 0 3 0 0 empty empty empty 0 -8 0 10 -262144 --1 -1 2.23 256; +-1 -1 3 256; #X obj 448 260 nbx 5 14 0 4 0 0 empty empty empty 0 -8 0 10 -262144 --1 -1 2.95 256; +-1 -1 4 256; #X obj 209 200 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 -1; #X obj 209 220 t b b, f 9; From 43e97ed5aff7cc28d392c871fea71b8709390625 Mon Sep 17 00:00:00 2001 From: Pierre Date: Thu, 23 Aug 2018 17:04:47 +0200 Subject: [PATCH 33/40] add support for default FAUST file --- external/.default.dsp | 3 +++ src/faustgen_tilde.c | 8 +++----- 2 files changed, 6 insertions(+), 5 deletions(-) create mode 100644 external/.default.dsp diff --git a/external/.default.dsp b/external/.default.dsp new file mode 100644 index 0000000..16d38de --- /dev/null +++ b/external/.default.dsp @@ -0,0 +1,3 @@ +import("stdfaust.lib"); + +process = _; diff --git a/src/faustgen_tilde.c b/src/faustgen_tilde.c index 4204dbf..de34f01 100644 --- a/src/faustgen_tilde.c +++ b/src/faustgen_tilde.c @@ -470,6 +470,8 @@ static void *faustgen_tilde_new(t_symbol* s, int argc, t_atom* argv) t_faustgen_tilde* x = (t_faustgen_tilde *)pd_new(faustgen_tilde_class); if(x) { + char default_file[MAXPDSTRING]; + sprintf(default_file, "%s/.default", class_gethelpdir(faustgen_tilde_class)); x->f_dsp_factory = NULL; x->f_dsp_instance = NULL; @@ -481,13 +483,9 @@ static void *faustgen_tilde_new(t_symbol* s, int argc, t_atom* argv) x->f_ui_manager = faust_ui_manager_new((t_object *)x); x->f_io_manager = faust_io_manager_new((t_object *)x, canvas_getcurrent()); x->f_opt_manager = faust_opt_manager_new((t_object *)x, canvas_getcurrent()); - x->f_dsp_name = atom_getsymbolarg(0, argc, argv); + x->f_dsp_name = argc ? atom_getsymbolarg(0, argc, argv) : gensym(default_file); x->f_clock = clock_new(x, (t_method)faustgen_tilde_autocompile_tick); faust_opt_manager_parse_compile_options(x->f_opt_manager, argc ? argc-1 : 0, argv ? argv+1 : NULL); - if(!argc) - { - return x; - } faustgen_tilde_compile(x); if(!x->f_dsp_instance) { From 25cc0ee6d0aac932afebce42c68d30067aadcb91 Mon Sep 17 00:00:00 2001 From: Pierre Date: Thu, 23 Aug 2018 17:33:48 +0200 Subject: [PATCH 34/40] updated travis to lock .default.dsp --- .travis.yml | 1 + ToDoList.md | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index fe3354a..c3de132 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,6 +38,7 @@ before_deploy: - cp -r src/ external/sources - cp README.md external/README.txt - cp LICENSE external/LICENSE.txt +- chmod 0444 external/.default.dsp - curl -o ./external/faust-quick-reference.pdf http://faust.grame.fr/images/faust-quick-reference.pdf - mv external faustgen~ - zip -r "faustgen_tilde-$release_arch-sources.zip" faustgen~ diff --git a/ToDoList.md b/ToDoList.md index f75d012..26ecf6f 100644 --- a/ToDoList.md +++ b/ToDoList.md @@ -1,4 +1,3 @@ - Mesure DSP time of the code - Use automatic optimizations with compile options -- Check if FAUST supports in-place processing - Add a default temporary FAUST file when no argument From 45008f50acc0dbc2278d10a70608d46352285ffc Mon Sep 17 00:00:00 2001 From: Pierre Date: Thu, 23 Aug 2018 17:37:25 +0200 Subject: [PATCH 35/40] fix read only attribut for windows --- appveyor.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/appveyor.yml b/appveyor.yml index 7492405..f4313ce 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -31,6 +31,7 @@ after_build: - copy LICENSE external\LICENSE.txt - xcopy /S /E /Y /I .\faust\libraries .\external\libs - xcopy /S /E /Y /I .\src .\external\sources + - attrib +R external\.default.dsp - rename external faustgen~ - 7z a "faustgen_tilde-%release_arch%-sources.zip" faustgen~ From 875642c36c473aba74e331cfd1ca7b1aa52e49cf Mon Sep 17 00:00:00 2001 From: Pierre Date: Fri, 24 Aug 2018 17:41:27 +0200 Subject: [PATCH 36/40] fix memory leak --- src/faustgen_tilde.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/faustgen_tilde.c b/src/faustgen_tilde.c index de34f01..9f65de5 100644 --- a/src/faustgen_tilde.c +++ b/src/faustgen_tilde.c @@ -98,7 +98,6 @@ static void faustgen_tilde_compile(t_faustgen_tilde *x) return; } - instance = createCDSPInstance(factory); if(instance) { @@ -117,6 +116,7 @@ static void faustgen_tilde_compile(t_faustgen_tilde *x) return; } + deleteCDSPFactory(factory); faustgen_tilde_delete_instance(x); faustgen_tilde_delete_factory(x); pd_error(x, "faustgen~: memory allocation failed - instance"); From cad245c182dcd96d70f6f108cc6bf9e78d28d60e Mon Sep 17 00:00:00 2001 From: Pierre Date: Fri, 24 Aug 2018 17:41:50 +0200 Subject: [PATCH 37/40] fix file path for windows --- src/faust_tilde_options.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/faust_tilde_options.c b/src/faust_tilde_options.c index 1e90bee..352666a 100644 --- a/src/faust_tilde_options.c +++ b/src/faust_tilde_options.c @@ -216,21 +216,26 @@ char const* faust_opt_manager_get_full_path(t_faust_opt_manager *x, char const* { if(x->f_canvas && name) { - char patht[MAXFAUSTSTRING], path[MAXFAUSTSTRING], realdir[MAXPDSTRING], *realname; + char path[MAXFAUSTSTRING], realdir[MAXPDSTRING], *realname = NULL; int filedesc = canvas_open(x->f_canvas, name, ".dsp", realdir, &realname, MAXPDSTRING, 0); if(filedesc < 0) { pd_error(x->f_owner, "faustgen~: can't find the FAUST DSP file %s.dsp", name); return NULL; } - else + if(!realname) { - close(filedesc); + pd_error(x->f_owner, "faustgen~: can't find the real name of the FAUST DSP file %s.dsp", name); + return NULL; } - - sprintf(patht, "%s/%s", realdir, realname); - sys_unbashfilename(patht, path); + sprintf(path, "%s/%s", realdir, realname); x->f_temp_path = gensym(path); + if(!x->f_temp_path) + { + pd_error(x->f_owner, "faustgen~: can't generate symbol for the FAUST DSP file %s.dsp", name); + return NULL; + } + //close(filedesc); return x->f_temp_path->s_name; } pd_error(x->f_owner, "faustgen~: invalid path or name"); From 8a6420db4752159211b3efb8e6a1416758207a96 Mon Sep 17 00:00:00 2001 From: Pierre Date: Sat, 25 Aug 2018 09:11:56 +0200 Subject: [PATCH 38/40] use sys_close instead of close --- src/faust_tilde_options.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/faust_tilde_options.c b/src/faust_tilde_options.c index 352666a..a8be766 100644 --- a/src/faust_tilde_options.c +++ b/src/faust_tilde_options.c @@ -8,12 +8,6 @@ #include "faust_tilde_options.h" #include -#ifdef _WIN32 -#include -#else -#include -#endif - #define MAXFAUSTSTRING 4096 typedef struct _faust_opt_manager @@ -223,6 +217,8 @@ char const* faust_opt_manager_get_full_path(t_faust_opt_manager *x, char const* pd_error(x->f_owner, "faustgen~: can't find the FAUST DSP file %s.dsp", name); return NULL; } + sys_close(filedesc); + if(!realname) { pd_error(x->f_owner, "faustgen~: can't find the real name of the FAUST DSP file %s.dsp", name); @@ -235,7 +231,6 @@ char const* faust_opt_manager_get_full_path(t_faust_opt_manager *x, char const* pd_error(x->f_owner, "faustgen~: can't generate symbol for the FAUST DSP file %s.dsp", name); return NULL; } - //close(filedesc); return x->f_temp_path->s_name; } pd_error(x->f_owner, "faustgen~: invalid path or name"); From 22bfcfeacaa99f3e5f5ae5b4326275c62085f66b Mon Sep 17 00:00:00 2001 From: Pierre Date: Sat, 25 Aug 2018 09:19:21 +0200 Subject: [PATCH 39/40] updated changelog, todo list and version --- ChangeLog.md | 3 ++- ToDoList.md | 1 - src/faustgen_tilde.c | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 7ac5209..156d2f2 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,9 +1,10 @@ -### v0.0.6 +### v0.1.0 - Add support to preserve parameters values during recompilation - Fix autocompilation when DSP instance not initialized - Fix support for the double-float-precision option - Add support to look for the DSP file in all Pd's search paths - Add support to open the FAUST file in the default text editor when object is clicked +- Add a default locked FAUST file used when no argument is provided ### v0.0.5 - Fix when no argument is provided diff --git a/ToDoList.md b/ToDoList.md index 26ecf6f..fa17b59 100644 --- a/ToDoList.md +++ b/ToDoList.md @@ -1,3 +1,2 @@ - Mesure DSP time of the code - Use automatic optimizations with compile options -- Add a default temporary FAUST file when no argument diff --git a/src/faustgen_tilde.c b/src/faustgen_tilde.c index 9f65de5..f558526 100644 --- a/src/faustgen_tilde.c +++ b/src/faustgen_tilde.c @@ -18,8 +18,8 @@ #include "faust_tilde_io.h" #include "faust_tilde_options.h" +#define FAUSTGEN_VERSION_STR "0.1.0" #define MAXFAUSTSTRING 4096 -#define MAXFAUSTOPTIONS 128 typedef struct _faustgen_tilde { @@ -518,6 +518,7 @@ void faustgen_tilde_setup(void) logpost(NULL, 3, "Faust website: faust.grame.fr"); logpost(NULL, 3, "Faust development: GRAME"); + logpost(NULL, 3, "faustgen~ version: %s", FAUSTGEN_VERSION_STR); logpost(NULL, 3, "faustgen~ compiler version: %s", getCLibFaustVersion()); logpost(NULL, 3, "faustgen~ default include directory: %s", class_gethelpdir(c)); logpost(NULL, 3, "faustgen~ institutions: CICM - ANR MUSICOLL"); From c147f74c62a7dcf3c4af21877a00db3c2f3e6c7f Mon Sep 17 00:00:00 2001 From: Pierre Date: Sat, 25 Aug 2018 09:23:02 +0200 Subject: [PATCH 40/40] update faust --- faust | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/faust b/faust index 5ef1f5e..e20faac 160000 --- a/faust +++ b/faust @@ -1 +1 @@ -Subproject commit 5ef1f5e325b9a7c0dec66107a7ede0531a02346f +Subproject commit e20faac53fe4ae051851e186544847f5bc57eb52