Using Audio Player to play unencoded files #1288
-
In my application, I am using LittleFS file storage to store short sound clips. The ESP32 will receive a command to play one of the tracks by getting a track number. With the emense help that I got previously, I was able to write a small program that could play a designated track using the streaming method. This demonstrated that a designated file would play but this was just preliminary code. I am now trying to move forward with the rest of the application. The sound clips are all stored in headerless files with 16-bit PWM format. I had originally intended to do it "the hard way" by reading the contents of the file to be played into a buffer and then stream that buffer in the same process as I had used before. But after studying the AudioPlayer class, that seems like the far better way to go. It will take in all the names of the files as defined from the source and all I have to do is set the index and initiate the play. (I assume that the player will have the capabilities as the copier did when streaming when it comes to looping.) My difficulty is that the AudioPlayer is looking for a decoder. There is no real decoder so how do I satisfy what the AudioPlayer is looking for. I played around with Codec16L and may have gotten close but wasn't able to get there. Thanks as always. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
Just use a CopyDecoder which does not change the data |
Beta Was this translation helpful? Give feedback.
-
I made no progress playing the headerless files but wav files play just fine. However, I have not been able to get the selected file to repeat. With player.setAutoNext as false, the selected file plays just once but player remains active. How are replays initiated and hopefully without a delay between them. |
Beta Was this translation helpful? Give feedback.
-
You will need to take care of this yourself by adding some logic. E.g. when you detect the end (e.g. copy returns 0) you can select the next relevant file. |
Beta Was this translation helpful? Give feedback.
-
Done and thank you. ` if (player.copy() == 0) { ` |
Beta Was this translation helpful? Give feedback.
Just use a CopyDecoder which does not change the data