[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-dev] SynthDef prefix error



On Nov 3, 2013 7:31 AM, "Lucas Samaruga" <samarugalucas@xxxxxxxxx> wrote:
>
> Hi
>
> I found this obscure:
>
> // it also happens with any other prefix x_
> // when the suffix is repeated.
> SynthDef(\test, { arg t_yyy, a_yyy, n_yyy;
>     Out.ar(0, 0);
> }).add;
>
> ERROR: Function argument 'yyy' already declared in Interpreter:functionCompileContext
>   in file 'selected text'
>   line 1 char 21:
>
>   #{ arg yyy, yyy, yyy;

When you add a SynthDef, a SynthDesc gets saved into the (global) SynthDescLib. The SynthDesc contains a msgFunc to map values in the event onto argument names. This mapping does *not* use the prefix -- if you have t_trig in the SynthDef, you'd use \trig in Pmono. This may or may not have been a good idea, but it was in James McCartney's original version of SynthDesc.

That function uses arguments, filled by valueEnvir, to get the event values. Since the prefix doesn't count, t_yyy and a_yyy both get argument names yyy.

Actually it's supposed to check for duplicate argument names, but I guess I forgot to strip the prefix before checking. It will print a more informative message if your def includes, e.g., "arg yyy, a bunch of other args, yyy." Can fix later, should be easy... I'm in transit now (and amusing myself on my phone with SC list traffic).

hjh