www.pudn.com > ETSI_ES_202_212_software.rar > PostProc.c
/*=============================================================================== * ETSI ES 202 212 Distributed Speech Recognition * Extended Advanced Front-End Feature Extraction Algorithm & Compression Algorithm * Speech Reconstruction Algorithm. * C-language software implementation * Version 1.1.1 October, 2003 *===============================================================================*/ /*------------------------------------------------------------------------------- * * FILE NAME: PostProc.c * PURPOSE: Apply post-processing (blind equalization) on a frame of * cepstral coefficients. * *-------------------------------------------------------------------------------*/ /*----------------- * File Inclusions *-----------------*/ #include#include "ParmInterface.h" #include "PostProcExports.h" /*------------------------ * Definitions and Macros *------------------------*/ #define PP_NB_TOPOSTPROC (NUM_CEP_COEFF-1) #define PP_INDEX_ENER (NUM_CEP_COEFF) #define PP_MIN_ENER_POSTPROC ((X_FLOAT32) 211) #define PP_DELTA_ENER_POSTPROC ((X_FLOAT32) 64) struct PostProcStructX { X_FLOAT32 weightLMS [PP_NB_TOPOSTPROC] ; }; static X_FLOAT32 targetLMS [PP_NB_TOPOSTPROC] = { (X_FLOAT32) -6.618909 , (X_FLOAT32) 0.198269 , (X_FLOAT32) -0.740308 , (X_FLOAT32) 0.055132 , (X_FLOAT32) -0.227086 , (X_FLOAT32) 0.144280 , (X_FLOAT32) -0.112451 , (X_FLOAT32) -0.146940 , (X_FLOAT32) -0.327466 , (X_FLOAT32) 0.134571 , (X_FLOAT32) 0.027884 , (X_FLOAT32) -0.114905 } ; static X_FLOAT32 lambda = (X_FLOAT32) 0.0087890625 ; /*------------------------ * start of Encapsulation *------------------------*/ /*---------------------------------------------------------------------------- * FUNCTION NAME: DoPostProcAlloc * * PURPOSE: Memory allocation of post-processing structure * * INPUT: * none * * OUTPUT: Post-processing structure * * * RETURN VALUE: Pointer to post-processing structure * * *---------------------------------------------------------------------------*/ extern PostProcStructX *DoPostProcAlloc(void) { PostProcStructX *newPost = calloc (1, sizeof (PostProcStructX)); return newPost; } /*---------------------------------------------------------------------------- * FUNCTION NAME: DoPostProcInit * * PURPOSE: Initialisation of post-processing structure * * INPUT: * FEParamsX * Pointer to front end parameter structure * * OUTPUT: weightLMS in post-processing structure * * * RETURN VALUE: * none * *---------------------------------------------------------------------------*/ extern void DoPostProcInit (FEParamsX *This) { X_INT16 i; PostProcStructX *PPX = This->PPX; for (i=0 ; i weightLMS[i] = 0; } /*---------------------------------------------------------------------------- * FUNCTION NAME: DoPostProc * * PURPOSE: Cepstral post-processing for a frame * * INPUT: * *Coef Pointer to cepstral coefficients * FEParamsX * Pointer to front end parameter structure * * OUTPUT: * *Coef Pointer to cepstral coefficients * * RETURN VALUE: * TRUE A frame is always output * *---------------------------------------------------------------------------*/ extern BOOLEAN DoPostProc (X_FLOAT32 *Coef, FEParamsX *This) { X_INT16 i; X_FLOAT32 weightingPar; PostProcStructX *PPX = This->PPX; weightingPar = (Coef[PP_INDEX_ENER] * PP_DELTA_ENER_POSTPROC - PP_MIN_ENER_POSTPROC) / PP_DELTA_ENER_POSTPROC; if (weightingPar < 0) { weightingPar = 0; } else if (weightingPar > 1) { weightingPar = lambda; } else { weightingPar *= lambda; } for (i=0 ; i weightLMS[i]) - targetLMS[i]); Coef[i] = Coef[i] - PPX->weightLMS[i]; val = dif * weightingPar; PPX->weightLMS[i] += val; } return TRUE; } /*---------------------------------------------------------------------------- * FUNCTION NAME: DoPostProcDelete * * PURPOSE: Memory free of post-processing structure * * INPUT: * *PPX Pointer to post-processing structure * * OUTPUT: * none * * RETURN VALUE: * none * *---------------------------------------------------------------------------*/ extern void DoPostProcDelete (PostProcStructX *PPX) { if (PPX != NULL) { free (PPX); } }