Mercurial > hg > qm-dsp
comparison dsp/keydetection/GetKeyMode.cpp @ 456:05378924b433
Fix a rounding issue, returning key value 25
The two bins above center B minor are treated as 25. This patch shifts also
the input chromagram by 2 to have center C on 1 like the profiles
| author | Daniel Schürmann <daschuer@mixxx.org> |
|---|---|
| date | Sat, 11 May 2019 02:08:22 +0200 |
| parents | f5b5f64835b9 |
| children | 8a8cf7296e58 |
comparison
equal
deleted
inserted
replaced
| 450:d20dafd127b3 | 456:05378924b433 |
|---|---|
| 175 ////////////////////////////////////////////// | 175 ////////////////////////////////////////////// |
| 176 m_Decimator->process( PCMData, m_DecimatedBuffer); | 176 m_Decimator->process( PCMData, m_DecimatedBuffer); |
| 177 | 177 |
| 178 m_ChrPointer = m_Chroma->process( m_DecimatedBuffer ); | 178 m_ChrPointer = m_Chroma->process( m_DecimatedBuffer ); |
| 179 | 179 |
| 180 | 180 // The Cromagram has the center of C at bin 0, while the major |
| 181 // Move bins such that the centre of the base note is in the | 181 // and minor profiles have the center of C at 1. We want to have |
| 182 // middle of its three bins : | 182 // the correlation for C result also at 1. |
| 183 // Added 21.11.07 by Chris Sutton based on debugging with Katy | 183 // To achieve this we have to shift two times: |
| 184 // Noland + comparison with Matlab equivalent. | 184 MathUtilities::circShift( m_ChrPointer, m_BPO, 2); |
| 185 MathUtilities::circShift( m_ChrPointer, m_BPO, 1); | |
| 186 /* | 185 /* |
| 187 std::cout << "raw chroma: "; | 186 std::cout << "raw chroma: "; |
| 188 for (int ii = 0; ii < m_BPO; ++ii) { | 187 for (int ii = 0; ii < m_BPO; ++ii) { |
| 189 if (ii % (m_BPO/12) == 0) std::cout << "\n"; | 188 if (ii % (m_BPO/12) == 0) std::cout << "\n"; |
| 190 std::cout << m_ChrPointer[ii] << " "; | 189 std::cout << m_ChrPointer[ii] << " "; |
| 264 std::cout << m_keyStrengths[ii] << " "; | 263 std::cout << m_keyStrengths[ii] << " "; |
| 265 } | 264 } |
| 266 std::cout << std::endl; | 265 std::cout << std::endl; |
| 267 */ | 266 */ |
| 268 double dummy; | 267 double dummy; |
| 269 // '1 +' because we number keys 1-24, not 0-23. | 268 // m_Keys[1] is C center 1 / 3 + 1 = 1 |
| 270 key = 1 + (int)ceil( (double)MathUtilities::getMax( m_Keys, 2* m_BPO, &dummy )/3 ); | 269 // m_Keys[4] is D center 4 / 3 + 1 = 2 |
| 270 // '+ 1' because we number keys 1-24, not 0-23. | |
| 271 key = MathUtilities::getMax( m_Keys, 2* m_BPO, &dummy ) / 3 + 1; | |
| 271 | 272 |
| 272 // std::cout << "key pre-sorting: " << key << std::endl; | 273 // std::cout << "key pre-sorting: " << key << std::endl; |
| 273 | 274 |
| 274 | 275 |
| 275 //Median filtering | 276 //Median filtering |
