Change Speed - Stretch audio to a specified length

Share your Audacity/Nyquist plug-ins here, or test drive the latest plug-ins submitted by Audacity users.

After testing a plug-in from this forum, please post feedback for the plug-in author.

Change Speed - Stretch audio to a specified length

Permanent link to this post Posted by steve » Wed Feb 29, 2012 12:39 am

As there's been several topic about this recently I've made a plug-in for the task.

Because this plug-in is a Nyquist effect it is quite a lot slower than the built-in "Change Speed" effect, but some users may find it easier to use.

The plug-in has 2 modes of operation:

Mode 1: Stretch audio to a specified length.

To use this mode, "Select input Control:" must be set to "New Duration" (default).
Type the required duration into the "New Duration" box as two numbers - minutes and seconds. (the plug-in will also accept the duration as just one number which will be the number of seconds.

Example: to stretch the audio to 2 minutes and 25.4 seconds, enter:
2 25.4

Example 2: to stretch the audio to 200 seconds (3 minutes and 20 seconds), any of the following will work:
200
200.000
3 20
3.0 20.0



Mode 2: New speed as a percentage

This is different and hopefully easier than the "% change" used in the built in effect.
To use this mode "Select input Control:" must be set to "as Percent".
Use the "New Speed as Percent" slider (or type a number into the box next to the slider). The new speed is defined as a percentage of the original speed, so 100% is the same as the original speed.

To make the audio faster, the percentage must be increased:
200% is double the original speed.
300% is 3 times the original speed.
400% is 4 times the original speed.

Increasing the speed means that the audio plays faster (and higher pitch), so the duration will be shorter.
At 200% the audio will play twice as fast, so the duration will be 1/2 of the original.
At 300% the audio will play 3 times as fast, so the duration will be 1/3rd of the original.
At 400% the audio will play 4 times as fast, so the duration will be 1/4 of the original.

To make the audio slower, the percentage must be decreased:
50% is half the original speed.
25% is a quarter of the original speed.
10% is a tenth of the original speed.

The plug-in has two "stretching methods" - "High Quality" and "Low Quality".
"High Quality" is the default.
Both methods are quite slow, but the Low Quality conversion is not quite as slow as High Quality conversion.
When slowing down audio, there is very little difference in sound quality, both methods are very good.
When speeding up audio, the Low Quality method may produce "aliasing distortion".


Installing.
Download the plug-in and put it in the Audacity plug-ins folder.
Restart Audacity to make it appear in the Effect menu.
The plug-in will be called "Change Speed (ny)..." and it will appear below the divider in the Effect menu.

Obsolete version:
change-speed.ny
(3.03 KiB) Downloaded 739 times


Current version: download/file.php?id=10291
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Senior Forum Staff
 
Posts: 34275
Joined: Sat Dec 01, 2007 11:43 am

Re: Change Speed - Stretch audio to a specified length

Permanent link to this post Posted by Gale Andrews » Mon May 05, 2014 6:50 pm

steve wrote:Mode 2: New speed as a percentage

This is different and hopefully easier than the "% change" used in the built in effect.

Quite so.


Gale
________________________________________FOR INSTANT HELP: (Click on Link below)
* * * * * Tips * * * * * Tutorials * * * * * Quick Start Guide * * * * * Audacity Manual
Gale Andrews
Quality Assurance
 
Posts: 13792
Joined: Fri Jul 27, 2007 12:02 am

Re: Change Speed - Stretch audio to a specified length

Permanent link to this post Posted by steve » Mon Jun 30, 2014 6:55 pm

For users that only need to stretch the audio to a specified length, here is a simplified version of the effect:
StretchAudio.ny
(583 Bytes) Downloaded 32 times


Installing.
To install Nyquist plug-ins: http://wiki.audacityteam.org/wiki/Downl ... g_Plug-ins
The plug-in will be called "Stretch..." and it will appear below the divider in the Effect menu.

It should be safe to use this effect on long tracks, but note that it is not very fast.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Senior Forum Staff
 
Posts: 34275
Joined: Sat Dec 01, 2007 11:43 am

Re: Change Speed - Stretch audio to a specified length

Permanent link to this post Posted by Gale Andrews » Tue Jul 01, 2014 10:06 am

I prefer the version that includes "New speed as a percentage" and hope that version will find its way on to Wiki.

Gale
________________________________________FOR INSTANT HELP: (Click on Link below)
* * * * * Tips * * * * * Tutorials * * * * * Quick Start Guide * * * * * Audacity Manual
Gale Andrews
Quality Assurance
 
Posts: 13792
Joined: Fri Jul 27, 2007 12:02 am

Re: Change Speed - Stretch audio to a specified length

Permanent link to this post Posted by steve » Tue Jul 01, 2014 11:41 am

Thanks for the feedback Gale.

If they are free of errors/typos, then I'd be happy to move both of them to the wiki. Personally the one that I usually have installed is the simple one (StretchAudio.ny) though I agree that some of the additional features in the more complex (change-speed.ny) version may be useful for some users.

One thing that I like about the simple version is that the code is very simple, and so provides a good example of converting a Nyquist script that can be run in the Nyquist Prompt effect, into a full plug-in. If you open StretchAudio.ny in a plain text editor (such as NotePad or NotePad++ you will see that the actual processing code is just one line:
Code: Select all
(force-srate (* *sound-srate* (/ target (get-duration 1))) s)

which is much like the Nyquist Prompt script that I've posted several times for people that need to make very small and accurate changes to the duration.

There is a disadvantage to the more complex "Change Speed (ny)..." effect, which is that in exceptional circumstances the output may be over 0 dB. An example of this is if you stretch white noise that has amplitude = 1 and use the "High Quality" setting. This is due to the anti-alias filter built into the high quality resampling code, combined with the extreme amount of high frequency content in white noise. On the other hand, the "Low Quality" will not produce output of higher amplitude than the input (though there will be more distortion in the frequency domain).

I've updated change-speed.ny to improve the program flow/readability but should otherwise be identical to the first version.
change-speed.ny
(3.24 KiB) Downloaded 80 times
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Senior Forum Staff
 
Posts: 34275
Joined: Sat Dec 01, 2007 11:43 am

Re: Change Speed - Stretch audio to a specified length

Permanent link to this post Posted by Robert J. H. » Tue Jul 01, 2014 12:19 pm

Steve, you could perhaps include high-quality resampling apart from the linear one.
Robert J. H.
 
Posts: 1234
Joined: Thu May 31, 2012 8:33 am

Re: Change Speed - Stretch audio to a specified length

Permanent link to this post Posted by steve » Tue Jul 01, 2014 2:04 pm

Robert J. H. wrote:Steve, you could perhaps include high-quality resampling apart from the linear one.

Thanks for the feedback Robert, "High Quality" resampling is included in the "change-speed.ny" effect (in first post of this topic).

The "Lite" version, which I've called "StretchAudio.ny" is deliberately simple, and seems to produce very good results for making small and precise changes to the length of the audio, so it is a very easy and effective solution to the fairly common problem of synchronising tracks that have drifted slightly out of sync (such as when synchronising a video track made on a camcorder with an audio track recorded on an audio recorder). In this use case it is very unlikely that there will be any noticeable aliasing distortion so I expect that some users will prefer the simple version.

I'll add a comment in the use notes when I upload them to the wiki, indicating the relative benefits of each.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Senior Forum Staff
 
Posts: 34275
Joined: Sat Dec 01, 2007 11:43 am

Re: Change Speed - Stretch audio to a specified length

Permanent link to this post Posted by Gale Andrews » Wed Jul 02, 2014 10:10 am

"Stretch" as the name of "StretchAudio.ny" is a little misleading for non-technical users - you can use reduce the length. Why not call it "Adjust length"?

I think it would be better to add length boxes to the built-in Change Speed than have a "simple" length adjust plug-in on Wiki that has only one control. Length boxes in Change Speed has 19 votes on Feature Requests.

I suppose we need Change Speed (ny) given we won't persuade the powers that be that Change Speed Percent Change should be a resulting speed percent (or factor). This has nine votes on Feature Requests.

Change Speed (ny) could look simpler with less text. I would not have any ;info text except "Change Speed (affecting Tempo and Pitch) by choosing new Speed or Duration.

Then something like:

  • Choose Speed or Duration
    • New Speed
    • New Duration
  • New Duration
  • New Speed as Percent
    50% = half, 200% = double
  • Quality
    • High (slower)
    • Low (faster)
Why is New Duration not a slider here?


Gale
________________________________________FOR INSTANT HELP: (Click on Link below)
* * * * * Tips * * * * * Tutorials * * * * * Quick Start Guide * * * * * Audacity Manual
Gale Andrews
Quality Assurance
 
Posts: 13792
Joined: Fri Jul 27, 2007 12:02 am

Re: Change Speed - Stretch audio to a specified length

Permanent link to this post Posted by steve » Wed Jul 02, 2014 11:24 am

Gale Andrews wrote:"Stretch" as the name of "StretchAudio.ny" is a little misleading for non-technical users

If I recall correctly, "stretch" was the term used by the user that was asking how to "stretch" one track to synchronise with another. In non-technical realms, I think of "stretchy" like chewing gum, which can go longer or shorter. Some manufacturers use the analogy of a "rubber band".

I agree that "stretching" implies "making longer", whereas this effect can "make longer or shorter", but I think I prefer "stretch" to "adjust" because it conveys the idea of "the same audio, but spread out wider (or shorter) than the original", whereas "adjust length" may well be interpreted as "truncating" or "chopping bits out/adding bits in" or as an alternative to "Change Tempo". "Change Speed" is probably the best name, but that is already in use, and many users miss the point that "Change Speed" affects the length.

As seen in the code, what the effect actually does is to "resample" the audio, but I think that term is too technical for these effects.


Gale Andrews wrote:I think it would be better to add length boxes to the built-in Change Speed than have a "simple" length adjust plug-in on Wiki that has only one control. Length boxes in Change Speed has 19 votes on Feature Requests.

Looking at that another way, why should it matter what language "Change Speed" is written in?

With a few improvements to the Audacity/Nyquist interface, most of the built in effects could be written in Nyquist, which has the significant advantages of rapid development, terrific maintainability and simple modification/customisation.


Gale Andrews wrote:given we won't persuade the powers that be that Change Speed Percent Change should be a resulting speed percent (or factor).

I agree that is unlikely, and I agree that in most cases that would be much more user friendly, but on the other hand it is good that there is consistency between Change Speed, Change Tempo and Change Pitch.


Gale Andrews wrote:Change Speed (ny) could look simpler with less text.

I agree, though "optional" plug-ins have the difficulty that they are not documented in the manual. One of the feature's of LL's "version 4" plug-ins is that they can have built-in help, accessed via a "Help button".

Unfortunately multiple text lines does not look good (squashed up), but if the ;info text is removed then I agree that "50% = half, 200% = double" still needs to be shown somewhere in the interface.

Gale Andrews wrote:Why is New Duration not a slider here?

Because it can be entered as "min s" (minutes and seconds). Nyquist plug-ins do not yet have "time" controls.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Senior Forum Staff
 
Posts: 34275
Joined: Sat Dec 01, 2007 11:43 am

Re: Change Speed - Stretch audio to a specified length

Permanent link to this post Posted by Gale Andrews » Wed Jul 02, 2014 1:25 pm

steve wrote:
Gale Andrews wrote:"Stretch" as the name of "StretchAudio.ny" is a little misleading for non-technical users

If I recall correctly, "stretch" was the term used by the user that was asking how to "stretch" one track to synchronise with another.

Probably, but another user could be wanting to contract a track to synchronise with another.

More advanced users may see an inference to time stretching, which is not what this plug-in does.

steve wrote:"adjust length" may well be interpreted as "truncating" or "chopping bits out/adding bits in"

Yes, perhaps, but I think on the whole it's less open to misinterpretation than "Stretch". Perhaps it could even just be called "Length".

steve wrote: many users miss the point that "Change Speed" affects the length.

Hence the suggestion that built-in Change Speed should address that issue (IIRC, Vaughan was not strongly opposed to adding Length boxes when someone on feedback@ asked for this). Then we wouldn't need "StretchAudio".

Also, what proportion of users realise that extra Nyquist plug-ins are available, or want that inconvenience for such an obvious limitation in the built-in effect?

Aside: Perhaps we should have a "Download" button in Effects Preferences pointing to Wiki Download Nyquist Plug-ins?

steve wrote:
Gale Andrews wrote:I think it would be better to add length boxes to the built-in Change Speed than have a "simple" length adjust plug-in on Wiki that has only one control. Length boxes in Change Speed has 19 votes on Feature Requests.

Looking at that another way, why should it matter what language "Change Speed" is written in?

Do you mean what coding language Change Speed is written in?

steve wrote:With a few improvements to the Audacity/Nyquist interface, most of the built in effects could be written in Nyquist, which has the significant advantages of rapid development, terrific maintainability and simple modification/customisation.

Is anyone planning Nyquist GUI in the near future?

steve wrote:
Gale Andrews wrote:Change Speed (ny) could look simpler with less text.

I agree, though "optional" plug-ins have the difficulty that they are not documented in the manual. One of the feature's of LL's "version 4" plug-ins is that they can have built-in help, accessed via a "Help button".

I think we had agreed not to load the interface with text even in optional plug-ins. We can use Help screens (Nyquist error interface) or a bundled help text file until there is a proper Help button, allied with good choice of label names.

In "Change Speed (ny)", the ;info text "Enter the required duration as two numbers" isn't mandatory (you can enter one number to get seconds). So it is misleading to have that text.


Gale
________________________________________FOR INSTANT HELP: (Click on Link below)
* * * * * Tips * * * * * Tutorials * * * * * Quick Start Guide * * * * * Audacity Manual
Gale Andrews
Quality Assurance
 
Posts: 13792
Joined: Fri Jul 27, 2007 12:02 am

Next

Return to New Plug-Ins



Who is online

Users browsing this forum: No registered users and 0 guests