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.

  • Equalizer frequency bands at 11025 Hz sample rate

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

3 kHz

4 kHz

5.5 kHz

  • Equalizer frequency bands at 22050 Hz sample rate

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

11 kHz

  • Equalizer frequency bands at 44100 and 48000 Hz sample rate

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.

Parameters
  • self – Audio element handle

  • rate – Audio sample rate

  • ch – Audio channel

Returns

  • ESP_OK on success

  • ESP_ERR_INVALID_ARG invalid arguments

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.

Parameters
  • self – Audio element handle

  • index – The position of center frequencies of equalizer. If channel is mono, the index range is [0, 9]; If channel is stereo and is_channels_gain_equal is true, the index range is [0, 9]; If channel is stereo and is_channels_gain_equal is false, the index range is [0, 19];

  • value_gain – The value of audio gain which in index

  • is_channels_gain_equal – If audio channel is stereo, the audio gain values of two channels are equal when is_channels_gain_equal is true, otherwise it means unequal.

Returns

  • ESP_OK on success

  • ESP_ERR_INVALID_ARG invalid arguments

audio_element_handle_t equalizer_init(equalizer_cfg_t *config)

Create an Audio Element handle that equalizes incoming data.

Parameters

config – The configuration

Returns

The audio element handler

Structures

struct equalizer_cfg

Equalizer Configuration.

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.