Does anyone have ideas for fading changes to the tempo of the default TempoClock?
Ideally I would like to have a smooth transition a bit like BeaconClock from the brilliant Utopia package has but with vanilla TempoClock.
Here is my attempt at doing so, but I wonder what other people do ?
(
// Tempo changer
Tdef(\tempo, {
// Time between tempo adjustments
var timeGrain = 0.01;
// Fade time
var fTime = 16;
// Current tempo
var ogTemp = TempoClock.default.tempo;
// Target tempo
var newTemp = 0.5;
// Envelope used for the fading
var env = Pseg([ogTemp, newTemp], fTime, \exp).asStream;
var val = 0;
// Do the tempo change
loop{
timeGrain.wait;
val = env.next;
if(val.isNil, {
Tdef(\tempo).stop
}, {
TempoClock.default.tempo = val;
})
}
}).play;
)
Mads, I just realised, there’s a problem with your definition, you’re setting the same clock on which the Tdef is running and which determines the fade, so the wait times are changed also. You need two different clocks, but of course a Tdef can accomplish this as well as a Pbind.
LOL I had totally forgotten about this. Thanks for pointing out.
As you say, using a Pbind is also a good idea. Maybe something like this is a lot simpler and more flexible (with the same problem of running on the same TempoClock)
Pbind(
\dur, 4,
\tempo, Pwhite(0.1,2.0),
\play, Pfunc({|ev|
var t = ev[\tempo];
"Tempo is now %".format(t).postln;
TempoClock.default.tempo = t
})
).play