# A script for variable tempo for a selected sound sample?

**URL:** <https://forum.audacityteam.org/t/a-script-for-variable-tempo-for-a-selected-sound-sample/125072>\
**Category:** Windows\
**Created:** [December 4, 2024, 7:27am UTC](https://forum.audacityteam.org/t/a-script-for-variable-tempo-for-a-selected-sound-sample/125072 "2024-12-04T07:27:23Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![bkpsusmitaa](https://forum.audacityteam.org/user_avatar/forum.audacityteam.org/bkpsusmitaa/32/32205_2.png) [@bkpsusmitaa](https://forum.audacityteam.org/u/bkpsusmitaa)\
**Post date:** [December 4, 2024, 7:27am UTC](https://forum.audacityteam.org/t/a-script-for-variable-tempo-for-a-selected-sound-sample/125072/1 "2024-12-04T07:27:23Z")

</div>

Is there a Nyquist script to treat a band of pulses at the sample rate of 44100Hz as a Time Period Δt and have a predetermined tempo change ΔT in relation to that Δt, to a fraction, or multiple, of that one band of sample pulses, so that the rate of change of Tempo to be applied for an audio sample could be represented by ΔT/Δt ∝ t? Or, ΔT/Δt = rt, where r is a fraction or number. Also, Lt Δt→ 0, ΔT/Δt = dT/dt

That is, the change of tempo begins normally for the selected sample and speeds up, or slow down continually, i.e., accelerated or decelerated, to a predetermined multiple or a fraction, respectively, of the original tempo at the end. So that d²T/dt² = (d/dt)(dT/dt) has a constant numerical value. That is, d²T/dt² = r.

I apologise if I couldn’t explain myself clearly enough.

In Audacity program the Effect Tempo is a constant value. When applied to a selected audio segment, the effect causes a sound sample to become fast or slow in tempo (beat of music) by a constant numerical value for the entire selected segment, from the original tempo.

But what I need is a varying tempo, accelerating up or decelerating down.

Later on, we could progress to geometric or exponential speeding up or slowing down. Presently, I would be satisfied with a constant acceleration (i.e., d²T/dt² linear, parallel to abscissa axis graphically, dT/dt, a straight line with a specific slope).

My leaders and seniors, please pardon for the apparent ambiguity. The fault is all mine.

---

<div class="post-metadata">

**Author:** ![steve](https://forum.audacityteam.org/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@steve](https://forum.audacityteam.org/u/steve)\
**Post date:** [December 4, 2024, 2:36pm UTC](https://forum.audacityteam.org/t/a-script-for-variable-tempo-for-a-selected-sound-sample/125072/2 "2024-12-04T14:36:07Z")

</div>

> [@bkpsusmitaa](#):
>
> But what I need is a varying tempo, accelerating up or decelerating down.

Audacity has [Sliding Stretch](https://manual.audacityteam.org/man/sliding_stretch.html).

---

<div class="post-metadata">

**Author:** ![bkpsusmitaa](https://forum.audacityteam.org/user_avatar/forum.audacityteam.org/bkpsusmitaa/32/32205_2.png) [@bkpsusmitaa](https://forum.audacityteam.org/u/bkpsusmitaa)\
**Post date:** [December 4, 2024, 3:06pm UTC](https://forum.audacityteam.org/t/a-script-for-variable-tempo-for-a-selected-sound-sample/125072/3 "2024-12-04T15:06:16Z")

</div>

> [@steve](#):
>
> Audacity has [Sliding Stretch](https://manual.audacityteam.org/man/sliding_stretch.html)

Wow, Mr. Steve! Thank you.  
Repeatedly, you and Mr. Trebor are always my solution-provider.  
It works as intended. Excellent! Fulfills my requirement.  
So the next question, though not urgent (in fact, I can wait for a few months):  
This appearing to be a linear application, is an exponential application possible?

---

<div class="post-metadata">

**Author:** ![steve](https://forum.audacityteam.org/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@steve](https://forum.audacityteam.org/u/steve)\
**Post date:** [December 4, 2024, 7:16pm UTC](https://forum.audacityteam.org/t/a-script-for-variable-tempo-for-a-selected-sound-sample/125072/4 "2024-12-04T19:16:59Z")

</div>

> [@bkpsusmitaa](#):
>
> This appearing to be a linear application, is an exponential application possible?

Short answer: No

Longer answer:  
Very early versions of this effect had many more options, including different stretch rates, but the large number of parameters made the effect rather complicated to use. It was decided to simplify the interface so that it would be more user friendly, and it was the simplified version that was included in Audacity.

If you are sufficiently interested, it may be worth trying to track down the VST effect that Clayton Otey refers to here: [GitHub - claytonotey/libsbsms](https://github.com/claytonotey/libsbsms)

---

<div class="post-metadata">

**Author:** ![bkpsusmitaa](https://forum.audacityteam.org/user_avatar/forum.audacityteam.org/bkpsusmitaa/32/32205_2.png) [@bkpsusmitaa](https://forum.audacityteam.org/u/bkpsusmitaa)\
**Post date:** [December 6, 2024, 4:27am UTC](https://forum.audacityteam.org/t/a-script-for-variable-tempo-for-a-selected-sound-sample/125072/5 "2024-12-06T04:27:47Z")

</div>

> [@steve](#):
>
> but the large number of parameters made the effect rather complicated to use. It was decided to simplify the interface so that it would be more user friendly,

Yes, I understand. Geometrical progression could be achieved by repeated application. But exponential means an inclusion of factorials in the denominators of the terms to construct the exponential series.  
Yes, it is complicated and merits an _Ignobel_ award for the idea that I had. On hindsight, it was foolish of me to have had that idea itself.  
So I will drop the issue altogether. The Sliding Stretch suffices. If necessary, it could be applied multiple times.  
Thank you, Mr. Steve. You halted my misadventure into absurdities, and you are completely justified in doing so. So I again thank you.

---

<div class="post-metadata">

**Author:** ![Trebor](https://forum.audacityteam.org/user_avatar/forum.audacityteam.org/trebor/32/45854_2.png) [@Trebor](https://forum.audacityteam.org/u/Trebor)\
**Post date:** [December 6, 2024, 5:16am UTC](https://forum.audacityteam.org/t/a-script-for-variable-tempo-for-a-selected-sound-sample/125072/6 "2024-12-06T05:16:01Z")

</div>

> [@bkpsusmitaa](#):
>
> … a band of pulses … varying tempo, accelerating up or decelerating down.

Like a [granulator](https://forum.audacityteam.org/t/grainimogrifier/51457/18) ?

---

<div class="post-metadata">

**Author:** ![bkpsusmitaa](https://forum.audacityteam.org/user_avatar/forum.audacityteam.org/bkpsusmitaa/32/32205_2.png) [@bkpsusmitaa](https://forum.audacityteam.org/u/bkpsusmitaa)\
**Post date:** [December 6, 2024, 6:49am UTC](https://forum.audacityteam.org/t/a-script-for-variable-tempo-for-a-selected-sound-sample/125072/7 "2024-12-06T06:49:52Z")

</div>

> [@Trebor](#):
>
> Like a [granulator](https://forum.audacityteam.org/t/grainimogrifier/51457/18) ?

Mr. Trebor, you are my teacher, my leader. I am sure that you have read the entire thread.

What I could understand from the Granulator link is that it reverses (playing backwards) a sound sample. I don’t need a reversal. My purpose is already served.

But yes, your indication is understood from the following perspective:

> [@Grainimogrifier](https://forum.audacityteam.org/t/grainimogrifier/51457/1):
>
> It chops some input audio into little pieces, rearranges the pieces and plays them back.

And yes, I could theoretically apply a pre-determined uniformly increasing or decreasing Tempo to each granule sequentially to accomplish the effect.

But are you hinting at something more? Something that I am missing? Please understand that our domains are different, and you and Mr. Steve are the masters of this domain, while I am just a toddler.

So …

---

<div class="post-metadata">

**Author:** ![Trebor](https://forum.audacityteam.org/user_avatar/forum.audacityteam.org/trebor/32/45854_2.png) [@Trebor](https://forum.audacityteam.org/u/Trebor)\
**Post date:** [December 6, 2024, 3:55pm UTC](https://forum.audacityteam.org/t/a-script-for-variable-tempo-for-a-selected-sound-sample/125072/8 "2024-12-06T15:55:28Z")

</div>

> [@bkpsusmitaa](#):
>
> What I could understand from the Granulator link is that it reverses

It’s not compulsory to play some/all of the grains backwards, you can play all of them forwards.  
The grainimogrifier nyquist plugin uses waveforms to control\* what part of the sample (the bottom track) is selected as the grain, and how frequently the grain is played.

 ![image](https://forum.audacityteam.org/uploads/default/original/3X/1/9/19ea96e38caccab1d6a7f933af057c842b4a2334.png)

[\* DAWs have this built-in: it’s called [automation](https://youtu.be/kkGGj98D5Pc?feature=shared&t=31) where the parameters of an effect change while it is being applied ]

---

<div class="post-metadata">

**Author:** ![bkpsusmitaa](https://forum.audacityteam.org/user_avatar/forum.audacityteam.org/bkpsusmitaa/32/32205_2.png) [@bkpsusmitaa](https://forum.audacityteam.org/u/bkpsusmitaa)\
**Post date:** [December 7, 2024, 3:34am UTC](https://forum.audacityteam.org/t/a-script-for-variable-tempo-for-a-selected-sound-sample/125072/9 "2024-12-07T03:34:44Z")

</div>

> [@Trebor](#):
>
> not compulsory to play some/all of the grains backwards,

Yes, as I read the thread and listened to the altered Prez Trump’s audio sample I could visualise its scope and range. I am already in awe for this Nyquist code. But I felt that while my needs are right down here, its scope and range of applicability is way up there. If my necessity deserves its application in future I have noted our interaction down so that I could use it.  
In the process I met another master by the name of Mr. [dem](https://forum.audacityteam.org/u/dem), that is my most tangible gain.  
Thank you, Mr. Trebor. Much appreciated, your suggestions, advice and interaction.

---

<div class="post-metadata">

**Author:** ![system](https://forum.audacityteam.org/uploads/default/original/1X/81a69b20bcd548215067cfaceccc8a10bfa2d176.png) [@system](https://forum.audacityteam.org/u/system)\
**Post date:** [January 3, 2025, 7:28am UTC](https://forum.audacityteam.org/t/a-script-for-variable-tempo-for-a-selected-sound-sample/125072/10 "2025-01-03T07:28:08Z")

</div>

Closed on January 3, 2025, 7:28am UTC

This topic was automatically closed after 30 days. New replies are no longer allowed.
