# Real-time resampling pitch-shifting (without corrective time-stretching)?

Is real-time resampling pitch-shifting impossible (without corrective time-stretching, such as WSOLA)? I've been told that it is.

Real-time resampling pitch-shifting would mean applying resampling in real-time, but it's claimed that it's impossible to overlap differently resampled segments in real-time (since the total length of the "window" varies in every window and in connection to every frequency of resampling).

• can you clarify?: normally we think of "pitch-shifting [with] corrective time-stretching, such as WSOLA" as an operation applied to audio that changes the pitch of a sound without changing the tempo. so it's not merely playing the tape faster or slower than the speed of recording, which would also increase or decrease the tempo. if we understand that in common, does "pitch-shifting... without corrective time-stretching, such as WSOLA" mean just speeding it up or slowing it down, including the corresponding change in both tempo and pitch? – robert bristow-johnson Dec 6 '15 at 2:50
• you haven't answered my question, making it difficult to ascertain your question and answer it. i want to know if the "resampling pitch-shifting" that you are asking if it's impossible, if that changes the tempo or not. if it the simple "speed up the tape", it can't be real-time indefinitely. but if it's the pitch-shifting that does not change the tempo, that can be real-time and run forever and there are many commercial products that do it. – robert bristow-johnson Dec 6 '15 at 3:09
• @robertbristow-johnson I'm asking about real-time pitch-shifting using resampling without corrective time-stretching (such as WSOLA). It does change the tempo and leaves it so (there's no correction done). – mavavilj Dec 6 '15 at 3:13
• Your question makes no sense. You can't change the length of a signal and have it be the same length. Resampling changes the length. A real-time process requires that the length be unchanged. – hotpaw2 Dec 6 '15 at 5:40
• @howpaw2 Which is what I'm asking about. The feasibility. One could've thought that the real-time process would be feasible if one had a way to "stitch together" the windows of different length. E.g. using multiple buffers so that one can reach for "future samples". – mavavilj Dec 6 '15 at 5:42

## 1 Answer

okay, the answer to the question is "no", from my understanding of what "real-time" in DSP means. a real-time DSP process is one that can run forever without either starvation of input samples or overflow of input samples. for every second of sound input, there is a second of sound output. just speeding up the sound or slowing it down, to change the pitch, is an operation you can do on a segment of sound or a sound file. but it is not a continuous operation that runs real time. this is not because the CPU or DSP cannot handle the number of operations, it's because, either the input or the output will have no time when the other still has time remaining.

now, there are DAW functions that play back sound files faster or slower that recorded without changing pitch. what they are really doing is playing back the sound file faster or slower (with an increased or decreased number of input samples) and the DSP algorithm is doing real-time and complementary resampling and time-scaling to get to the output.

• I could be able to save audio to disk. What does the process then look like? Is it just resampling the whole file first and then playing it back normally? Or is there some buffering to facilitate "changing the playback on the fly". Another question? – mavavilj Dec 6 '15 at 3:44
• you can do this with MATLAB. or the programming language of your choice, as long as you have the facilities to read and write sound files. (usually .wav files). – robert bristow-johnson Dec 6 '15 at 3:52
• they're quite fast. and memory is cheap and large. with MATLAB, you can read in an entire sound file into a single buffer, use the MATLAB resample() function to change the length (and pitch) and then write the buffer back out to disk. – robert bristow-johnson Dec 6 '15 at 4:01