MrBuddyCasino / ESP32_MP3_Decoder

A internet radio and bluetooth speaker project for the Espressif ESP32
776 stars 182 forks source link

Built-In DAC does not work #1

Closed MrBuddyCasino closed 7 years ago

MrBuddyCasino commented 7 years ago

Running without the I2S codec can be activated by uncommenting "#define USE_DAC", but this does not currently work.

If anyone has experience using I2S_MODE_DAC_BUILT_IN, please have a look!

negativekelvin commented 7 years ago

No experience but i2s_set_pin https://github.com/MrBuddyCasino/ESP32_MP3_Decoder/blob/master/main/app_main.c#L304 Looks like should be called with null value https://github.com/espressif/esp-idf/blob/master/components/driver/i2s.c#L390

MrBuddyCasino commented 7 years ago

Good catch! Will try that out.

MrBuddyCasino commented 7 years ago

Makes a sound now, but nothing you'd want to listen to.

negativekelvin commented 7 years ago

Hmm have you tried to use only I2S_MODE_DAC_BUILT_IN flag

MrBuddyCasino commented 7 years ago

Yes, look at he init_i2s_dac() function in app_main.c. Its doing exactly what the sample code in i2s.h says we should do:

` * ----------------EXAMPLE USING I2S WITH DAC ---------------------

Spritetm commented 7 years ago

Fyi, it seems the I2S driver has a bug in DAC mode: the sample rate it sets is actually 8 times the sample rate you tell it to use. I have a bug fix in the internal merge queue, it will probably be merged after the holidays.

glennhuber commented 7 years ago

When will this bug fix be available?

MrBuddyCasino commented 7 years ago

The SDK fix hasn't landed yet, but in theory you can workaround the issue by modifying set_dac_sample_rate(int rate) and init_i2s_dac() to divide the sample rate by 8. Haven't tested that, though.

MrBuddyCasino commented 7 years ago

Supersat's changes indeed fix this issue. I2S codec no longer strictly required. :-)