ax_audio_process.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /**********************************************************************************
  2. *
  3. * Copyright (c) 2019-2020 Beijing AXera Technology Co., Ltd. All Rights Reserved.
  4. *
  5. * This source file is the property of Beijing AXera Technology Co., Ltd. and
  6. * may not be copied or distributed in any isomorphic form without the prior
  7. * written consent of Beijing AXera Technology Co., Ltd.
  8. *
  9. **********************************************************************************/
  10. #ifndef _AX_AUDIO_PROCESS_H__
  11. #define _AX_AUDIO_PROCESS_H__
  12. #include "ax_base_type.h"
  13. #include "ax_global_type.h"
  14. typedef enum axAEC_MODE_E {
  15. AEC_MODE_DISABLE = 0,
  16. AEC_MODE_FLOAT,
  17. AEC_MODE_FIXED,
  18. } AEC_MODE_E;
  19. typedef enum axSUPPRESSION_LEVEL_E {
  20. SUPPRESSION_LEVEL_LOW = 0,
  21. SUPPRESSION_LEVEL_MODERATE,
  22. SUPPRESSION_LEVEL_HIGH
  23. } SUPPRESSION_LEVEL_E;
  24. typedef struct axAEC_FLOAT_CONFIG_S {
  25. SUPPRESSION_LEVEL_E enSuppressionLevel;
  26. } AEC_FLOAT_CONFIG_S;
  27. // Recommended settings for particular audio routes. In general, the louder
  28. // the echo is expected to be, the higher this value should be set. The
  29. // preferred setting may vary from device to device.
  30. typedef enum axROUTING_MODE_E {
  31. ROUTING_MODE_QUITE_EARPIECE_OR_HEADSET = 0,
  32. ROUTING_MODE_EARPIECE,
  33. ROUTING_MODE_LOUD_EARPIECE,
  34. ROUTING_MODE_SPEAKERPHONE,
  35. ROUTING_MODE_LOUD_SPEAKERPHONE
  36. } ROUTING_MODE_E;
  37. typedef struct axAEC_FIXED_CONFIG_S {
  38. ROUTING_MODE_E eRoutingMode;
  39. } AEC_FIXED_CONFIG_S;
  40. typedef struct axAEC_CONFIG_S {
  41. AEC_MODE_E enAecMode;
  42. union {
  43. /*0 ~ 2 default 0*/
  44. AEC_FLOAT_CONFIG_S stAecFloatCfg;
  45. /*0 ~ 4 default 3*/
  46. AEC_FIXED_CONFIG_S stAecFixedCfg;
  47. };
  48. } AEC_CONFIG_S;
  49. // Determines the aggressiveness of the suppression. Increasing the level
  50. // will reduce the noise level at the expense of a higher speech distortion.
  51. typedef enum axAGGRESSIVENESS_LEVEL {
  52. AGGRESSIVENESS_LEVEL_LOW = 0,
  53. AGGRESSIVENESS_LEVEL_MODERATE,
  54. AGGRESSIVENESS_LEVEL_HIGH,
  55. AGGRESSIVENESS_LEVEL_VERYHIGH
  56. } AGGRESSIVENESS_LEVEL_E;
  57. typedef struct axNS_CONFIG_S {
  58. AX_BOOL bNsEnable;
  59. /*0 ~ 3 default 2*/
  60. AGGRESSIVENESS_LEVEL_E enAggressivenessLevel;
  61. } NS_CONFIG_S;
  62. typedef enum axAGC_MODE_E {
  63. // Adaptive mode intended for use if an analog volume control is available
  64. // on the capture device. It will require the user to provide coupling
  65. // between the OS mixer controls and AGC through the |stream_analog_level()|
  66. // functions.
  67. //
  68. // It consists of an analog gain prescription for the audio device and a
  69. // digital compression stage.
  70. AGC_MODE_ADAPTIVE_ANALOG = 0,
  71. // Adaptive mode intended for situations in which an analog volume control
  72. // is unavailable. It operates in a similar fashion to the adaptive analog
  73. // mode, but with scaling instead applied in the digital domain. As with
  74. // the analog mode, it additionally uses a digital compression stage.
  75. AGC_MODE_ADAPTIVE_DIGITAL,
  76. // Fixed mode which enables only the digital compression stage also used by
  77. // the two adaptive modes.
  78. //
  79. // It is distinguished from the adaptive modes by considering only a
  80. // short time-window of the input signal. It applies a fixed gain through
  81. // most of the input level range, and compresses (gradually reduces gain
  82. // with increasing level) the input signal at higher levels. This mode is
  83. // preferred on embedded devices where the capture signal level is
  84. // predictable, so that a known gain can be applied.
  85. AGC_MODE_FIXED_DIGITAL
  86. } AGC_MODE_E;
  87. typedef struct axAGC_CONFIG_S {
  88. AX_BOOL bAgcEnable;
  89. AGC_MODE_E enAgcMode;
  90. /*-31 ~ 0 default -3*/
  91. AX_S16 s16TargetLevel;
  92. /*0 ~ 90 default 9*/
  93. AX_S16 s16Gain;
  94. } AGC_CONFIG_S;
  95. typedef struct axAUDIO_PROCESS_ATTR_S {
  96. AX_S32 s32SampleRate;
  97. AX_U32 u32FrameSamples;
  98. AEC_CONFIG_S stAecCfg;
  99. NS_CONFIG_S stNsCfg;
  100. AGC_CONFIG_S stAgcCfg;
  101. } AUDIO_PROCESS_ATTR_S;
  102. #ifdef __cplusplus
  103. extern "C" {
  104. #endif
  105. AX_S32 AX_AUDIO_PROCESS_Init(const AUDIO_PROCESS_ATTR_S *pstAudioProcessAttr);
  106. AX_S32 AX_AUDIO_PROCESS_Proc(AX_VOID *in_data, AX_VOID *ref_data, AX_VOID *out_data);
  107. AX_S32 AX_AUDIO_PROCESS_DeInit();
  108. AX_VOID AX_AUDIO_InterleavedToNoninterleaved16(AX_S16 *interleaved, AX_U32 frameCount, AX_S16 *left, AX_S16 *right);
  109. AX_VOID AX_AUDIO_MonoToStereo16(AX_S16 *mono, AX_U32 frameCount, AX_S16 *stereo);
  110. #ifdef __cplusplus
  111. }
  112. #endif
  113. #endif /* _AX_AUDIO_PROCESS_H__ */