Page 1 of 1

i2s produces strange bluetooth audio

Posted: Mon Mar 25, 2019 7:13 pm
by Flostra
I used the a2dp_sink example from the esp idf and adapted it to use the internal DACs.
I adjusted the i2s config a bit:
a2dp_sink.zip
(18.17 KiB) Downloaded 355 times
[Codebox]
esp_log_level_set("*", ESP_LOG_VERBOSE);
/* Initialize NVS — it is used to store PHY calibration data */
esp_err_t ret = nvs_flash_init();
if (ret == ESP_ERR_NVS_NO_FREE_PAGES) {
ESP_ERROR_CHECK(nvs_flash_erase());
ret = nvs_flash_init();
}
ESP_ERROR_CHECK( ret );

i2s_config_t i2s_config = {
.mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_TX | I2S_MODE_PDM ), // Only TX
.sample_rate = 44100,
.bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT,
.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT, //2-channels
.communication_format = I2S_COMM_FORMAT_I2S,
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1,
.dma_buf_count = 6,
.dma_buf_len = 64, //
.use_apll = false,
};

i2s_driver_install(I2S_NUM_0, &i2s_config, 0, NULL);

/*i2s_pin_config_t pin_config = {
.bck_io_num = 26,
.ws_io_num = 25,
.data_out_num = 27,
.data_in_num = -1 //Not used
};*/
i2s_set_dac_mode(I2S_DAC_CHANNEL_BOTH_EN);
i2s_set_pin(I2S_NUM_0, NULL);
[/Codebox]

Now it plays with the built-in DACs. But the audio signal
pretty noisy when I play something.
Besides, the sounds are weird.
When I play a sine wave, the frequency sounds deeper.
In addition, I can see on an oscilloscope that the lower half of the sine is compressed and the upper one is pulled wide.
I hope, someone can help me.
Flo S

;) Sorry fpr my bad English. I am from Germany.