annotate dsp/phasevocoder/PhaseVocoder.h @ 340:c99d83236f0d

Do actual phase unwrapping in the phase vocoder!
author Chris Cannam <c.cannam@qmul.ac.uk>
date Wed, 02 Oct 2013 15:05:34 +0100
parents d5014ab8b0e5
children 2020c73dc997
rev   line source
c@225 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
c@225 2
c@225 3 /*
c@225 4 QM DSP Library
c@225 5
c@225 6 Centre for Digital Music, Queen Mary, University of London.
c@340 7 This file 2005-2006 Christian Landone, copyright 2013 QMUL.
c@309 8
c@309 9 This program is free software; you can redistribute it and/or
c@309 10 modify it under the terms of the GNU General Public License as
c@309 11 published by the Free Software Foundation; either version 2 of the
c@309 12 License, or (at your option) any later version. See the file
c@309 13 COPYING included with this distribution for more information.
c@225 14 */
c@225 15
c@225 16 #ifndef PHASEVOCODER_H
c@225 17 #define PHASEVOCODER_H
c@225 18
c@289 19 class FFTReal;
c@225 20
c@225 21 class PhaseVocoder
c@225 22 {
c@225 23 public:
c@340 24 PhaseVocoder(int size, int hop);
c@225 25 virtual ~PhaseVocoder();
c@225 26
c@340 27 /**
c@340 28 * Given one frame of time-domain samples, FFT and return the
c@340 29 * magnitudes, instantaneous phases, and unwrapped phases.
c@340 30 *
c@340 31 * src must have size values (where size is the frame size value
c@340 32 * as passed to the PhaseVocoder constructor), and should have
c@340 33 * been windowed as necessary by the caller (but not fft-shifted).
c@340 34 *
c@340 35 * mag, phase, and unwrapped must each be non-NULL and point to
c@340 36 * enough space for size/2 + 1 values. The redundant conjugate
c@340 37 * half of the output is not returned.
c@340 38 */
c@340 39 void process(double *src, double *mag, double *phase, double *unwrapped);
c@340 40
c@340 41 /**
c@340 42 * Reset the stored phases to zero. Note that this may be
c@340 43 * necessary occasionally (depending on the application) to avoid
c@340 44 * loss of floating-point precision in the accumulated unwrapped
c@340 45 * phase values as they grow.
c@340 46 */
c@340 47 void reset();
c@225 48
c@225 49 protected:
c@340 50 void FFTShift(double *src);
c@340 51 void getMagnitudes(double *mag);
c@340 52 void getPhases(double *theta);
c@340 53 void unwrapPhases(double *theta, double *unwrapped);
c@225 54
c@340 55 int m_n;
c@340 56 int m_hop;
c@289 57 FFTReal *m_fft;
c@340 58 double *m_imag;
c@340 59 double *m_real;
c@340 60 double *m_phase;
c@340 61 double *m_unwrapped;
c@225 62 };
c@225 63
c@225 64 #endif