# HG changeset patch # User Chris Cannam # Date 1400861007 -3600 # Node ID e1718e64a9216a44acfb2064f8e6cb415d4adb17 # Parent 10e7c3ff575e6380464e3627d85bc67ced9b8d48 Remove some irrelevant code diff -r 10e7c3ff575e -r e1718e64a921 src/NoteHypothesis.cpp --- a/src/NoteHypothesis.cpp Fri May 23 12:40:18 2014 +0100 +++ b/src/NoteHypothesis.cpp Fri May 23 17:03:27 2014 +0100 @@ -243,114 +243,3 @@ return i->time - start; } } - -std::vector -NoteHypothesis::sample(const std::set ¬es, - RealTime startTime, - RealTime endTime, - RealTime interval) -{ - //!!! where should this live? in AgentHypothesis? a Feeder class? - - assert(interval > RealTime::zeroTime); - - Observations obs = flatten(notes); - Observations::const_iterator oi = obs.begin(); - -// std::cerr << "sample: start " << startTime << " end " << endTime << " interval " << interval << std::endl; - -// std::cerr << "sample: flatten gives " << obs.size() << " observations" << std::endl; - - std::vector samples; - - RealTime obsInterval; - - RealTime t = startTime; - - while (oi != obs.end()) { - - Observation o = *oi; - - if (obsInterval == RealTime()) { - //!!! should pull out a function to establish this from the list - Observations::const_iterator oj = oi; - ++oj; - if (oj != obs.end()) { - obsInterval = oj->time - o.time; - } - } - -// std::cerr << "t = " << t << ", o.time = " << o.time << ", interval = " << interval << ", obsInterval = " << obsInterval << std::endl; - - if (t > endTime) { - break; - } else if (o.time > t) { - samples.push_back(0.0); - t = t + interval; - } else if (o.time + obsInterval <= t) { - ++oi; - } else { - samples.push_back(o.value); - t = t + interval; - } - } - - while (1) { -// std::cerr << "t = " << t << std::endl; - if (t > endTime) { - break; - } else { - samples.push_back(0.0); - t = t + interval; - } - } - - return samples; -} - -std::vector -NoteHypothesis::winnow(const Observations &obs, - RealTime startTime, - RealTime endTime, - RealTime interval) -{ - AgentFeederPoly feeder; - -#ifdef DEBUG_NOTE_HYPOTHESIS - std::cerr << "winnow: " << obs.size() << " input observations" - << std::endl; - int nonzero = 0; -#endif - - for (Observations::const_iterator i = obs.begin(); - i != obs.end(); ++i) { - if (i->value != 0.0) { // 0.0 is a special unvoiced value - feeder.feed(*i); -#ifdef DEBUG_NOTE_HYPOTHESIS - std::cerr << i->value << " "; - ++nonzero; - if (nonzero % 6 == 0) { - std::cerr << std::endl; - } -#endif - } - } - -#ifdef DEBUG_NOTE_HYPOTHESIS - std::cerr << "winnow: " << nonzero << " non-zero" - << std::endl; -#endif - - feeder.finish(); - - AgentFeederPoly::Hypotheses accepted = - feeder.getAcceptedHypotheses(); - -#ifdef DEBUG_NOTE_HYPOTHESIS - std::cerr << "winnow: " << accepted.size() << " accepted hypotheses" - << std::endl; -#endif - - return NoteHypothesis::sample(accepted, startTime, endTime, interval); -} - diff -r 10e7c3ff575e -r e1718e64a921 src/NoteHypothesis.h --- a/src/NoteHypothesis.h Fri May 23 12:40:18 2014 +0100 +++ b/src/NoteHypothesis.h Fri May 23 17:03:27 2014 +0100 @@ -79,43 +79,6 @@ */ Vamp::RealTime getDuration() const; - /** - * Convert the given sequence of accepted hypotheses into a - * sampled series of pitches (in Hz), returned at regular - * intervals determined by the given start time, end time, and - * interval. The range is [start,end], i.e. the end time is - * included. The interval must be greater than zero. - * - * Unvoiced samples are returned as 0Hz. - */ - static std::vector sample(const std::set &, - Vamp::RealTime startTime, - Vamp::RealTime endTime, - Vamp::RealTime interval); - - /** - *!!! No! Not equally spaced, should be able to be anything [ordered] - - * Given a series of equally spaced observations, return a series - * of the same number of pitches (in Hz) calculated by running an - * AgentFeeder on the observations and flattening - * and sampling the resulting accepted hypotheses. - * - * The result should contain only pitches that contributed to - * recognised notes in the input observations, with the remaining - * (unvoiced) samples returned as 0Hz. - * - * If the input observations are not equally spaced, the result is - * undefined. - *!!! (what about rounding errors from RealTime to frame and vice versa?) - *!!! (should provide a Timebase?) - *!!! update docs for updated api - */ - static std::vector winnow(const Observations &, - Vamp::RealTime startTime, - Vamp::RealTime endTime, - Vamp::RealTime interval); - //!!! bool operator==(const NoteHypothesis &other) const { return m_state == other.m_state && m_pending == other.m_pending;