comparison src/ConstantQ.cpp @ 127:8996465e39fc

Expose some more processing parameters, use a single parameter class
author Chris Cannam <c.cannam@qmul.ac.uk>
date Fri, 16 May 2014 10:12:03 +0100
parents 2375457f2876
children 9bdabd830609
comparison
equal deleted inserted replaced
126:b87290781071 127:8996465e39fc
45 using std::cerr; 45 using std::cerr;
46 using std::endl; 46 using std::endl;
47 47
48 //#define DEBUG_CQ 1 48 //#define DEBUG_CQ 1
49 49
50 ConstantQ::ConstantQ(double sampleRate, 50 ConstantQ::ConstantQ(CQParameters params) :
51 double minFreq, 51 m_inparams(params),
52 double maxFreq, 52 m_sampleRate(params.sampleRate),
53 int binsPerOctave) : 53 m_maxFrequency(params.maxFrequency),
54 m_sampleRate(sampleRate), 54 m_minFrequency(params.minFrequency),
55 m_maxFrequency(maxFreq), 55 m_binsPerOctave(params.binsPerOctave),
56 m_minFrequency(minFreq),
57 m_binsPerOctave(binsPerOctave),
58 m_fft(0) 56 m_fft(0)
59 { 57 {
60 if (minFreq <= 0.0 || maxFreq <= 0.0) { 58 if (m_minFrequency <= 0.0 || m_maxFrequency <= 0.0) {
61 throw std::invalid_argument("Frequency extents must be positive"); 59 throw std::invalid_argument("Frequency extents must be positive");
62 } 60 }
63 61
64 initialise(); 62 initialise();
65 } 63 }
87 85
88 void 86 void
89 ConstantQ::initialise() 87 ConstantQ::initialise()
90 { 88 {
91 m_octaves = int(ceil(log2(m_maxFrequency / m_minFrequency))); 89 m_octaves = int(ceil(log2(m_maxFrequency / m_minFrequency)));
92 m_kernel = new CQKernel(m_sampleRate, m_maxFrequency, m_binsPerOctave); 90 m_kernel = new CQKernel(m_inparams);
93 m_p = m_kernel->getProperties(); 91 m_p = m_kernel->getProperties();
94 92
95 // Use exact powers of two for resampling rates. They don't have 93 // Use exact powers of two for resampling rates. They don't have
96 // to be related to our actual samplerate: the resampler only 94 // to be related to our actual samplerate: the resampler only
97 // cares about the ratio, but it only accepts integer source and 95 // cares about the ratio, but it only accepts integer source and