annotate dsp/phasevocoder/PhaseVocoder.h @ 130:2053a308bb4d kissfft

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