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