Mercurial > hg > qm-vamp-plugins
comparison plugins/SimilarityPlugin.cpp @ 49:fc88b465548a
* Normalise type option for chromagram
* Minimum segment duration option for segmenter
* Bit more documentation
author | Chris Cannam <c.cannam@qmul.ac.uk> |
---|---|
date | Tue, 22 Jan 2008 17:27:48 +0000 |
parents | 3b4572153ce3 |
children | df7a0bc46592 |
comparison
equal
deleted
inserted
replaced
48:3b4572153ce3 | 49:fc88b465548a |
---|---|
16 #include "dsp/chromagram/Chromagram.h" | 16 #include "dsp/chromagram/Chromagram.h" |
17 #include "dsp/rateconversion/Decimator.h" | 17 #include "dsp/rateconversion/Decimator.h" |
18 #include "dsp/rhythm/BeatSpectrum.h" | 18 #include "dsp/rhythm/BeatSpectrum.h" |
19 #include "maths/KLDivergence.h" | 19 #include "maths/KLDivergence.h" |
20 #include "maths/CosineDistance.h" | 20 #include "maths/CosineDistance.h" |
21 #include "maths/MathUtilities.h" | |
21 | 22 |
22 using std::string; | 23 using std::string; |
23 using std::vector; | 24 using std::vector; |
24 using std::cerr; | 25 using std::cerr; |
25 using std::endl; | 26 using std::endl; |
175 config.FS = m_processRate; | 176 config.FS = m_processRate; |
176 config.min = Pitch::getFrequencyForPitch(24, 0, 440); | 177 config.min = Pitch::getFrequencyForPitch(24, 0, 440); |
177 config.max = Pitch::getFrequencyForPitch(96, 0, 440); | 178 config.max = Pitch::getFrequencyForPitch(96, 0, 440); |
178 config.BPO = 12; | 179 config.BPO = 12; |
179 config.CQThresh = 0.0054; | 180 config.CQThresh = 0.0054; |
180 config.isNormalised = true; | 181 // We don't normalise the chromagram's columns individually; |
182 // we normalise the mean at the end instead | |
183 config.normalise = MathUtilities::NormaliseNone; | |
181 m_chromagram = new Chromagram(config); | 184 m_chromagram = new Chromagram(config); |
182 m_fftSize = m_chromagram->getFrameSize(); | 185 m_fftSize = m_chromagram->getFrameSize(); |
183 | 186 |
184 std::cerr << "fftsize = " << m_fftSize << std::endl; | 187 std::cerr << "fftsize = " << m_fftSize << std::endl; |
185 | 188 |
271 config.FS = m_processRate; | 274 config.FS = m_processRate; |
272 config.min = Pitch::getFrequencyForPitch(24, 0, 440); | 275 config.min = Pitch::getFrequencyForPitch(24, 0, 440); |
273 config.max = Pitch::getFrequencyForPitch(96, 0, 440); | 276 config.max = Pitch::getFrequencyForPitch(96, 0, 440); |
274 config.BPO = 12; | 277 config.BPO = 12; |
275 config.CQThresh = 0.0054; | 278 config.CQThresh = 0.0054; |
276 config.isNormalised = false; | 279 config.normalise = MathUtilities::NormaliseNone; |
277 Chromagram *c = new Chromagram(config); | 280 Chromagram *c = new Chromagram(config); |
278 size_t sz = c->getFrameSize(); | 281 size_t sz = c->getFrameSize(); |
279 delete c; | 282 delete c; |
280 m_blockSize = sz * decimationFactor; | 283 m_blockSize = sz * decimationFactor; |
281 } else { | 284 } else { |
683 } | 686 } |
684 } | 687 } |
685 | 688 |
686 } else { | 689 } else { |
687 | 690 |
688 // Chroma are histograms already | 691 // We use the KL divergence for distributions of discrete |
692 // variables, as chroma are histograms already. Or at least, | |
693 // they will be when we've normalised them like this: | |
694 for (int i = 0; i < m_channels; ++i) { | |
695 MathUtilities::normalise(m[i], MathUtilities::NormaliseUnitSum); | |
696 } | |
689 | 697 |
690 KLDivergence kld; | 698 KLDivergence kld; |
691 | 699 |
692 for (int i = 0; i < m_channels; ++i) { | 700 for (int i = 0; i < m_channels; ++i) { |
693 for (int j = 0; j < m_channels; ++j) { | 701 for (int j = 0; j < m_channels; ++j) { |