sound overload when connecting an equalizer
Posted: Thu Oct 22, 2020 10:30 am
Hi,
I use the http_stream->mp3_decoder->equalizer->i2s_out stream chain.
The sound is very overloaded, there is no reaction to the settings band gain equalizer.
If you exclude the equalizer stream, then everything is ok.
What could be the problem?
Windows
ESP-IDF v4.2-beta1-86-gdddcc2ede-dirty
ESP-ADF v2.1-67-gbafffc5-dirty
I tried setting the bands from -50db to 0db. No change.
Init
Play:
I use the http_stream->mp3_decoder->equalizer->i2s_out stream chain.
The sound is very overloaded, there is no reaction to the settings band gain equalizer.
If you exclude the equalizer stream, then everything is ok.
What could be the problem?
Windows
ESP-IDF v4.2-beta1-86-gdddcc2ede-dirty
ESP-ADF v2.1-67-gbafffc5-dirty
I tried setting the bands from -50db to 0db. No change.
Init
Code: Select all
i2s_config_t i2s_config_out = {
.mode = I2S_MODE_MASTER | I2S_MODE_TX,
.sample_rate = SAMPLE_RATE,
.bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT,
.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT,
.communication_format = I2S_COMM_FORMAT_I2S,
.dma_buf_count = 4,
.dma_buf_len = 512,
.use_apll = 1,
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL2 | ESP_INTR_FLAG_IRAM,
.tx_desc_auto_clear = true,
};
i2s_pin_config_t out_pin_cfg = {
.bck_io_num = GPIO_SPEAKER_SCLK,
.ws_io_num = GPIO_SPEAKER_LRCK,
.data_out_num = GPIO_SPEAKER_DATA,
.data_in_num = I2S_PIN_NO_CHANGE
};
i2s_stream_cfg_t i2s_cfg = I2S_STREAM_CFG_DEFAULT();
i2s_cfg.i2s_port = I2S_NUM_1;
i2s_cfg.i2s_config = i2s_config_out;
i2s_cfg.out_rb_size = X_SIZE_BUFF * 8 * 1024;
i2s_cfg.stack_in_ext = true;
i2s_cfg.use_alc = true;
//i2s_cfg.task_core = 1;
i2s_output = i2s_stream_init(&i2s_cfg);
//install and start i2s driver
i2s_driver_install(I2S_NUM_1, &i2s_config_out, 0, NULL);
i2s_set_pin(I2S_NUM_1, &out_pin_cfg);
#ifdef GPIO_SPEAKER_MCLK_GPIO_0
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO0_U, FUNC_GPIO0_CLK_OUT1);
WRITE_PERI_REG(PIN_CTRL, 0xFFFF);
#else
#error "error pin speaker mclk"
#endif
audio_pipeline_cfg_t pipeline_cfg = DEFAULT_AUDIO_PIPELINE_CONFIG();
pipeline_cfg.rb_size = X_SIZE_BUFF * 8 * 1024;
pipeline[SOURCE_MUSIC] = audio_pipeline_init(&pipeline_cfg);
http_stream_cfg_t http_cfg = HTTP_STREAM_CFG_DEFAULT();
http_cfg.out_rb_size = X_SIZE_BUFF * 20 * 1024;
http_cfg.task_core = PLAYER_TASK_CORE;
http_reader = http_stream_init(&http_cfg);
mp3_decoder_cfg_t cfg = DEFAULT_MP3_DECODER_CONFIG();
cfg.out_rb_size = X_SIZE_BUFF * 2 * 1024;
cfg.task_core = PLAYER_TASK_CORE;
audio_element_handle_t decoder = mp3_decoder_init(&cfg);
equalizer_cfg_t eq_cfg = DEFAULT_EQUALIZER_CONFIG();
int set_gain[] = { -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, -13};
//int set_gain[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
//int set_gain[] = { -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50};
eq_cfg.samplerate = SAMPLE_RATE;
eq_cfg.channel = 2;
eq_cfg.task_core = PLAYER_TASK_CORE;
eq_cfg.out_rb_size = X_SIZE_BUFF * 8 * 1024;
eq_cfg.set_gain =
set_gain; // The size of gain array should be the multiplication of NUMBER_BAND and number channels of audio stream data. The minimum of gain is -13 dB.
equalizer = equalizer_init(&eq_cfg);
audio_pipeline_register(pipeline[SOURCE_MUSIC], http_reader, "http_stream");
audio_pipeline_register(pipeline[SOURCE_MUSIC], decoder, "http_decode");
audio_pipeline_register(pipeline[SOURCE_MUSIC], equalizer, "equalizer");
audio_pipeline_register(pipeline[SOURCE_MUSIC], i2s_output, "i2s_out");
audio_pipeline_link(pipeline[SOURCE_MUSIC], (const char *[]) {"http_stream", "http_decode", "equalizer", "i2s_out"}, 4);
audio_element_set_event_callback(decoder, audio_element_event_handler, NULL);
for (uint8_t i = 0; i < 20; i++)
equalizer_set_gain_info(equalizer,i, -40, false);
Code: Select all
audio_element_set_uri(http_reader, uri);
i2s_alc_volume_set(i2s_output, 0);
audio_pipeline_run(pipeline[SOURCE_MUSIC]);
equalizer_set_info(equalizer, 44100, 2);
for (uint8_t i = 0; i < 20; i++)
equalizer_set_gain_info(equalizer,i, -40, false);