void pre_emphasis(fract16 data[], int arr_length, struct Coef shelving_coef) { fract16 xBuffer[BUFFER_SIZE]; // input buffer fract16 yBuffer[BUFFER_SIZE]; // output buffer int current; for (current = 0; current < BUFFER_SIZE; ++current) { xBuffer[current] = yBuffer[current] = float_to_fr16(0.0); } current = 0; int index; for (index = 0; index < arr_length; index++) { fract16 temp_b0 = mult_fr1x16(shelving_coef.b0, data[index]); fract16 temp_b1 = mult_fr1x16(shelving_coef.b1, xBuffer[INDEX(current-1)]); fract16 temp_b2 = mult_fr1x16(shelving_coef.b2, xBuffer[INDEX(current-2)]); fract16 temp_a1 = mult_fr1x16(shelving_coef.a1, yBuffer[INDEX(current-1)]); fract16 temp_a2 = mult_fr1x16(shelving_coef.a2, yBuffer[INDEX(current-2)]); fract16 temp_b = add_fr1x16(add_fr1x16(temp_b0, temp_b1), temp_b2); fract16 temp_a = add_fr1x16(temp_a1, temp_a2); fract16 temp = sub_fr1x16(temp_b, temp_a); yBuffer[current] = shl_fr1x16(temp, 2); xBuffer[current] = data[index]; //input data[index] = yBuffer[current]; //output current++; current %= BUFFER_SIZE; } }
void echo_generator(void) { echo_output = in_fir; // Produce First echo echo_output = add_fr1x16(echo_output, multr_fr1x16(0x1000, echo_delayed_input[echo_reader_first])); // Produce Second echo echo_output = add_fr1x16(echo_output, multr_fr1x16(0x2000, echo_delayed_input[echo_reader_second])); // Produce Third echo echo_output = add_fr1x16(echo_output, multr_fr1x16(0x4000, echo_delayed_input[echo_reader_third])); echo_delayed_input[echo_writer] = in_fir; //Store the current input in the echo delay buffer //Increment the echo buffer readers echo_writer++; echo_reader_first++; echo_reader_second++; echo_reader_third++; if(echo_writer == echo_TAP_NUM) { echo_writer = 0; } if(echo_reader_first == echo_TAP_NUM) { echo_reader_first = 0; } if(echo_reader_second == echo_TAP_NUM) { echo_reader_second = 0; } if(echo_reader_third == echo_TAP_NUM) { echo_reader_third = 0; } }