comparison 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
comparison
equal deleted inserted replaced
114:f6ccde089491 115:f3c69325cca2
2 2
3 /* 3 /*
4 QM DSP Library 4 QM DSP Library
5 5
6 Centre for Digital Music, Queen Mary, University of London. 6 Centre for Digital Music, Queen Mary, University of London.
7 This file 2005-2006 Christian Landone. 7 This file 2005-2006 Christian Landone, copyright 2013 QMUL.
8 8
9 This program is free software; you can redistribute it and/or 9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License as 10 modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation; either version 2 of the 11 published by the Free Software Foundation; either version 2 of the
12 License, or (at your option) any later version. See the file 12 License, or (at your option) any later version. See the file
19 class FFTReal; 19 class FFTReal;
20 20
21 class PhaseVocoder 21 class PhaseVocoder
22 { 22 {
23 public: 23 public:
24 PhaseVocoder( unsigned int size ); 24 PhaseVocoder(int size, int hop);
25 virtual ~PhaseVocoder(); 25 virtual ~PhaseVocoder();
26 26
27 void process( double* src, double* mag, double* theta); 27 /**
28 * Given one frame of time-domain samples, FFT and return the
29 * magnitudes, instantaneous phases, and unwrapped phases.
30 *
31 * src must have size values (where size is the frame size value
32 * as passed to the PhaseVocoder constructor), and should have
33 * been windowed as necessary by the caller (but not fft-shifted).
34 *
35 * mag, phase, and unwrapped must each be non-NULL and point to
36 * enough space for size/2 + 1 values. The redundant conjugate
37 * half of the output is not returned.
38 */
39 void process(double *src, double *mag, double *phase, double *unwrapped);
40
41 /**
42 * Reset the stored phases to zero. Note that this may be
43 * necessary occasionally (depending on the application) to avoid
44 * loss of floating-point precision in the accumulated unwrapped
45 * phase values as they grow.
46 */
47 void reset();
28 48
29 protected: 49 protected:
30 void getPhase(unsigned int size, double *theta, double *real, double *imag); 50 void FFTShift(double *src);
31 // void coreFFT( unsigned int NumSamples, double *RealIn, double* ImagIn, double *RealOut, double *ImagOut); 51 void getMagnitudes(double *mag);
32 void getMagnitude( unsigned int size, double* mag, double* real, double* imag); 52 void getPhases(double *theta);
33 void FFTShift( unsigned int size, double* src); 53 void unwrapPhases(double *theta, double *unwrapped);
34 54
35 unsigned int m_n; 55 int m_n;
56 int m_hop;
36 FFTReal *m_fft; 57 FFTReal *m_fft;
37 double *m_imagOut; 58 double *m_imag;
38 double *m_realOut; 59 double *m_real;
39 60 double *m_phase;
61 double *m_unwrapped;
40 }; 62 };
41 63
42 #endif 64 #endif