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

Re: [sc-users] array dynamically in synthdef



all args to a SynthDef are actually converted into Controls for you. You just don't see it happen. :

SynthDef(\test1, {
	var freq;
	freq = Control.names(\freq).kr(440);
	...
	})

is the same as:

SynthDef(\test1, {arg freq = 440;
	...
	})

Josh

On Jul 28, 2009, at 8:12 AM, Andrew C. Smith wrote:

Yeah, Hjalte's email popped up just as I hit send.  I've got the
Control help file open right now.  Every time I think something can't
be done there's probably just a UGen I haven't heard of.

Questions about Control, though: could Control (or NamedControl) be
used instead of arg in all cases?  It seems that it supports defaults
and names.  The help file also has uses where a synth is initialized
using an arg and a Control with no difference between their syntax.
Thanks again.

Andrew

On Tue, Jul 28, 2009 at 10:48 AM, James Harkins<jamshark70@xxxxxxxxx> wrote:
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


_______________________________________________
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/

******************************************
/* Joshua D. Parmenter
http://www.realizedsound.net/josh/

“Every composer – at all times and in all cases – gives his own interpretation of how modern society is structured: whether actively or passively, consciously or unconsciously, he makes choices in this regard. He may be conservative or he may subject himself to continual renewal; or he may strive for a revolutionary, historical or social palingenesis." - Luigi Nono
*/


_______________________________________________
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/