noise_reduction_util.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /* Copyright 2018 The TensorFlow Authors. All Rights Reserved.
  2. Licensed under the Apache License, Version 2.0 (the "License");
  3. you may not use this file except in compliance with the License.
  4. You may obtain a copy of the License at
  5. http://www.apache.org/licenses/LICENSE-2.0
  6. Unless required by applicable law or agreed to in writing, software
  7. distributed under the License is distributed on an "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. See the License for the specific language governing permissions and
  10. limitations under the License.
  11. ==============================================================================*/
  12. #ifndef TENSORFLOW_LITE_EXPERIMENTAL_MICROFRONTEND_LIB_NOISE_REDUCTION_UTIL_H_
  13. #define TENSORFLOW_LITE_EXPERIMENTAL_MICROFRONTEND_LIB_NOISE_REDUCTION_UTIL_H_
  14. #include "tensorflow/lite/experimental/microfrontend/lib/noise_reduction.h"
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. struct NoiseReductionConfig {
  19. // scale the signal up by 2^(smoothing_bits) before reduction
  20. int smoothing_bits;
  21. // smoothing coefficient for even-numbered channels
  22. float even_smoothing;
  23. // smoothing coefficient for odd-numbered channels
  24. float odd_smoothing;
  25. // fraction of signal to preserve (1.0 disables this module)
  26. float min_signal_remaining;
  27. };
  28. // Populates the NoiseReductionConfig with "sane" default values.
  29. void NoiseReductionFillConfigWithDefaults(struct NoiseReductionConfig* config);
  30. // Allocates any buffers.
  31. int NoiseReductionPopulateState(const struct NoiseReductionConfig* config,
  32. struct NoiseReductionState* state,
  33. int num_channels);
  34. // Frees any allocated buffers.
  35. void NoiseReductionFreeStateContents(struct NoiseReductionState* state);
  36. #ifdef __cplusplus
  37. } // extern "C"
  38. #endif
  39. #endif // TENSORFLOW_LITE_EXPERIMENTAL_MICROFRONTEND_LIB_NOISE_REDUCTION_UTIL_H_