SpectMorph

lib/smlpc.hh

00001 /* 
00002  * Copyright (C) 2011 Stefan Westerfeld
00003  *
00004  * This library is free software; you can redistribute it and/or modify it
00005  * under the terms of the GNU Lesser General Public License as published by the
00006  * Free Software Foundation; either version 3 of the License, or (at your
00007  * option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful, but WITHOUT
00010  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00011  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
00012  * for more details.
00013  *
00014  * You should have received a copy of the GNU Lesser General Public License
00015  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 
00018 
00019 #ifndef SPECTMORPH_LPC_HH
00020 #define SPECTMORPH_LPC_HH
00021 
00022 #include <vector>
00023 #include <complex>
00024 
00025 namespace SpectMorph
00026 {
00027 
00028 namespace LPC
00029 {
00030 
00031 void compute_lpc (std::vector<double>& lpc, const float *begin, const float *end);
00032 void lpc2lsf (const std::vector<double>& lpc, std::vector<float>& lpc_lsf_p, std::vector<float>& lpc_lsf_q);
00033 void lsf2lpc (const std::vector<float>& lsf_p, const std::vector<float>& lsf_q, std::vector<double>& lpc);
00034 
00035 double eval_lpc (const std::vector<double>& lpc, double f);
00036 
00037 class LSFEnvelope {
00038   std::vector<double>                 p_a;
00039   std::vector<double>                 p_b;
00040   double                              p_real_root;
00041 
00042   std::vector<double>                 q_a;
00043   std::vector<double>                 q_b;
00044   double                              q_real_root;
00045 
00046   bool                                m_init;
00047 public:
00048   LSFEnvelope();
00049 
00050   bool init (const std::vector<float>& lpc_lsf_p, const std::vector<float>& lpc_lsf_q);
00051   double eval (double f);
00052 };
00053 
00054 long double eval_z (const std::vector<double>& lpc, std::complex<long double> z);
00055 bool find_roots (const std::vector<double>& lpc, std::vector< std::complex<double> >& roots);
00056 void roots2lpc (const std::vector< std::complex<double> >& roots, std::vector<double>& lpc);
00057 void make_stable_roots (std::vector< std::complex<double> >& roots);
00058 
00059 }
00060 
00061 }
00062 
00063 #endif
 All Classes Functions Variables Enumerations Enumerator