Mercurial > hg > silvet
comparison src/Silvet.cpp @ 294:19fd6cb033c7
Add pitch activation matrix output
author | Chris Cannam |
---|---|
date | Wed, 15 Oct 2014 17:40:20 +0100 |
parents | 8aff275f16b5 |
children | aa7be9d8112e |
comparison
equal
deleted
inserted
replaced
293:71bef111e130 | 294:19fd6cb033c7 |
---|---|
247 d.unit = ""; | 247 d.unit = ""; |
248 d.hasFixedBinCount = true; | 248 d.hasFixedBinCount = true; |
249 d.binCount = m_instruments[0].templateHeight; | 249 d.binCount = m_instruments[0].templateHeight; |
250 d.binNames.clear(); | 250 d.binNames.clear(); |
251 if (m_cq) { | 251 if (m_cq) { |
252 char name[20]; | 252 char name[50]; |
253 for (int i = 0; i < m_instruments[0].templateHeight; ++i) { | 253 for (int i = 0; i < m_instruments[0].templateHeight; ++i) { |
254 // We have a 600-bin (10 oct 60-bin CQ) of which the | 254 // We have a 600-bin (10 oct 60-bin CQ) of which the |
255 // lowest-frequency 55 bins have been dropped, for a | 255 // lowest-frequency 55 bins have been dropped, for a |
256 // 545-bin template. The native CQ bins go high->low | 256 // 545-bin template. The native CQ bins go high->low |
257 // frequency though, so these are still the first 545 bins | 257 // frequency though, so these are still the first 545 bins |
266 d.isQuantized = false; | 266 d.isQuantized = false; |
267 d.sampleType = OutputDescriptor::FixedSampleRate; | 267 d.sampleType = OutputDescriptor::FixedSampleRate; |
268 d.sampleRate = m_colsPerSec; | 268 d.sampleRate = m_colsPerSec; |
269 d.hasDuration = false; | 269 d.hasDuration = false; |
270 m_fcqOutputNo = list.size(); | 270 m_fcqOutputNo = list.size(); |
271 list.push_back(d); | |
272 | |
273 d.identifier = "pitchactivation"; | |
274 d.name = "Pitch activation distribution"; | |
275 d.description = "Pitch activation distribution resulting from expectation-maximisation algorithm, prior to note extraction."; | |
276 d.unit = ""; | |
277 d.hasFixedBinCount = true; | |
278 d.binCount = m_instruments[0].templateNoteCount; | |
279 d.binNames.clear(); | |
280 if (m_cq) { | |
281 for (int i = 0; i < m_instruments[0].templateNoteCount; ++i) { | |
282 d.binNames.push_back(noteName(i, 0, 1)); | |
283 } | |
284 } | |
285 d.hasKnownExtents = false; | |
286 d.isQuantized = false; | |
287 d.sampleType = OutputDescriptor::FixedSampleRate; | |
288 d.sampleRate = m_colsPerSec; | |
289 d.hasDuration = false; | |
290 m_pitchOutputNo = list.size(); | |
271 list.push_back(d); | 291 list.push_back(d); |
272 | 292 |
273 return list; | 293 return list; |
274 } | 294 } |
275 | 295 |
567 m_pianoRollShifts.push_back(map<int, int>()); | 587 m_pianoRollShifts.push_back(map<int, int>()); |
568 } | 588 } |
569 continue; | 589 continue; |
570 } | 590 } |
571 | 591 |
572 postProcess(localPitches[i], localBestShifts[i], wantShifts); | 592 vector<double> filtered = postProcess |
593 (localPitches[i], localBestShifts[i], wantShifts); | |
594 | |
595 Feature f; | |
596 for (int j = 0; j < (int)filtered.size(); ++j) { | |
597 float v(filtered[j]); | |
598 if (v < pack.levelThreshold) v = 0.f; | |
599 f.values.push_back(v); | |
600 } | |
601 fs[m_pitchOutputNo].push_back(f); | |
573 | 602 |
574 FeatureList noteFeatures = noteTrack(shiftCount); | 603 FeatureList noteFeatures = noteTrack(shiftCount); |
575 | 604 |
576 for (FeatureList::const_iterator fi = noteFeatures.begin(); | 605 for (FeatureList::const_iterator fi = noteFeatures.begin(); |
577 fi != noteFeatures.end(); ++fi) { | 606 fi != noteFeatures.end(); ++fi) { |
664 } | 693 } |
665 | 694 |
666 return out; | 695 return out; |
667 } | 696 } |
668 | 697 |
669 void | 698 vector<double> |
670 Silvet::postProcess(const vector<double> &pitches, | 699 Silvet::postProcess(const vector<double> &pitches, |
671 const vector<int> &bestShifts, | 700 const vector<int> &bestShifts, |
672 bool wantShifts) | 701 bool wantShifts) |
673 { | 702 { |
674 const InstrumentPack &pack = m_instruments[m_instrument]; | 703 const InstrumentPack &pack = m_instruments[m_instrument]; |
714 m_pianoRoll.push_back(active); | 743 m_pianoRoll.push_back(active); |
715 | 744 |
716 if (wantShifts) { | 745 if (wantShifts) { |
717 m_pianoRollShifts.push_back(activeShifts); | 746 m_pianoRollShifts.push_back(activeShifts); |
718 } | 747 } |
748 | |
749 return filtered; | |
719 } | 750 } |
720 | 751 |
721 Vamp::Plugin::FeatureList | 752 Vamp::Plugin::FeatureList |
722 Silvet::noteTrack(int shiftCount) | 753 Silvet::noteTrack(int shiftCount) |
723 { | 754 { |