George Locke
2014-10-03 15:00:01 UTC
Hi,
I want to take input from controllers and send it to running synths after
some smoothing. I have some working code below (largely based on
http://www.sussex.ac.uk/Users/nc81/modules/cm1/workshop.html section 4.2 ),
and, as I am very new to SC, I want to check to make sure I'm not
reinventing the wheel in a ham-fisted way.
The signal path is like this: controller -> inputBus -> slewing synthDef ->
control bus -> map control bus to target synth.
The input bus feels like the most useless part of this chain. is there a
way to get the ctrlLagger to work by directly taking the input of slid2d?
I looked for a UGen that would just hold a constant value but I couldn't
find it. (Latch was pretty close but it still requires something like
inBus that takes a .set message afaict.)
Thanks,
George
(
SynthDef(\basicSin,
{
|freq = 100, gain = 0.1, outBus=0|
Out.ar(outBus, SinOsc.ar(freq, 0, gain).dup);
}
).add;
SynthDef(\ctrlLagger,
{
| inBus, outBus=0, lagTime=1 |
Out.kr(outBus, Lag.kr(In.kr(inBus), lagTime))
}
).add;
)
(
var w, slid2d, syn, fInBus, gInBus, fSlew, gSlew, fOutBus, gOutBus, lagTime;
lagTime = 1;
w=Window("My Window", Rect(100,300,200,200));
slid2d= Slider2D(w,Rect(5,5,175,175));
syn=Synth(\basicSin);
fInBus = Bus.control(s, 1); fInBus.set(200);
gInBus = Bus.control(s, 1); gInBus.set(0.05);
fOutBus = Bus.control(s, 1);
gOutBus = Bus.control(s, 1);
fSlew = Synth(\ctrlLagger, [\inBus, fInBus, \outBus, fOutBus, \lagTime,
lagTime]);
gSlew = Synth(\ctrlLagger, [\inBus, gInBus, \outBus, gOutBus, \lagTime,
lagTime]);
syn.map(\freq, fOutBus, \gain, gOutBus);
slid2d.action_({
//[slid2d.x, slid2d.y].postln;
// this seems a little clunky!
fInBus.set(100+(10000*slid2d.x));
gInBus.set(slid2d.y);
});
w.front;
w.onClose={syn.free;};
)
I want to take input from controllers and send it to running synths after
some smoothing. I have some working code below (largely based on
http://www.sussex.ac.uk/Users/nc81/modules/cm1/workshop.html section 4.2 ),
and, as I am very new to SC, I want to check to make sure I'm not
reinventing the wheel in a ham-fisted way.
The signal path is like this: controller -> inputBus -> slewing synthDef ->
control bus -> map control bus to target synth.
The input bus feels like the most useless part of this chain. is there a
way to get the ctrlLagger to work by directly taking the input of slid2d?
I looked for a UGen that would just hold a constant value but I couldn't
find it. (Latch was pretty close but it still requires something like
inBus that takes a .set message afaict.)
Thanks,
George
(
SynthDef(\basicSin,
{
|freq = 100, gain = 0.1, outBus=0|
Out.ar(outBus, SinOsc.ar(freq, 0, gain).dup);
}
).add;
SynthDef(\ctrlLagger,
{
| inBus, outBus=0, lagTime=1 |
Out.kr(outBus, Lag.kr(In.kr(inBus), lagTime))
}
).add;
)
(
var w, slid2d, syn, fInBus, gInBus, fSlew, gSlew, fOutBus, gOutBus, lagTime;
lagTime = 1;
w=Window("My Window", Rect(100,300,200,200));
slid2d= Slider2D(w,Rect(5,5,175,175));
syn=Synth(\basicSin);
fInBus = Bus.control(s, 1); fInBus.set(200);
gInBus = Bus.control(s, 1); gInBus.set(0.05);
fOutBus = Bus.control(s, 1);
gOutBus = Bus.control(s, 1);
fSlew = Synth(\ctrlLagger, [\inBus, fInBus, \outBus, fOutBus, \lagTime,
lagTime]);
gSlew = Synth(\ctrlLagger, [\inBus, gInBus, \outBus, gOutBus, \lagTime,
lagTime]);
syn.map(\freq, fOutBus, \gain, gOutBus);
slid2d.action_({
//[slid2d.x, slid2d.y].postln;
// this seems a little clunky!
fInBus.set(100+(10000*slid2d.x));
gInBus.set(slid2d.y);
});
w.front;
w.onClose={syn.free;};
)