Chris@52: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@52: /* Chris@52: This file is Copyright (c) 2012 Chris Cannam Chris@52: Chris@52: Permission is hereby granted, free of charge, to any person Chris@52: obtaining a copy of this software and associated documentation Chris@52: files (the "Software"), to deal in the Software without Chris@52: restriction, including without limitation the rights to use, copy, Chris@52: modify, merge, publish, distribute, sublicense, and/or sell copies Chris@52: of the Software, and to permit persons to whom the Software is Chris@52: furnished to do so, subject to the following conditions: Chris@52: Chris@52: The above copyright notice and this permission notice shall be Chris@52: included in all copies or substantial portions of the Software. Chris@52: Chris@52: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, Chris@52: EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF Chris@52: MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND Chris@52: NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR Chris@52: ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF Chris@52: CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION Chris@52: WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Chris@52: */ Chris@52: Chris@52: #ifndef _AGENT_FEEDER_H_ Chris@52: #define _AGENT_FEEDER_H_ Chris@52: Chris@52: #include "NoteHypothesis.h" Chris@52: Chris@52: #include Chris@52: Chris@52: /** Chris@52: * Take a series of estimates (one at a time) and feed them to a set Chris@52: * of note hypotheses, creating a new candidate hypothesis for each Chris@52: * observation and also testing the observation against the existing Chris@52: * set of hypotheses. Chris@52: * Chris@52: * One satisfied hypothesis is considered to be "accepted" at any Chris@52: * moment (that is, the earliest contemporary hypothesis to have Chris@52: * become satisfied). The series of accepted and completed hypotheses Chris@52: * from construction to the present time can be queried through Chris@52: * getAcceptedHypotheses(). Chris@52: * Chris@52: * Call feed() to provide a new observation. Call finish() when all Chris@52: * observations have been provided. The set of hypotheses returned by Chris@52: * getAcceptedHypotheses() will not be complete unless finish() has Chris@52: * been called. Chris@52: */ Chris@52: class AgentFeeder Chris@52: { Chris@52: public: Chris@54: AgentFeeder() : m_haveCurrent(false) { } Chris@52: Chris@52: void feed(NoteHypothesis::Estimate); Chris@52: void finish(); Chris@52: Chris@52: typedef std::vector Hypotheses; Chris@52: Chris@57: const Hypotheses &getAcceptedHypotheses() const { Chris@52: return m_accepted; Chris@52: } Chris@52: Chris@54: Hypotheses reap(Hypotheses); Chris@54: Chris@52: private: Chris@52: Hypotheses m_candidates; Chris@52: NoteHypothesis m_current; Chris@54: bool m_haveCurrent; Chris@52: Hypotheses m_accepted; Chris@52: }; Chris@52: Chris@52: Chris@52: #endif Chris@52: