Skip to content

Commit

Permalink
add parameter list support
Browse files Browse the repository at this point in the history
  • Loading branch information
pierreguillot committed Jul 18, 2018
1 parent ec40b91 commit 3ff0f4b
Show file tree
Hide file tree
Showing 6 changed files with 140 additions and 93 deletions.
2 changes: 1 addition & 1 deletion external/examples/dummy.dsp
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ declare version "1.0";
declare author "Heu... me...";


process = _, _, _;
process = _, _, _, _ :> _, _;
7 changes: 7 additions & 0 deletions external/examples/gain.dsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import("stdfaust.lib");

process = _ * (gain)
with
{
gain = vslider("gain [unit:linear]", 0,0,1,0.001);
};
52 changes: 0 additions & 52 deletions external/examples/noise.dsp

This file was deleted.

11 changes: 11 additions & 0 deletions external/examples/resonator.dsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import("stdfaust.lib");

// Example programmed by Christophe Lebreton - GRAME

f(i) = hslider("freq%3i", 160.,-0.,20000.,0.001);
r(i) = hslider("decay%3i", 0.,0.,1.,0.001):((pow(4.78)*6)+0.0001):ba.tau2pole;
g(i) = hslider("gain%3i", 0.,0.,1.,0.0001);

resonator(n) = _<:par(i,n,*(g(i)):fi.nlf2(f(i),r(i)):_,!:*(ba.db2linear((100*(log(1/r(i))))))):>*(0.003162);

