Audacity has a “Change Speed” effect, but it is only accurate to three decimal places. For greater accuracy a short Nyquist script can be used in the Nyquist Prompt effect.
1 2 3 4 5 |
(setq current-duration 599.999) (setq target-duration 600) (force-srate (/ (* *sound-srate* target-duration) current-duration) *track*) |
In this example the length of the selected audio was 599.999 seconds and I wanted to stretch it to 600 seconds duration.
The durations may be in any units (samples, seconds, minutes,… ) as long as both “current-duration” and “target-duration” are both in the same units and each is a decimal number.
A slightly shorter version to save typing:
1 2 3 |
(psetq dur 599.999 new-dur 600) (force-srate (/ (* *sound-srate* new-dur) dur) *track*) |
This shorter version uses shorter, but hopefully still obvious variable names dur replacing current-duration and new-dur replacing target-duration.
The length of the names of variables has no effect on the speed or efficiency of the code and only a minuscule effect on the file size, so as a rule it is recommended that variable names should be as long as is necessary for their meaning to be clear. The same applies to function names and macro names.
It also uses the PSETQ command, which is much like the regular SETQ command except that it allows multiple symbols to be bound to values in parallel.