Closed podaen closed 2 years ago
I pushed the related correction to main. I also extended the example to demo how to debounce the input...
in you example you need to change debouncer.debounce to nextBuffonDebouncer.debounce()
I did some tests with player.next and I can not change between other channels than 0 en 1.
Is this issue with my example ?
This would happen if the arraySize has not been defined correctly in the constructor of AudioSourceURL.
Anyhow I will retest this tomorrow...
I diden't set it right in the AudioSourceURL. I changed it from 5 to 2. I do the test now... and it works.
I changed the constructor so that the array size is not needed any more to prevent this problem for others. Are we ready to close this issue as well ?
Good, no I want to select a station over a2dp if this is possible. I am looking now for making this possible...
Not sure if I understand your correctly but note the following: https://github.com/pschatzmann/arduino-audio-tools/issues/9
I have updated the library and now the player doesn't compile anymore...
AudioOutput.h: 575:73: error: suggest parentheses around assignment used as truth value [-Werror=parentheses] } else if (p_info_in->channels = 1 && p_info_out->channels>1){
AudioOutput.h: 579:48: error: suggest parentheses around assignment used as truth value [-Werror=parentheses] } else if (p_info_out->channels = 1){
Sorry about that, but I did't not get this when I tested in Arduino...
Did you enabled the warnings for compiling?
It's set to Default
mine too...
It is compiling now. Thx
I tried to set the config file back to the settings that worked in the previous topic I have made. But now the music stops. Soo I tried different settings but it keeps chunking.
Maybe it was the antenna again. I's running good now with the default settings
Did you use the resolved links in your examples?
I am using now a local http link out of your xml and it's running much better now.
Could you please add a procedure "select radio station by index number" of the array url? I have 25 radiostations added and it would be handy if I just could type a number to selected one radio station I want to lissen too.
I have made a station select. I will look to upload when I am back.
have you tried the following in your sketch:
player.stop();
source.setPos(idx);
player.play();
I did not want to provide the direct navigation on the player level because not all AudioSource objects can support this...
I know, I did it the same way... It diden't cost me a lot of work to do, but I will take over the latest version.
I also add this...
Serial.print(RadioPos); Serial.print("/"); Serial.println(sizeof(urls) / sizeof(urls[0]));
it says url 1 of 5 is playing... You could add this to your log if you like.
If I want to make a portable radio I was thinking to impliment a small display... For that it will be usefull to have the name of the radio station in that array. You could also add the index to it.
For now I will integrate it in to a existing build in spreaker system without display. But maybe I will make something like a portable in the futer. This is what I had in mind.
I just wanted to highlight, that this is the advantage of my design: It is object oriented! So all you need to do is to create your own subclass from the AudioSourceURL and adding all your additional (e.g. display related) functionality.
Then you can just provide your own implementation as parameter to the AudioPlayer....
have you tried the following in your sketch:
player.stop(); source.setPos(idx); player.play();
I did not want to provide the direct navigation on the player level because not all AudioSource objects can support this...
I don't know why this continuesly doesn't work with me and after revise it it does, but it doesn't change the station on index with me. The log says it is changing but nothing ever happend...
This doesn't shows up
[W] HttpHeader.h : 226 - Waiting for data... [W] HttpRequest.h : 141 - no CONTENT_LENGTH found in reply
I looked into the audioplayer.h file and now I see.. Set stream and begin stream is not called.
Here is my shetch. I let out the bouncing thing out... For me it is easier too understand.
#define USE_HELIX
#include "AudioTools.h"
#include "AudioCodecs/CodecMP3Helix.h"
using namespace audio_tools;
const char* urls[] = {
"http://19983.live.streamtheworld.com/QMUSIC.mp3",
"http://mp3.streampower.be/sporza-high",
"http://20723.live.streamtheworld.com/QFOUTERADIO.mp3",
"http://22183.live.streamtheworld.com/JOE.mp3",
"http://21303.live.streamtheworld.com/STUDIO_BRUSSEL_128.mp3",
"http://icecast-servers.vrtcdn.be/stubru_tgs-high.mp3",
"http://icecast-servers.vrtcdn.be/stubru_tijdloze-high.mp3",
"http://icecast-servers.vrtcdn.be/ketnetradio-high.mp3",
"http://22353.live.streamtheworld.com/MNM_128.mp3",
"http://icecast-servers.vrtcdn.be/mnm_90s00s-high.mp3",
"http://icecast-servers.vrtcdn.be/mnm_hits-high.mp3",
"http://icecast-servers.vrtcdn.be/mnm_urb-high.mp3",
"http://fred.torontocast.com:1050/stream",
"http://icecast-servers.vrtcdn.be/radio1_classics_high.mp3",
"http://icecast-servers.vrtcdn.be/radio2_benebene-high.mp3",
"http://icecast-servers.vrtcdn.be/radio2_unwind-high.mp3",
"http://icecast-servers.vrtcdn.be/stubru_bruut-high.mp3",
"http://icecast-servers.vrtcdn.be/stubru_untz-high.mp3"
"http://23553.live.streamtheworld.com:80/RADIO_2_VLAAMSBR_128.mp3",
"http://randstad.wirelessbelgie.be:8330/stream.mp3",
"https://22323.live.streamtheworld.com/TOPRETRO.mp3",
"http://21253.live.streamtheworld.com/RADIO1_128.mp3",
};
const char* StationName[] = {
"QMusic",
"Sporza",
"Q Foute Radio",
"JOE",
"Studio Brussel",
"Stubru Tgs",
"Stubru Tijdloze",
"Ketnet Radio",
"MNM",
"MNM 90s 00s",
"MNM Hits",
"MNM urban",
"Fred",
"Radio1 Classics",
"Radio2 Benebene",
"Radio2 Unwind",
"Stubru Bruut",
"Stubru Untz",
"Radio 2",
"Randstad",//versneld
"TOPRETRO",
"Radio 1"
};
const char* wifi = "SSID";
const char* password = "Pass";
URLStream urlStream(wifi, password);
AudioSourceURL source(urlStream, urls, "audio/mp3");
I2SStream i2s;
VolumeOutput volume(i2s);
MP3DecoderHelix decoder;
AudioPlayer player(source, volume, decoder);
unsigned long currentMillis;
unsigned const long StationDelay = 15000;
unsigned long StationMillis = 0;
int RadioPos = 2;
void setup() {
Serial.begin(115200);
//AudioLogger::instance().begin(Serial, AudioLogger::Info);
// setup output
auto cfg = i2s.defaultConfig(TX_MODE);
i2s.begin(cfg);
// setup player
//player.setCallbackMetadata(printMetaData);
player.begin();
volume.setVolume(0.1);
}
void loop() {
player.copy();
AutoNextStation();
//AutoSelectStation();
//delay(5);
}
void AutoNextStation() {
currentMillis = millis();
if (currentMillis - StationMillis > StationDelay) {
Serial.println("Next Stream");
StationMillis = currentMillis;
NextStation();
RadioPos += +1;
if (RadioPos > sizeof(urls) / sizeof(urls[0]))RadioPos = 1;
}
}
void NextStation() {
player.next();
Serial.print(RadioPos);
Serial.print("/");
Serial.println(sizeof(urls) / sizeof(urls[0]));
Serial.println(urls[RadioPos-1]);
Serial.println(StationName[RadioPos - 1]);
}
void AutoSelectStation() {
currentMillis = millis();
if (currentMillis - StationMillis > StationDelay) {
Serial.println("Next Stream");
StationMillis = currentMillis;
SelectStation(RadioPos);
RadioPos += +1;
if (RadioPos > sizeof(urls) / sizeof(urls[0]))RadioPos = 1;
}
}
void SelectStation(uint8_t IntRadioPos) {
player.stop();
delay(200);
player.Select(IntRadioPos);
player.play();
//player.stop();
//source.setPos(RadioPos);
//player.play();
Serial.print(IntRadioPos);
Serial.print("/");
Serial.println(sizeof(urls) / sizeof(urls[0]));
Serial.println(urls[IntRadioPos - 1]);
Serial.println(StationName[RadioPos - 1]);
}
The only thing that is bothering me is that after a switch the station remains producing sound of the previous radio station for a second and than it addapt. It would be bether if the sound stops and after we do play, the next staton can be heard.
I tried to empty the buffer but than it's producing a scratching sound. Maybe mute the sound for a second could be a solution. There could be others too...
Another solution would be
void SelectStation(uint8_t IntRadioPos) {
player.stop();
volume.setVolume(0.0);
delay(200);
player.Select(IntRadioPos);
player.play();
unsigned long starttime = millis();
unsigned long endtime = starttime;
while((endtime - starttime) <= 1000)
{
endtime = millis();
player.copy();
}
volume.setVolume(0.1);
//player.stop();
//source.setPos(RadioPos);
//player.play();
Serial.print(IntRadioPos);
Serial.print("/");
Serial.println(sizeof(urls) / sizeof(urls[0]));
Serial.println(urls[IntRadioPos - 1]);
Serial.println(StationName[RadioPos - 1]);
}
Test report:
I would take the active stream, than it can be called in the middle of a program.
/// (Re)Starts the playing of the music (from the beginning)
virtual bool begin(bool isActive = true) {
LOGD(LOG_METHOD);
bool result = false;
// start dependent objects
p_out_decoding->begin();
p_source->begin();
meta_out.begin();
// get first streem
p_input_stream = p_source->nextStream(1);
if (p_input_stream!=nullptr) {
if (meta_active){
copier.setCallbackOnWrite(decodeMetaData, this);
}
copier.begin(*p_out_decoding, *p_input_stream);
timeout = millis() + p_source->timeoutMs();
active = isActive;
result = true;
} else {
LOGW("-> begin: no data found");
}
return result;
}
- After many switches sometimes it get stuck and than it switch to an other station, but the doesn't output the audio anymore.
Diden't occur anymore after the push and 1440 station switches.
- sometimes it gives [E] HttpRequest.h : 181 - Connect failed in url http://icecast-servers.vrtcdn.be/stubru_bruut-high.mp3 and http://19983.live.streamtheworld.com/QMUSIC.mp3
If not connected and switch to an other station, than it gives this message too. Tested with longer switching times, but problem was not solved. I am sure it will connect tomorow again without changing anything and happens again.
I want to add previous stream and want to determe the size of the array. I get 4 and I have more than 21 urls.
sizeof(urlArray)
Any idea's?
The easiest is to add an additional size() method to AudioSourceURL and just return this->max
ps. previous is next(-1)
yes,that's the size. I think the urlarray is not loaded completly... It get stuck
pos -1 pos 21 [I] AudioPlayer.h : 294 - previousStream: 21 -> ? [I] URLStream.h : 57 - URLStream.begin ? [I] Url.h : 73 - Url::parse .....
ps. previous is next(-1)
I'm not sure
if (pos < 0 || pos >= max) { pos = max; }
vs
if (pos<0 || pos>=max){ pos=0; }
if (pos < 0 || pos >= max) { pos = max; }
My mistake, it has to be.
if (pos < 0 || pos >= max) {
pos = max-1;
}
I would recommend if (pos < 0) { pos = 0 } else if (pos >= max) { pos = max-1; }
Could you please check again the lastest version. I don't have sound anymore and it get stuck.
Opening port Port open �[D] I2SStream.h : 87 - void audio_tools::I2SStream::begin(audio_tools::I2SConfig) [D] I2SESP32.h : 37 - void audio_tools::I2SBase::begin(audio_tools::I2SConfig) [I] I2SESP32.h : 244 - rx/tx mode: TX [I] I2SESP32.h : 245 - sample rate: 44100 [I] I2SESP32.h : 246 - bits per sample: 16 [I] I2SESP32.h : 247 - number of channels: 2 [I] I2SESP32.h : 248 - is_master: Master [I] I2SESP32.h : 249 - mode: 0 [I] I2SESP32.h : 253 - pin bck_io_num: 26 [I] I2SESP32.h : 254 - pin ws_io_num: 25 [I] I2SESP32.h : 255 - pin data_num: 22 [D] I2SESP32.h : 91 - begin - started [D] AudioPlayer.h : 609 - virtual void audio_tools::AudioPlayer::setCallbackMetadata(void ()(audio_tools::MetaDataType, const char, int)) [D] AudioPlayer.h : 472 - virtual bool audio_tools::AudioPlayer::begin(int, bool) [D] AudioOutput.h : 295 - void audio_tools::EncodedAudioStream::begin() [D] CodecMP3Helix.h : 76 - virtual void audio_tools::MP3DecoderHelix::begin() [D] AudioPlayer.h : 279 - virtual void audio_tools::AudioSourceURL::begin() [I] AudioPlayer.h : 303 - url array out of limits: 0 -> 1 [I] AudioPlayer.h : 309 - selectStream: 1/20 -> http://19983.live.streamtheworld.com/QMUSIC.mp3 [I] AudioOutput.h : 427 - setVolume: 0.100000 end setup [D] AudioPlayer.h : 589 - virtual void audio_tools::AudioPlayer::copy() [D] AudioPlayer.h : 589 - virtual void audio_tools::AudioPlayer::copy() ... [D] AudioPlayer.h : 589 - virtual void audio_tools::AudioPlayer::copy() Next Stream [I] AudioOutput.h : 427 - setVolume: 0.000000 [D] AudioPlayer.h : 530 - virtual bool audio_tools::AudioPlayer::next(int) [I] AudioPlayer.h : 288 - nextStream: 2/20 -> http://20723.live.streamtheworld.com/QFOUTERADIO.mp3 [D] URLStreamESP32.h : 170 - void audio_tools::URLStream::begin(const char, const char, MethodID, const char, const char) [I] URLStream.h : 57 - URLStream.begin http://20723.live.streamtheworld.com/QFOUTERADIO.mp3 [D] Url.h : 59 - setUrl http://20723.live.streamtheworld.com/QFOUTERADIO.mp3 [D] StrExt.h : 109 - StrExt::grow(52) [I] Url.h : 73 - Url::parse [D] StrExt.h : 109 - StrExt::grow(4) [D] StrExt.h : 109 - StrExt::grow(29) [D] StrExt.h : 109 - StrExt::grow(16) [D] StrExt.h : 109 - StrExt::grow(36) [I] Url.h : 109 - url->http://20723.live.streamtheworld.com/QFOUTERADIO.mp3 [I] Url.h : 110 - host->20723.live.streamtheworld.com [I] Url.h : 111 - protocol->http [I] Url.h : 112 - path->/QFOUTERADIO.mp3 [I] Url.h : 113 - port->80 [D] URLStream.h : 197 - connectWiFi ..... [I] URLStream.h : 179 - WiFiClient [I] HttpRequest.h : 178 - process connecting to host 20723.live.streamtheworld.com port 80 [I] HttpRequest.h : 166 - connect 20723.live.streamtheworld.com [I] HttpRequest.h : 189 - Free heap: 219140 [I] HttpHeader.h : 348 - HttpRequestHeader::setValues - path: /QFOUTERADIO.mp3 [D] HttpHeader.h : 305 - HttpHeader::headerLine - new line created for Host [D] StrExt.h : 109 - StrExt::grow(4) [I] HttpHeader.h : 96 - HttpHeader::put -> 'Host' : '20723.live.streamtheworld.com' [D] StrExt.h : 109 - StrExt::grow(29) [D] HttpHeader.h : 305 - HttpHeader::headerLine - new line created for Connection [D] StrExt.h : 109 - StrExt::grow(10) [I] HttpHeader.h : 96 - HttpHeader::put -> 'Connection' : 'close' [D] StrExt.h : 109 - StrExt::grow(5) [D] HttpHeader.h : 106 - HttpHeader::put - value ignored because it is null for User-Agent [D] HttpHeader.h : 106 - HttpHeader::put - value ignored because it is null for Accept-Encoding [D] HttpHeader.h : 305 - HttpHeader::headerLine - new line created for Accept [D] StrExt.h : 109 - StrExt::grow(6) [I] HttpHeader.h : 96 - HttpHeader::put -> 'Accept' : 'audio/mp3' [D] StrExt.h : 109 - StrExt::grow(9) [D] HttpHeader.h : 106 - HttpHeader::put - value ignored because it is null for Content-Type [I] HttpHeader.h : 249 - HttpHeader::write [I] HttpHeader.h : 357 - HttpRequestHeader::write1stLine [I] HttpHeader.h : 372 - -> GET /QFOUTERADIO.mp3 HTTP/1.1 [D] HttpHeader.h : 164 - HttpHeader::writeHeaderLine: Host [I] HttpHeader.h : 185 - -> Host: 20723.live.streamtheworld.com [D] HttpHeader.h : 164 - HttpHeader::writeHeaderLine: Connection [I] HttpHeader.h : 185 - -> Connection: close [D] HttpHeader.h : 164 - HttpHeader::writeHeaderLine: Accept [I] HttpHeader.h : 185 - -> Accept: audio/mp3 [I] HttpHeader.h : 288 - ->
[I] HttpRequest.h : 213 - Request written ... waiting for reply [I] HttpHeader.h : 219 - HttpHeader::read [W] HttpHeader.h : 226 - Waiting for data... [D] HttpLineReader.h : 20 - HttpLineReader readlnInternal [I] HttpHeader.h : 155 - HttpHeader::readLine -> HTTP/1.0 403 Forbidden [I] HttpHeader.h : 443 - HttpReplyHeader::parse1stLine: HTTP/1.0 403 Forbidden [D] HttpLineReader.h : 20 - HttpLineReader readlnInternal [I] HttpHeader.h : 155 - HttpHeader::readLine -> Expires: Thu, 01 Dec 2003 16:00:00 GMT [D] HttpLineReader.h : 20 - HttpLineReader readlnInternal [I] HttpHeader.h : 155 - HttpHeader::readLine -> Cache-Control: no-cache, must-revalidate [D] HttpLineReader.h : 20 - HttpLineReader readlnInternal [I] HttpHeader.h : 155 - HttpHeader::readLine -> Pragma: no-cache [D] HttpLineReader.h : 20 - HttpLineReader readlnInternal [I] HttpHeader.h : 155 - HttpHeader::readLine -> Access-Control-Allow-Headers: [D] HttpLineReader.h : 20 - HttpLineReader readlnInternal [I] HttpHeader.h : 155 - HttpHeader::readLine -> Access-Control-Expose-Headers: [D] HttpLineReader.h : 20 - HttpLineReader readlnInternal [I] HttpHeader.h : 155 - HttpHeader::readLine -> Access-Control-Allow-Methods: GET, HEAD [D] HttpLineReader.h : 20 - HttpLineReader readlnInternal [I] HttpHeader.h : 155 - HttpHeader::readLine -> Access-Control-Allow-Origin: * [D] HttpLineReader.h : 20 - HttpLineReader readlnInternal [I] HttpHeader.h : 155 - HttpHeader::readLine -> Connection: close [D] HttpLineReader.h : 20 - HttpLineReader readlnInternal [I] HttpHeader.h : 155 - HttpHeader::readLine -> Content-Length: 103 [D] HttpLineReader.h : 20 - HttpLineReader readlnInternal [I] HttpHeader.h : 155 - HttpHeader::readLine -> Content-Type: text/html [D] HttpLineReader.h : 20 - HttpLineReader readlnInternal [I] HttpHeader.h : 155 - HttpHeader::readLine -> X-STW-Error: 430 Invalid Mount [D] HttpLineReader.h : 20 - HttpLineReader readlnInternal [I] HttpHeader.h : 155 - HttpHeader::readLine -> [D] HttpLineReader.h : 20 - HttpLineReader readlnInternal [I] HttpHeader.h : 155 - HttpHeader::readLine -> 403 Forbidden 403 Forbidden
Invalid Mount [W] HttpRequest.h : 141 - no CONTENT_LENGTH found in reply [I] URLStream.h : 72 - size: 0 [I] URLStream.h : 211 - Request written ... waiting for reply
No change from my side which would cause this. If you open the url in the browser you can see the same error. So the issue is with the url.
ps. After the last commit, I have all AudioPlayer scenarios working properly now - even the Streaming to Bluetooth is working nicely.
No change from my side which would cause this.
I have tested with you example streams-url_mp3-i2s and that one works great. You dident't make big changes... That right! I But you did a few smaller ones in here 35741bc
If you open the url in the browser you can see the same error. So the issue is with the url.
That was the issue on my first push I have made. I had a weekend radio station as first link and another issue was that it diden't change to the next. But that is all solved now.
Now I have no sound on the player at that same url I used in streams-url_mp3-i2s.
How can I reproduce this ?
wait! I just tested with the original urls and they work. I looking what is going on...
Found the issue why it get stuck. I see it happens offen that radiostation give errors like
403 forbidden 503 Service Temporarily Unavailable
That information is in the [I] HttpHeader.h : 155
Could you skip if this happens and go on to the next please? I think you have to be carefull with that because if we are going up it will go to next. But if we go down (previous) and we use next than it get stuck on that.
Hmm, the following is implemented: We wait for data - if we do not get any data after a timeout we skip to the next entry. I would have expected that this is covered by this logic.
Maybe you just need to decrease the timeout if you want to limit the waiting time. Currently the default is a little bit high with 60000ms.
I tried to add some additional logic and decreased the max timeoutto 10 secs...
Still getting [I] URLStream.h : 211 - Request written ... waiting for reply
here is the link http://20723.live.streamtheworld.com/QFOUTERADIO.mp3
this helps...
And this one does not spond if it is not broadcasting.
http://mp3.streampower.be/sporza-high
Then I get a backtrace
> E:\Documents\Visual Studio 2019\Projects\Arduino\libraries\arduino-audio-tools\src/AudioTools/AudioPlayer.h(45): error 0x400d5014:audio_tools
> E:\Documents\Visual Studio 2019\Projects\Arduino\libraries\arduino-audio-tools\src/AudioHttp/URLStreamESP32.h:202:::(inlined by) audio_tools:
> 0x400014fd: ?? ??:0
> 0x4000150d: ?? ??:0
> E:\Documents\Visual Studio 2019\Projects\Arduino\libraries\arduino-audio-tools\src/AudioTools/AudioPlayer.h(45): error 0x400d6d5f:audio_tools
> E:\Documents\Visual Studio 2019\Projects\Arduino\libraries\arduino-audio-tools\src/AudioTools/AudioPlayer.h(45): error 0x400d1e49:audio_tools
> E:\Documents\Visual Studio 2019\Projects\Arduino\libraries\arduino-audio-tools\src/AudioTools/AudioPlayer.h(45): error 0x400d1de2:audio_tools
> E:\Documents\Visual Studio 2019\Projects\Arduino\libraries\arduino-audio-tools\src/AudioTools/AudioPlayer.h(45): error 0x400d60e7:NextStation()
> E:\Documents\Visual Studio 2019\Projects\Arduino\libraries\arduino-audio-tools\src/AudioTools/AudioPlayer.h(45): error 0x400d613d:AutoNextStation()
> E:\Documents\Visual Studio 2019\Projects\Arduino\libraries\arduino-audio-tools\src/AudioTools/AudioPlayer.h(45): error 0x400d6161:loop()
> C:\Users\Dave2Moon\AppData\Local\arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/main.cpp(23): error 0x400ddd90:loopTask(void*)
> /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c:355 (discriminator 1):::0x400899c2:vPortTaskWrapper
> 0x40078000: ?? ??:0
> 0x40080400: ?? ??:0
> 0x400806a8: ?? ??:0
I am afraid that for this one I wont have a solution - the browser behaves the same and never returns...
The player-url-i2s works for changing from one to next. After that it stays on the second channel. It is trying to change to next but for one reason it keeps taking the second url.