Marsyas  0.6.0-alpha
/usr/src/RPM/BUILD/marsyas-0.6.0/src/marsyas/marsystems/HWPS.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_HWPS_H
00020 #define MARSYAS_HWPS_H
00021 
00022 #include <marsyas/system/MarSystem.h>
00023 
00024 namespace Marsyas
00025 {
00036 class HWPS: public MarSystem
00037 {
00038 private:
00039   // HWPS feature vector format:
00040   //[peakFreq, frameNumPeaks, pkSetFreq0,...,pkSetFreqN, pkSetAmp0,..., pkSetAmpN]'
00041   //where N+1=maxFrameNumPeaks
00042   enum pkFields {
00043     pkFreqIdx = 0,
00044     frameNumPeaksIdx = 1,
00045     pkSetFeatsIdx = 2
00046   };
00047   realvec vec_i_;
00048   realvec vec_j_;
00049 
00050   mrs_real pk_i_freq_;
00051   mrs_real pk_j_freq_;
00052 
00053   mrs_natural i_frameNumPeaks_;
00054   mrs_natural j_frameNumPeaks_;
00055 
00056   realvec pkSet_i_Freqs_;
00057   realvec pkSet_j_Freqs_;
00058 
00059   realvec pkSet_i_WrapFreqs_;
00060   realvec pkSet_j_WrapFreqs_;
00061 
00062   realvec pkSet_i_Amps_;
00063   realvec pkSet_j_Amps_;
00064 
00065   realvec histogram_i_;
00066   realvec histogram_j_;
00067 
00068   MarControlPtr ctrl_calcDistance_;
00069   MarControlPtr ctrl_histSize_;
00070   mrs_natural histSize_;
00071 
00072   void harmonicWrap(mrs_real peak1Freq, mrs_real peak2Freq,
00073                     realvec& peak1SetFreqs, realvec& peak2SetFreqs);
00074   void discretize(const realvec& peakSetWarpFreqs, const realvec& peakAmps,
00075                   const mrs_natural& histSize, realvec& resultHistogram);
00076 
00077   void addControls();
00078   void myUpdate(MarControlPtr sender);
00079 
00080 public:
00081   HWPS(std::string name);
00082   HWPS(const HWPS& a);
00083   ~HWPS();
00084   MarSystem* clone() const;
00085 
00086   void myProcess(realvec& in, realvec& out);
00087 };
00088 
00089 }
00090 
00091 #endif
00092 
00093 
00094