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

Re: [sc-users] array dynamically in synthdef



Hi,
playing around with variants of synths is quite simple with JITLib:

// a named proxy for a synth process
Ndef(\dynk, {
	var n = 30;
	var freqs = NamedControl(\freqs, { (30 + 75.rand).midicps }.dup(n));
	var amps = NamedControl(\amps, { 0.002 + 0.007.rand }.dup(n));
	var ringtimes = NamedControl(\ringtimes, { 0.05 + 0.25.rand }.dup(n));

DynKlank.ar([`[freqs, amps, ringtimes], `[freqs, amps, ringtimes]], WhiteNoise.ar(0.001.dup))
});

// play to the main outputs
Ndef(\dynk).play;

// set the params after the synth is running:
Ndef(\dynk).setn(\freqs, { (30 + 75.rand).midicps }.dup(30));
Ndef(\dynk).setn(\amps, { 0.002 + 0.007.rand }.dup(30));
Ndef(\dynk).setn(\ringtimes, { 0.05 + 0.25.rand }.dup(30));

// the last settings are stored here
Ndef(\dynk).getKeysValues;

// xfade to a new copy of the synth process,
// with a new setting for freqs
Ndef(\dynk).fadeTime = 1;
Ndef(\dynk).xsetn(\freqs, { (30 + 75.rand).midicps }.dup(30));


hope that helps,

best, adc


On Tue, Jul 28, 2009 at 10:37 AM, Andrew C. Smith <<mailto:acsmith@xxxxxxxxxxxxxx>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 = \<http://x.kr>x.kr(default);
    ...
})

hjh



--
James Harkins /// dewdrop world
<mailto:jamshark70@xxxxxxxxxxxxxxxxx>jamshark70@xxxxxxxxxxxxxxxxx
<http://www.dewdrop-world.net>http://www.dewdrop-world.net

"Come said the Muse,
Sing me a song no poet has yet chanted,
Sing me the universal."  -- Whitman


--
--
Prof Dr Alberto de Campo
Bergstrasse 59/33
A-8020 Graz, Austria
e-mail : adc@xxxxxxxx
--

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