# Calculating the sample position for simulating the effect of gradually raising the playback rate

Suppose I have a sound recording of a tone whose instantaneous frequency keeps falling (continuously, not in steps) in inverse proportion to the running time -- i.e. the initial frequency is 1000 Hz, then 1 second later the frequency is 500 Hz, 2 seconds later it's ~333.333 Hz, 3 seconds later it's 250 Hz and so on. The total length of the recording is 9 seconds, which means that the final frequency of the tone will be 100 Hz. Let's call this source sound the "wave1" (this "wave1" is GoldWave's terminology, I'm saying this just because I often use GoldWave).

Now suppose I want to make (at the same sample rate and of the same length) another sound file, called "wave2", which will sound as if "wave1" were played faster and faster so that the tone whose frequency was falling turns into a tone whose frequency is constant. To do this, let's say I have the following variables:

• N = total length given in samples, which should be the same for both wave1 and wave2.
• n = current sample position, starting at 0 and increasing by 1 for every sample.
• T = 1/SampleRate, which should be the same for both wave1 and wave2.
• t = running time in seconds = n*T.

Now let's add a new variable, for example "o", which would contain the required sample position of wave1 for every single sample position of wave2 -- i.e. the main goal is that wave2(n) should be equal to wave1(o) and that "o" has to be defined for every integer "n" in the range [0,N]. This means that I have to know how to calculate "o" for every "n". Trouble is, at this moment I only know that for n=0 we have o=0 and that for n=N we have o=N. But I have no idea how I should find the other values.