{
   "labels" : [
      "code fork",
      "tempo",
      "accelerando",
      "decelerando"
   ],
   "code" : "// Put this in your extensions directory\r\n+ TempoClock {\r\n    gradualTempo_ {|newTempo, beats=4, quant=1|\r\n        if(beats <=1, {\r\n            this.tempo_(newTempo);\r\n        },{\r\n            var startTime = this.nextTimeOnGrid(quant);\r\n            this.schedAbs(this.nextTimeOnGrid(quant), {\r\n                this.prRecurseGradualTempo(newTempo, beats);\r\n            });\r\n        });\r\n    }\r\n\r\n    prRecurseGradualTempo {|finalTempo, beatsRemaining|\r\n        if(beatsRemaining <= 0, {\r\n            this.tempo_(finalTempo);\r\n        }, {\r\n            var stepTempo = 1.linexp(0, beatsRemaining, this.tempo, finalTempo);\r\n            this.tempo_(stepTempo);\r\n            this.sched(1, {\r\n                this.prRecurseGradualTempo(finalTempo, beatsRemaining-1);\r\n            });\r\n        });\r\n    }\r\n}",
   "is_private" : null,
   "id" : "1-5fO",
   "name" : "Re: [improved] Gradually change TempoClock tempo [ accelerando / decelerando ] [extension]",
   "author" : "tom.dugovic",
   "ancestor_list" : [
      "1-5fG"
   ],
   "description" : "This gradually changes the tempo of a TempoClock, each beat of a specified number of beats, and starting at the next bar.\r\n\r\n\r\nPersonally, I was not able to heavily distinguish between `.linlin` and `.linexp` for reasonable musical tempos.\r\n\r\n\r\nThere may be a mathematically smoother way of handling this at the control rate.\r\n\r\n\r\nThis function does not gracefully handle multiple simultaneous invocations."
}
