Mercurial > hg > svapp
diff align/Align.cpp @ 771:1d6cca5a5621 pitch-align
Allow use of proper sparse models (i.e. retaining event time info) in alignment; use this to switch to note alignment, which is what we have most recently been doing in the external program. Not currently producing correct results, though
author | Chris Cannam |
---|---|
date | Fri, 29 May 2020 17:39:02 +0100 |
parents | 1b1960009be6 |
children | 699b5b130ea2 |
line wrap: on
line diff
--- a/align/Align.cpp Thu May 28 17:52:19 2020 +0100 +++ b/align/Align.cpp Fri May 29 17:39:02 2020 +0100 @@ -46,8 +46,8 @@ return "match-alignment"; case MATCHAlignmentWithPitchCompare: return "match-alignment-with-pitch"; - case SungPitchContourAlignment: - return "sung-pitch-alignment"; + case SungNoteContourAlignment: + return "sung-note-alignment"; case TransformDrivenDTWAlignment: return "transform-driven-alignment"; case ExternalProgramAlignment: @@ -137,29 +137,36 @@ break; } - case SungPitchContourAlignment: + case SungNoteContourAlignment: { auto refModel = ModelById::get(reference); if (!refModel) return false; - + Transform transform = TransformFactory::getInstance()-> - getDefaultTransformFor("vamp:pyin:pyin:smoothedpitchtrack", + getDefaultTransformFor("vamp:pyin:pyin:notes", refModel->getSampleRate()); - transform.setParameter("outputunvoiced", 2.f); - aligner = make_shared<TransformDTWAligner> (doc, reference, toAlign, transform, - TransformDTWAligner::RiseFall, - [](double freq) { - if (freq < 0.0) { - return 0.0; + [](double prev, double curr) { + RiseFallDTW::Value v; + if (curr <= 0.0) { + v = { RiseFallDTW::Direction::None, 0.0 }; + } else if (prev <= 0.0) { + v = { RiseFallDTW::Direction::Up, 0.0 }; } else { - return double(Pitch::getPitchForFrequency(freq)); + double prevP = Pitch::getPitchForFrequency(prev); + double currP = Pitch::getPitchForFrequency(curr); + if (currP >= prevP) { + v = { RiseFallDTW::Direction::Up, currP - prevP }; + } else { + v = { RiseFallDTW::Direction::Down, prevP - currP }; + } } + return v; }); break; }