Hello,
I have two questions:
-
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? -
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!