«Re: [improved] Gradually change TempoClock tempo [ accelerando / decelerando ] [extension]» by tom.dugovic

on 13 Apr'22 02:50 in code forktempoaccelerandodecelerando

This gradually changes the tempo of a TempoClock, each beat of a specified number of beats, and starting at the next bar.

Personally, I was not able to heavily distinguish between .linlin and .linexp for reasonable musical tempos.

There may be a mathematically smoother way of handling this at the control rate.

This function does not gracefully handle multiple simultaneous invocations.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Put this in your extensions directory
+ TempoClock {
    gradualTempo_ {|newTempo, beats=4, quant=1|
        if(beats <=1, {
            this.tempo_(newTempo);
        },{
            var startTime = this.nextTimeOnGrid(quant);
            this.schedAbs(this.nextTimeOnGrid(quant), {
                this.prRecurseGradualTempo(newTempo, beats);
            });
        });
    }

    prRecurseGradualTempo {|finalTempo, beatsRemaining|
        if(beatsRemaining <= 0, {
            this.tempo_(finalTempo);
        }, {
            var stepTempo = 1.linexp(0, beatsRemaining, this.tempo, finalTempo);
            this.tempo_(stepTempo);
            this.sched(1, {
                this.prRecurseGradualTempo(finalTempo, beatsRemaining-1);
            });
        });
    }
}
raw 801 chars (focus & ctrl+a+c to copy)
reception
comments
tedthetrumpet user 13 Apr'22 07:49

Interesting. Did you know something like this exists already? https://swiki.hfbk-hamburg.de/MusicTechnology/763

tom.dugovic user 17 Apr'22 20:41

I was not aware of that, though I was thinking of trying to implement something like that. Thanks for sharing!