I have a MIDI controller that writes values to Control Busses and sets a GUI. I would like to connect some of the parameters of a synth to the busses. this synth is also being controlled by a simple Line.kr ramp generator synth. This works except for the controller part (~twisterBusses[0] here, define in a different file and working with no issues elsewhere). No matter what I do whirAmp does not change when I move the knob. Any idea what I’m doing wrong? I presume that the other file does not need to know about the group these Synths are associated with but that’s a guess.
// Ramp SynthDef
(
SynthDef(\lineRamp, { | bus, start = 0, end = 1, dur = 5 |
Out.kr(bus, Line.kr(start, end, dur, doneAction: 0));
}).add;
)
leaving the SynthDef out for the sake of brevity. Below is the function that controls everything.
// Ramp function
(
~rampProjector = { | direction = \in, freqEnd = 18, ampEnd = 0.72, freqDur = 8, ampDur = 3, whirInDur = 7, whirOutDur = 1.5 |
var isIn = (direction == \in);
if(isIn) {
if(~group.notNil)
{ ~group.free; ~group = nil; };
~clickBus = Bus.control(s, 1);
~ampModBus = Bus.control(s, 1);
~whirModBus = Bus.control(s, 1);
~group = Group.new;
~freqMod = Synth(\lineRamp, [\bus, ~clickBus, \start, 0, \end, freqEnd, \dur, freqDur], ~group);
~ampMod = Synth(\lineRamp, [\bus, ~ampModBus, \start, 0.001, \end, ampEnd, \dur, ampDur], ~group);
~whirMod = Synth(\lineRamp, [\bus, ~whirModBus, \start, 0, \end, 0.12, \dur, whirInDur], ~group);
// test
~currentKnob = ~twisterBusses[0].getSynchronous;
~currentKnob.postln;
x = Synth(\filmProjector, [
\mixAmp, 0.0, \clickFreq, 0,
\clickAmt, 1.45, \thunkAmt, 0.22, \gritAmt, 1.25,
\scrapeAmt, 1.3, \metalAmt, 2.0,
\whirSpeed, 1.1, \toneAmt, 0.09, \whirAmp, ~currentKnob
], ~group)
.map(\whirAmp, ~twisterBusses[0])
.map(\clickFreq, ~clickBus)
.map(\mixAmp, ~ampModBus)
.map(\whirLevel, ~whirModBus);
/* // connect to ramps to parameters
x.map(\clickFreq, ~clickBus);
x.map(\mixAmp, ~ampModBus);
x.map(\whirLevel, ~whirModBus);*/
"Projector FADE IN".postln;
} {
if(x.isNil) { "Projector not running".postln; ^nil };
~freqMod.free;
~freqMod = Synth(\lineRamp, [\bus, ~clickBus, \start, ~clickBus.getSynchronous ?? freqEnd, \end, 0, \dur, freqDur*0.75], ~group);
~ampMod.free;
~ampMod = Synth(\lineRamp, [\bus, ~ampModBus, \start, ~ampModBus.getSynchronous ?? ampEnd, \end, 0.001, \dur, ampDur], ~group);
~whirMod.free;
~whirMod = Synth(\lineRamp, [\bus, ~whirModBus, \start, ~whirModBus.getSynchronous ?? 0.12, \end, 0, \dur, whirOutDur], ~group);
"Projector FADE OUT".postln;
Routine({ (freqDur*0.75 + 1).wait; if(x.notNil){x.free; x=nil}; if(~group.notNil){~group.free; ~group=nil}; "Projector stopped".postln; }).play;
};
};
)
// Usage
~rampProjector.(\in, whirInDur: 8);
~rampProjector.(\out, whirOutDur: 1.2);