Change duration/tempo of a .Wav file without introducing pops or pitch shift? I am attempting to develop a similar function as Audacity's Effects&gt;Change Tempo effect. 

Or more specifically: I am in need of a way to create a function in my own project that can modify the length of a .wav file without changing it's pitch or introducing pops/leakage.

I am writing a standalone application (in C#) that already has some functions to create and save .wav files. But I just realized that I must add some processing to allow me to adjust the duration/length of a .wav so I can sync it to be exactly as long as an associated animation (which can not be altered).

I am very interested in knowing if there are any examples that exist which demonstrate concepts on how to change a .wav file's tempo (without noticeable distortion)?

I should specify that I would not need to adjust the length by much more than ±5%.

What I have tried already is to remove slices of data at regular intervals for a given "slice width", which kind of worked but introduced many pops as the sine waves were no longer smooth/continuous.

I have also tried simply adjusting the playback speed at the player by a multiplier to adjust to a desired duration, but this obviously cause the pitch to change (and somewhat noticeably too).

This is something that I am very anxious to understand as my project now seems to be in trouble unless I can somehow synchronize the audio. Could someone please help me figure out if I can write my own function to process this?
I would suggest the following steps:


identify voices and unvoiced sounds: for this you can use zero-crossing rate and intensity as a basic approach or use more complex methods: cepstrum, harmonicity, others.
the unvoiced sounds can be simply cut, usually without concerns
for the voiced sounds apply PSOLA or WSOLA. For PSOLA there are many implementation and it might be easier. So first you must identify the glotal pulses to be able to identify glotal periods. Then you can "cut" full periods (in a overlap and add sense). Always cut periods in the middle of the phonemes and never near the transition zones (borders)