void adaptive_lms(void) { // First, produce y_lms. fir_fr16(pointer, pointer_out, 1, &state); //Call the in-built efficient FIR filter. // Find the error signal adder_unit(); // Calculate the step size------------------------------------ // If you do not want to update the step size automatically, // comment this section of step size calculation between the // top and bottom comments. _NLMS_step_updater_sum(sum_int_p, sum_fract_p, &state); sum = sum_int + fr16_to_float(sum_fract); meu = 1 / (0.5 + sum); //alpha = 1 and gamma = 0.5. if(meu>=1) { step_size=0x7fff; } else { step_size = float_to_fr16(meu); } //Step size calculation ends---------------------------------- // Lastly, update the filter coefficients _coeff_updater(error_sig, step_size, &state); }
int main() { fract16 data[WINDOW_LENGTH]; int index; for (index = 0; index < WINDOW_LENGTH; index++) { data[index] = float_to_fr16(test_input[index]); } struct Coef shelving_coef = get_shelving_coef(); pre_emphasis(data, WINDOW_LENGTH, shelving_coef); for (index = 0; index < WINDOW_LENGTH; ++index) { float test = fr16_to_float(data[index]); // printf("%f\n", fr16_to_float(data[index])); } return 0; }