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

Re: [sc-users] array dynamically in synthdef



then you need to use Control...

(
var n = 30;
var f = Array.fill(n, { (30 + 75.rand).midicps});
var a = Array.fill(n, { 0.002 + 0.007.rand });
var r = Array.fill(n, { 0.05 + 0.25.rand });

// set them from outside later:
SynthDef('help-dynKlank', {
    var freqs, amps, ringtimes, signal;
    freqs = Control.names([\freqs]).kr(f);
    amps = Control.names([\amps]).kr(a);
    ringtimes = Control.names([\ringtimes]).kr(r);
    signal = DynKlank.ar(`[freqs, amps, ringtimes ], WhiteNoise.ar(0.001));
    Out.ar(0, signal);
}).load(s);
)

Best,
Hjalte

2009/7/28 Perdo <pelectron69@xxxxxxxxx>
Thanks for your response Hjalte, but your solution is still the same I have before...
With this one I can't change neither freqs, amps, ringtimes from the external world for example:

a = Synth('dynKlanklac');

a.setn(\freqs, Array.rand(30, 20, 5000)); //not possible with the var solution...

Any other idea?

Best

p




It's because you're trying to use the filled arrays as arguments to the Synth, either you should change arg to var or use Control...

(
var n = 30;

SynthDef('dynKlanklac', { var freqs  = Array.fill(n, { (30 + 75.rand).midicps}), amps  = Array.fill(n, { 0.002 + 0.007.rand }), ringtimes = Array.fill(n, { 0.05 + 0.25.rand });

Out.ar(0, DynKlank.ar([`[freqs, amps, ringtimes], `[freqs, amps, ringtimes]], WhiteNoise.ar * 0.001))
}
).load(s)
)

Best,
Hjalte

2009/7/28 Perdo <pelectron69@xxxxxxxxx>
Thanks Hjalte,

I have a lots of things to learn!!

Btw can somebody say me why this doesn't work? Ok I can't change dynamically the number of elements in a SynthDef but it's possible in the compilation? 

(
//var freqs, amps, ringtimes, n;
var n;
n = 30;

//freqs = Array.fill(n, { (30 + 75.rand).midicps});
//amps = Array.fill(n, { 0.002 + 0.007.rand });
//ringtimes = Array.fill(n, { 0.05 + 0.25.rand });

SynthDef('dynKlanklac', { arg freqs  = Array.fill(n, { (30 + 75.rand).midicps}), amps  = Array.fill(n, { 0.002 + 0.007.rand }), ringtimes = Array.fill(n, { 0.05 + 0.25.rand });

Out.ar(0, DynKlank.ar([`[freqs, amps, ringtimes], `[freqs, amps, ringtimes]], WhiteNoise.ar * 0.001))
}
).load(s)
)

Thanks for your patience!

Best

p


The reason for this is that the Pattern / Event way of using synths has been added after the .load / .send methods. store / memStore adds info about the SynthDef to the SynthDescLib, which makes it available to the client.

There was a discussion about this very recently.

To me it still seems very weird that .store dosen't work, I thought it was the same thing to the server ?