pitch shifting (stretching) code

Stephan M. Sprenger sms at dspdimension.com
Thu Jan 27 07:53:29 EST 2000

robert bristow-johnson wrote:
> >Greetings,
> >
> >Can anybody point me to some pitch-shifting, actually time stretching,
> >code. (rbj, dont ride me if that aint the right terms! :)
> "time-streching" ain't a bad word for it. 

I don't agree. Time-Stretching implies making the signal longer and
forgets the fact that the same process can also be used to make the
signal shorter while maintaining pitch.

So, a better name would be "Time Compression/Expansion" or just "Time
Scaling". "Change Tempo" is also a good name, I believe, since it
suggests that only the tempo changes and this usually does not
incorporate a change in pitch (at least tempo in the musical sense).

> i can't remember what word i
> thought was bad.  some people said that "pitch-shifting" was just
> resampling and "frequency-shifting" definitely means the ring-modulator
> sorta thing.

rbj, now we're fighting our terminology war again ;-). As you do for
wavetable synthesis, I still claim that pitch scaling, pitch shifting
and pitch transposition are three different things, each with distinct
meaning. I have explained my viewpoint with regard to this on my "Pitch
Scaling Using the Fourier Transform" page, so for those of you
interested in it take a look.

> >I took a look at Stephan Sprenger's page, which is very good.  But, I dont
> >understand how Embree's polyphase implementation is linked to TDHS. 

It isn't. Embree makes a common mistake in that he calls his process
'pitch shifting' while he describes a sample rate conversion. He has
other minor glitches in his code as well (unused variables, errors,
typos) so this one probably also escaped his attention when proofreading
the book. I still recommend it to students as it is a valuable resource
for people who want to get started with DSP without the numerical fuss.

> Can
> >anybody help me make the connection?  Is TDHS easy to code up?

If you know how to do it, it's fairly easy ;-). 

> not too bad.  but even if it's public knowledge, i can't say how.

I would, but on the other hand why make rbj's life more difficult? :-).

Besides, I've not yet encountered any two TDHS algorithms that are equal
or produce equal results, which might be an indication that it is
apparently not that trivial to code, even if this might appear to be the


Stephan M.Sprenger
The DSP Dimension                           http://www.dspdimension.com

dupswapdrop -- the music-dsp mailing list and website: subscription info,
FAQ, source code archive, list archive, book reviews, dsp links

More information about the music-dsp mailing list