digital_agc.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #ifndef MODULES_AUDIO_PROCESSING_AGC_LEGACY_DIGITAL_AGC_H_
  11. #define MODULES_AUDIO_PROCESSING_AGC_LEGACY_DIGITAL_AGC_H_
  12. #include "common_audio/signal_processing/include/signal_processing_library.h"
  13. namespace webrtc {
  14. typedef struct {
  15. int32_t downState[8];
  16. int16_t HPstate;
  17. int16_t counter;
  18. int16_t logRatio; // log( P(active) / P(inactive) ) (Q10)
  19. int16_t meanLongTerm; // Q10
  20. int32_t varianceLongTerm; // Q8
  21. int16_t stdLongTerm; // Q10
  22. int16_t meanShortTerm; // Q10
  23. int32_t varianceShortTerm; // Q8
  24. int16_t stdShortTerm; // Q10
  25. } AgcVad; // total = 54 bytes
  26. typedef struct {
  27. int32_t capacitorSlow;
  28. int32_t capacitorFast;
  29. int32_t gain;
  30. int32_t gainTable[32];
  31. int16_t gatePrevious;
  32. int16_t agcMode;
  33. AgcVad vadNearend;
  34. AgcVad vadFarend;
  35. } DigitalAgc;
  36. int32_t WebRtcAgc_InitDigital(DigitalAgc* digitalAgcInst, int16_t agcMode);
  37. int32_t WebRtcAgc_ComputeDigitalGains(DigitalAgc* digitalAgcInst,
  38. const int16_t* const* inNear,
  39. size_t num_bands,
  40. uint32_t FS,
  41. int16_t lowLevelSignal,
  42. int32_t gains[11]);
  43. int32_t WebRtcAgc_ApplyDigitalGains(const int32_t gains[11],
  44. size_t num_bands,
  45. uint32_t FS,
  46. const int16_t* const* in_near,
  47. int16_t* const* out);
  48. int32_t WebRtcAgc_AddFarendToDigital(DigitalAgc* digitalAgcInst,
  49. const int16_t* inFar,
  50. size_t nrSamples);
  51. void WebRtcAgc_InitVad(AgcVad* vadInst);
  52. int16_t WebRtcAgc_ProcessVad(AgcVad* vadInst, // (i) VAD state
  53. const int16_t* in, // (i) Speech signal
  54. size_t nrSamples); // (i) number of samples
  55. int32_t WebRtcAgc_CalculateGainTable(int32_t* gainTable, // Q16
  56. int16_t compressionGaindB, // Q0 (in dB)
  57. int16_t targetLevelDbfs, // Q0 (in dB)
  58. uint8_t limiterEnable,
  59. int16_t analogTarget);
  60. } // namespace webrtc
  61. #endif // MODULES_AUDIO_PROCESSING_AGC_LEGACY_DIGITAL_AGC_H_