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

Re: [sc-users] array dynamically in synthdef



Huff!! Thank you for all your quick responses!!

Alberto, thank you also but I don't really see why the use JITLib is simplest if it is not by the use of xfade really useful but not for me at this time...

Hjalte your solution is ok! thank you!!

Andrew, your solution seems the one I looking for from the beginning but unfortunately doesn't work... btw to detune .midicps  I found this .midiratio(x) in the list.

James SCGuru, thanks again!!

So the solution for me at this time is this one and next step is to use the dynamic ability of DynKlank and DynKlang and why not a little gui to control it...
Is ok for you?

Best

p

(
var n = 30;
var f = Array.fill(n, { [(40 + 75.rand) * (0.50.midiratio),(40 + 75.rand)].choose.postln.midicps}); //diatonic and cuarter tones random 
var a = Array.fill(n, { 0.002 + 0.007.rand });
var r = Array.fill(n, { 0.05 + 0.25.rand });


SynthDef('dynKlanklac', {
    var freqs, amps, ringtimes, signal;
    freqs = \freqs.kr(f);
    amps = \amps.kr(a);
    ringtimes = \ringtimes.kr(r);
    signal = DynKlank.ar([`[freqs, amps, ringtimes], `[freqs, amps, ringtimes]], WhiteNoise.ar(0.01));
    Out.ar(0, signal);
}).load(s);
)

a = Synth('dynKlanklac');
a.set(\freqs, { [(40 + 75.rand) * (0.50.midiratio),(40 + 75.rand)].choose.postln.midicps} ! 30);






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 ?