You're making it more complicated than it needs to be. SynthDef.wrap
automatically promotes arguments of the given function to be synthdef
controls, so you don't need to take any action related to the func's
argnames and so forth.
d = SynthDef(\demo, { |out|
Out.ar(out, SynthDef.wrap({ |freq| SinOsc.ar(freq) }))
});
d.allControlNames;
--> [ ControlName P 0 out control 0, ControlName P 1 freq control 0 ]
Therefore both the \out and \freq controls will respond to set
messages etc.
hjh
On Dec 28, 2008, at 12:12 PM, Batuhan Bozkurt wrote:
Hello all,
I'm trying to use SynthDef.wrap for hiding some of the complexity for
generating synths with the same set of parameters, envelopes etc. I'm
trying to build a class that will get a function as an input and
inject that function into a predefined synthdef structure.
I want the arguments of the supplied function to act like the
arguments of the SynthDef so I can access them via OSC but can't
".wrap" my head around it.
My shot was something like this, a blank synthdef for now and a function:
(
f =
{
arg name, func;
SynthDef(name,
{
var out = SynthDef.wrap(func, 0.dup(func.def.argNames.size),
func.def.argNames);
Out.ar(0, out);
}).send(s);
};
)
f.value("siner", { arg freq = 440; SinOsc.ar(freq); });
It doesn't compile, I was not really expecting it to work but maybe
someone can help. I want this freq argument supplied in the function
to act as an argument for the SynthDef. I want to be able to add
arbitrarily named arguments that way (to the function) that will act
the same way. How can I achieve this?
: H. James Harkins
: jamshark70@xxxxxxxxxxxxxxxxx <mailto:jamshark70@xxxxxxxxxxxxxxxxx>
: http://www.dewdrop-world.net
.::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..:
"Come said the Muse,
Sing me a song no poet has yet chanted,
Sing me the universal." -- Whitman