ESP ADF : Pipe (SDCard - MP3Decoder - I2S) => Wrong Sample Rate
Posted: Tue Feb 14, 2023 2:23 pm
Good afternoon,
I have tried to implement a pipe in order to decode a MP3 file on a SDCard and to sent it to an audio amplifier using I2S.
The program compiles normally, using an oscilloscope, I can see datas on the I2S_Out, so I think that the MP3 file is decoded and sent.
However, the LR_CLK and the BIT_CLK are not OK.
I would like to have a LR_CLK = 16KHz (Equal to the sample rate) but I have a LR_CLK = 1,3KHz.
The BIT_CLK is 96Khz.
So I do not ear anything on my amplifier.
Here is my config :
i2s_stream_cfg_t i2s_cfg;
i2s_cfg.type = AUDIO_STREAM_WRITER;
i2s_cfg.i2s_config.mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_TX);
i2s_cfg.i2s_config.sample_rate = 16000;
i2s_cfg.i2s_config.bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT;
i2s_cfg.i2s_config.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT;
i2s_cfg.i2s_config.communication_format = I2S_COMM_FORMAT_STAND_I2S;
i2s_cfg.i2s_config.intr_alloc_flags = ESP_INTR_FLAG_LEVEL2 | ESP_INTR_FLAG_IRAM;
i2s_cfg.i2s_config.dma_buf_count = 3;
i2s_cfg.i2s_config.dma_buf_len = 300;
i2s_cfg.i2s_config.use_apll = false;
i2s_cfg.i2s_config.tx_desc_auto_clear = true;
i2s_cfg.i2s_config.fixed_mclk = 0;
i2s_cfg.i2s_config.mclk_multiple = I2S_MCLK_MULTIPLE_384;
i2s_cfg.i2s_port = I2S_NUM_0;
i2s_cfg.use_alc = false;
i2s_cfg.volume = 0;
i2s_cfg.out_rb_size = I2S_STREAM_RINGBUFFER_SIZE;
i2s_cfg .task_stack = I2S_STREAM_TASK_STACK;
i2s_cfg.task_core = I2S_STREAM_TASK_CORE;
i2s_cfg.task_prio = I2S_STREAM_TASK_PRIO;
i2s_cfg.stack_in_ext = false;
i2s_cfg.multi_out_num = 0;
i2s_cfg.uninstall_drv = true;
i2s_cfg.need_expand = false;
i2s_cfg.expand_src_bits = I2S_BITS_PER_SAMPLE_16BIT;
i2s_stream_writer = i2s_stream_init(&i2s_cfg);
Could you please help me on the subject ?
Best regards,
Thomas TRUILHE.
I have tried to implement a pipe in order to decode a MP3 file on a SDCard and to sent it to an audio amplifier using I2S.
The program compiles normally, using an oscilloscope, I can see datas on the I2S_Out, so I think that the MP3 file is decoded and sent.
However, the LR_CLK and the BIT_CLK are not OK.
I would like to have a LR_CLK = 16KHz (Equal to the sample rate) but I have a LR_CLK = 1,3KHz.
The BIT_CLK is 96Khz.
So I do not ear anything on my amplifier.
Here is my config :
i2s_stream_cfg_t i2s_cfg;
i2s_cfg.type = AUDIO_STREAM_WRITER;
i2s_cfg.i2s_config.mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_TX);
i2s_cfg.i2s_config.sample_rate = 16000;
i2s_cfg.i2s_config.bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT;
i2s_cfg.i2s_config.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT;
i2s_cfg.i2s_config.communication_format = I2S_COMM_FORMAT_STAND_I2S;
i2s_cfg.i2s_config.intr_alloc_flags = ESP_INTR_FLAG_LEVEL2 | ESP_INTR_FLAG_IRAM;
i2s_cfg.i2s_config.dma_buf_count = 3;
i2s_cfg.i2s_config.dma_buf_len = 300;
i2s_cfg.i2s_config.use_apll = false;
i2s_cfg.i2s_config.tx_desc_auto_clear = true;
i2s_cfg.i2s_config.fixed_mclk = 0;
i2s_cfg.i2s_config.mclk_multiple = I2S_MCLK_MULTIPLE_384;
i2s_cfg.i2s_port = I2S_NUM_0;
i2s_cfg.use_alc = false;
i2s_cfg.volume = 0;
i2s_cfg.out_rb_size = I2S_STREAM_RINGBUFFER_SIZE;
i2s_cfg .task_stack = I2S_STREAM_TASK_STACK;
i2s_cfg.task_core = I2S_STREAM_TASK_CORE;
i2s_cfg.task_prio = I2S_STREAM_TASK_PRIO;
i2s_cfg.stack_in_ext = false;
i2s_cfg.multi_out_num = 0;
i2s_cfg.uninstall_drv = true;
i2s_cfg.need_expand = false;
i2s_cfg.expand_src_bits = I2S_BITS_PER_SAMPLE_16BIT;
i2s_stream_writer = i2s_stream_init(&i2s_cfg);
Could you please help me on the subject ?
Best regards,
Thomas TRUILHE.