"Funk so.u..l b..r...o....t.....h......e.......r "
Timestretching is the process of making a sound fragment longer in duration without altering its pitch. It has many applications. On radio, for instance, it is often necessary for all commercials to have exactly the same length to be able to fit them in the radio timetable. Obviously, it is pretty difficult to record something like a spoken radio commercial at an exact length of, say, 30 seconds, since peolpe do not have internal chronometers.
Besides that, musicians use timestretching to adjust the duration of samples or drumloops to fit them exactly to the tempo of a composition. Musicians also use extreme timestretching as a sound effect. A famous example of this is the line from Fatboy Slim's 'The Rockafeller Skank', quoted above. In this case, the timestretching is done in such an extreme manner that the algorithm fails to produce a clean result. The shortcomings of the timestretching algorithm are thus used as a sound effect in itself.
How does timestretching work?
Well, it is quite simple actually. First, you make a recording of a sound. Since timestretching is easiest in the digital domain, we will assume that you make a PCM wavefile of some sort of it. Then, you change the playback speed of the sound so that it will have the length you desire. Finally, you pitchshift the sound to compensate for the drop due to the slowing down of the recording. The amount by which you pitchshift should be proportional to the amount of length change: if you make the recording twice as long, you should double the pitch (shift up by one octave).
As mentioned before, extreme timestretching produces rather bizarre results, like in the Fatboy Slim example. This is due to the fact that pitchshifting divides the sound in granules, little snippets of sound, which are then played back several times at a higher speed. If you stretch too far, you will have to pitchshift a lot and that produces an unnatural grainy effect.
N.B.: For obvious reasons, timestretching can never be done in realtime.
N.B. 2: The process and theory expressed above is identical for time compression. There, we would speed the sound up and pitchshift it downwards.