Skip to content

Commit

Permalink
Extend the number of Q bins always to a full octave
Browse files Browse the repository at this point in the history
  • Loading branch information
daschuer committed May 12, 2019
1 parent 957aed5 commit b9c6bde
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 4 additions & 4 deletions lib/qm-dsp/dsp/chromagram/Chromagram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ int Chromagram::initialise( ChromaConfig Config )
m_BPO = Config.BPO; // bins per octave
m_normalise = Config.normalise; // if frame normalisation is required

// No. of constant Q bins
m_uK = ( unsigned int ) ceil( m_BPO * log(m_FMax/m_FMin)/log(2.0));
// No. of constant Q bins, extended to a full cotave
m_uK = m_BPO * (unsigned int)ceil(log(m_FMax/m_FMin)/log(2.0));

// Create array for chroma result
m_chromadata = new double[ m_BPO ];
Expand Down Expand Up @@ -159,8 +159,8 @@ double* Chromagram::process( const double *real, const double *imag )
m_ConstantQ->process( real, imag, m_CQRe, m_CQIm );

// add each octave of cq data into Chromagram
const unsigned octaves = (int)floor(double( m_uK/m_BPO))-1;
for (unsigned octave = 0; octave <= octaves; octave++)
const unsigned octaves = m_uK / m_BPO;
for (unsigned octave = 0; octave < octaves; octave++)
{
unsigned firstBin = octave * m_BPO;
for (unsigned i = 0; i < m_BPO; i++)
Expand Down
6 changes: 4 additions & 2 deletions lib/qm-dsp/dsp/chromagram/ConstantQ.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,10 @@ void ConstantQ::initialise( CQConfig Config )
m_BPO = Config.BPO; // bins per octave
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 = (unsigned int) ceil(m_BPO * log(m_FMax/m_FMin)/log(2.0)); // No. of constant Q bins
// Work out Q value for Filter bank
m_dQ = 1/(pow(2,(1/(double)m_BPO))-1);
// No. of constant Q bins, extended to a full cotave
m_uK = m_BPO * (unsigned int)ceil(log(m_FMax/m_FMin)/log(2.0));

// std::cerr << "ConstantQ::initialise: rate = " << m_FS << ", fmin = " << m_FMin << ", fmax = " << m_FMax << ", bpo = " << m_BPO << ", K = " << m_uK << ", Q = " << m_dQ << std::endl;

Expand Down

0 comments on commit b9c6bde

Please sign in to comment.