Mercurial > hg > cepstral-pitchtracker
changeset 67:dd5ab48fd58a parameters mirex2013
Add "fill gaps" option, add new outputs to rdf
author | Chris Cannam |
---|---|
date | Fri, 30 Aug 2013 17:00:02 +0100 |
parents | 7ad142c710c6 |
children | f301e1578cec |
files | CepstralPitchTracker.cpp CepstralPitchTracker.h cepstral-pitchtracker.n3 |
diffstat | 3 files changed, 62 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/CepstralPitchTracker.cpp Fri Aug 30 15:35:49 2013 +0100 +++ b/CepstralPitchTracker.cpp Fri Aug 30 17:00:02 2013 +0100 @@ -53,6 +53,7 @@ m_slack(40), m_sensitivity(10), m_threshold(0.1), + m_fillGaps(false), m_binFrom(0), m_binTo(0), m_bins(0), @@ -172,6 +173,17 @@ d.isQuantized = false; list.push_back(d); + d.identifier = "fill"; + d.name = "Fill f0 gaps within a note"; + d.description = "Return an f0 value for every frame within each discovered note, interpolating results into any gaps in the measurement"; + d.unit = ""; //!!! todo: convert this threshold to a meaningful unit! + d.minValue = 0; + d.maxValue = 1; + d.defaultValue = 0; + d.isQuantized = true; + d.quantizeStep = 1; + list.push_back(d); + return list; } @@ -181,6 +193,7 @@ if (identifier == "sensitivity") return m_sensitivity; else if (identifier == "slack") return m_slack; else if (identifier == "threshold") return m_threshold; + else if (identifier == "fill") return (m_fillGaps ? 1 : 0); return 0.f; } @@ -190,6 +203,7 @@ if (identifier == "sensitivity") m_sensitivity = value; else if (identifier == "slack") m_slack = value; else if (identifier == "threshold") m_threshold = value; + else if (identifier == "fill") m_fillGaps = (value > 0.5); } CepstralPitchTracker::ProgramList @@ -308,19 +322,44 @@ CepstralPitchTracker::addFeaturesFrom(NoteHypothesis h, FeatureSet &fs) { NoteHypothesis::Estimates es = h.getAcceptedEstimates(); + NoteHypothesis::Note n = h.getAveragedNote(); - for (int i = 0; i < (int)es.size(); ++i) { - Feature f; - f.hasTimestamp = true; - f.timestamp = es[i].time; - f.values.push_back(es[i].freq); - fs[0].push_back(f); + if (!m_fillGaps) { + + for (int i = 0; i < (int)es.size(); ++i) { + Feature f; + f.hasTimestamp = true; + f.timestamp = es[i].time; + f.values.push_back(es[i].freq); + fs[0].push_back(f); + } + + } else { + + int ix = 0; + RealTime increment = RealTime::frame2RealTime + (m_stepSize, m_inputSampleRate); + + float freq = 0; + + for (RealTime t = n.time; t < n.time + n.duration; t = t + increment) { + if (ix < (int)es.size() && t >= es[ix].time) { + freq = es[ix].freq; + ++ix; + } + if (freq > 0) { + Feature f; + f.hasTimestamp = true; + f.timestamp = t; + f.values.push_back(freq); + fs[0].push_back(f); + } + } } Feature nf; nf.hasTimestamp = true; nf.hasDuration = true; - NoteHypothesis::Note n = h.getAveragedNote(); nf.timestamp = n.time; nf.duration = n.duration; nf.values.push_back(n.freq);
--- a/CepstralPitchTracker.h Fri Aug 30 15:35:49 2013 +0100 +++ b/CepstralPitchTracker.h Fri Aug 30 17:00:02 2013 +0100 @@ -79,6 +79,7 @@ float m_slack; float m_sensitivity; float m_threshold; + bool m_fillGaps; int m_binFrom; int m_binTo;
--- a/cepstral-pitchtracker.n3 Fri Aug 30 15:35:49 2013 +0100 +++ b/cepstral-pitchtracker.n3 Fri Aug 30 17:00:02 2013 +0100 @@ -33,6 +33,7 @@ vamp:output plugbase:cepstral-pitchtracker_output_f0 ; vamp:output plugbase:cepstral-pitchtracker_output_notes ; + vamp:output plugbase:cepstral-pitchtracker_output_raw ; . plugbase:cepstral-pitchtracker_output_f0 a vamp:DenseOutput ; vamp:identifier "f0" ; @@ -62,4 +63,17 @@ # vamp:computes_feature <Place feature attribute URI here and uncomment> ; # vamp:computes_signal_type <Place signal type URI here and uncomment> ; . - +plugbase:cepstral-pitchtracker_output_raw a vamp:DenseOutput ; + vamp:identifier "raw" ; + dc:title "Raw frequencies" ; + dc:description """Raw peak frequencies from cepstrum, including unvoiced segments""" ; + vamp:fixed_bin_count "true" ; + vamp:unit "Hz" ; + a vamp:KnownExtentsOutput ; + vamp:min_value 50 ; + vamp:max_value 900 ; + vamp:bin_count 1 ; +# vamp:computes_event_type <Place event type URI here and uncomment> ; +# vamp:computes_feature <Place feature attribute URI here and uncomment> ; +# vamp:computes_signal_type <Place signal type URI here and uncomment> ; + .