process = resonator(20) ;
106 changes: 74 additions & 32 deletions external/faustgen~-help.pd
Original file line number Diff line number Diff line change
@@ -1,48 +1,90 @@
#N canvas 364 281 470 537 10;
#N canvas 428 137 481 548 10;
#X obj 12 15 cnv 15 360 17 empty empty faustgen~ 2 9 0 14 -233017 -66577
0;
#X obj 286 155 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
#X obj 286 115 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
1;
#X msg 286 175 \; pd dsp \$1;
#X msg 286 135 \; pd dsp \$1;
#X obj 32 308 dac~ 1 2;
#X obj 32 158 nbx 5 14 0 1 0 0 empty empty empty 0 -8 0 10 -262144
#X obj 62 192 nbx 5 14 0 1 0 0 empty empty empty 0 -8 0 10 -262144
-1 -1 0 256;
#X msg 32 177 Volume \$1;
#X obj 32 116 loadbang;
#X msg 32 137 0;
#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 341 FAUST institution: GRAME;
#X text 26 355 FAUST website: faust.grame.fr;
#X text 132 370 Yann Orlarey \, Stéphane Letz \, Dominique Fober \,
#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 text 26 369 FAUST developers:;
#X text 26 439 This object is inspired by faustgen~ for Max developed
#X text 26 379 FAUST developers:;
#X text 26 449 This object is inspired by faustgen~ for Max developed
by Martin Di Rollo and Stéphane Letz., f 50;
#X text 192 256 Use compilation options. See the FAUST documentation
for further information, f 24;
#X text 95 16 the FAUST compiler embedded in a Pd external;
#X text 26 469 Another faust~ object has been developed by Albert Graef
#X text 26 479 Another faust~ object has been developed by Albert Graef
using the programming language "Pure" : https://github.com/agraef/pure-lang.
, f 67;
#X text 95 155 Control the parameters with their names, f 15;
#X obj 32 265 faustgen~ examples/noise;
#X text 26 389 faustgen~ institutions: CICM - ANR MUSICOLL;
#X text 26 403 faustgen~ website: github.com/grame-cncm/faust-pd;
#X text 26 417 faustgen~ developer: Pierre Guillot;
#X msg 52 207 compile;
#X text 103 208 Reload and recompile the FAUST file;
#X msg 82 231 compileoptions -vs 64 -vec;
#X obj 192 305 faustgen~ examples/noise -vs 64 -vec;
#X text 125 189 Control the parameters with their names, f 15;
#X text 26 399 faustgen~ institutions: CICM - ANR MUSICOLL;
#X text 26 413 faustgen~ website: github.com/grame-cncm/faust-pd;
#X text 26 427 faustgen~ developer: Pierre Guillot;
#X msg 62 211 gain \$1;
#X obj 32 118 osc~ 220;
#X obj 31 265 faustgen~ examples/gain;
#N canvas 389 171 372 237 options 0;
#X text 16 70 Change the compile options and recompile;
#X msg 17 91 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 obj 17 165 faustgen~ examples/gain -vec -lv 1 -double;
#X text 21 27 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 connect 1 0 4 0;
#X connect 6 0 4 0;
#X restore 247 235 pd options;
#N canvas 287 129 388 208 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 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.
;
#X text 50 62 Active/deactivate the autocompilation when the dsp file
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 connect 0 0 1 0;
#X connect 1 0 2 0;
#X connect 4 0 5 0;
#X connect 5 0 18 0;
#X connect 6 0 7 0;
#X connect 7 0 4 0;
#X connect 18 0 3 0;
#X connect 18 0 3 1;
#X connect 22 0 18 0;
#X connect 24 0 18 0;
#X connect 6 0 2 0;
#X restore 247 264 pd recompilation;
#N canvas 467 328 450 300 controls 0;
#X obj 30 168 dac~ 1 2;
#X obj 30 107 osc~ 220;
#X msg 92 107 gain \$1;
#X obj 92 87 nbx 5 14 0 1 0 0 empty empty Gain 0 -8 0 10 -262144 -1
-1 0 256;
#X obj 30 135 faustgen~ examples/resonator -vs 64 -vec;
#X msg 161 105 print;
#X connect 1 0 4 0;
#X connect 2 0 4 0;
#X connect 3 0 2 0;
#X connect 4 0 0 0;
#X connect 4 0 0 1;
#X connect 5 0 4 0;
#X restore 247 293 pd controls;
#X connect 1 0 2 0;
#X connect 4 0 19 0;
#X connect 5 0 6 0;
#X connect 6 0 4 0;
#X connect 19 0 21 0;
#X connect 20 0 21 0;
#X connect 21 0 3 0;
#X connect 21 0 3 1;
55 changes: 47 additions & 8 deletions src/faustgen_tilde.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,20 +172,59 @@ static void faustgen_tilde_anything(t_faustgen_tilde *x, t_symbol* s, int argc,
{
if(x->f_dsp_instance)
{
t_float value;
if(!faust_ui_manager_set(x->f_ui_manager, s, atom_getfloatarg(0, argc, argv)))
if(!argc)
{
t_float value;
if(!faust_ui_manager_get(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);
return;
}
if(!faust_ui_manager_get(x->f_ui_manager, s, &value))
else if(argc == 1)
{
t_atom av;
SETFLOAT(&av, value);
outlet_anything(faust_io_manager_get_extra_output(x->f_io_manager), s, 1, &av);
if(argv[0].a_type != A_FLOAT)
{
pd_error(x, "faustgen~: active parameter requires a float value");
return;
}
if(!faust_ui_manager_set(x->f_ui_manager, s, argv[0].a_w.w_float))
{
return;
}
pd_error(x, "faustgen~: active parameter '%s' not defined", s->s_name);
return;
}
else
{
int i, start;
char name[MAXFAUSTSTRING];
if(argv[0].a_type != A_FLOAT)
{
pd_error(x, "faustgen~: list parameters requires a first index");
return;
}
start = (int)argv[0].a_w.w_float;
for(i = 0; i < argc; ++i)
{
sprintf(name, "%s %i", s->s_name, start+i);
if(argv[i+1].a_type != A_FLOAT)
{
pd_error(x, "faustgen~: active parameter requires a float value");
return;
}
if(faust_ui_manager_set(x->f_ui_manager, gensym(name), argv[i+1].a_w.w_float))
{
pd_error(x, "faustgen~: active parameter '%s' not defined", name);
return;
}
}
return;
}
pd_error(x, "faustgen~: ui glue '%s' not defined", s->s_name);
return;
}
pd_error(x, "faustgen~: no dsp instance");
}
Expand Down

0 comments on commit 3ff0f4b

Please sign in to comment.