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

Re: [sc-users] array dynamically in synthdef



On Tue, Jul 28, 2009 at 10:37 AM, Andrew C. Smith <acsmith@xxxxxxxxxxxxxx> wrote:
I think that you can't pass arrays as arguments.

You can -- see Hjalte's email. For both of the "ok" synthdefs below, you can send the array directly with set or new:

a = Synth(\ok, [x: [5, 6, 7, 8]]);
a.set(\x, { 10.rand } ! 4);

The issue with Perdo's latest try is that an array given as an argument default must be a literal array. That is, this is OK:

SynthDef(\ok, { arg x = #[1, 2, 3, 4];
...
})

But this is not.

var default = [0, 1, 2, 3];
SynthDef(\no, { arg x = default;
...
});

And the solution as Hjalte said is to use Control, or (easier syntax) NamedControl by way of Symbol:kr.

var default = [0, 1, 2, 3];
SynthDef(\alsoOK, {
    var    x = \x.kr(default);
    ...
})

hjh


--
James Harkins /// dewdrop world
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