Marsyas  0.6.0-alpha
/usr/src/RPM/BUILD/marsyas-0.6.0/src/marsyas/marsystems/TimeFreqPeakConnectivity.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_TimeFreqPeakConnectivity_H
00020 #define MARSYAS_TimeFreqPeakConnectivity_H
00021 
00022 #include <marsyas/system/MarSystem.h>
00023 
00024 class DoubleListEntries;
00025 
00026 namespace Marsyas
00027 {
00044 class marsyas_EXPORT TimeFreqPeakConnectivity: public MarSystem
00045 {
00046 private:
00047 
00049   void addControls();
00050 
00052   void myUpdate(MarControlPtr sender);
00053 
00054   // don't change the order!
00055   enum Direction_t
00056   {
00057     kFromDown,
00058     kFromLeft,
00059     kFromUp,
00060 
00061     kNumDirections
00062   };
00063 
00064   static inline mrs_real dtwFindMin (mrs_real *prevCost, unsigned char &tbIdx)
00065   {
00066     mrs_real    min = 1e30;
00067     tbIdx   = kFromLeft;
00068 
00069     for (unsigned char i = 0; i < kNumDirections; i++)
00070     {
00071       if (prevCost[i] <= min)
00072       {
00073         min     = prevCost[i];
00074         tbIdx   = i;
00075       }
00076     }
00077     return min;
00078   };
00079 
00080   void AllocMemory (mrs_natural numSamples);
00081   void FreeMemory ();
00082 
00083   void SetOutput(mrs_realvec &out, const mrs_real cost, mrs_natural idxRowA, mrs_natural idxColA, mrs_natural idxRowB, mrs_natural idxColB);
00084   mrs_natural Freq2RowIdx (mrs_real barkFreq, mrs_real bres);
00085   void CalcDp (mrs_realvec &Matrix, mrs_natural startr, mrs_natural startc, mrs_natural stopr, mrs_natural stopc);
00086   void InitMatrix (mrs_realvec &Matrix, unsigned char **traceback, mrs_natural rowIdx, mrs_natural colIdx);
00087   MarControlPtr ctrl_reso_;
00088   mrs_realvec       peakMatrix_,
00089                 costMatrix_;
00090   mrs_real      downFreq_,
00091               upFreq_;
00092   mrs_natural       numBands_,
00093                 textWinSize_;
00094   mrs_natural       *path_,
00095                 **peakIndices_;
00096   unsigned char** tracebackIdx_;
00097   DoubleListEntries *multipleIndices;
00098 
00099 public:
00101   TimeFreqPeakConnectivity(std::string name);
00102 
00104   TimeFreqPeakConnectivity(const TimeFreqPeakConnectivity& a);
00105 
00107   ~TimeFreqPeakConnectivity();
00108 
00110   MarSystem* clone() const;
00111 
00113   void myProcess(realvec& in, realvec& out);
00114 };
00115 
00116 }
00117 //namespace Marsyas
00118 
00119 #endif
00120 //MARSYAS_TimeFreqPeakConnectivity_H
00121