How to avoid "exception in GraphDef_Load: exceeded number of interconnect buffers." How to make certain sliders of MultiSlider 'read-only'?

Hello,

I have two questions:

  1. In the attached code, I get an exception in GraphDef_Load: exceeded number of interconnect buffers' when I increase the number 32 in numSliders = 32;`. Is there a way to avoid this problem?

  2. I want to prevent users from changing the value of specific sliders by dragging the mouse pointer of MultiSliderView if the corresponding frequency of the slider is above half the sample rate. Is there a way to make certain sliders of MultiSlider ‘read only’?

(
s.waitForBoot {
	var numSliders, indexThumbSize, centre, width, win, infoHeader, info, freqBox, multiSlider;
	
	numSliders = 32;
	indexThumbSize = 16;
	centre = [Window.screenBounds.width, Window.screenBounds.height] / 2;
	width = numSliders * indexThumbSize + 5;
	win = Window("overtone explorer", Rect(centre[0] - (width / 2), centre[1] - 50, width, 200));
	win.front.onClose_{ x.free }
	.acceptsMouseOver_(true);
	infoHeader = "Base frequency (Hz):" ++ "\t\t";
	info = StaticText(win, Rect(10, 0, win.bounds.width - 20, 20)).string_(infoHeader);
	freqBox = NumberBox(win, Rect(140, 0, 50, 20));
	freqBox.value_(880)
	.action_{ |numb|
		x.set(\freq, numb.value)
	};
	multiSlider = MultiSliderView(win, Rect(0, 20, width, win.bounds.height - 20));
	multiSlider.value_(0 ! numSliders)
	.indexThumbSize_(indexThumbSize)
	.showIndex_(true)
	.action_{ |sliders|
		var thisFreq;
		thisFreq = sliders.index + 1 * freqBox.value;
		x.set(\amplitudes, sliders.value);
		info.string_(
			infoHeader + (sliders.index + 1) 
			+ "(" ++ thisFreq + "Hz):" 
			+
			(
				if (thisFreq < (s.sampleRate / 2)) {
					(sliders.value[sliders.index] * 100).round(0.01).asString ++ "%"
				}
				{
					multiSlider.value_(multiSlider.value.put(sliders.index, 0));
					"0 % to prevent aliasing";
				}
			)
		)
	}
	.mouseOverAction_{ |view, x, y| 
		var mouseOverIndex = ((x - 5) / indexThumbSize).round + 1;
		info.string_(infoHeader + mouseOverIndex.asInteger + "(" ++ (mouseOverIndex.asInteger* freqBox.value) + "Hz)");
	};
	
	SynthDef(\overtone_additive, { |overtoneFirst = 1, overtoneLast = 64|
		var freq, maxLayers, numOvertones, amplitudes, temp, signalArray;
		freq = \freq.kr(freqBox.value);
		maxLayers = numSliders;
		numOvertones = overtoneLast - overtoneFirst + 1;
		amplitudes = \amplitudes.kr(0 ! maxLayers);
		signalArray = maxLayers.collect { |i|
			var nthOvertone, minDetect, maxDetect, aliasingDetect, switch;
			nthOvertone = i + 1 * freq ! 2;
			minDetect = overtoneFirst <= (i + 1);
			maxDetect = overtoneLast >= (i + 1);
			aliasingDetect = nthOvertone < (SampleRate.ir / 2);
			switch = (minDetect * maxDetect * aliasingDetect).lag(0.1);
			SinOsc.ar(nthOvertone) * numOvertones.lag(0.1).reciprocal * 0.1 * switch
		};
		signalArray = signalArray * amplitudes;
		Out.ar(0, signalArray.sum);
	}).add;
	
	s.sync;
	
	x = Synth(\overtone_additive);
}
)

Thank you in advance!

Easy solution: increase the number of wire buffers.

Perhaps more interesting solution: A new approach to SynthDef control input syntax

You’ve stumbled into a problem with NamedControl style inputs in this type of additive synthesis. It’s difficult to explain briefly, though. The “interesting” solution consolidates the control-input arrays into a single Control object, and this optimizes the UGen sorting order to use fewer wire buffers.

hjh

3 Likes

@jamshark70
Thank you very much!

On my end (on macOS 13.6.3, Windows 11 and Ubuntu 22.04), the second (more interesting) solution gives the following error:

ERROR: syntax error, unexpected '#', expecting NAME or CLASSNAME or WHILE or '['
  in interpreted text
  line 3 char 6:

      ##freq = 440;
       ^
      ##amp = 0.1;
-----------------------------------
ERROR: Command line parse failed
-> nil

when evaluating the following code:

(
a = {
    ##freq = 440;
    ##amp = 0.1;
    SinOsc.ar(freq, 0, amp).dup
}.play;
)

after evaluating the following three pieces of code:

Quarks.install("https://github.com/jamshark70/ddwSynthArgPreprocessor");

thisProcess.recompile;

// then...
s.boot;

So, I did solve the problem with the first simple way. There seems not to be a way to make certain sliders of MultiSlider ‘read only’. So, I used StaticText with Color:
https://sccode.org/1-5hC

Ah… The first example left out SynthArgPreprocessor.install; – I think this is mentioned in the help file.

But I found, after posting, that there’s a bug in the preprocessor for your code example (in the original post). So it didn’t work anyway, but it should. I hope to look at it today, but I’m jetlagged so it might not happen right away.

hjh

1 Like

OK, now there’s a temporary fix – but it’s in a different branch. So you’d need to clone the repository, and check out the topic/ctlKeyword branch. (The fix isn’t complete, so I won’t merge it into the main branch just yet.)

hjh

1 Like