giuliomoro
Hey Giulio,
Thanks again for your answer, and sorry for my late response: is that I am relaly focused on putting my musical idea into the code.
So I tried several block sizes (every multiple of 2 of course); I get no errors but still no sound comes from bela and I really do not understand why. It also does not post any scheduled function even though it should!
Of course I tried other examples, even on SC, and the bela is working just fine; and the code is of course working on my PC... So, is it possible that something is related to some object in my code, even though I am not using any Quark or external library? (sorry if it is a long one!)
//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 = 64;
s.options.numInputBusChannels = 2;
s.options.numOutputBusChannels = 2;
s.options.headphoneLevel = -12;
s.options.postln;
/*
o = Server.default.options;
o.inDevice_("ASIO : MOTU Pro Audio");
o.outDevice_("ASIO : MOTU Pro Audio")
*/
);
//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,
];
~path = PathName(thisProcess.nowExecutingPath).parentPath++"buf/";
~times = [rrand(10, 20), rrand(100, 130), rrand(150, 220), rrand(250, 330), rrand(350, 460)];
~stops = ~times + Array.fill(~times.size, {rrand(30, 70)});
~times_1 = Array.fill(rrand(2, 5), {|i| ~times.scramble[i] + rrand (-10, 20)});
~stops_1 = ~times_1 + Array.fill(~times_1.size, {rrand(30, 70)});
~times_2 = Array.fill(rrand(2, 5), {|i| ~times.scramble[i] + rrand (-10, 40)});
~stops_2 = ~times_2 + Array.fill(~times_2.size, {rrand(40, 60)});
~times_3 = Array.fill(rrand(2, 5), {|i| ~times.scramble[i] + rrand (-10, 40)});
~stops_3 = ~times_3 + Array.fill(~times_3.size, {rrand(40, 60)});
~atimes = Array.fill(rrand(2, 4), {|i| ~times.scramble[i] + rrand (-10, 20)});
~astops = ~atimes + Array.fill(~atimes.size, {rrand(40, 60)});
~btimes_1 = Array.fill(rrand(2, 4), {|i| ~times.scramble[i] + rrand (-10, 40)});
~bstops_1 = ~btimes_1 + Array.fill(~btimes_1.size, {rrand(40, 80)});
);
//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);
}
)
);
};
~kickDir = b[\kick];
~hihatDir = b[\hihat];
~snareDir = b[\snare];
~sinesDir = b[\sines];
};
~makeBusses = s.makeBundle(s.latency, {
~textBus = Bus.audio(s,2);
~bufBus = Bus.audio(s,2);
~masterBus = Bus.audio(s,2);
});
~makeNodes = {
s.bind(
~srcGrp = Group.new;
~bufGrp = Group.after(~srcGrp);
~msGrp = Group.after(~bufGrp);
s.sync;
~textMix = Synth.new(\textMix, [\in, ~textBus, \out, ~masterBus, \vol, 0.5], ~msGrp);
~bufMix = Synth.new(\bufMix, [\in, ~bufBus, \out, ~masterBus, \vol, 1.2], ~msGrp);
~masterSynth = Synth.new(\master, [\in, ~masterBus], ~msGrp, \addToTail);
)
}
);
//reg
(
ServerBoot.add(~makeBuffers);
ServerBoot.add(~makeRhythmBuffers);
ServerBoot.add(~makeBusses);
ServerQuit.add(~cleanUp);
);
//boot
(
s.waitForBoot({
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 = 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, pan=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 = Pan2.ar(sig, pan);
Out.ar(out,sig);
}).add;
SynthDef.new(\textMix, {
arg in=0, out=0, vol;
var sig;
sig = In.ar(in, 2) * vol;
Out.ar(out, sig);
}).add;
SynthDef.new(\bufMix, {
arg in=0, out=0, vol;
var sig;
sig = In.ar(in, 2) * vol;
Out.ar(out, sig);
}).add;
SynthDef(\master, {
arg in = 0, out = 0;
var sig;
sig = In.ar(in, 2);
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, 15000),
\detuneAmount, rrand(0.01, 0.55),
\jitAmount, rrand(0.001, 0.2),
\buf, ~bufSin.bufnum,
\out, ~textBus
], ~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, if(rrand(0.15, 1).coin,
rrand(0.005, 0.2),
0),
\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, 16000),
\detuneAmount, rrand(0.01, 0.55),
\jitAmount, rrand(0.001, 0.2),
\buf, ~bufSin.bufnum,
\out, ~textBus
], ~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, if(rrand(0.15, 1).coin,
rrand(0.005, 0.2),
0),
\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, 18000),
\detuneAmount, rrand(0.01, 0.55),
\jitAmount, rrand(0.001, 0.2),
\buf, ~bufSin.bufnum,
\out, ~textBus
], ~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]);
};
~myAngryTextures = { |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("myAngryTextures at");
synthi = Array.fill(16, {
Synth.new(\vOsc,
if(rrand(0,1).coin, [
\freq, chords.choose.clip(45, 90),
\pos, rrand(0.5, 1.5),
\cutoff, rrand(45, 180),],
[
\freq, chords.choose.clip(6000,18000),
\pos, rrand(0.5, 2.7),
\cutoff, rrand(9000, 18000),]) ++ [
\amp, rrand(0.2, 0.4),
\atk, rrand(0, 0.1),
\dcy, rrand(8, 10.5),
\sus, rrand(0.01, 0.8),
\rel, rrand(0, 0.1),
\crv, if(rrand(0, 1).coin, rrand(-6,-0.001), rrand(0.0001,6)),
\detuneAmount, rrand(0.001, 0.55),
\jitAmount, rrand(0.001, 0.2),
\buf, ~bufSin.bufnum,
\out, ~textBus]
, ~srcGrp
)});
});
SystemClock.sched(stop, {
synthi.do(_.set(\gate, 0));
});
};//myCoolTextures ends
[~atimes, ~astops].flop.do { |pair|
~myAngryTextures.value(pair[0], pair[1])
};
~myCoolRhythm= { |start, stop|
var kick, snare, hihat, sines;
SystemClock.sched(start, {
SystemClock.seconds.debug("myCoolRhythm at");
kick = Pbind(
\instrument, \BUF,
\tempo, Pwrand([
Pwrand([62/60, 124/90], [6, 1].normalizeSum, inf),
Pwrand([15/60, 30/90], [12, 1].normalizeSum, inf),
80/60,
1/60,
], [4, 6, 8, 9], inf),
\dur, Prand([
1/4,
1/8,
Pwrand([1/2, 1/4], [10, 2].normalizeSum, inf),
Pwrand([1/4, 1/16], [10, 2].normalizeSum, inf),
Pgeom(0.5, 0.9, 35),
0.5,
], inf),
\amp, Pwrand([
0,
Pwhite(0.9, 1.7, inf),
Pwhite(0.3, 1, inf),
Pwhite(0.01, 0.3, inf),
], [10, 8, 6, 4], inf),
\buf, ~kickDir[0],
\rate, Pwhite(0.95, 1.35, inf),
\pan, Pwhite(-0.2, 0.2, inf),
\out, ~bufBus,
\group, ~bufGrp).play;
sines = Pbind (
\instrument, \BUF,
\tempo, Prand([40/60, 80/90], inf),
\dur, Pwrand([1/7, 1/4, 1/5, 1/13], [10, 4, 8, 2].normalizeSum, inf),
\amp, Prand([
Pwhite(0.005, 0.3, inf),
0], inf),
\buf, ~sinesDir[[0, 1].choose],
\rate, Pwhite(0.001, 13, inf),
\pan, Pwhite(-1.0, 1.0, inf),
\out, ~masterBus,
\group, ~bufGrp
).play;
snare = Pbind (
\instrument, \BUF,
\tempo, Prand([40/60, 80/90], inf),
\dur, Pwrand([
Pwrand([1/4, 1/7, 1/3], [10, 4, 2, 0.5].normalizeSum, inf),
Pwrand([9, 11, 13], [10, 4, 2, 0.5].normalizeSum, inf)
], [6,4].normalizeSum, inf),
\amp, Pwrand([
Pwhite(0.005, 0.3, inf),
0], [7, 3].normalizeSum, inf),
\buf, ~snareDir[(0..2).choose],
\rate, Pwhite(1.3, 2, inf),
\pan, Pwhite(-1.0, 1.0, inf),
\out, ~bufBus,
\group, ~bufGrp
).play;
hihat = Pbind (
\instrument, \BUF,
\tempo, Prand([40/60, 60/60, 80,60, 100/60, 120/60], inf),
\dur, Pwrand([
Pwrand([1/2, 1/7, 1/16, 1/3, 1/5, 1/4, 1/6], [10, 8, 2, 7, 6, 5, 4].normalizeSum, inf),
Pwrand([2, 7, 16, 3, 5, 4, 6], [10, 8, 2, 7, 6, 5, 4].normalizeSum, inf),
], [4,6].normalizeSum, inf),
\amp, Prand([
Pwhite(0.05, 0.9, inf),
0], 3),
\buf, ~hihatDir[(0..3).choose],
\rate, Pwhite(1.5, 16, inf),
\pan, Pwhite(-1.0, 1.0, inf),
\out, ~bufBus,
\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
)