-
Notifications
You must be signed in to change notification settings - Fork 36
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
About examples->WebRadioDemo #47
Comments
I don't think it needs to be fixed. It works fine without any changes. Please close after reading this issue. |
Hi @nopnop2002! Thank you. |
Yes |
Yup, metadata while streaming are disabled by default on most servers. You can control this by "Icy-MetaData: 0" header. |
Hi, I made several tries and I understand now why sometime the sound is brassy, and sometime it is clicking. Sorry but for my experience ring buffer does not solve my problem. First: For some radios the sound is brassy. This is solve by increasing the buffer size : the brassy effect seems to be the routine is too low compare to the streaming. By increasing the buffer the client.read function is done less time, so it is faster. Second: For some stations that make many clicking effect after a moment (few seconds to few minutes) the VS1053 crash, I must reboot to come back to make it running again. void VS1053::sdi_send_buffer(uint8_t *data, size_t len) {
} Third: I have told in another thread that when I compare a radio reception from the device and a PC, I noticed that the streaming from this web radio is much faster that on the PC. After a while the web radio either looses the signal, either crashes. Depending of the signal bitrate, the client.read should be cadenced at the right time. I do not know how to do, because for the moment I do not know how to automatically define how long client.read takes to fill its buffer. static byte tempo = 0; // if signal is lost // if connected to the radio station :) This code uses very short time of 'pause' that synchronize the streaming. To improve this code, tempo%10 == 0 should be define automatically depending of the data flow speed. |
Whey you send 256 buffer to VS1053 then sdi_send_buffer will split that buffer to 32 (vs1053_chunk_size) and will send to VS1053 in loop. sdi_send_buffer already have proper delay in await_data_request() function. When Delay(1) in sdi_send_buffer helps you then I don't understand why...
|
@fabitom include now in the VS1053::begin() function, however I don't notice significant improvement. |
Ok, you can try this:
and watch if problems occour when client don't have data. |
I did similar yet: I never hear the specific sampleMp3 when a radio is listened. So the client.available is always true, and in fact I do not understand this test must be performed each loop. |
.... I cannot see the way Edzelf has coded the equivalent of the client.read in its Esp-radio.... |
@philippedc Thanks for this analysis.
Are you using ESP8266? Right? AFIK the "yield" is designed to solve such issues (As described here, the reason for Yielding is preventing from various issues. The ESP8266 runs a lot of utility functions in the background – keeping WiFi connected, managing the TCP/IP stack, and performing other duties. Blocking these functions from running can cause the ESP8266 to crash and reset itself). If the yield works fine, I would add it to |
|
@baldram it sounds much better !
il is after. I've also had a yield in the loop: It make twenty minutes the web radio did not crash. |
.... there is no WD reset because of the yield() in await_data_request(); I suppose ? |
I will release the version corresponding to ESP-IDF. https://github.com/nopnop2002/esp-idf-vs1053 It use RingBuffer. But sometimes it lose network connection. I don't know why. Your modifications are welcome. |
I'm not sure I follow. Does this
Do I understand correct? I try to clarify whether to add
To be honest I don't have an answer to this question, unfortunately. |
@baldram I have 3 of these web radios at home. So it is easy to compare different code version. I had the idea of a delay(1) after the SPI.writeBytes just like it is for an anlogRead(), just to let the time for the device to settle... In fact I did not test with the yield() before SPI.writeBytes , I will test this afternoon. |
I mean using yield after the I will add the final solution to the library as it should not harm, but help in some cases, like yours.
It could be too, indeed. |
If you are developing an ESP32 application in an Arduino environment, it will be built with a single task and usually scheduled on Core 1, unless you use xTaskCreate (). delay () returns control to the scheduler and grants execution rights to other tasks waiting to run, but has no effect if core1 has no other tasks. On the other hand, SPI transfer requests are temporarily stored in the system ring buffer and processed by the system task, but the system task is executed by the core 0. In the case of ESP32, Delay () is not effective in a single task environment. This is my personal opinion. |
IMHO putting Delay() between SPI.BeginTransaction and SPI.EndTransaction is quite risky.
or after playChunk like here: frokats-project |
Maybe wifi power save mode. I saw some similar problems. esp_wifi_set_ps |
@fabitom |
I added esp_wifi_set_ps, but still sometimes lose network connection. There are other causes. |
Thanks. Now, looking at the ESP_VS1053_Library it was correctly extracted and has this part too: I wonder whether anything else is needed or just the client code might deal with |
@nopnop2002 does it lose the signal by the same way with all stations? |
@baldram I have left the idea of a yield or a delay in the library. I'm sure now the problem of clicking comes from client.read for some radio stations, unfortunately it happens for the one I listen the most. |
Thank you for clarification.
Sadly to hear that. PS: On the other hand, looking at Edzelf's main radio loop, he is yielding a lot in the method mentioned below. So it's worth to keep this ESP feature in mind for some cases. |
@philippedc please send me address of that 64k station. I will check on my radio. |
@fabitom here is the clicking station: This one is loosing signal from time to time, to get it back I change of station then I come back to it: I have not yet studied in detail how Edzelf get the streaming, may be its method is more accurate. |
@philippedc All good here. Streams are ok. |
@nopnop2002 hm... idk, you need to test this. Imho its not problem with stream bitrate but TCP/IP stack implementation. |
As @fabitom already told, it is needed. It was even mentioned in a comment to the basic WebRadio example. The article mentioned by @fabitom shows how to enable it by those who use ArduinoIDE (you have to select it manually from the "tools" menu). Now you see btw. why PlatformIO is so good. Happy to see a release candidate of the code provided by @wmarkow. Would @philippedc you please test it to check whether it works well on your side? |
Unlike ESP8266, ESP32 may not be effective. With build_flags = -D PIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH:
Without build_flags = -D PIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH:
My code:
Not an important issue. |
@nopnop2002 If you use ESP32, this flag is not relevant. |
The web radio is playing France culture for 10 hours now, without any abort and surely 99% of clicks off. Of course it is very less elegant than a ring buffer, however it can compile with Arduino IDE and core ESP8266 2.4.2 |
@philippedc good for you ;) your example checking every byte of stream, does not matter if stream is chunked or not, I prefer doing this only if "transfer-encoding: chunked" header exists. But after all if you don't need CPU for other things then thats ok. After all need to check diffirence on esp load. |
@philippedc Sounds good that it works. |
yes it is not elegant. Increasing buffer size from 32 to 128 helps for a lower probability to happen. @baldram I tested all ring buffer examples available in this discussion. I do not know the reason, each time the program compiles, run a while but the sound is not displayed. It is the same for the @wmarkow code example : https://github.com/wmarkow/ESP_VS1053_Library/blob/web-radio-chunked-demo/examples/WebRadioChunkedDemo/WebRadioChunkedDemo.ino but nothing is playing. Please note I use a different pins connection for ESP8266: |
both examples (my, @wmarkow) works here on arduino 1.8.12 with esp8266 framework 2.6.3 |
@baldram , PR ready. To keep the chunked transfer demo simple, I do not use the ring buffer there - as it is not required to correctly handle the audio stream. Only an 8 bytes length buffer is introduced to remove the chunk control data.
I'm using Sloeber which is based on Eclipse CDT. The default formatter is not good enough as it uses TABs as indentation but in my PR I have used some custom formatter which is more or less compatible with Arduino IDE. |
I use a new clean PC, install Arduino 1.8.12, ESP8266 2.6.3, etc... |
@wmarkow I test your code https://github.com/wmarkow/ESP_VS1053_Library/blob/web-radio-chunked-demo/examples/WebRadioChunkedDemo/WebRadioChunkedDemo.ino by the way, if the code gives sound, the quality is awful with much more glitches than ever :( |
@philippedc Thank you for testing the code.
I will add your remarks. @wmarkow PS:
Arduino IDE is not any reference from my point of view ;-) PlatformIO allows you to use an editor of your choice. There are several great IDEs, and one of them is Eclipse. I asked about the editor since I'm considering adding |
@wmarkow I will add editorconfig separately for whole project and it looks like it will be compatible with your PR formatting. |
OK, please add the editorconfig for the whole projects. I will use in my PR. |
@philippedc, you wrote:
I just had the same situation; nothing was played in the headphones. Then I have restarted the board and everything was correct; the music was there. The code was the same: first the audio was not there (but I saw some printouts on the console), aftere reset everything was fine. |
@wmarkow I've just added coding style settings for the project. Enabling the EditorConfig support should be easy. I use CLion, and it was just a matter of installing a plugin. Same if about Eclipse editor. Some editors like VS Code have the support enabled out of the box. Finally, the formatting just works for the project. My IDE simply sees the |
There was problem with my ring buffer example, it didn't really work ;( There is PR with fixed version. Please test it. #54 |
@philippedc Did you have a chance to test the latest version? |
hi @baldram sorry for my late answer. I've done the tests for several months. Note I request the web radio url in http 1.0 instead of http1.1 when I update the firmware I lose in stability. The radio stops working after few minutes of use. I need to reboot to be able to listen back. |
@philippedc Thanks for reply. This might have a significant impact on improving stability. |
Hi @baldram, yes I've followed the discussion. One question: the firmware update is done once, or does it needed at every reboot ? |
Hi @philippedc
Every time.
For sure not. The documentation says that patch must be re-loaded after each hardware or software reset. |
ok, in this case I do not perform the firmware update anymore. |
Hi @baldram I didn't notice I own a VS1003. So I've ordered a VS1053, to be aac compliant and to test the patches. I will be able to answer in few weeks.... |
Hello.
client.read() also reads the HTTP header.
There is no fatal problem, but you can exclude the HTTP header as follows.
My Code:
Test result:
The text was updated successfully, but these errors were encountered: