Handle correctly in proxy space synthdef pbind proxy and audio buffering

Hello,
I’m finishing my Live Coding set with SC. I have several documents. A setting.scd with the general configuration, where I create a dictionary to handle loops, increase the number of buffers the server has access to for loading samples, node tree windows, freqscope, plotTree and scope. The ProxySpace is started and the StageLimiter is activated (a fantastic tool that I love, by the way).
In another document I have all the SynthDef.
And in a third one the snippets.

I think I feel quite comfortable with this configuration although I won’t know exactly until I do the session on the 21st.

At the moment the only thing that is driving me crazy and giving me a lot of headaches is the management of the audio files and the use of them in the SynthDefs that I have designed to handle them.
I’ll give you an example:
Once I open the blank file to make a session, I load the configuration with (‘/…/settings.scd’).loadRelative. Then I start with the different Pbinds, creating the main and secondary sounds, rhythmic, tonal and atonal, etc… So far so good! But when I go to use a Synthdef with PlayBuf and the problems start.
I’m sorry for being so long but I’ve been having a hard time these weeks. I’ll give you a concrete example. I have this SynthDef (by the way from Ely):


SynthDef(\grainbuf, {
	var sig, env;

	env = Env([0,1,1,0], [\atk.ir(1),\sus.ir(4),\rel.ir(1)], [1,0,-1]).kr(2);
         

	sig = GrainBuf.ar(
		numChannels:2,
		trigger:Dust.kr(40), // 40 grains per second
		dur:0.05,
		sndbuf: \buf.kr(0),
		rate:BufRateScale.kr(\buf.kr(0)) * \rate.kr(1),
		pos: Line.kr(0,1,BufDur.kr(\buf.kr(0))* \timescale.kr(5)),
		interp:2,
		pan:0,
		envbufnum:-1,
		maxGrains:\mgra.kr(512),

	);
	sig = sig * env ;

	Out.ar(\out.kr(0), sig);

}).add;

When I’m going to use it with a Pbind Pattern as simple as this:


~a = Pbind(
	\instrument, \grainbuf,
	\buf, q.buffers[1],
	\dur,1
)

The group with SyntheDef is loaded:

And when running ~a.play:

everything looks OK but it doesn’t play anything.
I can’t get the synthdef to play no matter how hard I try. Any help would be appreciated.
Thank you very much for your help!!

I tried your code and it plays just fine.

Use Server Dump OSC and see if your messaging looks like this:

// this is a synth from Pbind -- "out" should be nonzero
[ "#bundle", 16863982384402329092, 
  [ 9, "grainbuf", 1042, 0, 1000, "buf", 0, "out", 4 ]
]

// this is ~a.play -- "in" should match Pbind's "out"
[ "#bundle", 16863982385161634342, 
  [ 21, 1043, 1, 1 ],
  [ 9, "system_link_audio_1", 1044, 1, 1043, "out", 0, "in", 4, "level", 1, "fadeTime", 0.02, "vol", 1 ],
  [ 9, "system_link_audio_1", 1045, 1, 1043, "out", 1, "in", 5, "level", 1, "fadeTime", 0.02, "vol", 1 ]
]

Check that buffers are really loaded. (Are all buffers mono? GrainBuf does not support stereo files.)

Or try Stethoscope(s, 2, index: ~a.bus.index) to verify that a signal is really being produced on ~a’s bus.

hjh

My audio library that I use with SC are all stereo files. I used Buffer.readChannels, and problem solved…Thank you very much!