comparison dsp/chromagram/Chromagram.cpp @ 276:4c901426b9f3

* Do not calculate CQ sparse kernel when chromagram is constructed: only when it's actually used * Pre-calculate CQ sparse kernels in the sizes required for the default configurations of some of our transforms
author Chris Cannam <c.cannam@qmul.ac.uk>
date Thu, 04 Dec 2008 11:59:29 +0000
parents c96785becf96
children 6cb2b3cd5356
comparison
equal deleted inserted replaced
275:cded679e12c2 276:4c901426b9f3
13 #include "maths/MathUtilities.h" 13 #include "maths/MathUtilities.h"
14 #include "Chromagram.h" 14 #include "Chromagram.h"
15 15
16 //---------------------------------------------------------------------------- 16 //----------------------------------------------------------------------------
17 17
18 Chromagram::Chromagram( ChromaConfig Config ) 18 Chromagram::Chromagram( ChromaConfig Config ) :
19 m_skGenerated(false)
19 { 20 {
20 initialise( Config ); 21 initialise( Config );
21 } 22 }
22 23
23 int Chromagram::initialise( ChromaConfig Config ) 24 int Chromagram::initialise( ChromaConfig Config )
60 m_CQIm = new double[ m_uK ]; 61 m_CQIm = new double[ m_uK ];
61 62
62 m_window = 0; 63 m_window = 0;
63 m_windowbuf = 0; 64 m_windowbuf = 0;
64 65
65 // Generate CQ Kernel
66 m_ConstantQ->sparsekernel();
67 return 1; 66 return 1;
68 } 67 }
69 68
70 Chromagram::~Chromagram() 69 Chromagram::~Chromagram()
71 { 70 {
117 } 116 }
118 117
119 118
120 double* Chromagram::process( const double *data ) 119 double* Chromagram::process( const double *data )
121 { 120 {
121 if (!m_skGenerated) {
122 // Generate CQ Kernel
123 m_ConstantQ->sparsekernel();
124 m_skGenerated = true;
125 }
126
122 if (!m_window) { 127 if (!m_window) {
123 m_window = new Window<double>(HammingWindow, m_frameSize); 128 m_window = new Window<double>(HammingWindow, m_frameSize);
124 m_windowbuf = new double[m_frameSize]; 129 m_windowbuf = new double[m_frameSize];
125 } 130 }
126 131
135 return process(m_FFTRe, m_FFTIm); 140 return process(m_FFTRe, m_FFTIm);
136 } 141 }
137 142
138 double* Chromagram::process( const double *real, const double *imag ) 143 double* Chromagram::process( const double *real, const double *imag )
139 { 144 {
145 if (!m_skGenerated) {
146 // Generate CQ Kernel
147 m_ConstantQ->sparsekernel();
148 m_skGenerated = true;
149 }
150
140 // initialise chromadata to 0 151 // initialise chromadata to 0
141 for (unsigned i = 0; i < m_BPO; i++) m_chromadata[i] = 0; 152 for (unsigned i = 0; i < m_BPO; i++) m_chromadata[i] = 0;
142 153
143 double cmax = 0.0; 154 double cmax = 0.0;
144 double cval = 0; 155 double cval = 0;