Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use an existing buffer #22

Open
lidense opened this issue Dec 13, 2023 · 3 comments
Open

How to use an existing buffer #22

lidense opened this issue Dec 13, 2023 · 3 comments

Comments

@lidense
Copy link

lidense commented Dec 13, 2023

Hi, I have used your app to listen to some radios and works great. Now I have developed a small app that provides a buffer in a loop with some aac audio data in chunks of about 1600 bytes coming from an decoded HLS stream. The buffer has this format: uint8 * data.
I can play the data using Adafruit VS1053 library with this code
if(vs_player.readyForData())
vs_player.playData(data,read);
but the sound is hashed and sometimes some bits are skipped.
I thought that using a circular buffer like esp32 Stream vs1053 might be better but I don't see how to feed the data to the stream.
I see that the main function stream.connectTohost is used to create a stream from a website, how can I instead feed by data buffer to the stream and get it played from vs1053?
Thanks for your help.

@CelliesProjects
Copy link
Owner

Hi lidense.

how can I instead feed by data buffer to the stream and get it played from vs1053?

Not that easy I think. This library is intended purely as a (internet) stream client.
All internal functions depend on a WiFiClient pointer to function.
Something like you suggest would require a separate codepath in the loop to function.
And probably several helper functions.

@CelliesProjects
Copy link
Owner

CelliesProjects commented Dec 14, 2023

If that is all your app is doing then you could maybe use just the VS1053 library and use the
VS1053 playChunk() function.

It says that the function blocks, but that is only true if you dont use data_request() as a good to go signal.

This library uses playChunk() exactly in that way. Simplified:

While data_request() is true, { send max 32 bytes if any data left }

https://github.com/CelliesProjects/ESP32_VS1053_Stream/blob/master/src/ESP32_VS1053_Stream.cpp#L584-L596

If you dont mind blocking use it to send the whole buffer in one go:

void playChunk(data, len);

@lidense
Copy link
Author

lidense commented Dec 15, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants