FFT based Phase Vocoder/Pitch Shifter

DSP related issues, mathematics, processing and techniques
Post Reply
User avatar
martinvicanek
Posts: 1334
Joined: Sat Jun 22, 2013 8:28 pm

FFT based Phase Vocoder/Pitch Shifter

Post by martinvicanek »

Hi gang,
here is another application of the stream FFT: a basic phase vocoder used for pitch shifting in real time (with some latency though). There is a lot of relevant reading on the Web about the phase vocoder. One useful implementation guide is http://www.ece.uvic.ca/~peterd/48409/Bernardini.pdf.
The schematic below is, however, rather academic - the quality is not overwhelming. Various improvements to the basic structure were published in the late nineties, the keyword here is vertical coherence. The schematic below only cares about horizontal coherence, i.e. the proper phase continuity between subsequent frames. Vertical coherence considers, in addition, the phase relations between frequency bins within each frame. The result is a better impulse response and less phasing.
Anyway, I thought I share this as a first demonstration. I have to say that I learned a lot from this little exercise.

@MyCo, how do you get those useful looking Spectrum Plot modules to respond? There seems to be a problem with the Prepare Data module inside. My Ruby skills are too limited to figure it out. :oops:
Attachments
Stream FFT Phase Vocoder v1.fsm
(112.78 KiB) Downloaded 1510 times
User avatar
MyCo
Posts: 718
Joined: Tue Jul 13, 2010 12:33 pm
Location: Germany
Contact:

Re: FFT based Phase Vocoder/Pitch Shifter

Post by MyCo »

Here is your schematic with the displays set up. Don't know why you had problems with that. It's important to note, that the top ones are synchronized with the FFT counter, so you have to input the data corresponding to the counter that generates the data.

The stuff looks so terribly complicated... I don't think that I'll ever understand what's going on.

I had a look at pitch shifting algorithms before, especially at this one:
http://www.dspdimension.com/admin/pitch ... ng-the-ft/

I somehow understand what's going on in this one, but yours is way over my head... or maybe it's just hard to understand because of those various delays running in it. BTW: is it safe to use delays in a block oriented setup like this? When you have a delay of 1/4 FFT size, and you go over the block boundary, you'll read for 1/4th of the blocksize, data from a previous block.
Attachments
Stream FFT Phase Vocoder v1 (+MyCo).fsm
(219.46 KiB) Downloaded 1536 times
User avatar
martinvicanek
Posts: 1334
Joined: Sat Jun 22, 2013 8:28 pm

Re: FFT based Phase Vocoder/Pitch Shifter

Post by martinvicanek »

Thanks, MyCo. The wave and phase displays work fine, was never a problem, however the spectrum plots still don't respond here. The signal seems to be broken at the Prepare Data module. I must be doing something wrong. :?

DSPDimension is a good reference, Bernsee certainly knows his stuff and provides very clear explanations. In the link you referenced, the idea is to pitch scale in the frequency domain, whereas in my schematic the signal is first time stretched and then re-sampled. The latter may look more complicated, not sure.

Those delay modules are just a way of accessing frequency bins other than the one just being processed in the serialized stream. If we had the data as arrays we would just work with indexes. You could actually do that if you stuff everything including the FFTs in a big ASM but I doubt t will be clearer then.

Your concern about possible boundary crossings is well justified, indeed that would mess up things in an unpredictable way. However note that the 1/4 FFT size delay accesses data from an adjacent SSE channel which is processed exactly that amount of time in advance. It is a bit tricky I admit, and it took me a while to get it right. (The worst part was the phase accumulator, where you have to compensate 1 sample delay for the feedback loop. :mrgreen: )
Post Reply