I understand the differences between \namedControl.ar(), \namedControl.kr(), \namedControl.ir(). But what is \namedControl.tr()? Suppose you have a trigger, is there any advantage of using .tr instead of .kr? I understand that .tr generates a TrigControl, but the helpfile for TrigControl is empty, so i all i can do is guess.
A trigger occurs when a signal crosses from y <= 0 to y > 0.
So an ideal trigger signal is 0 most of the time, and positive only when needed.
If you set a normal kr control, it holds its value until the next set
… so it will not be “0 most of the time” unless you manually set it to 0 after setting a positive value.
A tr control, when set, takes the nonzero value for only one control cycle, and then reverts to 0, automatically ready for the next trigger.
hjh
Here are a few examples of code I’ve used recently that might help to illustrate what James explained above:
(
SynthDef(\jet, {
var dry = LFClipNoise.ar(\noiseFreq.kr(48000).clip(0.01, SampleRate.ir));
var wet = DelayN.ar(dry, 0.2, Env.perc(\freqAtk.kr(1), \freqDec.kr(3), 1).ar(0, \trig.tr(0)).exprange(\startFreq.kr(20), \endFreq.kr(20000)).reciprocal);
var sig = XFade2.ar(dry, wet, \mix.kr(0.5));
sig = Pan2.ar(sig, \pan.kr(0)).tanh;
Out.ar(\out.kr(0), sig);
}).add;
)
x = Synth(\jet); //just comb filtered noise - trig is 0 by default here
x.set(\trig, 1) //whoosh
(
x.set(
\trig, 1,
\freqAtk, 0.001,
\freqDec, 3.0.rand,
\startFreq, 20,
\endFreq, rrand(15000.0, 20000.0)
);
) //run this as fast as you like for a new whoosh every time
Another example where a tr control is being used to rearticulate notes played by one synth without releasing the its envelope:
(
SynthDef(\303, {
var sig = LFPulse.ar(\freq.kr(110, \glide.kr(0.1)), 0, 0.5).unipolar;
var env = Env.asr(\atk.kr(0.01), 1, \rel.kr(0.01), -4).kr(\doneAction.kr(2), \gate.kr(1));
var fEnv = Env.perc(\fAtk.kr(0.08), \fRel.kr(0.1), 1, \lin).kr(0, \trig.tr(1)).exprange(\cutoff.kr(200), \peak.kr(15000));
sig = RLPF.ar(sig, fEnv, \rq.kr(0.5));
Out.ar(\out.kr(0), sig!2);
}).add;
)
x = Synth(\303);
//legato sequence, no retrigger
(
x = Synth(\303, [\freq, 30.midicps]);
fork{
5.do{
[30, 37, 41, 40, 33, 48, 29, 31].do{|n|
s.bind{x.set(\freq, n.midicps, \trig, 0)};
0.2.wait;
};
};
};
)
//triggering the filter envelope
(
x = Synth(\303, [\freq, 30.midicps]);
fork{
5.do{
[30, 37, 41, 40, 33, 48, 29, 31].do{|n|
s.bind{x.set(\freq, n.midicps, \trig, 1)};
0.2.wait;
};
};
};
)
2 Likes