sound overload when connecting an equalizer

Dimych
Posts: 13
Joined: Tue Feb 05, 2019 6:09 am

sound overload when connecting an equalizer

Postby Dimych » 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

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);
Play:

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);

Dimych
Posts: 13
Joined: Tue Feb 05, 2019 6:09 am

Re: sound overload when connecting an equalizer

Postby Dimych » Thu Oct 22, 2020 4:55 pm

I was able to figure out that the equalizer settings are not applied at initialization.
If you adjust the equalizer after starting playback, it works. But in most cases it throws an error ...
Is there a workaround? :cry:

Code: Select all

        audio_element_set_uri(http_reader, uri);    
        audio_pipeline_run(pipeline[SOURCE_MUSIC]);
        //equalizer_t *eq = (equalizer_t *)audio_element_getdata(equalizer);
        int gain[] = { -13, -13, -13, -13, -13, 10, 20, 20, 30, 30, -13, -13, -13, -13, -13, 10, 20, 20, 30, 30};
        for (uint8_t i = 0; i < 20; i++) {
            equalizer_set_gain_info(equalizer, i, gain[i], false);
            //eq->set_gain[i] = gain[i];
        }
        //eq->gain_flag = 1; 

Code: Select all

I (18754) AUDIO_PIPELINE: Pipeline started
I (18754) I2S_STREAM: AUDIO_STREAM_WRITER
I (18755) EQUALIZER: The reset gain[0] of audio stream is -13.
I (18765) EQUALIZER: The reset gain[1] of audio stream is -13.
I (18771) EQUALIZER: The reset gain[2] of audio stream is -13.
I (18778) EQUALIZER: The reset gain[3] of audio stream is -13.
I (18781) EQUALIZER: Reopen equalizer
I (18789) DOWNMIX: Reopen downmix
I (18816) EQUALIZER: The reset gain[4] of audio stream is -13.
I (18816) EQUALIZER: The reset gain[5] of audio stream is 10.
I (18818) EQUALIZER: The reset gain[6] of audio stream is 20.
I (18822) EQUALIZER: Reopen equalizer
I (18832) EQUALIZER: The reset gain[7] of audio stream is 20.
I (18834) EQUALIZER: Reopen equalizer
I (18843) EQUALIZER: The reset gain[8] of audio stream is 30.
I (18846) EQUALIZER: Reopen equalizer
I (18853) EQUALIZER: The reset gain[9] of audio stream is 30.
I (18857) EQUALIZER: Reopen equalizer
I (18864) EQUALIZER: The reset gain[10] of audio stream is -13.
I (18869) EQUALIZER: Reopen equalizer
I (18875) EQUALIZER: The reset gain[11] of audio stream is -13.
I (18878) EQUALIZER: The reset gain[12] of audio stream is -13.
I (18881) EQUALIZER: Reopen equalizer
I (18896) EQUALIZER: The reset gain[13] of audio stream is -13.
I (18896) EQUALIZER: The reset gain[14] of audio stream is -13.
I (18905) EQUALIZER: Reopen equalizer
I (18911) EQUALIZER: The reset gain[15] of audio stream is 10.
I (18913) EQUALIZER: The reset gain[16] oGuru Meditation Error: Core  0 panic'ed (IllegalInstruction). Exception was unhandled.
Memory dump at 0x4008247c: fff3a520 00000090 b2004136
0x4008247c: esp_crosscore_int_send_yield at C:/esp/esp-idf/components/esp32/crosscore_int.c:115

Core  0 register dump:
PC      : 0x40082480  PS      : 0x00060b30  A0      : 0x0000000a  A1      : 0x3ffbb4c0
0x40082480: esp_crosscore_int_send_yield at C:/esp/esp-idf/components/esp32/crosscore_int.c:116

A2      : 0x00000000  A3      : 0x00004356  A4      : 0x3ffc3288  A5      : 0x00060720
A6      : 0x000000fe  A7      : 0x00000001  A8      : 0x80082480  A9      : 0x3ffbb4a0
A10     : 0x3ff000dc  A11     : 0x00000001  A12     : 0x3ffbdd48  A13     : 0x3ffeba54
A14     : 0x3ffebbb0  A15     : 0x00000000  SAR     : 0x0000001d  EXCCAUSE: 0x00000000
EXCVADDR: 0x00000000  LBEG    : 0x40093018  LEND    : 0x40093034  LCOUNT  : 0xffffffff
0x40093018: memcpy at /builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/xtensa-esp32-elf/src/newlib/newlib/libc/machine/xtensa/memcpy.S:175

0x40093034: memcpy at /builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/xtensa-esp32-elf/src/newlib/newlib/libc/machine/xtensa/memcpy.S:197


Backtrace:0x4008247d:0x3ffbb4c0 0x00000007:0x3ffbb4e0 |<-CORRUPTED
0x4008247d: esp_crosscore_int_send_yield at C:/esp/esp-idf/components/esp32/crosscore_int.c:115



ELF file SHA256: dc6ecb4d906e0097

Rebooting...
ets Jun  8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x1b (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:4
load:0x3fff0034,len:7384
load:0x40078000,len:15344
ho 0 tail 12 room 4
load:0x40080400,len:4888
0x40080400: _init at ??:?

entry 0x400806a4

Who is online

Users browsing this forum: No registered users and 19 guests