// file: extract_feature/extf_func_3.cc
//

// isip include files
//
#include "extract_feature.h"
#include "extract_feature_constants.h"
#include <signal_constants.h>

// method: func_lifter_cc
//
// arguments:
//  float_8* cepstrum_a: (output) the cepstrum
//  int_4 num_coeffs_a: (input) number of samples in cepstrum
//  float_8 lifter_coeff_a: (input) liftering coefficient
//
// This method computes the Fourier transform of a signal
//
logical_1 Extract_feature::func_lifter_cc(float_8* cepstrum_a,
					  int_4 num_coeffs_a) {


  // implement liftering to smooth the cepstral coefficients
  //
  //  Rabiner, Juang, Fundamentals of Speech Recognition, pp. 169
  //  The HTK Book, pp 68
  //
  float_8 h = lifter_coeff_d / 2.0;
  
  int_4 n = 1;  
  if (c0_d) {
    n = 0;
  }
  else
    cepstrum_a[0] = 0.0;
  
  for (; n < num_coeffs_a; n++) {
    if (n <= lifter_coeff_d) {
      cepstrum_a[n] *= (1 + h * sin(M_PI * n / lifter_coeff_d));
    }
    else {
      cepstrum_a[n] = 0.0;
    }
  }

  // exit gracefully
  //
  return ISIP_TRUE;
}
