Hello,
I am experiencing a weird behaviour with a BufRd SynthDef that is set with an Array of data in a Routine
the SynthDef has two signals with the same Buffer (for mixing purposes) I am aware that this is not the best way to mix the signals, but since I am not sure, if the problem originates here, I left it in.
SynthDef(\brForum, {
arg buf=0, rate=1;
var sig, sig2, ptr, ptr2, env;
ptr = Phasor.ar(0, BufRateScale.kr(buf) * rate * \harm.kr(0).midiratio, 0, BufFrames.kr(buf)-1);
ptr2 = Phasor.ar(0, BufRateScale.kr(buf), 0, BufFrames.kr(buf)-1);
sig2 = BufRd.ar(1, buf, ptr2);
env = Env.asr(\atk.ir(1),\sus.ir(1),\rls.ir(1)).kr(2, \gate.kr(1));
sig = 2.collect({
var lag = LFNoise1.kr(\lg1.kr(0)).bipolar(\lg2.kr(0.0));
lag = lag * s.sampleRate;
BufRd.ar(1, buf, ptr + lag, \lp.kr(1.0));
}).sum ;
sig = RLPF.ar(sig, \ffreq.kr(200), \rq.kr(0.5));
sig2 = sig2 * env * \fade2.kr(0.1);
sig = sig * env * \amp.kr(0.3) * \fade.kr(1);
SendReply.kr(Impulse.kr(10), '/br', buf);
sig = Mix.ar([sig, sig2]);
Out.ar(\out.kr(0), sig);
}).add;
The problem occurs when playing this Routine, where I manipulate the Synth(\brForum) with some data.
buf1 = ‘https://drive.google.com/file/d/1r0sdTe90qmJJ811oKfjm2to81opjAXtO/view?usp=drive_link’
buf2 = ‘https://drive.google.com/file/d/1XUfNz-Yt3S89--cU6ovskPVTLs0YLeys/view?usp=drive_link’
var rout;
o = OSCdef(\br, { |msg| msg[3].postln}, '/br');
rout = r({
var data, normalized, buf, buf1, buf2, syn;
data = (0..300);
normalized = data.normalize(80, 3000);
buf1 = Buffer.read(s, path/buf1);
buf2 = Buffer.read(s, path/buf2);
buf = buf2;
syn = Synth(\brForum, [\buf, buf, \fade, 0.7, \fade2, 0.3, \end, buf.numFrames-1]);
normalized.do({
|d, i|
"normalized data % at %".format(d, i).postln;
syn.set(\ffreq, d, \lg2, d.linexp(80, 3000, 0.03, 0.5), \harm, d.linlin(80,3000, 12, 36));
0.05.wait;
if(i >=( normalized.size-1), {"end of data, releasing synth %".format(syn); syn.release(2)});
});
}).play
It works well for half a second and then the sound stops, and the SendReply.kr in the SynthDef stops sending data to the OSC Function. There is no error message, though.
When I Command . the server status turns yellow.
I am guessing it is something with the Buffer handling but I can’t figure out what. Strange thing is, it did work a couple of days ago.
Does someone have a clue?
thanks a lot.