annotate dsp/phasevocoder/PhaseVocoder.h @ 344:5eb9c2387108

Phase vocoder: provide time-domain and freq-domain inputs separately; update tests etc
author Chris Cannam <c.cannam@qmul.ac.uk>
date Thu, 03 Oct 2013 12:58:36 +0100
parents c99d83236f0d
children a586888bc06c
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@344 24 //!!! review: size must be a power of two, or not?
c@340 25 PhaseVocoder(int size, int hop);
c@225 26 virtual ~PhaseVocoder();
c@225 27
c@340 28 /**
c@340 29 * Given one frame of time-domain samples, FFT and return the
c@340 30 * magnitudes, instantaneous phases, and unwrapped phases.
c@340 31 *
c@340 32 * src must have size values (where size is the frame size value
c@340 33 * as passed to the PhaseVocoder constructor), and should have
c@340 34 * been windowed as necessary by the caller (but not fft-shifted).
c@340 35 *
c@340 36 * mag, phase, and unwrapped must each be non-NULL and point to
c@340 37 * enough space for size/2 + 1 values. The redundant conjugate
c@340 38 * half of the output is not returned.
c@340 39 */
c@344 40 void processTimeDomain(const double *src,
c@344 41 double *mag, double *phase, double *unwrapped);
c@344 42
c@344 43 /**
c@344 44 * Given one frame of frequency-domain samples, return the
c@344 45 * magnitudes, instantaneous phases, and unwrapped phases.
c@344 46 *
c@344 47 * reals and imags must each contain size/2+1 values (where size
c@344 48 * is the frame size value as passed to the PhaseVocoder
c@344 49 * constructor).
c@344 50 *
c@344 51 * mag, phase, and unwrapped must each be non-NULL and point to
c@344 52 * enough space for size/2+1 values.
c@344 53 */
c@344 54 void processFrequencyDomain(const double *reals, const double *imags,
c@344 55 double *mag, double *phase, double *unwrapped);
c@340 56
c@340 57 /**
c@340 58 * Reset the stored phases to zero. Note that this may be
c@340 59 * necessary occasionally (depending on the application) to avoid
c@340 60 * loss of floating-point precision in the accumulated unwrapped
c@340 61 * phase values as they grow.
c@340 62 */
c@340 63 void reset();
c@225 64
c@225 65 protected:
c@340 66 void FFTShift(double *src);
c@340 67 void getMagnitudes(double *mag);
c@340 68 void getPhases(double *theta);
c@340 69 void unwrapPhases(double *theta, double *unwrapped);
c@225 70
c@340 71 int m_n;
c@340 72 int m_hop;
c@289 73 FFTReal *m_fft;
c@344 74 double *m_time;
c@340 75 double *m_imag;
c@340 76 double *m_real;
c@340 77 double *m_phase;
c@340 78 double *m_unwrapped;
c@225 79 };
c@225 80
c@225 81 #endif