// file: $ECE_8993/util/calculate_lpc/v1.0/clpc_comp_7.cc // // computes the lp predictor spectrum from the predictor coefficients // // system include files // #include // isip include files // #include #include // local include files // #include "calculate_lpc.h" #include "calculate_lpc_constants.h" // function: compute_lp_spect_cc // // arguments: // // float_4* pred_coeffs: (output) predictor coefficients // float_4* spect_coeffs: (output) spectrum coefficients // int_4 lp_order: (input) order of the lp model // int_4 num_samples: (input) number of samples // float_4 gain: (input) gain of the lp model to estimate the signal spectrum // // return value: a logical_1 indicating status // // this function computes the spectrum given a set of lp predictor // and a gain value coefficients // logical_1 compute_lp_spect_cc(float_4* pred_coeffs_a, float_4* spect_coeffs_a, int_4 lp_order_a, int_4 num_samples_a, float_4 gain_a) { // loop over all spectrum components // for (int_4 i = (int_4)0; i < num_samples_a; i++) { // initialize the real and imaginary portions of the spectrum // float_4 real_part = (float_4)1.0; float_4 imag_part = (float_4)0.0; // loop over each of the predictor values // for (int_4 j = 1; j <= lp_order_a; j++) { real_part -= pred_coeffs_a[j] * cos((ISIP_TWOPI / (float_4) num_samples_a) * (float_4)((i * j) % num_samples_a)); imag_part += pred_coeffs_a[j] * sin((ISIP_TWOPI / (float_4) num_samples_a) * (float_4)((i * j) % num_samples_a)); } // save the magnitude of the spectrum // spect_coeffs_a[i] = sqrt(gain_a / ((real_part * real_part) + (imag_part * imag_part))); } // exit gracefully // return ISIP_TRUE; }