What actually happens when bufnum arg == nil?

I’m working on a big modular setup à la @Sam_Pluta’s Live Modular Instrument, and I’ve run into a weird bug…it’s a bit tricky to post a MWE, so I’ll try to explain:

In my setup channel strips have slots accepting synthesis or processing modules running in series; synths in each module are built with a custom wrapper class around ReplaceOut.ar (with a mix argument, similar to XOut.ar) so that all modules on a channel strip is on the same audio bus. There are 24 channel strips in the setup organized in groups that ensure proper order of execution.

When I instantiate a buffer synth, I get a Buffer UGen: no buffer data message in the post window - fair enough. When I set the \bufnum arg, the audio file plays as expected. However, it has happened once or twice that upon starting a buffer synth with no \bufnum arg I hear audio from another channel strip earlier in the node order. What’s weird is that each channel strip has a fader synth where I can mute the signal; even if the earlier strip is muted, the strip with the buffer synth receives the audio, meaning it is reading the earlier strip pre-fader.

This behaviour only appeared after I implemented a method to .pause channelStrips (and their modules) that aren’t in use. Not sure if this is relevant or not. Polling the Phasor.ar driving the buffer synth reveals that it outputs 0 before the \bufnum arg is set.

My guess is that I’ve messed up my routing somewhere…but this doesn’t happen if I instead replace the buffer synth with a synthesis module (for example) using the same ReplaceOut wrapper with the \mix arg set to 0, which I would have expected. I’m wondering if there is something special that happens in a Synth with a BufRd UGen when the bufnum arg is nil upon initialization?

Sorry I can’t supply any code, hoping this rings a bell for someone here - thanks in advance!

Okay, I might have a possible explanation…in the setup that is producing the bug, the earlier channel strip has a resonant filter drone feeding into a Delay module that is using DelTapWr.ar and DelTapRd.ar which are writing their signal to a buffer…could it be that these are the first buffers allocated on the server, and a bufnum of nil defaults to read bufnum == 0, and before my buffer synth gets a bufnum, it’s reading this delay buffer? That would explain why the synthesis modules that aren’t reading from buffers don’t pass the earlier signal through when \mix == 0

I can confirm that the server turns nil in an argument list into a 0 (to my recollection, I’m pretty sure that’s the case).

hjh

1 Like