annotate dsp/phasevocoder/PhaseVocoder.h @ 115:f3c69325cca2 pvoc

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