comparison cq/CQInverse.h @ 147:1060a19e2334

Report validity of CQKernel construction, and avoid NaN values for invalid parameters. Also documentation.
author Chris Cannam <c.cannam@qmul.ac.uk>
date Thu, 10 Jul 2014 12:19:39 +0100
parents ff8ae033615f
children
comparison
equal deleted inserted replaced
146:0cbd9c904dbb 147:1060a19e2334
36 #include "CQKernel.h" 36 #include "CQKernel.h"
37 37
38 class Resampler; 38 class Resampler;
39 class FFTReal; 39 class FFTReal;
40 40
41 /**
42 * Calculate an inverse constant-Q transform. The input must be the
43 * same representation as returned as output of a \ref ConstantQ
44 * object with the same parameters. The output is a time-domain
45 * signal.
46 *
47 * Note that you cannot perform an inverse transform from the
48 * magnitude-only output of \ref CQSpectrogram; you need the complex
49 * valued data from \ref ConstantQ.
50 *
51 * Our implementation of the Constant-Q transform is not exactly
52 * invertible, and this produces only an approximation of the original
53 * signal (see publications for details).
54 */
41 class CQInverse : public CQBase 55 class CQInverse : public CQBase
42 { 56 {
43 public: 57 public:
58 /**
59 * Construct an inverse Constant-Q transform object using the
60 * given transform parameters.
61 */
44 CQInverse(CQParameters params); 62 CQInverse(CQParameters params);
45 virtual ~CQInverse(); 63 virtual ~CQInverse();
46 64
65 // CQBase methods, see CQBase.h for documentation
66 virtual bool isValid() const { return m_kernel && m_kernel->isValid(); }
47 virtual double getSampleRate() const { return m_sampleRate; } 67 virtual double getSampleRate() const { return m_sampleRate; }
48 virtual int getBinsPerOctave() const { return m_binsPerOctave; } 68 virtual int getBinsPerOctave() const { return m_binsPerOctave; }
49 virtual int getOctaves() const { return m_octaves; } 69 virtual int getOctaves() const { return m_octaves; }
50 virtual int getTotalBins() const { return m_octaves * m_binsPerOctave; } 70 virtual int getTotalBins() const { return m_octaves * m_binsPerOctave; }
51 virtual int getColumnHop() const { return m_p.fftHop / m_p.atomsPerFrame; } 71 virtual int getColumnHop() const { return m_p.fftHop / m_p.atomsPerFrame; }
52 virtual int getLatency() const { return m_outputLatency; } 72 virtual int getLatency() const { return m_outputLatency; }
53 virtual double getMaxFrequency() const { return m_p.maxFrequency; } 73 virtual double getMaxFrequency() const { return m_p.maxFrequency; }
54 virtual double getMinFrequency() const; // actual min, not that passed to ctor 74 virtual double getMinFrequency() const; // actual min, not that passed to ctor
55 virtual double getBinFrequency(double bin) const; 75 virtual double getBinFrequency(double bin) const;
56 76
57 // Input is the format produced by ConstantQ class, 77 /**
58 // i.e. uninterpolated complex, not the real-valued stuff produced 78 * Given a series of constant-Q columns in the form produced by
59 // by CQSpectrogram 79 * the \ref ConstantQ class, return a series of time-domain
80 * samples resulting from approximately inverting the constant-Q
81 * transform.
82 */
83 RealSequence process(const ComplexBlock &);
60 84
61 RealSequence process(const ComplexBlock &); 85 /**
86 * Return the remaining time-domain samples following the end of
87 * processing.
88 */
62 RealSequence getRemainingOutput(); 89 RealSequence getRemainingOutput();
63 90
64 private: 91 private:
65 const CQParameters m_inparams; 92 const CQParameters m_inparams;
66 const double m_sampleRate; 93 const double m_sampleRate;