# Sliding the pitch of an audio file in a particular way

I’m looking for a technique/application/algorithm to slide the pitch of an auto file, but in a very specific way.

For example, I have an 60 second audio file sampled at 12000 which contains just a 700Hz sine wave and a 1200Hz sine wave. What I want is a new file, of the same length and sampled at the same rate which starts out at 700 Hz and 1200Hz and ends up at 710 Hz and 1210 Hz (and at the 30s point is 705Hz and 1205Hz). So I want the same frequency chance (in absolute, not relative terms) for all frequencies. I want to add between 0Hz and 10Hz to all frequencies, the exact amount added being a function of time. The file may contain multiple tones, not just two. I’d want the same absolute frequency shift for all frequencies. At time “t” each frequency would become “F+f(t)” where F is the frequency concerned and f(t) is some function of t.

The only way I can think of to do this would be to split the file into multiple short segments, then, for each segment, take the FFT, shift the FFT by a small frequency step, take the inverse FFT - then stitch all the segments back together. Even then you might have phase discontinuities where the segments joined. It might even be easier to do in the analog domaine then the digital using modulation and heterodyning.

There are lots of applications that will change the pitch of an audio file by a fixed percentage while retaining the same tempo, in fact Audacity does this very well. While this is close, it’s not quite what I want. I want an absolute, not relative, pitch change and I want to vary the pitch change as a function of time. All while keeping the same tempo.

I’m 99% sure there’s no simple existing application that will do this (if there is please tell me!), but I’d be interested in any thoughts/suggestions on how it might most easily be done.

Thanks

The easiest way to do this would be to generate the sliding tones as sliding tones, rather than trying to frequency shift constant tones.

Here’s an example that can run in the Nyquist Prompt effect:

``````;version 4
;type generate

(setf amp 0.5) ;amplitude of each sine wave

(setf start1 700)
(setf end1 710)
(setf start2 1200)
(setf end2 1210)
(setf dur 60) ;seconds

(setf hz-ctrl1 (pwlv start1 dur end1 dur))
(setf hz-ctrl2 (pwlv start2 dur end2 dur))

(mult amp
(sim (hzosc hz-ctrl1)
(hzosc hz-ctrl2)))
``````

That would indeed be the best way to generate a sliding tone or set of tones.

Unfortunately I need to slide the pitch of existing audio files which have multiple tones in them, while keeping the timing (tempo) unchanged. The slide has to apply the same frequency change to each tone (e.g. +5Hz), not by a percentage (e.g. 5%).

I wasn’t aware of the Nyquist programing language, so thanks for that link. There may be something there of use.

In that case you need to look for a “frequency shift” (rather than “pitch shift”) effect. Unfortunately I don’t know of one. It is possible to do frequency shifting with Nyquist, but it’s difficult (definitely not a “beginner” project).

There is a free plugin called DtBlkFx, which uses FFT, which has two frequency-shift options,
one is “Const shift” which is “non-harmonic shifting by a fixed frequency”

DtBlkFx works in Audacity on Windows.

Another free plugin which may do the job …
https://www.fullbucket.de/music/freqshifter.html
(I can testify it works in Audacity on Windows).

Freqshifter looks interesting an might almost do what I need, but I couldn’t get the file from https://www.fullbucket.de/music/freqshifter.html to work in Audacity (2.1.3 or 2.2.2). I can move the .dll file from the zip archive to the plugin directory, I can see it in the enable/disable effects dropdown and I can click to enable it, but when I click on “OK” I get an error message that it failed to register and could not load the library.

You got it running OK in Windows? Which version of Audacity and windows. I’m running Windows7 (64bit) and have Audacity 2.1.3 and 2.2.2 installed.

Currently Audacity only accepts 32-bit plugins, even if your machine is 64-bit.
So you need the 32-bit version of Freqshifter, i.e. “freqshifter.dll”, not “freqshifter64.dll”

BTW shifting, say, 1000Hz by +/-5Hz is only just detectable to the human ear.
The frequency-resolution of human hearing @1000Hz is only about 3Hz.

Why?

My money is on binaural beats.

The application is to compensate for doppler shift in digital frequency shift codes signals reflected from the moon. Audio shifts rates of up to 60Hz/minute are possible. By compensating for changing doppler shift rates, recorded signal decoding may be easier. The change in absolute doppler shift can be compensated for at RF frequencies, but if you have an uncompensated recording of the signal you’d have to do it at audio frequencies.

I’m just playing around a little to see if can be done with existing tools. I did get the 32 bit version of Frequency Shifter to run as an Audacity plugin. It sort of can be kluges to work for this application, but it does seem to introduce some distortions which can hinder signal decoding when S/N is very low.

How does this work? I thought that the Doppler shift (“δf”) was (δv/c)*f0, which is a ratio rather than an absolute shift.

Yes, doppler shift is a ratio, but I’m looking at the frequency difference in demodulated audio signals of autio signals used to modulate an RF carrier. The audio signals may be, for example at 1000Hz and 2000Hz, while the RF carrier may be 1000000000Hz. If that RF carrier is shifted by 5Hz, the demodulated audio signals (using the same local oscillator to down shift it) will be at 1005 Hz and 2005 Hz. The demodulated frequencies change, but the spacing between them doesn’t. To get them back to 1000Hz and 2000Hz need a frequency shift of 5Hz, not a pitch change of 0.5%

Are you sure that’s right?

1. What happens if you have:
• a carrier frequency of 1000000000 Hz
• two audio frequencies at 100 Hz and 200 Hz
• a Doppler shift of the carrier to 999999900 Hz
1. What would happen if there was a Doppler shift of the carrier to 500000000 Hz (100 MHz to 50 MHz)?

2. If I was listening to the radio in a car and drove past the transmitter at 100 km/h, why is there no noticeable pitch shift in the audio?

@ka1gt I’m not knowledgeable in most aspects of audio editing but,
are you trying to create a binaural beats effect?
I ask because I am interested in doing that.

A binaural beat is when you play a tone in the left ear and you play the same thing in the right ear, but the frequency is shifted a few Hz.
For example:
Left ear: steady tone of 100Hz
Right ear: steady tone of 110Hz

I’m actually looking to get more complicated than that. I want to take a music file, change it to mono. Then make a copy, shifted by 10Hz. I then plan to take them and make a stereo file where the left channel is unshifted and the right channel is shifted.

He wrote previously that he was trying to decode signals reflected from the moon.
If you have a question about binaural beats please start a new topic.