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
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.
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:
(setq N 0.4) ;increase pitch by 0.4 semitones
(force-srate (/ *sound-srate* (power 2.0 (/ N 12.0))) s)
(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.
Thank you very much for that excellent explanation!