Mercurial > hg > qm-vamp-plugins
comparison plugins/KeyDetect.cpp @ 247:e6abd6e99051
This is not actually a tonic-strength output - it's a key-strength output in which the relative major and minor (which have different tonics but the same key signatures) have been summed into a single bin
author | Chris Cannam <cannam@all-day-breakfast.com> |
---|---|
date | Thu, 26 Sep 2019 15:44:47 +0100 |
parents | a3612b821a0b |
children | 73c9922fb649 |
comparison
equal
deleted
inserted
replaced
246:2426f4d30cad | 247:e6abd6e99051 |
---|---|
296 true); | 296 true); |
297 d.binNames.push_back(label); | 297 d.binNames.push_back(label); |
298 } | 298 } |
299 list.push_back(d); | 299 list.push_back(d); |
300 | 300 |
301 d.identifier = "tonicstrength"; | 301 d.identifier = "mergedkeystrength"; |
302 d.name = "Tonic Strength Plot"; | 302 d.name = "Merged Key Strength Plot"; |
303 d.unit = ""; | 303 d.unit = ""; |
304 d.description = "Correlation of the chroma vector with stored key profile for each tonic pitch across both major and minor mode"; | 304 d.description = "Correlation of the chroma vector with stored key profile for each key, with major and minor alternatives merged"; |
305 d.hasFixedBinCount = true; | 305 d.hasFixedBinCount = true; |
306 d.binCount = 12; | 306 d.binCount = 12; |
307 d.hasKnownExtents = false; | 307 d.hasKnownExtents = false; |
308 d.isQuantized = false; | 308 d.isQuantized = false; |
309 d.sampleType = OutputDescriptor::OneSamplePerStep; | 309 d.sampleType = OutputDescriptor::OneSamplePerStep; |
310 d.binNames.clear(); | 310 d.binNames.clear(); |
311 for (int i = 0; i < 12; ++i) { | 311 for (int i = 0; i < 12; ++i) { |
312 int idx = conversion[i]; | 312 int idx = conversion[i]; |
313 std::string label = getKeyName(idx > 12 ? idx-12 : idx, | 313 std::string label = getBothKeyNames(idx > 12 ? idx-12 : idx); |
314 i >= 12, | |
315 false); | |
316 d.binNames.push_back(label); | 314 d.binNames.push_back(label); |
317 } | 315 } |
318 list.push_back(d); | 316 list.push_back(d); |
319 | 317 |
320 return list; | 318 return list; |
462 | 460 |
463 if (minor) return base + " minor"; | 461 if (minor) return base + " minor"; |
464 else return base + " major"; | 462 else return base + " major"; |
465 } | 463 } |
466 | 464 |
465 std::string | |
466 KeyDetector::getBothKeyNames(int index) const | |
467 { | |
468 // Keys are numbered with 1 => C, 12 => B | |
469 | |
470 static const char *names[] = { | |
471 "C maj / A min", | |
472 "Db maj / Bb min", | |
473 "D maj / B min", | |
474 "Eb maj / C min", | |
475 "E maj / C# min", | |
476 "F maj / D min", | |
477 "F#/Gb maj / Eb/D# min", | |
478 "G maj / E min", | |
479 "Ab maj / F min", | |
480 "A maj / F# min", | |
481 "Bb maj / G min", | |
482 "B maj / G# min" | |
483 }; | |
484 | |
485 if (index < 1 || index > 12) { | |
486 return "(unknown)"; | |
487 } | |
488 | |
489 return names[index - 1]; | |
490 } | |
491 | |
492 |