Like this if you really want to remap on the fly…
(
~map_bus = { |parentSynth, normedInputBus, spec|
var sync = { |f| var r = f.(); s.sync; r };
var per = normedInputBus.rate;
var arOrKr = if(per == \audio, \ar, \kr);
var outBus = sync.({ Bus.perform(per, s, normedInputBus.numChannels) });
var def = sync.({
SynthDef(\tempMapp, {
var in = In.perform(arOrKr, normedInputBus, normedInputBus.numChannels);
var out = spec.map(in);
Out.perform(arOrKr, outBus, out);
}).add;
});
var mapper = sync.({Synth.before(parentSynth, \tempMapp) });
parentSynth.onFree({
"free".postln;
mapper.free;
outBus.free;
});
outBus;
};
)
~synth = { \val.kr().poll }.play;
~bus = Bus.control(s, 1)
(
s.waitForBoot {
~synth.map(\val, ~map_bus.(~synth, ~bus, \freq.asSpec))
}
)
~bus.set(0.0)
~bus.set(1.0)
~synth.free
I’m using a ControlSpec
to do the mapping here, makes the most sense I think.