«how to generate the synthdef with a pattern» by grirgz

on 05 Jan'24 02:28 in patternsynthdef

synthdef building should take less time than s.latency for this to work

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
(
Pdef(\zed, 
    Pbind(
        \osc, Pseq([SinOsc, LFSaw],inf),
        \instrument, Prout({ arg ev;
            SynthDef(\zed, { arg out=0, gate=1, amp=0.1, pan=0, freq=200;
                var sig;
                sig = ev[\osc].ar(freq);
                sig = sig * EnvGen.kr(\adsr.kr(Env.adsr(0.1,0.1,0.8,0.1)), gate, doneAction:2);
                sig = Pan2.ar(sig, pan, amp);
                Out.ar(out, sig);
            }).add.yield;
        }).loop,
        \degree, Pseq([0],inf),
        \dur, 1,
        \amp, 0.1,
    )
).play;
);
raw 564 chars (focus & ctrl+a+c to copy)
reception
comments
56228375 user 05 Jan'24 07:21

Do you have a use case in mind? This approach feels a little non-idiomatic (dangerous for getting random failures if synthdef building time becomes comparable to s.latency).

grirgz user 14 Feb'24 15:39

it was a question on a discord if i remember correctly, i don't really use this kind of code, but it is possible so why not ? ^^