"WAV" very slow playback #1011
-
sdcard->i2s This library is great, but,The examples in this library are a bit too concise for me. It took me almost a week to get the MP3 playback working properly. I discovered from your previous answers in the issues that the stuttering during MP3 playback was caused by insufficient buffer size. It was necessary to adjust the buffer size and set an appropriate value for I2S_BUFFER_COUNT. Finally, the MP3 playback became normal. static char startFilePath="/"; void setup() { Now I started playing the next file format, "WAV," and encountered the problem of very slow playback. I noticed that most of the reference examples were for MP3 files, with very few examples for other formats. I don't know where to start looking for the cause of this issue, and I'm unsure if it could be related to the buffer size. I hope to find the solution here. char startFilePath="/"; AudioSourceSDFAT source(startFilePath, ext); |
Beta Was this translation helpful? Give feedback.
Replies: 15 comments 18 replies
-
Significantly increasing the DEFAULT_BUFFER_SIZE and I2S_BUFFER_COUNT has improved the situation, but the exact values still need to be determined. I hope to have a reference value. |
Beta Was this translation helpful? Give feedback.
-
For me all the examples are working perfectly w/o any changes. I suggest that you investigate and maybe try to optimize the SD speed. As far as the other topics are concerned I suggest to spend some more time to read the documentation. There is a separate chapter about codecs! If you have issues with decoding high bitrate MP3 you would need to read the documentation provided by libhelix. |
Beta Was this translation helpful? Give feedback.
-
I agree 2 seems to be a bit low and I am usually using 10 with the AudioKit. I will increase the default to 10. |
Beta Was this translation helpful? Give feedback.
-
You would not need to do anything, this should be automatically handled by the decoder from the information in the WAV or mp3 file |
Beta Was this translation helpful? Give feedback.
-
Well, I have never tried something like this because the resulting file size just takes up too much space w/o gaining anything. |
Beta Was this translation helpful? Give feedback.
-
Maybe you will need to follow up the error! |
Beta Was this translation helpful? Give feedback.
-
playing a 48000Hz 24-bit WAV file.
data length > result, causing a memory access error MCU Rebooting.... When I changed it to:
data length = result, but there is no sound (no data output to I2S). I tried to find the cause of the error.
It seems that the line size_t result = writer_ptr->write(data, len) in AudioEncoded.h is related, but I don't know which file it jumps to and couldn't find the specific execution code." |
Beta Was this translation helpful? Give feedback.
-
The crash is coming from the volume processing because of the wrong size for int14_t. But there is another problem which needs to be addressed: in the wav file int24 has 3 bytes but on the ESP32 it expects 4 bytes. I am not sure yet how and where to handle this. Probably with some special logic in the wav decoder |
Beta Was this translation helpful? Give feedback.
-
I committed some draft implementation. ps. I just made the test with your file on an AudioKit with SDMMC and it works perfectly: please note that the SD speed becomes critical here and it important to set the log level to Warning or Error! |
Beta Was this translation helpful? Give feedback.
-
Strange: for me it is working perfectly! You should not even get any copy size > 1024 ! 10:11:23.446 -> [I] StreamCopy.h : 139 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops Are you sure that you did not do any local changes ? |
Beta Was this translation helpful? Give feedback.
-
So, in a nutshell, you need to work on improving the speed for reading from your sd! The best way to deal with this is by measuring the transfer speed and compare it with the required speeds ps. you can still test the 24bits but you need to resample your file to reduce the sample rate to e.g 8000 |
Beta Was this translation helpful? Give feedback.
-
You don't give me any information I could work with. For the other APIs double check and increase the SPI rate! You should not really increase the DEFAULT_BUFFER_SIZE above 1k... .. I am starting to think that something is wrong with your SD card. It can't be that a simple copy from the SD to I2S w/o doing anything is slow... |
Beta Was this translation helpful? Give feedback.
-
I can't reproduce any of your issues: my example is playing just fine w/o any changes to the configuration! I think you just forgot to set the logger to some reasonable setting... |
Beta Was this translation helpful? Give feedback.
-
Actually, I tried it with the player and I can hear what you mean. It seems that the volume calculation for 24 bit is taking too long! Maybe we should extend the AudioPlayer to make the volume control optional... |
Beta Was this translation helpful? Give feedback.
-
https://github.com/pschatzmann/arduino-audiokit/wiki/Supported-Sampling-Rates |
Beta Was this translation helpful? Give feedback.
For me all the examples are working perfectly w/o any changes.
I suggest that you investigate and maybe try to optimize the SD speed.
The best thru-put you can get with a 4 pin SDMMC.
As far as the other topics are concerned I suggest to spend some more time to read the documentation. There is a separate chapter about codecs!
If you have issues with decoding high bitrate MP3 you would need to read the documentation provided by libhelix.