Marsyas  0.6.0-alpha
/usr/src/RPM/BUILD/marsyas-0.6.0/src/marsyas/marsystems/LPC.h
Go to the documentation of this file.
00001 /*
00002 ** Copyright (C) 1998-2005 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 
00020 #ifndef MARSYAS_LPC_H
00021 #define MARSYAS_LPC_H
00022 
00023 #include <marsyas/system/MarSystem.h>
00024 
00025 namespace Marsyas
00026 {
00044 class LPC: public MarSystem
00045 {
00046 private:
00047   void addControls();
00048   void myUpdate(MarControlPtr sender);
00049 
00050   MarControlPtr ctrl_coeffs_;
00051   MarControlPtr ctrl_power_;
00052   MarControlPtr ctrl_pitch_;
00053   mrs_natural order_;
00054   mrs_natural featureMode_;
00055 
00056   realvec Zs_;
00057   realvec temp_;
00058 
00067   void autocorrelationWarped(const realvec& in, realvec& r, mrs_real& pitch, mrs_real lambda);
00068 
00076   void LevinsonDurbin(const realvec& r, realvec& a, realvec& k, mrs_real& e);
00077 
00083   mrs_real predictionError(const realvec& data, const realvec& coeffs);
00084 
00085   /*implementation from peter Kabal
00086      *http://www-mmsp.ece.mcgill.ca/Documents/Software/index.html
00087    *
00088    * Returns the dot product of two vectors x1 and x2 of size N
00089    */
00090   mrs_real VRfDotProd (mrs_real * x1, mrs_real * x2, mrs_natural N);
00091 
00092   /* Computes the Nt (order+1) reflection coefficients cor from a time serie x of size Nx
00093   */
00094   void SPautoc (mrs_real * x, mrs_natural Nx, mrs_real * cor, mrs_natural Nt);
00095 
00096   /* Computes the Np autocorrelation coefficients pc [a(1) ... a(order)] from the reflections coefficients rxx
00097      and return the prediction error
00098    */
00099   mrs_real SPcorXpc (mrs_real * rxx, mrs_real * pc, mrs_natural Np);
00100 
00101 public:
00102   LPC(std::string name);
00103   LPC(const LPC&);
00104   ~LPC();
00105 
00106   MarSystem* clone() const;
00107 
00108   void myProcess(realvec& in, realvec& out);
00109 };
00110 
00111 }//namespace Marsyas
00112 
00113 #endif
00114 
00115 
00116