Mercurial > hg > qm-dsp
changeset 468:a72d98f8baa3
Revise mechanism for extending chromagram to round number of octaves -
do it only in the chromagram itself, so that we can still create deviant
constant-Q spectrograms if desired
author | Chris Cannam <cannam@all-day-breakfast.com> |
---|---|
date | Thu, 30 May 2019 11:35:35 +0100 |
parents | 1db23b9a8da4 |
children | 8d84e5d16314 |
files | dsp/chromagram/Chromagram.cpp dsp/chromagram/ConstantQ.cpp |
diffstat | 2 files changed, 8 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/dsp/chromagram/Chromagram.cpp Wed May 29 15:56:30 2019 +0100 +++ b/dsp/chromagram/Chromagram.cpp Thu May 30 11:35:35 2019 +0100 @@ -33,8 +33,9 @@ m_BPO = Config.BPO; // bins per octave m_normalise = Config.normalise; // if frame normalisation is required - // No. of constant Q bins, extended to a full octave - m_uK = m_BPO * int(ceil(log(m_FMax/m_FMin)/log(2.0))); + // Extend range to a full octave + double octaves = log(m_FMax / m_FMin) / log(2.0); + m_FMax = m_FMin * pow(2.0, ceil(octaves)); // Create array for chroma result m_chromadata = new double[ m_BPO ]; @@ -53,6 +54,9 @@ // Initialise ConstantQ operator m_ConstantQ = new ConstantQ( ConstantQConfig ); + // No. of constant Q bins + m_uK = m_ConstantQ->getK(); + // Initialise working arrays m_frameSize = m_ConstantQ->getfftlength(); m_hopSize = m_ConstantQ->gethop();
--- a/dsp/chromagram/ConstantQ.cpp Wed May 29 15:56:30 2019 +0100 +++ b/dsp/chromagram/ConstantQ.cpp Thu May 30 11:35:35 2019 +0100 @@ -293,14 +293,14 @@ m_CQThresh = Config.CQThresh;// ConstantQ threshold for kernel generation m_dQ = 1/(pow(2,(1/(double)m_BPO))-1); // Work out Q value for Filter bank - m_uK = m_BPO * int(ceil(log(m_FMax/m_FMin)/log(2.0))); // No. of constant Q bins, extended to a full octave + m_uK = (unsigned int) ceil(m_BPO * log(m_FMax/m_FMin)/log(2.0)); // No. of constant Q bins // std::cerr << "ConstantQ::initialise: rate = " << m_FS << ", fmin = " << m_FMin << ", fmax = " << m_FMax << ", bpo = " << m_BPO << ", K = " << m_uK << ", Q = " << m_dQ << std::endl; // work out length of fft required for this constant Q Filter bank m_FFTLength = (int) pow(2, nextpow2(ceil( m_dQ*m_FS/m_FMin ))); - m_hop = m_FFTLength/8; // <------ hop size is window length divided by 32 + m_hop = m_FFTLength/8; // std::cerr << "ConstantQ::initialise: -> fft length = " << m_FFTLength << ", hop = " << m_hop << std::endl;