I can’t quite get your code to run, and can’t quite tell exactly what you’re intending, but here’s a few pointers that might help…
In general, sequencing by using Select
is not ideal, this is really meant to switch between multiple continuously-running signal chains rather than step through values.
You might look at the Demand ugens - these provide ways to generate sequences of values inside of a Synth or Ndef. Here’s a quick example that might spark some ideas…
Start with simple Impulse driven kick:
(
Ndef(\kick, {
var trig, env, kick;
trig = Impulse.ar(2);
env = Env.perc(0.01, 0.6).ar(gate:trig);
kick = LPF.ar(Saw.ar(
freq: env.lincurve(0, 1, 30, 90, 20),
mul: 16 * env
), 90).tanh;
kick = kick + (-3.dbamp * Amplitude.ar(kick, 0.01, 0.4) * FreeVerb.ar(LPF.ar(kick, 200), 1, 3.1, 0.1));
-16.dbamp * kick * [1, 1]
}).play;
)
This is the same thing but with a Dseq
describing a sequence of timings (in this case, just repeating 1/2 second durations forever)
(
Ndef(\kick, {
var pattern, trig, env, kick;
pattern = Dseq([1/2], inf);
trig = TDuty.ar(pattern);
env = Env.perc(0.01, 0.6).ar(gate:trig);
kick = LPF.ar(Saw.ar(
freq: env.lincurve(0, 1, 30, 90, 20),
mul: 16 * env
), 90).tanh;
kick = kick + (-3.dbamp * Amplitude.ar(kick, 0.01, 0.4) * FreeVerb.ar(LPF.ar(kick, 200), 1, 3.1, 0.1));
-16.dbamp * kick * [1, 1]
}).play;
)
With a more complex pattern:
(
Ndef(\kick, {
var pattern, trig, env, kick;
pattern = Dseq([2, 2, 1.5, 1.5, 1], inf);
pattern = (1/4) * pattern;
trig = TDuty.ar(pattern);
env = Env.perc(0.01, 0.5).ar(gate:trig);
kick = LPF.ar(Saw.ar(
freq: env.lincurve(0, 1, 30, 90, 20),
mul: 16 * env
), 90).tanh;
kick = kick + (-3.dbamp * Amplitude.ar(kick, 0.01, 0.4) * FreeVerb.ar(LPF.ar(kick, 200), 1, 3.1, 0.1));
-16.dbamp * kick * [1, 1]
}).play;
)
And randomizing the order of the durations in the sequence:
(
Ndef(\kick, {
var pattern, trig, env, kick;
var durations;
durations = Drand([1, 1, 1, 1, 1.5, 1.5, 2], inf);
pattern = Dseq([durations], inf);
pattern = (1/4) * pattern;
trig = TDuty.ar(pattern);
env = Env.perc(0.01, 0.5).ar(gate:trig);
kick = LPF.ar(Saw.ar(
freq: env.lincurve(0, 1, 30, 90, 20),
mul: 16 * env
), 90).tanh;
kick = kick + (-3.dbamp * Amplitude.ar(kick, 0.01, 0.4) * FreeVerb.ar(LPF.ar(kick, 200), 1, 3.1, 0.1));
-16.dbamp * kick * [1, 1]
}).play;
)
Hopefully this gives you some ideas about how to implement random sequencing things? In the long term, the better way to do this is probably with Patterns, since sequencing things are somewhat limited if you’re doing it from inside a SynthDef - but, anything you can get working with Demand UGens you can also build with Patterns, so this is a reasonable place to start experimenting, and you can decide if you want to learn the Pattern stuff later on.