|
Constant-Q Library
|
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 CQ_KERNEL_H 00033 #define CQ_KERNEL_H 00034 00035 #include "CQParameters.h" 00036 00037 #include <vector> 00038 #include <complex> 00039 00040 class FFT; 00041 00042 class CQKernel 00043 { 00044 public: 00045 CQKernel(CQParameters params); 00046 ~CQKernel(); 00047 00048 bool isValid() const { return m_valid; } 00049 00050 struct Properties { 00051 double sampleRate; 00052 double maxFrequency; 00053 double minFrequency; 00054 int binsPerOctave; 00055 int fftSize; 00056 int fftHop; 00057 int atomsPerFrame; 00058 int atomSpacing; 00059 int firstCentre; 00060 int lastCentre; 00061 double Q; 00062 }; 00063 00064 Properties getProperties() const { return m_p; } 00065 00066 std::vector<std::complex<double> > processForward 00067 (const std::vector<std::complex<double> > &); 00068 00069 std::vector<std::complex<double> > processInverse 00070 (const std::vector<std::complex<double> > &); 00071 00072 private: 00073 const CQParameters m_inparams; 00074 Properties m_p; 00075 bool m_valid; 00076 FFT *m_fft; 00077 00078 struct KernelMatrix { 00079 std::vector<int> origin; 00080 std::vector<std::vector<std::complex<double> > > data; 00081 }; 00082 KernelMatrix m_kernel; 00083 00084 std::vector<double> makeWindow(int len) const; 00085 bool generateKernel(); 00086 void finaliseKernel(); 00087 }; 00088 00089 #endif
1.7.6.1