Mercurial > hg > qm-dsp
comparison dsp/chromagram/Chromagram.cpp @ 466:46375e6d1b54
Apply fix from daschuer/mixxx:b9c6bde3 Extend the number of Q bins always to a full octave
author | Chris Cannam <cannam@all-day-breakfast.com> |
---|---|
date | Wed, 29 May 2019 14:08:43 +0100 |
parents | 50a97c8d52ed |
children | 1db23b9a8da4 |
comparison
equal
deleted
inserted
replaced
465:50a97c8d52ed | 466:46375e6d1b54 |
---|---|
31 m_FMin = Config.min; // min freq | 31 m_FMin = Config.min; // min freq |
32 m_FMax = Config.max; // max freq | 32 m_FMax = Config.max; // max freq |
33 m_BPO = Config.BPO; // bins per octave | 33 m_BPO = Config.BPO; // bins per octave |
34 m_normalise = Config.normalise; // if frame normalisation is required | 34 m_normalise = Config.normalise; // if frame normalisation is required |
35 | 35 |
36 // No. of constant Q bins | 36 // No. of constant Q bins, extended to a full octave |
37 m_uK = (int) ceil( m_BPO * log(m_FMax/m_FMin)/log(2.0)); | 37 m_uK = m_BPO * int(ceil(log(m_FMax/m_FMin)/log(2.0))); |
38 | 38 |
39 // Create array for chroma result | 39 // Create array for chroma result |
40 m_chromadata = new double[ m_BPO ]; | 40 m_chromadata = new double[ m_BPO ]; |
41 | 41 |
42 // Create Config Structure for ConstantQ operator | 42 // Create Config Structure for ConstantQ operator |
157 | 157 |
158 // Calculate ConstantQ frame | 158 // Calculate ConstantQ frame |
159 m_ConstantQ->process( real, imag, m_CQRe, m_CQIm ); | 159 m_ConstantQ->process( real, imag, m_CQRe, m_CQIm ); |
160 | 160 |
161 // add each octave of cq data into Chromagram | 161 // add each octave of cq data into Chromagram |
162 const int octaves = (int)floor(double( m_uK/m_BPO))-1; | 162 const int octaves = m_uK / m_BPO; |
163 for (int octave = 0; octave <= octaves; octave++) | 163 for (int octave = 0; octave < octaves; octave++) |
164 { | 164 { |
165 int firstBin = octave*m_BPO; | 165 int firstBin = octave*m_BPO; |
166 for (int i = 0; i < m_BPO; i++) | 166 for (int i = 0; i < m_BPO; i++) |
167 { | 167 { |
168 m_chromadata[i] += kabs( m_CQRe[ firstBin + i ], m_CQIm[ firstBin + i ]); | 168 m_chromadata[i] += kabs( m_CQRe[ firstBin + i ], m_CQIm[ firstBin + i ]); |