Marsyas  0.6.0-alpha
/usr/src/RPM/BUILD/marsyas-0.6.0/src/marsyas/marsystems/PhaseLock.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_PHASELOCK_H
00020 #define MARSYAS_PHASELOCK_H
00021 
00022 #include <marsyas/system/MarSystem.h>
00023 #include <string.h>
00024 using namespace std;
00025 
00026 namespace Marsyas
00027 {
00058 class PhaseLock: public MarSystem
00059 {
00060 private:
00061   //Add specific controls needed by this MarSystem.
00062   void addControls();
00063   MarControlPtr ctrl_beatHypotheses_;
00064   MarControlPtr ctrl_inductionTime_;
00065   MarControlPtr ctrl_nrPeriodHyps_;
00066   MarControlPtr ctrl_nrPhasesPerPeriod_;
00067   MarControlPtr ctrl_scoreFunc_;
00068   MarControlPtr ctrl_tickCount_;
00069   MarControlPtr ctrl_mode_;
00070   MarControlPtr ctrl_hopSize_;
00071   MarControlPtr ctrl_srcFs_;
00072   MarControlPtr ctrl_gtBeatsFile_;
00073   MarControlPtr ctrl_backtrace_;
00074   MarControlPtr ctrl_innerMargin_;
00075   MarControlPtr ctrl_lftOutterMargin_;
00076   MarControlPtr ctrl_rgtOutterMargin_;
00077   MarControlPtr ctrl_corFactor_;
00078   MarControlPtr ctrl_maxPeriod_;
00079   MarControlPtr ctrl_minPeriod_;
00080   MarControlPtr ctrl_adjustment_;
00081   MarControlPtr ctrl_dumbInduction_;
00082   MarControlPtr ctrl_inductionOut_;
00083   MarControlPtr ctrl_triggerInduction_;
00084   MarControlPtr ctrl_curBestScore_;
00085   MarControlPtr ctrl_triggerBestScoreFactor_;
00086 
00087   mrs_real lastGTIBI_;
00088   mrs_real triggerBestScoreFactor_;
00089   mrs_real lastGTBeatTime_;
00090   mrs_real curBestScore_;
00091   mrs_bool triggerInduction_;
00092   mrs_bool gtAfter2ndBeat_;
00093   mrs_string inductionOut_;
00094   mrs_bool dumbInduction_;
00095   mrs_real adjustment_;
00096   mrs_natural minPeriod_;
00097   mrs_natural maxPeriod_;
00098   mrs_natural innerMargin_;
00099   mrs_string gtBeatsFile_;
00100   mrs_bool inductionFinished_;
00101   mrs_natural hopSize_;
00102   mrs_real srcFs_;
00103   mrs_string mode_;
00104   mrs_string line_;
00105   ifstream inStream_;
00106   mrs_real gtScore_;
00107   mrs_natural gtInitPeriod_;
00108   mrs_natural gtLastPeriod_;
00109   mrs_string sourceFile_;
00110   mrs_natural gtInitPhase_;
00111   mrs_natural gtLastPhase_;
00112   mrs_string scoreFunc_;
00113   mrs_natural nrPhasesPerPeriod_;
00114   mrs_natural nrPeriodHyps_;
00115   mrs_natural inductionTime_;
00116   mrs_natural nInitHyp_;
00117   mrs_realvec beatHypotheses_;
00118   mrs_realvec hypSignals_;
00119   mrs_realvec firstBeatPoint_;
00120   mrs_realvec trackingScore_;
00121   mrs_natural timeElapsed_;
00122   mrs_realvec maxLocalTrackingScore_;
00123   mrs_realvec maxLocalTrackingScoreInd_;
00124   mrs_realvec metricalSalience_;
00125   mrs_realvec rawScore_;
00126   mrs_realvec rawScoreNorm_;
00127   mrs_realvec metricalRelScore_;
00128   mrs_realvec scoreNorm_;
00129   mrs_realvec initPhases_;
00130   mrs_realvec lastPhases_;
00131   mrs_realvec initPeriods_;
00132   mrs_realvec lastPeriods_;
00133   mrs_realvec beatCount_;
00134   mrs_bool backtrace_;
00135   mrs_natural outterWinLft_;
00136   mrs_natural outterWinRgt_;
00137   mrs_real lftOutterMargin_;
00138   mrs_real rgtOutterMargin_;
00139   mrs_real corFactor_;
00140 
00141   void myUpdate(MarControlPtr sender);
00142   mrs_real calcRelationalScore(mrs_natural i, mrs_realvec rawScoreVec);
00143   mrs_natural metricalRelation(mrs_real period1, mrs_real period2);
00144   void regularFunc(realvec& in, realvec& out);
00145   mrs_realvec readGTFile(mrs_string gtFilePath);
00146   void handleGTHypotheses(realvec& in, realvec& out, mrs_string gtFilePath, mrs_realvec gtHypotheses);
00147   mrs_realvec GTInitialization(realvec& in, realvec& out, mrs_natural gtIniPhase,
00148                                mrs_natural gtInitPeriod);
00149   void forceInitPeriods(mrs_string mode);
00150 
00151 public:
00152   PhaseLock(std::string name);
00153   PhaseLock(const PhaseLock& a);
00154   ~PhaseLock();
00155   MarSystem* clone() const;
00156 
00157   void myProcess(realvec& in, realvec& out);
00158 };
00159 
00160 }//namespace Marsyas
00161 
00162 #endif