dc_blocker.c 550 B

12345678910111213141516171819
  1. #include "dc_blocker.h"
  2. void dc_blocker_init(dc_blocker_t *handle, float blocking_factor)
  3. {
  4. handle->blocking_factor = blocking_factor;
  5. handle->gain = (1 + blocking_factor) / 2;
  6. handle->prev_input = 0;
  7. handle->prev_output = 0;
  8. }
  9. float dc_blocker_process(dc_blocker_t *handle, float current_input)
  10. {
  11. float output = handle->gain * (current_input - handle->prev_input) +
  12. handle->blocking_factor * handle->prev_output;
  13. handle->prev_input = current_input;
  14. handle->prev_output = output;
  15. return output;
  16. }