Hi everyone!
I’d like to use a MIDI controller knob to control an EZKnob that sets dinamically the value of the \freq in a pattern.
Can someone help me?
Thanks in advance
Here my code (//??? = big doubts!) :
(
MIDIClient.init ;
MIDIIn.connectAll ;
)
(
SynthDef(\stdSD_PatternMIDI, {
arg freq = 50, atk = 0.01, rel = 1,
vol = -12, pan = 0, out = 0 ;
var sig, env ;
sig = SinOsc.ar(freq, 0, 1) ;
env = EnvGen.kr(Env.perc(atk, rel), 1, doneAction:2) ;
sig = Pan2.ar(sig, pan, vol.dbamp);
sig = sig * env ;
Out.ar(out, sig) ;
}).add ;
) ;
(
var window, knob, pattern, spec, pattFreq ;
window = Window("midi", Rect(0, 0, 500, 500)) ;
knob = EZKnob(window, Rect(0, 0, 100, 100),
label:"Freq", controlSpec: spec, action:???) ; // ???
spec = ControlSpec(minval:50, maxval:20000) ;
window.front ;
pattern = Pdef(
\stdSD_PatternMIDI1,
Pbind(
\instrument, \stdSD_PatternMIDI,
\dur, 1,
\freq, Pfunc({pattFreq}), // ???
) ;
).play;
pattFreq = MIDIdef.cc(\knob1, {arg value;
{knob.valueAction_(spec.map(value/127))}.defer
}, 1) ; // ???
)