Constant-Q Library
cq/CQInverse.h
Go to the documentation of this file.
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
00002 /*
00003     Constant-Q library
00004     Copyright (c) 2013-2014 Queen Mary, University of London
00005 
00006     Permission is hereby granted, free of charge, to any person
00007     obtaining a copy of this software and associated documentation
00008     files (the "Software"), to deal in the Software without
00009     restriction, including without limitation the rights to use, copy,
00010     modify, merge, publish, distribute, sublicense, and/or sell copies
00011     of the Software, and to permit persons to whom the Software is
00012     furnished to do so, subject to the following conditions:
00013 
00014     The above copyright notice and this permission notice shall be
00015     included in all copies or substantial portions of the Software.
00016 
00017     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00018     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00019     MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00020     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
00021     CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
00022     CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00023     WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00024 
00025     Except as contained in this notice, the names of the Centre for
00026     Digital Music; Queen Mary, University of London; and Chris Cannam
00027     shall not be used in advertising or otherwise to promote the sale,
00028     use or other dealings in this Software without prior written
00029     authorization.
00030 */
00031 
00032 #ifndef CQINVERSE_H
00033 #define CQINVERSE_H
00034 
00035 #include "CQBase.h"
00036 #include "CQKernel.h"
00037 
00038 class Resampler;
00039 class FFTReal;
00040 
00055 class CQInverse : public CQBase
00056 {
00057 public:
00062     CQInverse(CQParameters params);
00063     virtual ~CQInverse();
00064 
00065     // CQBase methods, see CQBase.h for documentation
00066     virtual bool isValid() const { return m_kernel && m_kernel->isValid(); }
00067     virtual double getSampleRate() const { return m_sampleRate; }
00068     virtual int getBinsPerOctave() const { return m_binsPerOctave; }
00069     virtual int getOctaves() const { return m_octaves; }
00070     virtual int getTotalBins() const { return m_octaves * m_binsPerOctave; }
00071     virtual int getColumnHop() const { return m_p.fftHop / m_p.atomsPerFrame; }
00072     virtual int getLatency() const { return m_outputLatency; } 
00073     virtual double getMaxFrequency() const { return m_p.maxFrequency; }
00074     virtual double getMinFrequency() const; // actual min, not that passed to ctor
00075     virtual double getBinFrequency(double bin) const;
00076 
00083     RealSequence process(const ComplexBlock &);
00084 
00089     RealSequence getRemainingOutput();
00090 
00091 private:
00092     const CQParameters m_inparams;
00093     const double m_sampleRate;
00094     const double m_maxFrequency;
00095     const double m_minFrequency;
00096     const int m_binsPerOctave;
00097 
00098     int m_octaves;
00099     CQKernel *m_kernel;
00100     CQKernel::Properties m_p;
00101 
00102     std::vector<Resampler *> m_upsamplers;
00103     std::vector<RealSequence> m_buffers;
00104     std::vector<RealSequence> m_olaBufs; // fixed-length, for overlap-add
00105     
00106     int m_outputLatency;
00107 
00108     FFTReal *m_fft;
00109     
00110     void initialise();
00111     void processOctave(int octave, const ComplexBlock &block);
00112     void processOctaveColumn(int octave, const ComplexColumn &column);
00113     void overlapAddAndResample(int octave, const RealSequence &);
00114     RealSequence drawFromBuffers();
00115 };
00116 
00117 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator