# pitch vs playback rate

Let's say I have an audio sample, whose pitch is known to be C4 (don't wanna go in detail here, let's say I just sampled a tuned piano playing the C4 key).

The rules of the game are: I can only change the sample playback rate by any ratio. No pitchshifter module, no frequency analysis. If I set the playbackrate to 2.0, for example, the sample is played back at twice its speed. If I set it to 0.5, the sample is played back at half its speed, and so on. This changes the playback time as well as the sample pitch.

If I wanted to generate any arbitrary "note" from this sample, what is the relation between the playback rate and the sample pitch? For example, I know that C4 fundamental frequency is 261.63 Hz. What playback rate should I set to make the sample "sound like" a C#4/Db4 (277.18 Hz) or a D4 (293.66 Hz)? What is the general, formulaic, relationship?

• Very interesting topic. So do you have any issues with the duration of the note changing based on the pitch? – user2718 Feb 1 '13 at 22:50

## 1 Answer

The ratio of sample playback rates should be equal to the ratio of pitches you want to obtain.

For example, if your C4 note was sampled at 48kHz, you'll need to play it back at $48000 \times \frac{277.18}{261.63} = 50.85kHz$ to make it sound like a C#4.

• Since sampling rate is ininfluent (fixed) here, my playback rate should be 277.18 / 261.63 = 1.05943508, am I right? – janesconference Feb 1 '13 at 12:19
• Yes, this is correct. – pichenettes Feb 1 '13 at 12:28