Annoying problem when changing playback spead

This section is now closed.
Forum rules
Audacity 1.3.x is now obsolete. Please use the current Audacity 2.1.x version.

The final version of Audacity for Windows 98/ME is the legacy 2.0.0 version.
steve
Site Admin
Posts: 81627
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Annoying problem when changing playback spead

Post by steve » Thu Oct 21, 2010 11:25 am

Gale Andrews wrote:Someone may jump in and point out that reducing the sample rate in "Change Rate" also removes the high frequencies, even though it is not resampling but only changing the rate the samples are being "pushed out" at (Is there a better description than that)?
We need to be a bit careful with the terminology - we have 6 related "effects" but they are all different.

Effect Menu:
  • Change Speed - Literally speeds up or slows down the audio, like changing the speed of a tape or record. The final sample rate of the audio is the same as the original audio.
    When speeding up, the samples, hence the waveform, is "squashed" into a shorter time, which would increase the sample rate, so the audio is then resampled, (discarding some samples) so that the final sample rate is brought back down to the original track rate.
    When slowing down, the samples, hence the waveform, is "stretched" to a longer duration, which would decrease the sample rate, so the audio is then resampled (adding/interpolating extra samples) so that the final sample rate is brought back up to the original track rate.
  • Change Tempo - Changes the tempo without changing the pitch, like asking a musician to play faster or slower but still play the same notes.
    This effect breaks up the audio into small "packets" and either spreads the packets out so that they occupy a longer time, or pushes them together so that they occupy a shorter duration. To achieve a reasonably smooth effect, the "packets" all overlap. Distortion occurs due to the inevitable mismatch between packets as the overlap in the final audio is different to the overlap in the original. (a little bit of magic dust is sprinkled over the result to make the final audio sound better than this simplified description implies, but there is still a marked loss of sound quality).
  • Change Pitch - Changes the pitch while maintaining the original tempo, like singing in a higher or lower key.
    This works in a similar way to "Change Tempo", but the result is then resampled (like in the "Change Speed" effect) to bring the duration back to a similar duration of the original (this is inexact and the final duration will usually be a bit longer or shorter than the original).
  • Sliding Time Scale/Pitch Shift - This is similar to a combination of "Change Tempo" and "Change Pitch". The main differences are:
    1) The Tempo Change/Pitch Shift amount can vary over time. (initial and final values are set and the result is an interpolation (linear?) between these values.
    2) The handling of the overlaps between "packets" uses a lot of magic dust to produce much higher quality than Change Speed/Temp effects.
    3) This effect is more precise, but a lot slower than Change Speed/Temp effects.
Tracks Menu
  • Resample - Depending on the Audacity build, this either uses a very high quality algorithm (libresample) or an extremely high quality algorithm (libsamplerate) to change the sample rate of the track. As it changes the track sample rate it is always applied to the entire track, not just the current selection. Resampling either increases or decreases the number of samples per second, but the waveform (hence the Tempo and Pitch) remains essentially unchanged.
    Important to note that the highest frequency that can be represented in digitally sampled audio is half of the sample rate. This is known as the "Nyquist Frequency".
Track Drop-down Menu
  • Set Rate - This changes the sample rate of the track, but unlike Resample, affecting the length (hence tempo and pitch) of the track.
    Increasing the sample rate will squeeze the samples together into a shorter time (playback will be faster and higher pitch).
    Decreasing the sample rate will spread the samples out over a longer time (playback will be slower and lower pitch).
    Unlike the aforementioned effects, no samples are harmed in this production, they are just moved to different positions along the time line.
    This effect (unlike the aforementioned) is 100% reversible - If the track rate is changed and then changed back, the final audio will be identical to the original.
Gale Andrews wrote:So in an audio track at a sample rate of 44100 Hz, however much you speed up the audio using Change Speed, you cannot increase the highest frequency it contains above 22050 Hz
True - because the Nyquist frequency is 22050 Hz.
The highest quality way to change the speed (pitch and tempo) of an entire track is to change the sample rate form the Track drop-down menu (Set Rate).
If it is necessary to lower the speed (pitch and tempo) of a selection, then "Change Speed" can be used and the result will be very high quality.
If it is necessary to raise the speed (pitch and tempo) of a selection, then any resulting frequencies above the Nyquist will be lost. To mitigate this problem the track could be "Resampled" (Tracks menu) to a higher sample rate before changing the speed. This is only an issue if the intention is to change the speed back again later. While it's true that increasing the sample rate to 96 kHz will raise the Nyquist frequency to 48 kHz, frequencies above 20 kHz are inaudible, so it's only if we intend to reduce the speed later (bringing frequencies above 20 kHz back into the audible range) that we need to be concerned about them.

