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

Re: [sc-users] Can't wrap my head around SynthDef.wrap



Ah thanks, that was easy. Maybe adding this little snippet to the SynthDef help file would be nice, because the .wrap examples in the help file, I found quite confusing. Because all that lagtime stuff (which is not a standard in my sc repertory that I use often) and argument overriding stuff hides the easiness of the implementation of .wrap (because it tries to show probably full functionality of it, so it is also necessary).

Or maybe its just me. Anyway, thanks a lot!

BB.

James Harkins wrote:
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



_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: https://listarc.bham.ac.uk/marchives/sc-users/
search: https://listarc.bham.ac.uk/lists/sc-users/search/