I am trying to map four different sliders to control an synthdef and a trigger button. They are for frequency, duration, vibrato, and amplitude. I keep getting this error: FAILURE IN SERVER /n_free Node 1025 not found
Code:
(
SynthDef.new(\basic, {
arg freq=440, amp=0.125, dur=1, vib=1;
var sig, filter, env;
sig = SinOsc.ar(Vibrato.ar(DC.ar(freq),vib,0.01)) * amp; //choose one of these
//sig = LFSaw.ar(Vibrato.ar(DC.ar(freq),vib,0.01)) * amp;
//sig = Pulse.ar(Vibrato.ar(DC.ar(freq),vib,0.01)) * amp;
//sig = LFTri.ar(Vibrato.ar(DC.ar(freq),vib,0.01)) * amp;
filter = LPF.ar(sig, EnvGen.kr(Env([100, 1000, 100], [1, 4]), doneAction:0)); //Other filter names: LPF, BPF, HPF,
env = EnvGen.kr(Env([0,1,0], [0.01, dur]), doneAction:2);
Out.ar(0, env*filter.dup);
}).add;
)
x = Synth.new(\basic, [\dur, 5, \freq, 440, \vib, 5]);
x.set(\freq, 300); // slider
x.set(\dur, 1); //0.5-10, slider
x.set(\vib, 2); //1-10, slider
x.set(\amp, 0.129); //slider
x.free;
(
Window.closeAll;//this is important because it makes sure things don’t layer on top of each other when you re-evaluate
w = Window(“basic”, Rect(750,50,350,250))
.front
.alwaysOnTop_(true);
//frequency
~freqslider = Slider(w, Rect(20,100,150,30)) //x, y, size x, size y
.background_(Color(0.2,0.75,0.95))
.action_({
arg obj;
var ff;
ff = obj.value.linexp(0,1,100,4000).postln;
if(
x.isPlaying, //takes the failure messages out if the slider is moving while the button is off
{x.set(\freq, ff)}
);
~freqnumberBox.value_(obj.value.linexp(0,1,100,4000));//slider updates the number box
});
//freq number box
~freqnumberBox = NumberBox(w, Rect(180,100,80,30))
.value_(100)
.clipLo_(100)
.clipHi_(4000)
.decimals_(2)
.action_({
arg obj;
~freqslider.valueAction_(obj.value.explin(100,4000,0.1)) //the slider updates the number box
});
//freq label
~freqLabel = StaticText(w, Rect(180,60,80,20))
.string_(“freq”)
.align_(\center);
//----------------------------------------
//duration: 0.5-10, slider
~durslider = Slider(w, Rect(20,35,150,30)) //x, y, size x, size y (20,20,150,30))
.background_(Color(0.2,0.75,0.95))
.action_({
arg obj;
var df;
df = obj.value.linexp(0,1,0.5,10).postln;
if(
x.isPlaying, //takes the failure messages out if the slider is moving while the button is off
{x.set(\dur, df)}
);
~durnumberBox.value_(obj.value.linexp(0,1,0.5,10));//slider updates the number box
});
//dur number box
~durnumberBox = NumberBox(w, Rect(180,30,80,30))
.value_(0.5)
.clipLo_(0.5)
.clipHi_(10)
.decimals_(2)
.action_({
arg obj;
~durslider.valueAction_(obj.value.explin(0.5,10,0.1)) //the slider updates the number box
});
//dur label
~durLabel = StaticText(w, Rect(180,130,80,20))
.string_(“dur”)
.align_(\center);
//---------------------------------------------------------
//vibrato: 1-10, slider
~vibslider = Slider(w, Rect(20,150,150,30)) //x, y, size x, size y (20,20,150,30))
.background_(Color(0.2,0.75,0.95))
.action_({
arg obj;
var vf;
vf = obj.value.linexp(0,1,1,10).postln;
if(
x.isPlaying, //takes the failure messages out if the slider is moving while the button is off
{x.set(\vib, vf)}
);
~vibnumberBox.value_(obj.value.linexp(0,1,1,10));//slider updates the number box
});
//vib number box
~vibnumberBox = NumberBox(w, Rect(180,150,80,30))
.value_(1)
.clipLo_(1)
.clipHi_(10)
.decimals_(2)
.action_({
arg obj;
~vibslider.valueAction_(obj.value.explin(1,10,0.1)) //the slider updates the number box
});
//vib label
~vibLabel = StaticText(w, Rect(180,180,80,20))
.string_(“vib”)
.align_(\center);
//-----------------------------------------------
/*
//amplitude: 0-1
~ampslider = Slider(w, Rect(20,200,150,30)) //x, y, size x, size y (20,20,150,30))
.background_(Color(0.2,0.75,0.95))
.action_({
arg obj;
var af;
af = obj.value.linexp(0,1,0.0,1.0).postln;
if(
x.isPlaying, //takes the failure messages out if the slider is moving while the button is off
{x.set(\amp, af)}
);
~ampnumberBox.value_(obj.value.linexp(0,1,0.0,1.0));//slider updates the number box
});
//amp number box
~ampnumberBox = NumberBox(w, Rect(180,200,80,30))
.value_(0.0)
.clipLo_(0.0)
.clipHi_(1.0)
.decimals_(2)
.action_({
arg obj;
~ampslider.valueAction_(obj.value.explin(0,1,0.1)) //the slider updates the number box
});
//amp label
~ampLabel = StaticText(w, Rect(180,230,80,20))
.string_(“amp”)
.align_(\center);
*/
//-----------------------------------------------
//trigger button
~button = Button(w, Rect(270,30,50,30))
.states_([
[“Trigger”, Color.white, Color(0.2,0.75,0.95)],
[“Trigger”, Color.black, Color.gray(0.8)]
])
.action_({
arg obj;
if(
obj.value == 1,
{
x = Synth(
\basic,
[
\freq,
~freqslider.value.linexp(0,1,100,4000).reciprocal,
\dur,
~durslider.value.linexp(0,1,0.5,10).reciprocal,
\vib,
~vibslider.value.linexp(0,1,1,10).reciprocal,
]
).register},
{x.free}
);
});
)