Marsyas  0.5.0-beta1
/Users/jleben/code/marsyas/src/marsyas/marsystems/BeatAgent.h
Go to the documentation of this file.
00001 /*
00002 ** Copyright (C) 1998-2006 George Tzanetakis <gtzan@cs.uvic.ca>
00003 **
00004 ** This program is free software; you can redistribute it and/or modify
00005 ** it under the terms of the GNU General Public License as published by
00006 ** the Free Software Foundation; either version 2 of the License, or
00007 ** (at your option) any later version.
00008 **
00009 ** This program is distributed in the hope that it will be useful,
00010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 ** GNU General Public License for more details.
00013 **
00014 ** You should have received a copy of the GNU General Public License
00015 ** along with this program; if not, write to the Free Software
00016 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017 */
00018 
00019 #ifndef MARSYAS_BeatAgent_H
00020 #define MARSYAS_BeatAgent_H
00021 
00022 #include <marsyas/system/MarSystem.h>
00023 
00024 namespace Marsyas
00025 {
00049 class BeatAgent: public MarSystem
00050 {
00051 private:
00052   //Add specific controls needed by this MarSystem.
00053   void addControls();
00054   MarControlPtr ctrl_identity_;
00055   MarControlPtr ctrl_timming_;
00056   MarControlPtr ctrl_agentControl_;
00057   MarControlPtr ctrl_scoreFunc_;
00058   MarControlPtr ctrl_lftOutterMargin_;
00059   MarControlPtr ctrl_rgtOutterMargin_;
00060   MarControlPtr ctrl_innerMargin_;
00061   MarControlPtr ctrl_maxPeriod_;
00062   MarControlPtr ctrl_minPeriod_;
00063 
00064   mrs_real periodFraction_;
00065   mrs_natural minPeriod_;
00066   mrs_natural maxPeriod_;
00067   mrs_real lftOutterMargin_;
00068   mrs_real rgtOutterMargin_;
00069   mrs_real innerMargin_;
00070   mrs_string scoreFunc_;
00071   mrs_natural innerWin_;
00072   mrs_natural outterWinLft_;
00073   mrs_natural outterWinRgt_;
00074   mrs_bool isNewOrUpdated_;
00075   mrs_string identity_;
00076   mrs_real fraction_;
00077   mrs_real score_;
00078   mrs_natural error_;
00079   mrs_natural curBeat_;
00080   mrs_natural prevBeat_;
00081   mrs_natural beatCount_;
00082   mrs_natural period_;
00083   mrs_natural phase_;
00084   mrs_natural timeElapsed_;
00085   mrs_natural lastBeatPoint_;
00086   mrs_real curBeatPointValue_;
00087   mrs_realvec history_;
00088   mrs_natural myIndex_;
00089   mrs_realvec agentControl_;
00090 
00091   void fillOutput(realvec& out, mrs_real flag, mrs_real tempo, mrs_real phase,
00092                   mrs_real tolerance, mrs_real error, mrs_real score);
00093   mrs_natural getChildIndex();
00094   void myUpdate(MarControlPtr sender);
00095   mrs_real calcDScoreCorr(realvec& in, mrs_natural maxInd);
00096   mrs_real calcDScoreCorrSquare(realvec& in);
00097 
00098 public:
00099   BeatAgent(std::string name);
00100   BeatAgent(const BeatAgent& a);
00101   ~BeatAgent();
00102   MarSystem* clone() const;
00103 
00104   void myProcess(realvec& in, realvec& out);
00105 };
00106 
00107 }//namespace Marsyas
00108 
00109 #endif