Mercurial > hg > qm-vamp-plugins
changeset 244:ed249a345715
Add tonic strength output, like key strength but without separating major/minor
author | Chris Cannam <cannam@all-day-breakfast.com> |
---|---|
date | Mon, 12 Aug 2019 15:00:45 +0100 |
parents | 2e12b4a3c47d |
children | a3612b821a0b |
files | plugins/KeyDetect.cpp |
diffstat | 1 files changed, 38 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/KeyDetect.cpp Thu Jun 06 14:27:02 2019 +0100 +++ b/plugins/KeyDetect.cpp Mon Aug 12 15:00:45 2019 +0100 @@ -74,7 +74,7 @@ int KeyDetector::getPluginVersion() const { - return 5; + return 6; } string @@ -131,7 +131,7 @@ return m_tuningFrequency; } if (param == "length") { - return m_length; + return float(m_length); } if (param == "rapid") { return m_rapid ? 1.f : 0.f; @@ -230,7 +230,7 @@ float osr = 0.0f; if (m_stepSize == 0) (void)getPreferredStepSize(); - osr = m_inputSampleRate / m_stepSize; + osr = m_inputSampleRate / float(m_stepSize); OutputDescriptor d; d.identifier = "tonic"; @@ -297,6 +297,24 @@ } list.push_back(d); + d.identifier = "tonicstrength"; + d.name = "Tonic Strength Plot"; + d.unit = ""; + d.description = "Correlation of the chroma vector with stored key profile for each tonic pitch across both major and minor mode"; + d.hasFixedBinCount = true; + d.binCount = 12; + d.hasKnownExtents = false; + d.isQuantized = false; + d.sampleType = OutputDescriptor::OneSamplePerStep; + for (int i = 0; i < 12; ++i) { + int idx = conversion[i]; + std::string label = getKeyName(idx > 12 ? idx-12 : idx, + i >= 12, + false); + d.binNames.push_back(label); + } + list.push_back(d); + return list; } @@ -356,14 +374,29 @@ m_first = false; Feature ksf; + ksf.hasTimestamp = false; ksf.values.reserve(25); + + Feature tsf; + tsf.hasTimestamp = false; + tsf.values.reserve(12); + double *keystrengths = m_getKeyMode->getKeyStrengths(); + for (int i = 0; i < 24; ++i) { + if (i == 12) ksf.values.push_back(-1); - ksf.values.push_back(keystrengths[conversion[i]-1]); + ksf.values.push_back(float(keystrengths[conversion[i]-1])); + + if (i < 12) { + tsf.values.push_back(float(keystrengths[conversion[i]-1])); + } else { + tsf.values[i-12] += float(keystrengths[conversion[i]-1]); + } } - ksf.hasTimestamp = false; + returnFeatures[3].push_back(ksf); + returnFeatures[4].push_back(tsf); return returnFeatures; }