Simple pitch change question

Using Nyquist scripts in Audacity.
Post and download new plug-ins.
Forum rules
If you require help using Audacity, please post on the forum board relevant to your operating system:
Windows
Mac OS X
GNU/Linux and Unix-like
Post Reply
guranbanan
Posts: 14
Joined: Fri May 09, 2014 8:02 am
Operating System: Please select

Simple pitch change question

Post by guranbanan » Mon Dec 22, 2014 1:42 am

Hi!

What would be the best way to adjust the pitch (in steps) of an audio file to change from, let's say 59.6 (a slightly flat C) to 60 (a nice perfect C)? I think I'm actually talking about speeding up the audio - since I don't wan't any time stretching or that sort of thing - just a regular pitch (and speed) change.

I've understood that one way to accomplish this would be to use the resample function. The problem is it only accepts sample rates as input values - and I don't know how to convert between steps and sample rates :oops:

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

Re: Simple pitch change question

Post by steve » Mon Dec 22, 2014 2:11 am

For a small change in pitch/speed, force-srate will work well. It is generally faster than resample, and for small changes I find that it subjectively sounds better. For down-sampling more than few tones, resample should be used so as to avoid aliasing distortion.
guranbanan wrote:The problem is it only accepts sample rates as input values - and I don't know how to convert between steps and sample rates
Very easy - it's just a matter of ratios, but there's a catch.
To raise the pitch by "N" semitones, the speed must be increased by 2^(N/12). However, (the catch), Nyquist does not control the sample rate of the track. When the audio is returned to the track, the samples are positioned according to the sample rate of the track.

As a simple example, if you double the sample rate in Nyquist, then Nyquist will return twice as many samples as their were originally. When returned to the track, they will occupy twice the original duration and play at half the speed - in other words, it's the opposite of what one might intuitively expect.

So, to increase the speed and pitch, you must reduce the sample rate in Nyquist, and to decrease the speed and pitch you must increase the sample rate in Nyquist.

To write that in Nyquist:

Code: Select all

(setq N 0.4) ;increase pitch by 0.4 semitones
(force-srate (/ *sound-srate* (power 2.0 (/ N 12.0))) s)

Code: Select all

(setq N 0.4) ;decrease pitch by 0.4 semitones
(force-srate (* *sound-srate* (power 2.0 (/ N 12.0))) s)
*sound-srate* is a special Nyquist variable that is set to the sample rate of the track.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

guranbanan
Posts: 14
Joined: Fri May 09, 2014 8:02 am
Operating System: Please select

Re: Simple pitch change question

Post by guranbanan » Mon Dec 22, 2014 2:22 am

Thank you very much for that excellent explanation!

Post Reply