# Re: [music-dsp] pitch shifting vs sample rate

```If you're just talking about recording (for example) 1 second of audio at
8kHz and playing it back at 9kHz, this will have two effects:```
```
1) the pitch will be shifted up by a factor of 9/8, or 12*log(9/8)/log(2) =
~2.04 semitones
2) your recording will play back 9/8 faster, so it will be done in ~0.889
seconds.

Usually in audio DSP when we talk about pitch shifting we're talking about
techniques that try to change the pitch without changing the speed of
playback, It's quite a bit harder to make this sound good.

-Ethan

On Fri, Mar 15, 2019 at 3:45 AM Alex Dashevski <alexd...@gmail.com> wrote:

> Hi,
>
> It should not be circular buffer.
> Could you explain meanings of "fade in", "fade out", "splice in", and
> "splice out" ?
>
> Thanks,
> Alex
>
> ‫בתאריך יום ו׳, 15 במרץ 2019 ב-0:14 מאת ‪robert bristow-johnson‬‏ <‪
> r...@audioimagination.com‬‏>:‬
>
>>
>>
>> ---------------------------- Original Message ----------------------------
>> Subject: [music-dsp] pitch shifting vs sample rate
>> From: "Alex Dashevski" <alexd...@gmail.com>
>> Date: Thu, March 14, 2019 2:55 pm
>> To: music-dsp@music.columbia.edu
>> --------------------------------------------------------------------------
>>
>> >
>> > Let's assume we have recorder buffer(input) and playback buffer(output)
>> > with the same size.
>> > I sample input signal at 8Khz and output signal at 9Khz.
>> > My question is:
>> > Why isn't it equivalent to pitch shifting ?
>> >
>>
>> well, you didn't say how the samples in the playback buffer are defined.
>> let's say that you are simply copying the input buffer to the output
>> buffer.  or, even simpler, let's say that the input buffer and output
>> buffer are coincidental, the same block of memory with two different points
>> writing into it and reading out of it.  and let's say that these buffers
>> are *circular* FIFO buffers.
>>
>> so, the output pointer advances 9 samples in the same amount of time that
>> the input pointer advances 8 samples.  that would be pitch shifting, but
>> you would have a click in the output every time the output pointer
>> overtakes and passes the input pointer.  a good pitch shifter would fade
>> out the signal from the output pointer before it catches up to the input
>> pointer and would fade in the signal from another output pointer that is
>> farther behind.  and would continue to do this.  once the signal is
>> output pointer (that was farther behind) becomes the nominal output pointer
>> (which is still advancing 9 samples in the time the input pointer advances
>> 8 samples).  when that gets too close behind the input pointer, we do this
>> again and begin cross-fading to the signal further behind.
>>
>> a better pitch shifter would make sure that the new, fade-in output
>> pointer is pointing to the waveform that looks similar to the fade-out
>> output pointer.  this is what pitch detection is good for.  so when extra
>> audio is spliced in (for up-shifting) or audio is spliced out (for
>> down-shifting), you want ideally that an integer number of periods of the
>> audio tone is spliced in or out.
>>
>>
>> --
>>
>> r b-j                         r...@audioimagination.com
>>
>> "Imagination is more important than knowledge."
>>
>>
>>
>>
>>
>>
>>
>> _______________________________________________
>> dupswapdrop: music-dsp mailing list
>> music-dsp@music.columbia.edu
>> https://lists.columbia.edu/mailman/listinfo/music-dsp
>
> _______________________________________________
> dupswapdrop: music-dsp mailing list
> music-dsp@music.columbia.edu
> https://lists.columbia.edu/mailman/listinfo/music-dsp
```
```_______________________________________________
dupswapdrop: music-dsp mailing list
music-dsp@music.columbia.edu
https://lists.columbia.edu/mailman/listinfo/music-dsp```