// file: clpc_cal_9.cc // // this function calculates the spectrum of the signal given the lp // coefficients // // system include file // #include #include #include // local include file // #include "global_constants.h" #include "calculate_lpc_constants.h" #include "calculate_lpc.h" // function: calculate_spect_cc // // arguments: // float**& lp_spect_coeffs_a: (output) spectrum of a signal // float** pred_coeffs_a: (input) buffer contains the prediction // coefficients of the signal // float* lp_gain_a: (output) predictor gain // int samples_per_win_a: (input) number of samples per window // int num_chans_a: (input) number of channels // int lp_order_a: (input) type of window // int debug_mode_a: (input) debug level // // return: an int to indicate status // // this function calculates spectrum of a signal using the coefficients // // int calculate_spect_cc (float**& lp_spect_coeffs_a, float** pred_coeffs_a, float* lp_gain_a, int samples_per_win_a, int num_chans_a, int lp_order_a, int debug_mode_a) { for (int chan = 0; chan < num_chans_a; chan++) { for (int sample = 0; sample < samples_per_win_a; sample++) { float factor_rl = 1; float factor_img = 0; for (int coeff = 0; coeff <= lp_order_a; coeff++) { float expn = (2 * M_PI / samples_per_win_a) * ((coeff * sample) % samples_per_win_a); factor_rl -= pred_coeffs_a[chan][coeff] * cos(expn); factor_img += pred_coeffs_a[chan][coeff] * sin(expn); } lp_spect_coeffs_a[chan][sample] += sqrt(lp_gain_a[chan] / (factor_rl * factor_rl + factor_img * factor_img)); } } if (debug_mode_a > DEBUG_FULL) { for (int chan = 0; chan < num_chans_a; chan++) { for (int coeff = 0; coeff <= lp_order_a; coeff++) { fprintf(stdout, "chan %d :: lp coeff [%d] = %.6f\n", chan, coeff, lp_spect_coeffs_a[chan][coeff]); } } fprintf(stdout, "\n"); } // exit gracefully // return TRUE; }