Equalizer¶
Provided in this API equalizer supports:
fixed number of ten (10) bands;
four sample rates: 11025 Hz, 22050 Hz, 44100 Hz and 48000 Hz.
The center frequencies of bands are shown in table below.
Band Index |
0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
---|---|---|---|---|---|---|---|---|---|---|
Frequency |
31 Hz |
62 Hz |
125 Hz |
250 Hz |
500 Hz |
1 kHz |
2 kHz |
4 kHz |
8 kHz |
16 kHz |
Default gain of each band is -13 dB. To set the gains of all bands use structure equalizer_cfg
. To set the gain of individual band use function equalizer_set_gain_info()
.
Application Example¶
Implementation of this API is demonstrated in the audio_processing/pipeline_equalizer example.
API Reference¶
Header File¶
Functions¶
-
esp_err_t
equalizer_set_info
(audio_element_handle_t self, int rate, int ch)¶ Set the audio sample rate and the number of channels to be processed by the equalizer.
- Return
ESP_OK on success
ESP_ERR_INVALID_ARG invalid arguments
- Parameters
self
: Audio element handlerate
: Audio sample ratech
: Audio channel
-
esp_err_t
equalizer_set_gain_info
(audio_element_handle_t self, int index, int value_gain, bool is_channels_gain_equal)¶ Set the audio gain to be processed by the equalizer.
- Return
ESP_OK on success
ESP_ERR_INVALID_ARG invalid arguments
- Parameters
self
: Audio element handleindex
: The position of center frequencies of equalizer. If channel is mono, the index range is [0, 9]; If channel is stereo andis_channels_gain_equal
is true, the index range is [0, 9]; If channel is stereo andis_channels_gain_equal
is false, the index range is [0, 19];value_gain
: The value of audio gain which inindex
is_channels_gain_equal
: If audio channel is stereo, the audio gain values of two channels are equal whenis_channels_gain_equal
istrue
, otherwise it means unequal.
-
audio_element_handle_t
equalizer_init
(equalizer_cfg_t *config)¶ Create an Audio Element handle that equalizes incoming data.
- Return
The audio element handler
- Parameters
config
: The configuration
Structures¶
-
struct
equalizer_cfg
¶ Equalizer Configuration.
+——————————————————–
+ | MONO | +——————————————————–+ | Only Left channel/Only Right channel | +——————————————————–+ |band0|band1|band2|band3|band4|band5|band6|band7|band8|band9| +——————————————————–+ | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | +——————————————————–+- Note
1) This figure indicate the default eq gain of every band in current equalizer. 2) Every channel have 10 band to set.
+——————————————————–+——————————————————–+ | DUAL | +——————————————————–+——————————————————–+ | Left channel | Right channel | +——————————————————–+——————————————————–+ |band0|band1|band2|band3|band4|band5|band6|band7|band8|band9|band0|band1|band2|band3|band4|band5|band6|band7|band8|band9| +——————————————————–+——————————————————–+ | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | +——————————————————–+——————————————————–+
3) Different sample rates support different EQ frequency bands. 11025: {31, 62, 125, 250, 500, 1000, 2000, 3000, 4000, 5500} 22050: {31, 62, 125, 250, 500, 1000, 2000, 4000, 8000, 11000} 44100/48000: {31, 62, 125, 250, 500, 1000, 2000, 4000, 8000, 16000}
Public Members
-
int
samplerate
¶ Audio sample rate. Supported samplerate: 11025, 22050, 44100, 48000, unit: Hz
-
int
channel
¶ Number of audio channels. Supported channel: mono, stereo
-
int *
set_gain
¶ Equalizer gain
-
int
out_rb_size
¶ Size of output ring buffer
-
int
task_stack
¶ Task stack size
-
int
task_core
¶ Task running in core…
-
int
task_prio
¶ Task priority
-
bool
stack_in_ext
¶ Try to allocate stack in external memory
Macros¶
-
EQUALIZER_TASK_STACK
¶
-
EQUALIZER_TASK_CORE
¶
-
EQUALIZER_TASK_PRIO
¶
-
EQUALIZER_RINGBUFFER_SIZE
¶
-
DEFAULT_EQUALIZER_CONFIG
()¶
Type Definitions¶
-
typedef struct equalizer_cfg
equalizer_cfg_t
¶ Equalizer Configuration.
+——————————————————–
+ | MONO | +——————————————————–+ | Only Left channel/Only Right channel | +——————————————————–+ |band0|band1|band2|band3|band4|band5|band6|band7|band8|band9| +——————————————————–+ | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | +——————————————————–+- Note
1) This figure indicate the default eq gain of every band in current equalizer. 2) Every channel have 10 band to set.
+——————————————————–+——————————————————–+ | DUAL | +——————————————————–+——————————————————–+ | Left channel | Right channel | +——————————————————–+——————————————————–+ |band0|band1|band2|band3|band4|band5|band6|band7|band8|band9|band0|band1|band2|band3|band4|band5|band6|band7|band8|band9| +——————————————————–+——————————————————–+ | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | +——————————————————–+——————————————————–+
3) Different sample rates support different EQ frequency bands. 11025: {31, 62, 125, 250, 500, 1000, 2000, 3000, 4000, 5500} 22050: {31, 62, 125, 250, 500, 1000, 2000, 4000, 8000, 11000} 44100/48000: {31, 62, 125, 250, 500, 1000, 2000, 4000, 8000, 16000}