Reusing the radio streaming code from the project #5
-
Hi Vlad. Its is not actually an issue but questions about your Cd player project. You have modified a little bit Pschatzmann´s code which has some issues with internet radio stream buffering and got better results as I understood. #include "Arduino.h" void setup() { Serial.begin(115200); audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT); } void loop() { } We take in consideration that one would use ESP32 module with PSRAM. Thank you for your comments. |
Beta Was this translation helpful? Give feedback.
Replies: 11 comments 10 replies
-
The whole radio pipeline is basically located in a separate file, where the AudioRouter's IOPortNub is your I2SStream in the simplest case. (I plan to potentially add other output routes someday later, so I obtain the output port from the router) So in the simplest case you would just take that class, change the argument to accept an I2SStream instead of the AudioRouter, then instantiate it and call something like I have to note that if you are not buying your ESP modules from a verified source such as Digikey (I was buying off some seller on Taobao), your mileage may vary. I was getting vastly different reliability among ESPs even in the same batch, although none of them worked with Phil's code at all. Increasing the Net Buffer to e.g. 2KB makes things more stable, but with some lower bitrate radios it takes a very long while for the buffer to fill up. One good idea would be to make an automatic buffer increase algorithm so that e.g. originally it only buffers to the 10% mark, upon stutter now it uses 20%, and so on... (please do a PR if you implement this :-) Be that as it may, this is my daily driver radio now and it works more stable than any other projects I've tried so far (KaRadio and Phil's examples) — but then again, maybe my ESPs or internet are just bad. Also note that you might have to juggle around the tasks and priorities thereof in this class, since those are balanced out to fit in particular the stuff that's running in the ESPer-CDP firmware. |
Beta Was this translation helpful? Give feedback.
-
Well, I made a try, but can not get it working..
It compiles, but silently crashes in urlStream.begin(url.c_str());. On the URLStream.h side on "if (!preProcess(urlStr, acceptMime))" where acceptMime gets null pointer. Hardcoding this doesnt help either. Any Ideas? Or what I am missing here? |
Beta Was this translation helpful? Give feedback.
-
Please use the code formatting (put ``` on the lines before and after) when pasting code, it's very hard to read otherwise If anything, I cannot find where is your |
Beta Was this translation helpful? Give feedback.
-
Sorry I took off too much lines to be it more readable but it may take in confution. Here is 100% sketch:
So we get on Serial that wifi is connected. Get into pipeline.h code, and rigt in the function url.begin(url.c_str()) it hangs. There it calls URLStream.h from audiotools and stops with preprocessor with acceptMime nullptr. No more output on Serial, no ESP WDT reboot, nothing more. Wondering if can be some memory issues, core issues or still error in code.. |
Beta Was this translation helpful? Give feedback.
-
Ok some news here, Ive got it working. Here is Arduino sketch and modified pipeline.h
There was some issues with AudioTools libraries which eventually were tweeked wrong with my experiments, and sound was very speed upp with constant buffer underrun. But after audiotools fresh copy installation all started perfect! And it seems its very stable so long with good reserv in buffers:
Still one problem. It seems it wont accept https just http? Or problem somewhere? For ex this link https://stream.m-1.fm/m1/MP3320.m3u gives errors:
|
Beta Was this translation helpful? Give feedback.
-
One more question. Now when I want to put alltogether with bluetooth option as well. I found that its not easy to switch between modes. Partially maybe that A2DP bluetooth has extensive RAM utilisation as well. When I try to end a2dp object and start pipeline again its not always succesfullt. Tried different methods, worked if all not stable sometimes switches between modes but often stops silently. How you solved this problem? Is there some clean way to switch between radio/BT. Needs Shutt down/restart of BT in some manner? |
Beta Was this translation helpful? Give feedback.
-
Very interresting idea what concerns further improvments!:
In the previous question here:
Still one a2dp.end(); command above? Youy mean we do not want to end a2dp, so it must be commented also? And after all you have Core::Services::WLAN::start(); Can it be ommited or we need to restart directly WLAN for some purpose? P.S: I see now a2dp.end(); accepts argument as true or false. So you call it without releasing memory, right? |
Beta Was this translation helpful? Give feedback.
-
@Raima010 Just curious as part of investigation — 1. What region is your WiFi router from and the channel it uses? Auto channel mode on/off? 2. Did you do any regional settings on the ESP32 for WiFi channels? 3. Did you buy the ESP32 from a big name vendor like Digikey or Mouser, or from a local shop or Aliexpress? Tl;dr I started implementing FTP — and this time it's from a LAN server so I thought it MUST work right away with the example code. And it stutters lol, albeit not as badly as net radio. |
Beta Was this translation helpful? Give feedback.
-
In your case it also strange behavior, too much mystics here. But somewhere above I also mentioned that Ive been getting strange effect with latest Audiotools library when sound was a lot speed-up and emptied buffer fast as it could not refill again. So I am using a little bit older version, somewhere from 2024 November +/- cant remember exactly. This was installed on time of development. I foud that after I have updated libraries. Problem that we are using a lot of migrating libraries in term of vertions. Wondering if there could be an issue also. On my side now it works flawlessly. Below is some log. By the way, it may be worth to check signal RSSI strenght/antenna on ESP32 also. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
You have uploaded a modified pipeline.h vertion. Just curious, have you got some better results or ruled out the problem? |
Beta Was this translation helpful? Give feedback.
The whole radio pipeline is basically located in a separate file, where the AudioRouter's IOPortNub is your I2SStream in the simplest case. (I plan to potentially add other output routes someday later, so I obtain the output port from the router)
So in the simplest case you would just take that class, change the argument to accept an I2SStream instead of the AudioRouter, then instantiate it and call something like
pipeline.start("www.example.com/radio.mp3", [](bool loading) { if(loading) Serial.println("NOW LOADING!"); });
and there it goes!I have to note that if you are not buying your ESP modules from a verified source such as Digikey (I was buying off some seller on Taobao), your mile…