annotate cq/CQInverse.h @ 196:da283326bcd3 tip master

Update plugin versions in RDF
author Chris Cannam <cannam@all-day-breakfast.com>
date Fri, 28 Feb 2020 09:43:02 +0000
parents 1060a19e2334
children
rev   line source
c@116 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
c@116 2 /*
c@116 3 Constant-Q library
c@116 4 Copyright (c) 2013-2014 Queen Mary, University of London
c@116 5
c@116 6 Permission is hereby granted, free of charge, to any person
c@116 7 obtaining a copy of this software and associated documentation
c@116 8 files (the "Software"), to deal in the Software without
c@116 9 restriction, including without limitation the rights to use, copy,
c@116 10 modify, merge, publish, distribute, sublicense, and/or sell copies
c@116 11 of the Software, and to permit persons to whom the Software is
c@116 12 furnished to do so, subject to the following conditions:
c@116 13
c@116 14 The above copyright notice and this permission notice shall be
c@116 15 included in all copies or substantial portions of the Software.
c@116 16
c@116 17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
c@116 18 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
c@116 19 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
c@116 20 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
c@116 21 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
c@116 22 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
c@116 23 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
c@116 24
c@116 25 Except as contained in this notice, the names of the Centre for
c@116 26 Digital Music; Queen Mary, University of London; and Chris Cannam
c@116 27 shall not be used in advertising or otherwise to promote the sale,
c@116 28 use or other dealings in this Software without prior written
c@116 29 authorization.
c@116 30 */
c@116 31
c@116 32 #ifndef CQINVERSE_H
c@116 33 #define CQINVERSE_H
c@116 34
c@116 35 #include "CQBase.h"
c@116 36 #include "CQKernel.h"
c@116 37
c@116 38 class Resampler;
c@116 39 class FFTReal;
c@116 40
c@147 41 /**
c@147 42 * Calculate an inverse constant-Q transform. The input must be the
c@147 43 * same representation as returned as output of a \ref ConstantQ
c@147 44 * object with the same parameters. The output is a time-domain
c@147 45 * signal.
c@147 46 *
c@147 47 * Note that you cannot perform an inverse transform from the
c@147 48 * magnitude-only output of \ref CQSpectrogram; you need the complex
c@147 49 * valued data from \ref ConstantQ.
c@147 50 *
c@147 51 * Our implementation of the Constant-Q transform is not exactly
c@147 52 * invertible, and this produces only an approximation of the original
c@147 53 * signal (see publications for details).
c@147 54 */
c@116 55 class CQInverse : public CQBase
c@116 56 {
c@116 57 public:
c@147 58 /**
c@147 59 * Construct an inverse Constant-Q transform object using the
c@147 60 * given transform parameters.
c@147 61 */
c@127 62 CQInverse(CQParameters params);
c@116 63 virtual ~CQInverse();
c@116 64
c@147 65 // CQBase methods, see CQBase.h for documentation
c@147 66 virtual bool isValid() const { return m_kernel && m_kernel->isValid(); }
c@116 67 virtual double getSampleRate() const { return m_sampleRate; }
c@116 68 virtual int getBinsPerOctave() const { return m_binsPerOctave; }
c@116 69 virtual int getOctaves() const { return m_octaves; }
c@116 70 virtual int getTotalBins() const { return m_octaves * m_binsPerOctave; }
c@116 71 virtual int getColumnHop() const { return m_p.fftHop / m_p.atomsPerFrame; }
c@116 72 virtual int getLatency() const { return m_outputLatency; }
c@116 73 virtual double getMaxFrequency() const { return m_p.maxFrequency; }
c@116 74 virtual double getMinFrequency() const; // actual min, not that passed to ctor
c@145 75 virtual double getBinFrequency(double bin) const;
c@116 76
c@147 77 /**
c@147 78 * Given a series of constant-Q columns in the form produced by
c@147 79 * the \ref ConstantQ class, return a series of time-domain
c@147 80 * samples resulting from approximately inverting the constant-Q
c@147 81 * transform.
c@147 82 */
c@147 83 RealSequence process(const ComplexBlock &);
c@116 84
c@147 85 /**
c@147 86 * Return the remaining time-domain samples following the end of
c@147 87 * processing.
c@147 88 */
c@116 89 RealSequence getRemainingOutput();
c@116 90
c@116 91 private:
c@127 92 const CQParameters m_inparams;
c@127 93 const double m_sampleRate;
c@127 94 const double m_maxFrequency;
c@127 95 const double m_minFrequency;
c@127 96 const int m_binsPerOctave;
c@127 97
c@116 98 int m_octaves;
c@116 99 CQKernel *m_kernel;
c@116 100 CQKernel::Properties m_p;
c@116 101
c@116 102 std::vector<Resampler *> m_upsamplers;
c@116 103 std::vector<RealSequence> m_buffers;
c@116 104 std::vector<RealSequence> m_olaBufs; // fixed-length, for overlap-add
c@116 105
c@116 106 int m_outputLatency;
c@116 107
c@116 108 FFTReal *m_fft;
c@116 109
c@116 110 void initialise();
c@116 111 void processOctave(int octave, const ComplexBlock &block);
c@116 112 void processOctaveColumn(int octave, const ComplexColumn &column);
c@116 113 void overlapAddAndResample(int octave, const RealSequence &);
c@116 114 RealSequence drawFromBuffers();
c@116 115 };
c@116 116
c@116 117 #endif