I often do something like this in my synths:
a = play {
var initPulse = Impulse.kr(0),
time = Select.kr(initPulse, [LocalIn.kr(1),
ExpRand(0.1, 0.25)]),
trig = Impulse.kr(time.reciprocal),
newTime = TExpRand.kr(0.1, 0.25, trig),
freqs = TExpRand.kr(200, 900, trig ! 2),
freq = EnvGen.kr(Env.new(freqs[[0, 0, 1]], [0, 1]),
trig, timeScale: newTime);
LocalOut.kr(newTime);
(SinOsc.ar(freq, 0, 0.3) * Decay2.kr(trig, 0.01, newTime * 0.7)) ! 2;
};
I need to know the time until the next trigger to get the frequency
and decay envelopes right.
With TDuty, I could get triggers appropriately timed but I don't see a
way to get the duration values outside TDuty. This would not work with
non-determinate demand ugens:
var demands = Dwhite(0.1, 0.5, inf),
trig = TDuty.kr(demands, 0, demands);
... because 'demands' would evaluate differently in the two places.
Have I overlooked a ugen that would do what I want here? Or should I
roll up my sleeves and write a new one? If there were a TDuty variant
that returned the duration value as the trigger's impulse, it would be
easy to latch it and have the time.
var demands = Dwhite(0.1, 0.5, inf),
trig = UnknownUGenHere.kr(demands),
time = Latch.kr(trig, trig);
Also it seems demand ugens don't work with n-ary operators, though
binary ops are ok.
This is OK:
a = SynthDef(\demandMath, {
var trig = Impulse.kr(2);
Demand.kr(trig, 0, Dwhite(0.0, 1.0, inf) + 2).poll(trig, "dwhite");
}).play;
This is not (always posts 200):
a = SynthDef(\demandMath, {
var trig = Impulse.kr(2);
Demand.kr(trig, 0, Dwhite(0.0, 1.0, inf).linexp(0.0, 1.0, 200,
800)).poll(trig, "dwhite");
}).play;
That is a problem for generating exponentially-distributed durations
for TDuty (unless Dexprand has been added - I don't see it in svn).
Thanks.
hjh
--
James Harkins /// dewdrop world
jamshark70@xxxxxxxxxxxxxxxxx
http://www.dewdrop-world.net
"Come said the Muse,
Sing me a song no poet has yet chanted,
Sing me the universal." -- Whitman
_______________________________________________
sc-dev mailing list
info (subscription, etc.):
http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: https://listarc.bham.ac.uk/marchives/sc-dev/
search: https://listarc.bham.ac.uk/lists/sc-dev/search/