// file: clpc_cal_7.cc // // this function computes the autocorrelation coefficients of a signal // // system include file // #include // local include file // #include "global_constants.h" #include "calculate_lpc_constants.h" #include "calculate_lpc.h" // function: calculate_autocorr_cc // // arguments: // float**& autocorr_coeffs_a: (output) buffer contains the autocorrelation // coefficients of the signal // float* signal_window_a: (input) buffer of signal // 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 the autocorrelation coefficients of a signal using // the equation: // // r(k) = sum ( x(n) * x(n-k) ) n = 0 .. N-1 where // // N is the number of samples in each channel and // k ranges from 0 - order of lpc // // int calculate_autocorr_cc (float**& autocorr_coeffs_a, float* signal_window_a, int samples_per_win_a, int num_chans_a, int lp_order_a, int debug_mode_a) { // total number of autocorrelation coefficients for all channels // int autocorr_coeffs = lp_order_a + 1; // total number of samples for all channels // int num_samples = samples_per_win_a * num_chans_a; for (int chan = 0; chan < num_chans_a; chan++) { for (int coeff = 0; coeff < autocorr_coeffs; coeff++) { autocorr_coeffs_a[chan][coeff] = 0; for (int sample = chan; sample < (num_samples - coeff * num_chans_a); sample += num_chans_a) { autocorr_coeffs_a[chan][coeff] += signal_window_a[sample] * signal_window_a[sample + coeff * num_chans_a]; } } } if (debug_mode_a > DEBUG_FULL) { for (int chan = 0; chan < num_chans_a; chan++) { for (int sample = 0; sample < autocorr_coeffs; sample += num_chans_a) { fprintf(stdout, "chan %d :: autocorrelation coeff [%d] = %.6f\n", chan, sample, autocorr_coeffs_a[chan][sample]); } } fprintf(stdout, "\n"); } // exit gracefully // return TRUE; }