Hi jamshark70,
Thanks a lot for your advices, they were really helpful.
So now I have things working nice, but not exactly as I would like them to sound.
One of the main problems I have right now is that i would like to stop all of the synths running (if they are not overlapped), and maybe before the stop, make them reach a little climax (so maybe a little volume increase could work just fine).
Plus, i would like the rythms to be more pointillistic and be less dense, cause until now, they spawn every time with the code, every type of rhytm.
Also, a sort of a mixing problem: these rhytms are more or less sucked into the textures… what should I do maybe? Route the textures through a bus a lower it?
Thanks in advance, and sorry if I am gonna post all the code… I swear I will use you suggestion on synthetize the logic, in the future!
//server config
(
s = Server.local;
s.newBusAllocators;
ServerBoot.removeAll;
ServerTree.removeAll;
ServerQuit.removeAll;
/*
s.options.numAnalogInChannels = 2;
s.options.numAnalogOutChannels = 2;
s.options.numDigitalChannels = 2;
s.options.blockSize = (2.pow(8));
s.options.numInputBusChannels = 2;
s.options.numOutputBusChannels = 2;
s.options.headphoneLevel = -3;
s.options.postln;
*/
o = Server.default.options;
o.inDevice_("ASIO : Focusrite USB");
o.outDevice_("ASIO : Focusrite USB")
);
//global var
(
~scale = [
Scale.dorian, Scale.hexPhrygian, Scale.hungarianMinor, Scale.ionian,
Scale.partch_o1, Scale.mixolydian, Scale.superLocrian, Scale.marva,
Scale.partch_o5, Scale.yakahDesc, Scale.suznak, Scale.romanianMinor,
];
~tempo = TempoClock.new;
~tempo.tempo_(80/60);
~path = PathName(thisProcess.nowExecutingPath).parentPath++"buf/";
~times_1 = [rrand(3, 20), rrand(80, 150), rrand(180, 260), rrand(290, 360), rrand(390, 560)];
~stops_1 = ~times_1 + Array.fill(~times_1.size, {rrand(30, 70)});
~times_2 = [exprand(~times_1[0], ~times_1[0]+15), exprand(~times_1[1], ~times_1[1]+15), exprand(~times_1[2], ~times_1[2]+15), exprand(~times_1[3], ~times_1[3]+15), exprand(~times_1[4], ~times_1[4]+15)];
~stops_2 = ~times_2 + Array.fill(~times_2.size, {rrand(40, 60)});
~times_3 = [exprand(~times_1[0], ~times_1[0]+10), exprand(~times_1[1], ~times_1[1]+10), exprand(~times_1[2], ~times_1[2]+10), exprand(~times_1[3], ~times_1[3]+10), exprand(~times_1[4], ~times_1[4]+10)];
~stops_3 = ~times_3 + Array.fill(~times_3.size, {rrand(40, 50)});
~times = [~times_1, ~times_2, ~times_3];
~stops = [~stops_1, ~stops_2, ~stops_3];
~btimes_1 = [exprand(~times_1[0], ~times_1[0]+15), exprand(~times_1[1], ~times_1[1]+15), exprand(~times_1[2], ~times_1[2]+15), exprand(~times_1[3], ~times_1[3]+15), exprand(~times_1[4], ~times_1[4]+15)];
~bstops_1 = ~btimes_1 + Array.fill(~btimes_1.size, {rrand(40, 50)});
[~btimes_1, ~bstops_1].flop.postln;
);
//global func
(
~cleanUp = {
s.newBusAllocators;
ServerBoot.removeAll;
ServerTree.removeAll;
ServerQuit.removeAll;
};
~makeBuffers={
var arrSqu, arrSaw;
var sigSqu, sigSaw, sigSin, sigRand;
arrSqu = {
var arr;
arr = Array.fill(2.pow(14).asInteger, {|i|
i = i+1;
if(i.odd){
i = 1/i;
}
{i = 1}
}
);
arr = arr * 0.75
};
sigSqu = Signal.sineFill(
2.pow(14).asInteger,
arrSqu.value,
0!8192);
arrSaw = {
var arr;
arr = Array.fill(2.pow(14).asInteger, {|i|
i = i+1;
i = 1/i;
});
arr = arr * 0.5
};
sigSaw = Signal.sineFill(
2.pow(14).asInteger,
arrSaw.value,
0!8192);
sigSin = Signal.sineFill(
2.pow(14).asInteger,
[1],
[0]);
sigRand = Env(
{rrand(-1, 1)}!14,
{exprand(1, 20)}!15,
{rrand(1, 20)}!15
).asSignal(2.pow(14).asInteger);
~bufSin = Buffer.alloc(s, (2.pow(15)).asInteger);
~bufSqu = Buffer.alloc(s, (2.pow(15)).asInteger);
~bufSaw = Buffer.alloc(s, (2.pow(15)).asInteger);
~bufRand = Buffer.alloc(s, (2.pow(15)).asInteger);
~bufSin.loadCollection(sigSin.asWavetable);
~bufSqu.loadCollection(sigSqu.asWavetable);
~bufSaw.loadCollection(sigSaw.asWavetable);
~bufRand.loadCollection(sigRand.asWavetable);
};
~makeRhythmBuffers={
b = Dictionary.new;
PathName(~path.asString).entries.do{
arg subfolder;
b.add(
subfolder.folderName.asSymbol ->
Array.fill(
subfolder.entries.size,
{
arg i;
Buffer.read(s, subfolder.entries[i].fullPath);
}
)
);
};
~kick = b[\kick][0];
~snare = b[\snare][(0..2).choose];
~hihat = b[\hihat][(0..3).choose];
~sines = b[\sines][(0..1).choose];
};
~makeBusses = s.makeBundle(s.latency, {
~masterBus = Bus.audio(s,2);
});
~makeNodes = {
s.bind(
~srcGrp = Group.new;
~bufGrp = Group.after(~srcGrp);
~msGrp = Group.after(~bufGrp);
s.sync;
~masterSynth = Synth.new(\master, [\in, ~masterBus], ~msGrp, \addToTail);
)
}
);
//reg
(
ServerBoot.add(~makeBuffers);
ServerBoot.add(~makeRhythmBuffers);
ServerBoot.add(~makeBusses);
ServerQuit.add(~cleanUp);
);
//boot
(
s.waitForBoot({
SystemClock.seconds.debug("myCoolTextures at");
SynthDef.new(\vOsc, {
arg buf=0, numBufs=4, pos= 1.0,
freq = 300, amp = 0.9, detuneAmount = 0.001, jitAmount=0.001, cutoff = 12000,
atk=0.001, dcy=0.2, sus = 1.0, rel = 0.4, dly=0.0, crv=1,
gate = 1, out=0;
var sig, env, bufpos, jitter, detuneSig;
jitter = LFNoise0.kr(jitAmount, jitAmount, jitAmount);
bufpos = buf + pos + jitter;
detuneSig = LFNoise1.kr(0.02!8).bipolar(detuneAmount).midiratio.lag(0.5);
env = EnvGen.kr(Env.dadsr(dly, atk, dcy, sus, rel, curve:crv), gate, doneAction:2);
sig = VOsc.ar(bufpos.clip(buf+0.1, numBufs-0.1), freq*(detuneSig).lag(0.3));
sig = Splay.ar(sig) * env * amp;
//sig = OnePole.ar(sig, exp(-2pi * (freq * SampleDur.ir * 9))); //http://tiny.cc/4462gz
sig = LPF.ar(sig, cutoff);
Out.ar(out, sig);
}).add;
SynthDef.new(\BUF, {
arg atk=0.00001, sus=1, rel=0.2,
buf=0, rate=1, lo=0,
amp=1, out=0;
var sig, env;
env = EnvGen.kr(Env([0,1,1,0],[atk,sus,rel],), doneAction:2);
sig = PlayBuf.ar(1, buf, rate*BufRateScale.ir(buf));
sig = sig*env*amp;
sig = Splay.ar(sig);
Out.ar(out,sig);
}).add;
SynthDef(\master, {
arg in = 0, out = 0;
var sig;
sig = In.ar(in, 2);
//sig = FreeVerb2.ar(sig, sig, 0.3, 0.5, 0.8);
sig = LeakDC.ar(sig);
sig = Limiter.ar(sig);
Out.ar(out, sig);
}).add;
s.sync;
ServerTree.add(~makeNodes);
s.sync;
s.freeAll;
~myCoolTextures_1 = { |start, stop|
var synthi, scale, chords;
scale = ~scale.choose;
chords = 16.collect{
[scale.degreeToFreq(scale.degrees.choose,
(if(rrand(0,1).coin,
rrand(3.1, 18),
rrand(98, 127))
),
(if(rrand(0,1).coin,
(rrand(0.01, 0.6)),
(rrand(4.5, 5)))
)
)].clip(0.1, 18000)
};
SystemClock.sched(start, {
SystemClock.seconds.debug("myCoolTextures_1 at");
synthi = Array.fill(4, {
Synth.new(\vOsc, [
\freq, chords.choose,
\amp, rrand(0.01, 0.25),
\atk, if(rrand(0, 0.1).coin, 0, rrand(6.1, 19)),
\dcy, rrand(3.1, 8),
\sus, rrand(0.2, 0.6),
\rel, if(rrand(0, 0.1).coin, 0, rrand(4.3, 15)),
\crv, if(rrand(0, 1).coin, rrand(-6,-0.001), rrand(0.0001,6)),
\pos, rrand(0.5, 2.7),
\cutoff, rrand(6000, 14000),
\detuneAmount, rrand(0.01, 0.55),
\jitAmount, rrand(0.001, 0.2),
\buf, ~bufSin.bufnum,
\out, ~masterBus
], ~srcGrp
)});
});
SystemClock.sched(stop, {
synthi.do(_.set(\gate, 0));
});
};//myCoolTextures ends
[~times_1, ~stops_1].flop.do { |pair|
~myCoolTextures_1.value(pair[0], pair[1]);
};
~myCoolTextures_2 = { |start, stop|
var synthi, scale, chords;
scale = ~scale.choose;
chords = 16.collect{
[scale.degreeToFreq(scale.degrees.choose,
(if(rrand(0,1).coin,
rrand(3.1, 18),
rrand(98, 127))
),
(if(rrand(0,1).coin,
(rrand(0.01, 0.6)),
(rrand(4.5, 5)))
)
)].clip(0.1, 18000)
};
SystemClock.sched(start, {
SystemClock.seconds.debug("myCoolTexture_2 at");
synthi = Array.fill(4, {
Synth.new(\vOsc, [
\freq, chords.choose,
\amp, rrand(0.01, 0.2),
\atk, if(rrand(0, 0.1).coin, 0, rrand(6.1, 21)),
\dcy, rrand(3.1, 8),
\sus, rrand(0.2, 0.6),
\rel, if(rrand(0, 0.1).coin, 0, rrand(4.3, 15)),
\crv, if(rrand(0, 1).coin, rrand(-6,-0.001), rrand(0.0001,6)),
\pos, rrand(0.5, 2.7),
\cutoff, rrand(6000, 14000),
\detuneAmount, rrand(0.01, 0.55),
\jitAmount, rrand(0.001, 0.2),
\buf, ~bufSin.bufnum,
\out, ~masterBus
], ~srcGrp
)});
});
SystemClock.sched(stop, {
synthi.do(_.set(\gate, 0));
});
};//myCoolTextures ends
[~times_2, ~stops_2].flop.do { |pair|
~myCoolTextures_2.value(pair[0], pair[1]);
};
~myCoolTextures_3 = { |start, stop|
var synthi, scale, chords;
scale = ~scale.choose;
chords = 16.collect{
[scale.degreeToFreq(scale.degrees.choose,
(if(rrand(0,1).coin,
rrand(3.1, 18),
rrand(98, 127))
),
(if(rrand(0,1).coin,
(rrand(0.01, 0.6)),
(rrand(4.5, 5)))
)
)].clip(0.1, 18000)
};
SystemClock.sched(start, {
SystemClock.seconds.debug("myCoolTexture_3 at");
synthi = Array.fill(4, {
Synth.new(\vOsc, [
\freq, chords.choose,
\amp, rrand(0.01, 0.2),
\atk, if(rrand(0, 0.1).coin, 0, rrand(6.1, 19)),
\dcy, rrand(3.1, 8),
\sus, rrand(0.2, 0.6),
\rel, if(rrand(0, 0.1).coin, 0, rrand(5.1, 15)),
\crv, if(rrand(0, 1).coin, rrand(-6,-0.001), rrand(0.0001,6)),
\pos, rrand(0.5, 2.7),
\cutoff, rrand(6000, 14000),
\detuneAmount, rrand(0.01, 0.55),
\jitAmount, rrand(0.001, 0.2),
\buf, ~bufSin.bufnum,
\out, ~masterBus
], ~srcGrp
)});
});
SystemClock.sched(stop, {
synthi.do(_.set(\gate, 0));
});
};//myCoolTextures ends
[~times_3, ~stops_3].flop.do { |pair|
~myCoolTextures_3.value(pair[0], pair[1]);
};
[~times, ~stops].postln;
~myCoolRhythm= { |start, stop|
var kick, snare, hihat, sines;
SystemClock.sched(start, {
SystemClock.seconds.debug("myCoolRhythm at");
//if(rrand(0.9,1).coin,
kick = Pbind (
\instrument, \BUF,
\tempo, Pwrand([62/60, 124/90], [6, 1].normalizeSum, inf),
\dur, Pwrand([1/2, 1/4], [10, 2].normalizeSum, inf),
\amp, Pwhite(0.7, 1.5, inf),
\buf, ~kick,
\rate, Pwhite(0.95, 1.05, inf),
\out, ~masterBus,
\group, ~bufGrp
).play;//);
//if(rrand(0.7,1).coin,
sines = Pbind (
\instrument, \BUF,
\tempo, Prand([40/60, 80/90], inf),
\dur, Pwrand([1/7, Rest(), 1/4, Rest(), 1/5], [10, 10, 4, 8, 2].normalizeSum, inf),
\amp, Pwhite(0.005, 0.25, inf),
\buf, ~sines,
\rate, Pwhite(0.3, 13, inf),
\out, ~masterBus,
\group, ~bufGrp
).play;//);
//if(rrand(0,0.6).coin,
snare = Pbind (
\instrument, \BUF,
\tempo, Prand([40/60, 80/90], inf),
\dur, Pwrand([1/4, Rest(), 1/7, 1/3], [10, 4, 2, 0.5].normalizeSum, inf),
\amp, Pwhite(0.005, 0.3, inf),
\buf, ~snare,
\rate, Pwhite(1.3, 2, inf),
\out, ~masterBus,
\group, ~bufGrp
).play;//);
//if(rrand(0,0.6).coin,
hihat = Pbind (
\instrument, \BUF,
\tempo, Prand([40/60, 60/60, 80,60, 100/60, 120/60], inf),
\dur, Pwrand([1/2, 1/7, 1/16, 1/3, 1/5, 1/4, 1/6], [10, 8, 2, 7, 6, 5, 4].normalizeSum, inf),
\amp, Pwhite(0.05, 0.9, inf),
\buf, ~hihat,
\rate, Pwhite(1.5, 16, inf),
\out, ~masterBus,
\group, ~bufGrp
).play;//);
});//start schedule ends
SystemClock.sched(stop, {
kick.stop;
snare.stop;
hihat.stop;
sines.stop;
});
};//myCoolRhytm ends
[~btimes_1, ~bstops_1].flop.do {|pair|
~myCoolRhythm.value(pair[0], pair[1]);
};
})//waitForBoot ends
)