0
$\begingroup$

I am trying to implement a phase vocoder overlap-add pitch shifting algorithm for part of a plugin I'm writing. I have done this kind of thing offline before and I understand the theory, but this is the first time I've attempted to do realtime processing. This seems to add extra difficulty.

Here's my issue: the audio routing library I'm using gives me 1024 samples of audio at a time, and I must return 1024 samples of supposedly pitch-shifted audio each time. I know that I can just use some kind of ring buffer or something to cache the samples needed for my overlap-add algorithm, but what do I return the very first time? That is, what do I do with the first 1024 samples of audio I'm given? It seems that with an overlap factor of 4, I would need at least 1792 (256*3 + 1024) samples before I could return my first 1024 samples, because of the overlap requirement.

Am I doomed to just output silence the first go-round, until I get enough samples to actually start doing the algorithm? It doesn't seem ideal to delay the audio, even if only by a couple of milliseconds. I would like it to be sample accurate if at all possible, even if there's a slight drop in quality for the first few windows of data.

thanks in advance

$\endgroup$
  • 2
    $\begingroup$ if your FFT length is 1024, you should be able to return non-zero samples in the first frame of output. it's just that what would be overlapping over that from the previous frame (and added) would be zero, since there is no previous frame when you're processing the "first frame" or some might call it the "0th frame". $\endgroup$ – robert bristow-johnson Jan 11 '14 at 6:56
  • $\begingroup$ Wow, it seems somewhat obvious now that you say it. I can literally take my routine and just preprocess the "-1st" frame, acting like a frame of all 0s came in before the "0th" frame. Thanks for that! $\endgroup$ – Chad Russell Jan 11 '14 at 7:24
  • 1
    $\begingroup$ Not sure why "sample accurate" is in your question title, as waiting for a buffer of 1024 samples (at 44.1) is over 20 mS delay, even assuming no additional system latencies. $\endgroup$ – hotpaw2 Jan 11 '14 at 18:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.