如果您查看 CCIn 的源代码,您会发现它正在做一些比普通 UGen 更复杂的事情:
kr { |chan = 0, num = 0, spec = \amp, lag = 0.05|
var outArray = [chan, num, spec, lag].flop.collect{ |args|
var ch, n, sp, lg;
# ch, n, sp, lg = args;
(sp.asSpec.map( In.kr(this.prGetBus(ch, n).index) ).lag3(lg))
};
if (outArray.size>1) {^outArray} {^(outArray[0])} //fix to work with muliout
具体来说,这...
this.prGetBus(ch, n)
正在使用提供的通道和编号(ch和n)来查找Bus它可以从中读取 MIDI 数据的通道(请参阅prGetBus)。它作为构建 SynthDef 的一部分进行此查找,而不是运行 Synth,因此一旦构建它,它正在读取的总线几乎是固定的。CCIn 夸克掩盖了一些相当复杂的东西,以便表现得像一个简单的 UGen,所以你不太可能很容易地得到你正在寻找的行为。
这里有一些选择。
1. 自己将 MIDI 数据写入总线
// One for each cc number
~ccBusses = 127.collect({
Bus.control(s, 1);
});
// A midi responder that sets the value of the right bus
MIDIdef.cc(\cc, {
|value, cc|
~ccBusses[cc].set(value);
}, ccNum: (0..127) ) // meaning: all cc values
// Once those are set up, to map a cc to a new synth use:
Synth(\mySynth, args:[\freq, ~ccBusses[10].asMap]);
2.使用连接夸克
// Create a value between 100..2400, controlled by MIDI
~freq = MIDIControlValue(spec:ControlSpec(100, 2400));
~freq.cc_(10); // cc number 10
// Run your synth
~note = Synth(\mySynth, args:[\freq, ~freq]);
// Connect the value of ~freq to the \freq argument of your synth. Now, MIDI changes will be broadcast to your synth.
~freq.signal(\value).connectTo(~note.argSlot(\freq));