Maybe this is a little more helpful. Change it as needed for your purposes.
(
SynthDef(\bioSynth, {
arg out = 0, amp = 0, cutoff = 0.5, freq = 110, pan = 0.5;
var sig = LFSaw.ar(freq) * 0.1; // scale the signal down not to overload the output
sig = LPF.ar(sig, cutoff.linlin(0, 1, 100, 2000)); // re-map the normalized value to a sensible range
sig = Pan2.ar(sig, pan.linlin(0, 1, -1, 1), amp); // amp does not need remapping, convert mono signal to stereo with Pan2
Out.ar(out, sig)
}).add
)
x = Synth(\bioSynth) // synth does not make sound, amp is set to 0
// test that it actually works
x.set(\amp, 0.5)
x.set(\pan, 0) // pan left
x.set(\pan, 1) // pan right
x.set(\pan, 0.5) // pan center
x.set(\cutoff, 0.8) // open the filter more
x.set(\cutoff, 0.2) // close it
x.set(\cutoff, 0.5) // 'default' filter value
x.set(\amp, 0) // quiet the synth, it is still active and on the server, just no sound now.
(
/// here a setup using randomly chosen ccvals: ccNum 4 = amp, ccNum 7 = cutoff, ccNum 9 = pan
MIDIdef.cc(\cc, {|val, ccNum|
var normalizedVal = val.linlin(0, 127, 0, 1);
case
{ ccNum == 4 }
{ x.set(\amp, normalizedVal.debug(\amp)) }
{ ccNum == 7 }
{ x.set(\cutoff, normalizedVal.debug(\cutoff)) }
{ ccNum == 9 }
{ x.set(\pan, normalizedVal.debug(\pan)) }
});
)
// Test the midi setup. This is what your Midi Sprout should do for you, this is just for testing without a midi interface connected. I am sending MIDI out of SC which loops back and is received by the mididef
m = MIDIOut(0); // define the midiout
m.control(0, 4, 64) // send a cc message on channel 0, ccNum = 4, val = 64
m.control(0, 9, 5) // send a cc message on channel 0, ccNum = 7, val = 5 -> pan almost all the way to the left
(
// making a filter-and-pan sweep
Routine{
m.control(0, 4, 64);
(128 * 2).do{|i|
m.control(0, 7, i.fold(0, 127));
m.control(0, 9, i.fold(0, 127));
0.02.wait
}
}.play
)