Using libFLAC on ESP32 with PCM5102A for 44.1/16/2 audio #1596
-
Hi Phil, Hope you're well. My setup is Adafruit Huzzah32 with ESP32 WROOM32 and an Adafruit Adalogger with SanDisk Ultra Extreme Pro SD card. I have connected a PCM5102A DAC board and have soldered the FMT jumper to LOW.
Here are my read and write callbacks with relevant definitions: FLAC__StreamDecoderReadStatus read_callback(
} // end while I run the decoding and i2s processing in a high priority task. APPLICATION_CPU is defined as 1 Sorry for the long post! and thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments 9 replies
-
I suggest to compare your result with my example sketch: Just replace the AudioBoardStream with an regular I2SStream. If this is giving the same bad result you will need to check the encoing of your files: I think a level of 0 (fastest) or 1 gives the best result and an ESP32 might not be powerfull enough to handle 8 (best quality). Using the AudioTools has the advantage that you don't need to rewrite your sketch if you move to the latest ESP 3.0.1 core version. |
Beta Was this translation helpful? Give feedback.
-
To add volume control, just wrap I2S with a VolumeStream and use the VolumeStream as output. You can compile an AudioTools sketch on Rasperrry Pi as well... |
Beta Was this translation helpful? Give feedback.
-
Coffee is on the way :) |
Beta Was this translation helpful? Give feedback.
-
Hey Phil, |
Beta Was this translation helpful? Give feedback.
-
I extended the begin() logic a bit, so that the decoder gets closed with FLAC__stream_decoder_finish when it is open before calling FLAC__stream_decoder_init_stream. So just call dec.begin() again after assigning a new file. |
Beta Was this translation helpful? Give feedback.
-
Ok, I see: I replaced the checking logic to use FLAC__stream_decoder_get_state() instead of is_active |
Beta Was this translation helpful? Give feedback.
-
I don't quite understand ?
You can avoid the 'not active' Error message above with while (dec) dec.copy(); |
Beta Was this translation helpful? Give feedback.
-
The line numbers of the logging does not match with the actual code. |
Beta Was this translation helpful? Give feedback.
I suggest to compare your result with my example sketch: Just replace the AudioBoardStream with an regular I2SStream.
If this is giving the same bad result you will need to check the encoing of your files: I think a level of 0 (fastest) or 1 gives the best result and an ESP32 might not be powerfull enough to handle 8 (best quality).
Using the AudioTools has the advantage that you don't need to rewrite your sketch if you move to the latest ESP 3.0.1 core version.