From the manual
For example, the more you slow down the audio, the more of the higher frequencies will be removed, making the audio sound "duller".
I'm not sure that is true - or at least not clear. Slowing down the audio (with the Change Speed effect) does not "remove" frequencies. When audio is slowed down, the pitch (frequencies) become lower. This applies to all frequencies present in the original audio, so if the original audio had frequencies at 16 kHz and it was slowed down to half speed, these frequencies will then become 8 kHz. This is not a limitation of the method or the technology, it is what should happen.
The limitation is that if the speed is increased, then very high frequencies in the original may rise above the Nyquist frequency unless the track sample rate is sufficiently high. As there can be no frequencies above the Nyquist frequency, these frequencies will be lost (permanently). This is not a problem if the speed is only being increased, as the lost frequencies would be inaudible anyway (assuming a track sample rate of at least 44.1 kHz). The problem only exists if the speed is later slowed down again.

For example:
  • Track Sample Rate = 44100 Hz (32 bit float)
  • Generate White Noise, amplitude 0.2
  • On a new track, generate a tone at 1000 Hz, amplitude 0.5
  • Mix the two tracks.
    "Plot Spectrum" will show an essentially flat frequency response up to 22050 Hz with a spike at 1000 Hz.
  • Use "Change Speed" to increase the the speed by 100%
    The duration will shorten to half its original length (will play at double speed).
    "Plot Spectrum" will show an essentially flat frequency response up to about 21 kHz with a spike at 2000 Hz. All the frequencies have been doubled, but (inaudible) frequencies above 21 kHz have been lost.
  • Use "Change Speed" to decrease the speed by 50%
    The duration will increase to double its original length (will play at half the previous speed - which is the same as the original speed).
    Plot Spectrum will show an essentially flat frequency response up to about 10.5 kHz with a spike at 1 kHz. All of the frequencies have been halved - as the highest frequencies present were 21 kHz, these will drop to 10.5 kHz. Because there were no frequencies above 21 kHz before this step, there will be no frequencies above 10.5 kHz after this step.
Now repeat the test with one extra step:
  • Track Sample Rate = 44100 Hz (32 bit float)
  • Generate White Noise, amplitude 0.2
  • On a new track, generate a tone at 1000 Hz, amplitude 0.5
  • Mix the two tracks.
    "Plot Spectrum" will show an essentially flat frequency response up to 22050 Hz with a spike at 1000 Hz.
  • Resample the track to 96 kHz (Tracks menu)
  • Use "Change Speed" to increase the the speed by 100%
    The duration will shorten to half its original length (will play at double speed).
    "Plot Spectrum" will show an essentially flat frequency response up to about 42 kHz with a spike at 2000 Hz. All the frequencies have been doubled, and (inaudible) frequencies above 20 kHz are present.
  • Use "Change Speed" to decrease the speed by 50%
    The duration will increase to double its original length (will play at half the previous speed - which is the same as the original speed).
    Plot Spectrum will show an essentially flat frequency response up to about 21 kHz with a spike at 1 kHz. All of the frequencies have been halved - as the highest frequencies present were 42 kHz, these will drop to 21 kHz.
  • (optional) The track may be resampled again back to 44.1 kHz, the spectrum will be essentially unchanged (though the scale in the Plot Spectrum window changes).
Gale Andrews wrote:I suppose this raises an interesting question if you want to reduce pitch and tempo, do you do it the "natural" way with Change Speed and risk losing high frequencies, or with Change Tempo followed by Change Pitch (or with Sliding Time Scale), and keep the frequency bandwidth but risk artifacts from the stretching?
"Change Tempo" and "Change Pitch" are both very lossy effects. "Sliding Time Scale/Pitch Shift" is also very lossy, but less so than the other two. "Change Speed" will always produce higher quality sound than "Change Tempo", "Change Pitch" or "Sliding Time Scale/Pitch Shift".

The most accurate way to change the speed is to change the sample rate of the track (from the Track drop down menu), however, when the track is finally Exported (File menu) Audacity will need to resample the track to whatever rate the final file will be in. As far as I'm aware this resampling uses the same method (libresample or libsamplerate) as is used by "Change Speed", so if only making one change to the speed (or changing only in one direction, faster OR slower) there is no difference between using "Change Speed" or changing the track sample rate (from the track drop-down menu). The "Change Speed" effect is probably more convenient in most situations.
Last edited by steve on Fri Apr 24, 2015 3:30 pm, edited 2 times in total.
Reason: Make headline for "Set Rate" a little clearer that this changes length
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Gale Andrews
Quality Assurance
Posts: 41761
Joined: Fri Jul 27, 2007 12:02 am
Operating System: Windows 10

Re: Annoying problem when changing playback spead

Post by Gale Andrews » Fri Oct 22, 2010 3:07 am

Thanks for the exposition, Steve. I just made it a little clearer in your message that "Set Rate" changes the track length, if that's OK with you.
stevethefiddle wrote: From the manual
For example, the more you slow down the audio, the more of the higher frequencies will be removed, making the audio sound "duller".
I'm not sure that is true - or at least not clear. Slowing down the audio (with the Change Speed effect) does not "remove" frequencies. When audio is slowed down, the pitch (frequencies) become lower. This applies to all frequencies present in the original audio,
OK, the fact that the tone spike in your spectrum example is moving along the frequency axis with speed changes is a good example of the point. This is probably less clear with "real world" music though both in the spectrum plot and what the ear perceives. I changed the Manual from
Change Speed works by ''resampling'' the audio, so affecting its ability to carry particular frequencies. For example, the more you slow down the audio, the more of the higher frequencies will be removed making the audio sound "duller"
to
Change Speed works by ''resampling'' the audio, affecting its frequency' content. For example, the more you slow down the audio, the more all its frequencies will be reduced, making the audio sound "duller".
I changed the first sentence as well because it was kind of inviting an explanantion of the Nyquist frequency and this isn't the place to do that. Does it seem reasonable now?

