Mercurial > hg > qm-dsp
diff 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 |
line wrap: on
line diff
--- a/dsp/chromagram/Chromagram.cpp Tue Nov 25 16:00:05 2008 +0000 +++ b/dsp/chromagram/Chromagram.cpp Thu Dec 04 11:59:29 2008 +0000 @@ -15,7 +15,8 @@ //---------------------------------------------------------------------------- -Chromagram::Chromagram( ChromaConfig Config ) +Chromagram::Chromagram( ChromaConfig Config ) : + m_skGenerated(false) { initialise( Config ); } @@ -62,8 +63,6 @@ m_window = 0; m_windowbuf = 0; - // Generate CQ Kernel - m_ConstantQ->sparsekernel(); return 1; } @@ -119,6 +118,12 @@ double* Chromagram::process( const double *data ) { + if (!m_skGenerated) { + // Generate CQ Kernel + m_ConstantQ->sparsekernel(); + m_skGenerated = true; + } + if (!m_window) { m_window = new Window<double>(HammingWindow, m_frameSize); m_windowbuf = new double[m_frameSize]; @@ -137,6 +142,12 @@ double* Chromagram::process( const double *real, const double *imag ) { + if (!m_skGenerated) { + // Generate CQ Kernel + m_ConstantQ->sparsekernel(); + m_skGenerated = true; + } + // initialise chromadata to 0 for (unsigned i = 0; i < m_BPO; i++) m_chromadata[i] = 0;