(
SynthDef(\sineCC, {
	var freq = \freq.kr(440);
	var sig = SinOsc.ar(freq) * 0.1;
	Out.ar(0, sig ! 2);
}).add;
)

~sine = Synth(\sineCC);

(
~ccToFreq = MIDIdef.cc(\ccFreqControl, {
	arg val, num, chan, src;

	if (chan == 0 and: { num == 0 }, {  // channel 2 = index 1
		var freq = val.linexp(0, 127, 100, 2000);  // map CC value to frequency range
		~sine.set(\freq, freq);
		("CC " ++ num ++ " = " ++ val ++ " → freq: " ++ freq).postln;
	});
});
)
