Server status yellow with certain Buffers and BufRd

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 =, * rate * \, 0,;
	ptr2 =,, 0,;
    sig2 =, buf, ptr2);
	env = Env.asr(\,\,\, \;
	sig = 2.collect({
		var lag =\\;
		lag = lag * s.sampleRate;, buf, ptr + lag, \;
	}).sum ;
	sig =, \, \;
    sig2 = sig2 * env * \;
	sig = sig * env * \ * \;, '/br', buf);
    sig =[sig, sig2]);\, sig);

The problem occurs when playing this Routine, where I manipulate the Synth(\brForum) with some data.

buf1 = ‘
buf2 = ‘

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 =, path/buf1);
                buf2 =, path/buf2);
                buf = buf2;
		syn = Synth(\brForum, [\buf, buf, \fade, 0.7, \fade2, 0.3, \end, buf.numFrames-1]);{
			|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));
			if(i >=( normalized.size-1), {"end of data, releasing synth %".format(syn); syn.release(2)});

It works well for half a second and then the sound stops, and the 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.

It looks like it’s a combination of memory leak and an operator issue. doesn’t just load data into a container. It allocates memory for a new Buffer object AND reads the data the path argument is pointing to. So you’re probably leaking memory in the routine.

The other more acute issue is here:

This should be (assuming path is a path string and the file name is “buf1” with no extension):

path +/+ "buf1"

Here, you’re asking for the variable path to be divided by buf1 which is null because nothing was assigned to it.

You can run it with memory leak, but you can’t divide var path by null.

As what @mjsyts said about the path of the buffer being nil. However, I don’t think the issue is leaking memory.

The messyness of the code obscures the issue here, which is server synchronisation — there was a big discussion about this recently…

var buf =, path/buf2); // you only use this buffer, no need for buf1
syn = Synth(\brForum, [
   \buf, buf,
   \fade, 0.7, 
   \fade2, 0.3, 
    \end, buf.numFrames - 1 /// uh-oh, buffer not loaded on server, this will be 0

The solution is to call s.sync before you get the buffer’s number of frames.

It should look like this…

var buf =, someRealPath); 
syn = Synth(\brForum, [
   \buf, buf,
   \fade, 0.7, 
   \fade2, 0.3, 
    \end, buf.numFrames - 1 // now its good

As an aside, I recently made a quark that makes this a little more obvious as you have to call await before you can use the buffer. The documentation isn’t done, so I wouldn’t suggest it be used just yet…
(GitHub - JordanHendersonMusic/Smart: A supercollider quark for async, promises, which will also provide new basic types.)

var rout = Routine({
	var buf ="path/asdf", s).await();
	var syn = Synth(\brForum, [\buf, buf, \fade, 0.7, \fade2, 0.3, \end, buf.numFrames - 1]);
	(0..300).normalize(80, 3000).do({
		|d, i|
		syn.set(\ffreq, d, \lg2, d.linexp(80, 3000, 0.03, 0.5), \harm, d.linlin(80,3000, 12, 36));

	syn.release(2) // this can be moved down here

Thank you Jordan and mjsyts,
Sorry for the confusing code with the paths, I did in fact have valid paths there.
Weirdly enough, I don’t run into problems anymore, even without the s.sync.
I will add the s.sync though, thinking of it as a good practice. May a restart cleared up some stuff…

s.sync might or might not be needed depending on how fast the server can execute the command… Therefore it is always needed as you can’t rely on it.