cannam@0: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ cannam@0: cannam@0: /* cannam@0: QM DSP Library cannam@0: cannam@0: Centre for Digital Music, Queen Mary, University of London. Chris@115: This file 2005-2006 Christian Landone, copyright 2013 QMUL. Chris@84: Chris@84: This program is free software; you can redistribute it and/or Chris@84: modify it under the terms of the GNU General Public License as Chris@84: published by the Free Software Foundation; either version 2 of the Chris@84: License, or (at your option) any later version. See the file Chris@84: COPYING included with this distribution for more information. cannam@0: */ cannam@0: cannam@0: #ifndef PHASEVOCODER_H cannam@0: #define PHASEVOCODER_H cannam@0: cannam@64: class FFTReal; cannam@0: cannam@0: class PhaseVocoder cannam@0: { cannam@0: public: Chris@115: PhaseVocoder(int size, int hop); cannam@0: virtual ~PhaseVocoder(); cannam@0: Chris@115: /** Chris@115: * Given one frame of time-domain samples, FFT and return the Chris@115: * magnitudes, instantaneous phases, and unwrapped phases. Chris@115: * Chris@115: * src must have size values (where size is the frame size value Chris@115: * as passed to the PhaseVocoder constructor), and should have Chris@115: * been windowed as necessary by the caller (but not fft-shifted). Chris@115: * Chris@115: * mag, phase, and unwrapped must each be non-NULL and point to Chris@115: * enough space for size/2 + 1 values. The redundant conjugate Chris@115: * half of the output is not returned. Chris@115: */ Chris@115: void process(double *src, double *mag, double *phase, double *unwrapped); Chris@115: Chris@115: /** Chris@115: * Reset the stored phases to zero. Note that this may be Chris@115: * necessary occasionally (depending on the application) to avoid Chris@115: * loss of floating-point precision in the accumulated unwrapped Chris@115: * phase values as they grow. Chris@115: */ Chris@115: void reset(); cannam@0: cannam@0: protected: Chris@115: void FFTShift(double *src); Chris@115: void getMagnitudes(double *mag); Chris@115: void getPhases(double *theta); Chris@115: void unwrapPhases(double *theta, double *unwrapped); cannam@0: Chris@115: int m_n; Chris@115: int m_hop; cannam@64: FFTReal *m_fft; Chris@115: double *m_imag; Chris@115: double *m_real; Chris@115: double *m_phase; Chris@115: double *m_unwrapped; cannam@0: }; cannam@0: cannam@0: #endif