so i'm trying to use the built-in DAC with i2s.
It's outputing audio which i'm streaming over a2dp from a android device.
My problem is, i only get a squarewave output, instead of a "analog" signal.
As a result the audio is horrible.
I tried it with the following code in my a2d data-callback:
Code: Select all
void a2dDataCallback(const uint8_t *buf, uint32_t len) {
const char* data = (char*)buf;
i2s_write_bytes(I2S_NUM_0, data, len, portMAX_DELAY);
}
Code: Select all
i2s_config_t i2sconfig;
i2sconfig.mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_TX | I2S_MODE_DAC_BUILT_IN);
i2sconfig.bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT;
i2sconfig.sample_rate = 44100;
i2sconfig.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT;
i2sconfig.communication_format = I2S_COMM_FORMAT_I2S_MSB;
i2sconfig.dma_buf_count = 8;
i2sconfig.dma_buf_len = 64;
i2sconfig.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1;
i2s_driver_install(I2S_NUM_0, &i2sconfig, 0, NULL);
i2s_set_dac_mode(I2S_DAC_CHANNEL_BOTH_EN);
i2s_set_pin(I2S_NUM_0, NULL);
Thanks for your help.