One other point to note may be that Selection Toolbar always calculates the number of samples according to the Project Rate bottom left. So when you Set Rate in the Track Drop-down menu, or Resample to some rate other than the Project Rate, Selection Toolbar does not show you the number of samples currently in the track waveform, but the number there would be if you mixed or exported at that Project Rate.




Gale
________________________________________FOR INSTANT HELP: (Click on Link below)
* * * * * Tips * * * * * Tutorials * * * * * Quick Start Guide * * * * * Audacity Manual

steve
Site Admin
Posts: 81627
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Annoying problem when changing playback spead

Post by steve » Fri Oct 22, 2010 1:18 pm

Gale Andrews wrote:Change Speed works by ''resampling'' the audio, affecting its frequency' content. For example, the more you slow down the audio, the more all its frequencies will be reduced, making the audio sound "duller".
I can see what you're getting at, and this is definitely better IMO, but I'm not sure that it is really necessary to say anything about "duller" in the introductory note. I've just tried slowing down (-15%) a section of Bob Marley's "Zion Train" and listened to the result - it is obviously lower pitch, and slower, but I don't think that I would describe it as sounding "duller". And if I then speed it up again (by 17.647058824%) the result sounds identical to the original (there is a very minor loss in high frequencies, but it's not noticeable, and is caused by imperfections in the resampling algorithm).

What is just about noticeable is if you do it the other way - increase the speed by +17.647058824% (faster and higher pitch) and then slow it down again (-15%). In this case there is a much more significant drop-off of high frequencies - though as it's at about 16 to 17kHz it is quite subtle even with very good hearing). In this case the loss in upper frequencies is primarily due to Nyquist limits. This may be worth mentioning as an "advanced user tip", but it is not going to be relevant for the vast majority of cases.
Gale Andrews wrote:One other point to note may be that Selection Toolbar always calculates the number of samples according to the Project Rate bottom left. So when you Set Rate in the Track Drop-down menu, or Resample to some rate other than the Project Rate, Selection Toolbar does not show you the number of samples currently in the track waveform, but the number there would be if you mixed or exported at that Project Rate.
That's a very good point, and one that I'd neither noticed or considered (I usually work with tracks that are all at the same sample rate).
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Gale Andrews
Quality Assurance
Posts: 41761
Joined: Fri Jul 27, 2007 12:02 am
Operating System: Windows 10

Re: Annoying problem when changing playback spead

Post by Gale Andrews » Sat Oct 23, 2010 2:15 am

stevethefiddle wrote:
Gale Andrews wrote:Change Speed works by ''resampling'' the audio, affecting its frequency' content. For example, the more you slow down the audio, the more all its frequencies will be reduced, making the audio sound "duller".
I can see what you're getting at, and this is definitely better IMO, but I'm not sure that it is really necessary to say anything about "duller" in the introductory note. I've just tried slowing down (-15%) a section of Bob Marley's "Zion Train" and listened to the result - it is obviously lower pitch, and slower, but I don't think that I would describe it as sounding "duller". And if I then speed it up again (by 17.647058824%) the result sounds identical to the original (there is a very minor loss in high frequencies, but it's not noticeable, and is caused by imperfections in the resampling algorithm).

What is just about noticeable is if you do it the other way - increase the speed by +17.647058824% (faster and higher pitch) and then slow it down again (-15%). In this case there is a much more significant drop-off of high frequencies - though as it's at about 16 to 17kHz it is quite subtle even with very good hearing). In this case the loss in upper frequencies is primarily due to Nyquist limits. This may be worth mentioning as an "advanced user tip", but it is not going to be relevant for the vast majority of cases.
As well as wanting to dissuade people from changing up and down, some users do actually remark on the "dullness" as well as the pitch drop when they do a one way slow down with Change Speed instead of Change Tempo. I agree pitch drop is often much more noticeable than dullness, but just trying it on some Shostakovich which includes high violin harmonics and brushed cymbals, those two effects are effectively gone after a 40% slow down.

I agree though there is no need to get complex, so probably no need to throw in the resampling concept in the Intro either. So mark III:
Use the Change Speed effect to change the speed of a track, affecting its tempo and pitch, and also its frequency content. For example, the more you slow down the audio, the more all its frequencies will be reduced.

To change the tempo of a track without affecting its pitch or frequency range, use Effect > Change Tempo... or Effect > Sliding Time Scale / Pitch Shift....


Gale
________________________________________FOR INSTANT HELP: (Click on Link below)
* * * * * Tips * * * * * Tutorials * * * * * Quick Start Guide * * * * * Audacity Manual

Locked