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

Re: [sc-users] array dynamically in synthdef



I think that you can't pass arrays as arguments.  Anyway, here's an
idea for you:

(
SynthDef('dynKlanklac', {

| base = 30, num = 30 |

var freqs = (Array.fill(n, { (base + num.rand).midicps})), // Look at
the variable controls on this line
amps = (Array.fill(n, { 0.06 + 0.007.rand })),
ringtimes = (Array.fill(n, { 1.75 + 10.rand }));

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

x = Synth('dynKlanklac');
x.setn(\num, 35, \base, 27);

So this way you can change the parameters without actually passing a
new array.  In order to get stranger (non-tuned) filters, you should
really move away from midicps and go toward a floating-point
exponential system.  It'll get much better detuned results.  Any other
ideas?

On Tue, Jul 28, 2009 at 10:21 AM, Perdo<pelectron69@xxxxxxxxx> wrote:
> 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 ?
>>
>
>
>

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