GNU Radio 3.6.5 C++ API

quantise.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002 
00003   FILE........: quantise.h
00004   AUTHOR......: David Rowe
00005   DATE CREATED: 31/5/92
00006 
00007   Quantisation functions for the sinusoidal coder.
00008 
00009 \*---------------------------------------------------------------------------*/
00010 
00011 /*
00012   All rights reserved.
00013 
00014   This program is free software; you can redistribute it and/or modify
00015   it under the terms of the GNU Lesser General Public License version 2.1, as
00016   published by the Free Software Foundation.  This program is
00017   distributed in the hope that it will be useful, but WITHOUT ANY
00018   WARRANTY; without even the implied warranty of MERCHANTABILITY or
00019   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
00020   License for more details.
00021 
00022   You should have received a copy of the GNU Lesser General Public License
00023   along with this program; if not, see <http://www.gnu.org/licenses/>.
00024 */
00025 
00026 #ifndef __QUANTISE__
00027 #define __QUANTISE__
00028 
00029 #define WO_BITS   7
00030 #define WO_LEVELS (1<<WO_BITS)
00031 #define E_BITS    5
00032 #define E_LEVELS  (1<<E_BITS)
00033 #define E_MIN_DB -10.0
00034 #define E_MAX_DB  40.0
00035 
00036 void quantise_init();
00037 float lpc_model_amplitudes(float Sn[], float w[], MODEL *model, int order,
00038                            int lsp,float ak[]);
00039 void aks_to_M2(float ak[], int order, MODEL *model, float E, float *snr,
00040                int dump);
00041 
00042 int   encode_Wo(float Wo);
00043 float decode_Wo(int index);
00044 
00045 void encode_lsps(int indexes[], float lsp[], int order);
00046 void decode_lsps(float lsp[], int indexes[], int order);
00047 void lspd_quantise(float lsp[], float lsp_[], int order);
00048 void lspdvq_quantise(float lsp[], float lsp_[], int order);
00049 
00050 int encode_energy(float e);
00051 float decode_energy(int index);
00052 
00053 void encode_amplitudes(int    lsp_indexes[],
00054                        int   *energy_index,
00055                        MODEL *model,
00056                        float  Sn[],
00057                        float  w[]);
00058 
00059 float decode_amplitudes(MODEL *model,
00060                         float  ak[],
00061                         int lsp_indexes[],
00062                         int energy_index,
00063                         float  lsps[],
00064                         float *e);
00065 
00066 void pack(unsigned char * bits, unsigned int *nbit, int index, unsigned int index_bits);
00067 int  unpack(const unsigned char * bits, unsigned int *nbit, unsigned int index_bits);
00068 
00069 int lsp_bits(int i);
00070 
00071 void apply_lpc_correction(MODEL *model);
00072 float speech_to_uq_lsps(float lsp[],
00073                         float ak[],
00074                         float Sn[],
00075                         float w[],
00076                         int   order
00077                         );
00078 void bw_expand_lsps(float lsp[],
00079                     int   order
00080                     );
00081 void decode_lsps(float lsp[], int indexes[], int order);
00082 
00083 #endif