Mercurial > hg > qm-dsp
comparison dsp/phasevocoder/PhaseVocoder.h @ 347:e3dedded9c4d
Merge from pvoc branch
author | Chris Cannam <c.cannam@qmul.ac.uk> |
---|---|
date | Fri, 04 Oct 2013 16:43:44 +0100 |
parents | 5eb9c2387108 |
children | a586888bc06c |
comparison
equal
deleted
inserted
replaced
336:f665f9ce2fd1 | 347:e3dedded9c4d |
---|---|
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 //!!! review: size must be a power of two, or not? |
25 PhaseVocoder(int size, int hop); | |
25 virtual ~PhaseVocoder(); | 26 virtual ~PhaseVocoder(); |
26 | 27 |
27 void process( double* src, double* mag, double* theta); | 28 /** |
29 * Given one frame of time-domain samples, FFT and return the | |
30 * magnitudes, instantaneous phases, and unwrapped phases. | |
31 * | |
32 * src must have size values (where size is the frame size value | |
33 * as passed to the PhaseVocoder constructor), and should have | |
34 * been windowed as necessary by the caller (but not fft-shifted). | |
35 * | |
36 * mag, phase, and unwrapped must each be non-NULL and point to | |
37 * enough space for size/2 + 1 values. The redundant conjugate | |
38 * half of the output is not returned. | |
39 */ | |
40 void processTimeDomain(const double *src, | |
41 double *mag, double *phase, double *unwrapped); | |
42 | |
43 /** | |
44 * Given one frame of frequency-domain samples, return the | |
45 * magnitudes, instantaneous phases, and unwrapped phases. | |
46 * | |
47 * reals and imags must each contain size/2+1 values (where size | |
48 * is the frame size value as passed to the PhaseVocoder | |
49 * constructor). | |
50 * | |
51 * mag, phase, and unwrapped must each be non-NULL and point to | |
52 * enough space for size/2+1 values. | |
53 */ | |
54 void processFrequencyDomain(const double *reals, const double *imags, | |
55 double *mag, double *phase, double *unwrapped); | |
56 | |
57 /** | |
58 * Reset the stored phases to zero. Note that this may be | |
59 * necessary occasionally (depending on the application) to avoid | |
60 * loss of floating-point precision in the accumulated unwrapped | |
61 * phase values as they grow. | |
62 */ | |
63 void reset(); | |
28 | 64 |
29 protected: | 65 protected: |
30 void getPhase(unsigned int size, double *theta, double *real, double *imag); | 66 void FFTShift(double *src); |
31 // void coreFFT( unsigned int NumSamples, double *RealIn, double* ImagIn, double *RealOut, double *ImagOut); | 67 void getMagnitudes(double *mag); |
32 void getMagnitude( unsigned int size, double* mag, double* real, double* imag); | 68 void getPhases(double *theta); |
33 void FFTShift( unsigned int size, double* src); | 69 void unwrapPhases(double *theta, double *unwrapped); |
34 | 70 |
35 unsigned int m_n; | 71 int m_n; |
72 int m_hop; | |
36 FFTReal *m_fft; | 73 FFTReal *m_fft; |
37 double *m_imagOut; | 74 double *m_time; |
38 double *m_realOut; | 75 double *m_imag; |
39 | 76 double *m_real; |
77 double *m_phase; | |
78 double *m_unwrapped; | |
40 }; | 79 }; |
41 | 80 |
42 #endif | 81 #endif |