-
Notifications
You must be signed in to change notification settings - Fork 37
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
A way to suppress the glitches and other streaming troubles #52
Comments
Probably with http/1.0 server sending not chunked stream because 1.0 doesn't support chunked transfer encoding. |
In fact, the radio example was delivered by vincegellar based on his hardware+software project (using this vS1053 library).
Maybe it's also about the hardware. There is a number of different boards.
Ok, this is also the way to work around the problem.
Hmm, this might be the thing. The good is that workaround works. |
I ran the WebRadioChunked sketch, and to my ear, it sounds much better. My wife is a trained professional musician, and she reported that it sounded worse than the original, non-chunked radio. I say it sounds better, because there is less of the clicking going on. I found that very annoying. But my wife may have a point. It may be that the chirping and burbling on this version is more frequent. I am not sure how to best describe the sound, I don't know how to make a recording. I would say that the audio has a watery sound, some times. Like a singer trying to sing with a mouth full of water. So thanks for the updated code. It sounds better to me. |
the watering effect may be due by a part of the streaming is lost. I made tests to listen a stream with few lost bytes, and I get this effect. |
@ewbarnes53 did you add build_flags = -D PIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH ? please look at RingBufferDemo.cpp https://github.com/baldram/ESP_VS1053_Library/pull/54/commits |
I saw this, but did not understand what it was, or how it worked, so I removed it. I am using the ESP32 from Adafruit, so I don't know if any changes are needed. Sorry. I do not have a clue here. Suddenly, a couple of nights ago, my Web Radio Player started working. For most stations now, the worst I am seeing is occasional drop outs. One channel has watery sounding audio still. Update: Ok, now I see some references to platformIO. I don't think I am going to install and learn a new tool. Sorry about that. |
@ewbarnes53 nwm, that option is for esp8266. But my pull request can help with proper buffering stream. |
@ewbarnes53 Would you willing to test this RingBufferDemo.cpp whether it works any better with your stations? |
I am now running the RingBufferDemo sketch. I am connected to a 320 kbps station. It seems to be working very well. The print statement doesn't tell me much. It always prints 0. |
hm... you should see 0-100%, its percent of used buffer space. 100% means full buffer with ready data to play. But in your case it can be problem with display terminal, at 320kbps with 0 buffer you should hear problems with audio. I will check again my demo. |
How strange. The only change I made was moving from one room to another (my amplified speakers are in a different room). Anyhow... most of the time it is now showing 100%. Once in a while, I see it change to a different value, but the audio sounds fine. I have tried playing both my 320 kbps stream, and the one you were using. |
@ewbarnes53
Did it also help to get rid of this other issue now? |
Ping @ewbarnes53 ;-) |
Sorry, I really wasn't ignoring you. I have been playing with the radios, trying to figure out what might have happened. I really am not sure. I will say that the radio I prefer is the Ring Buffer radio. Most stations sound very good. There may be occasional dropouts when the stream is interrupted for an extended period. I have seen the buffer % go down to 0, and some times, it keeps playing. I am puzzled about my earlier problems. They seem to have disappeared. I am wondering if I had some problem with my connection to the internet, that has now somehow been corrected. |
@ewbarnes53 when you see 0% and radio keeps playing that means stream is directly sent to vs0153 without buffering, then every package drop will case clicking. You can try to adjust RING_BUF_SIZE, if you have enough free heep try to increase (Im working on 34000 with esp32). |
@ewbarnes53 there is some problem with network speed on esp32 when you use 320kbps or more. I see where is the problem. Testing.... |
I do not seem to have any problem with 320 kbps streams. I have tuned 2 or 3 in without problem. At first, I did not change any of your buffer sizes, and it seemed to work fine. I have now increased the ring buffer size to 36,000 bytes, just to see if it would compile and run. I suppose there is some performance improvement, but I really cannot see any difference. |
that depends, when you have more other services (like me, web server, display, etc.) you can see diffirence. I tested on flac ~1000kbps and I see big diffirence now. The problem was with reading byte by byte from network. My esp32 get fresh air now with reading 1024 at onces, it matters a lot. |
Hello @baldram, I just wanted to write to thank you and I even created an account on GitHub especially for this :-) I just wanted to thank you for the ESP_VS1053_Library. I have spent hours reading web pages, making projects, looking for information and making montages that don't work or work very badly. What I'm writing to you for is mainly to find solutions to the sound glitches that we hear on some French radio stations. My wife listens to these stations (France Inter for esample) and... all my beautiful montages are useless if you can't listen to these stations :- This evening I'll just try to simply change the
in
but even if it doesn't work, I know your file works fine. Really, thank you again. Now that everything works, I can finally get down to the heart of the project: writing the HTML pages of the stations' choice, etc. Bye |
right, generally, a pure mp3 audio stream can have non-audio data only in two cases: chunked encoding and metadata. |
@baldram it was quite a long time ago and I don't remember the details, but for sure to avoid misunderstanding all examples should have Icy-MetaData=0 header in order to disable sending metadata in stream. Handling metadata is not supported by this library. As example:
|
@baldram Tonight I did the test from
to
removes glitches on streams that were causing problems (Radio France). Was that the meaning of your question? |
@DindonCurieux Yes, thanks. So it looks like both codes are solving mentioned glitched issue. Excellent 🥳 |
Hi all, First of all, thanks a lot to @baldram, @vincegellar, @fabitom @maniacbug @Edzelf ,..., for sharing your experience, the WebRadioDemo is a great starting point for creating your own Inernet Radio project. I hope you guys can give me a hint, I happen to have streamig issues with one particular radio station, which unfortunately is my favourite one over the past years: Double J, The stream seems to stop for a millisec every one or two seconds. However, VLC, Mozilla and the 2003 Version of Winamp do not seem to have any problems. So far I was not able to solve this issue. What I tried so far( and reading your comments was a great source of inspiration )
What I encountered is that the value of bytesread is pretty often lower (about five times per mp3 frame) than the requested size for mp3buff. The header of the stream is: ICY 200 OK I'm slowly running out of ideas, maybe one of you could test whether the stream produces microbreaks on your hard/software, too? One last idea I have is again the playback speed at bitrate 96, I remember, that my Bose used to sound terrible playing Double J with varying playback speed, until one or two years ago, maybe due to an update, now everything sounds fine. Which brings me to the question: Has anyone ever tried to add the following line to the VS1053.h ? const uint8_t SM_STREAM = 6; // Bitnumber in SCI_MODE for Streaming Mode and play around with this setting? The VS1003 data sheet says: Thanks again for your great work! :-) |
I tested this station (live-radio02.mediahubaustralia.com/4DJW/mp3/) on my ESP32 Radio. It does not sound too bad, but what I see is that the input stream (96 kbps) is empty most of the time: |
Thanks a lot! This probably corresponds with the VLC media info/statistics, while the data bitrate is announced with 96, the input bitrate switches between 94 and 97, sometimes 89... |
I fully associate myself with your thanks to @baldram, @vincegellar, @fabitom @maniacbug @Edzelf for the great work they make available to everyone. I did the test of the http://live-radio02.mediahubaustralia.com/4DJW/mp3/ feed. on an ESP32. Unfortunately, like you, I have a sound that stops about every second and is very jerky. I don't see what I can do about it. But maybe something could put us on the way to a solution : |
Unfortunately, no additional hints from my side apart from earlier mentioned in this and the other thread (#47). However, I would like to add kudos to @wmarkow also for his contribution. Seen similar issues (stops playing accidentally) for some radio stations even on commercial radio devices like: Creative or iRiver (Astell&Kern). |
At the moment I don't have a complete test setup built. I will try to cobble together a minimal setup for testing purposes in the coming days. If I can come up with some kind of a solution I will report back. |
@DindonCurieux I will report back, too, if I find any solution.. |
In fact, the ESP32 plays too fast, or exactly at 96kbps. The inputstream seem to be too slow. |
So, bad news, my VS1053 board seems to have died since the last time I hooked it up to anything. I will order a new one, but it will be quite longer before I can test anything out. |
Hi there, my problem is solved. For the sake of completeness first here's what didn't work, but might be interesting:
and
to VS1053.h and
to VS1053.cpp making it possible to switch the VS1003's stream mode on and off during playback. |
Now to the solution: I noticed the same effect( microbreaks, ESP out of sync, playback falling behind ) on other Radio stations after playing for 20-30 minutes. The main reason for this was my suboptimal ;-) implementation of a ring buffer. The main difference and maybe the reason why the WebRadio demo also has trouble for this particular stream ( Double J ): As far as I can see, all of this is implemented in the code of @Edzelf , so I guess the stream caused no problem here at all. Unfortunately, I see no simple way of modyfing the WebRadio demo to handle this. Thanks a lot! |
Hi All, For now we have two PRs with a simple example on how to improve data streaming and get rid of unwanted artefacts:
The more complex example by @CelliesProjects uses a data patch (aka plugin) feature to apply these patches. These are VS1053b Patches v2.9 and they help to get rid of some streaming problems, as well as handle ID3 tag things better (so that binary data inside the tag is not erroneously interpreted as audio), and so on. I opened a discussion here #66 to discuss further steps .
Would you please leave your thoughts in #66? CC: @wmarkow @fabitom @philippedc @ewbarnes53 @DindonCurieux @Dr-Dawg @Edzelf @vincegellar |
An important change related to this topic was delivered #69. I'm closing an issue. |
Hi, I love the baldam exemple web radio. I built 3 of them. Unfortunately I have 2 problems with this code, especially with French radio station:
http://live02.rfi.fr/rfiafrique-64.mp3
http://icecast.radiofrance.fr/franceinter-lofi.mp3 or http://icecast.radiofrance.fr/franceinter-midfi.mp3
http://icecast.radiofrance.fr/franceculture-lofi.mp3 or http://icecast.radiofrance.fr/franceculture-midfi.mp3
https://icecast.radiofrance.fr/fip-lofi.mp3 or https://icecast.radiofrance.fr/fip-midfi.mp3
I have spent may be an hundred of hours to try to solve this problem. I thank wmarkow and fabitom for their help. In #51 they tried several workarounds like round buffer, but are mostly incomprehensible for my basic level of programming. But I learnt the following:
The glitches are due to \r\nX\r\n sequences, and then it looks like the streaming is chunked.
Works had been done to suppress these chunk messages, see #48, but I still have glitches for these particular French radios. Moreover, wmarkow and fabitom confirm that their codes are working well for themselves, but not for me :(
There is not many information about chunked transfer data, except this https://en.wikipedia.org/wiki/Chunked_transfer_encoding
When you read in detail, follow the links, you will find that chunked data stream is mostly for video transfer, here it is sound only, so I'm wondering if these chunks are not fake.... AND chunked transfer is only supported for HTTP1.1. Not in HTTP1.0
EUREKA !
@baldram I suggest to replace:
with:
It is a miracle: no more glitches, no lost stations, everything is fine now :)
The text was updated successfully, but these errors were encountered: