Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 14:35 26 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Internet radio working on the WebMite with VS1053

     Page 1 of 3    
Author Message
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9115
Posted: 05:02pm 09 Nov 2023
Copy link to clipboard 
Print this post

Just a few lines of code

Option escape
Option explicit
Option default none
' create the request for the radio site (ClassicFM)
Dim a$="ice-the.musicradio.com"
Dim q$="GET "
Inc q$,"/ClassicFMMP3"
Inc q$," HTTP/1.1\r\n"
Inc q$,"Host: "
Inc q$,a$
Inc q$,"\r\nConnection: close\r\n\r\n"

'create a circular buffer for reading the internet stream and
'read and write pointers
Dim buff%(4095),w%,r%

' Configure the VS1053 and tell it to play from the circular buffer
Play vs1053 GP9, gp8, gp7, gp6, buff%(), r%, w%

' Open the internet radio site
WEB open tcp stream a$,80

' Send the request to start the stream using the circular buffer specified
WEB TCP CLIENT STREAM q$, buff%(), r%, w%

'sit back and listen
Do
Pause 500
Loop


Hardware requirement
1 PicoW
1 VS1053
9 Dupont connection cables

Software requirement
Peter and Geoff's magic WebMite MMBasic V5.07.08RC15


WebMiteV5.07.08RC15.zip



Edited 2023-11-10 05:38 by matherp
 
Plasmamac

Guru

Joined: 31/01/2019
Location: Germany
Posts: 554
Posted: 08:07pm 09 Nov 2023
Copy link to clipboard 
Print this post

👍
Plasma
 
hitsware2

Guru

Joined: 03/08/2019
Location: United States
Posts: 713
Posted: 09:19pm 09 Nov 2023
Copy link to clipboard 
Print this post

  matherp said  Just a few lines of code

Option escape
Option explicit
Option default none
' create the request for the radio site (ClassicFM)
Dim a$="ice-the.musicradio.com"
Dim q$="GET "
Inc q$,"/ClassicFMMP3"
Inc q$," HTTP/1.1\r\n"
Inc q$,"Host: "
Inc q$,a$
Inc q$,"\r\nConnection: close\r\n\r\n"

'create a circular buffer for reading the internet stream and
'read and write pointers
Dim buff%(4095),w%,r%

' Configure the VS1053 and tell it to play from the circular buffer
Play vs1053 GP9, gp8, gp7, gp6, buff%(), r%, w%

' Open the internet radio site
WEB open tcp stream a$,80

' Send the request to start the stream using the circular buffer specified
WEB TCP CLIENT STREAM q$, buff%(), r%, w%

'sit back and listen
Do
Pause 500
Loop


Hardware requirement
1 PicoW
1 VS1053
9 Dupont connection cables

Software requirement
Peter and Geoff's magic WebMite MMBasic V5.07.08RC15


WebMiteV5.07.08RC15.zip



It would almost seem You are on the verge of a complete
internet appliance ?.......
my site
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9115
Posted: 08:12pm 11 Nov 2023
Copy link to clipboard 
Print this post

Code updated for the latest version RC15 syntax just posted

  Quote  Option escape
Option explicit
Option default none
' create the request for the radio site (ClassicFM)
Dim a$="ice-the.musicradio.com"
Dim q$="GET "
Inc q$,"/ClassicFMMP3"
Inc q$," HTTP/1.1\r\n"
Inc q$,"Host: "
Inc q$,a$
Inc q$,"\r\nConnection: close\r\n\r\n"

'create a circular buffer for reading the internet stream and
'read and write pointers
Dim buff%(4095),w%,r%

' Configure the VS1053 and tell it to play from the circular buffer
Play stream buff%(), r%, w%

' Open the internet radio site
WEB open tcp stream a$,80

' Send the request to start the stream using the circular buffer specified
WEB TCP CLIENT STREAM q$, buff%(), r%, w%

'sit back and listen
Do
Pause 500
Loop
 
morgs67
Regular Member

Joined: 10/07/2019
Location: Australia
Posts: 75
Posted: 07:23am 14 Nov 2023
Copy link to clipboard 
Print this post

Tried with a Arduino VS1053 shield similar to Geeetech one.
Works fine.





Tony
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9115
Posted: 08:49am 14 Nov 2023
Copy link to clipboard 
Print this post

  Quote  Tried with a Arduino VS1053 shield similar to Geeetech one.


Great.

Everyone who tries this, please post any station settings that you discover on this thread.
Unfortunately, many stations have now moved to HLS and this is outside the capability of the VS1053 but there are still lots of mp3 streams out there. The code should also cope with AAC streams but I haven't found one to test.
 
LucV

Regular Member

Joined: 19/02/2023
Location: Netherlands
Posts: 62
Posted: 03:48pm 14 Nov 2023
Copy link to clipboard 
Print this post

Hey guys,

Long time no see, but I am very busy.
I still follow this forum regularly and saw this. So here is my contribution.

A large list of MP3 streams:

https://www.webradiostreams.nl/

A Webmite with an oled screen or TFT screen, and a rotary connector to choose the radio stations would not be too difficult to build.
Add a small amplifier and a connection to your hifi installation and we have something unique that costs loads more in the shops.......

And here is another source (more internationally oriented):
https://www.rcast.net/dir/mp3/page1

Google is your friend:
https://www.internet-radio.com/search/?radio=mp3&page=/

And this one might be the best:
http://fmstream.org/index.php?c=FT

Luc
Edited 2023-11-15 02:00 by LucV
Luc's tech Blog
 
morgs67
Regular Member

Joined: 10/07/2019
Location: Australia
Posts: 75
Posted: 12:06pm 18 Nov 2023
Copy link to clipboard 
Print this post

Found a couple of AAC streams the VS1053 can play:
CLASSIC HITS RADIO
http://classichitsradio.streamingmedia.it:8017/usa
for this-
Dim a$="classichitsradio,streamingmedia.it"

Inc q$,"/usa"

WEB open tcp stream a$,8017      ' not 80

Classic1027 NZ
http://edge.iono.fm/xice/49_high.aac
for this-
Dim a$="edge.iono.fm"

Inc q$,"/xice/49_high.aac"

WEB open tcp stream a$,80

Need to add a volume control to the VS1053 via the WebMite and rotary control.

Tony
 
Pluto
Guru

Joined: 09/06/2017
Location: Finland
Posts: 358
Posted: 12:27pm 04 Jan 2024
Copy link to clipboard 
Print this post

My intention is to build the WebMite webradio (a la matherp above). Again a great development by Peter! Thanks!

Ordered the VS1053 module from AE two months ago. Not yet arrived.
The company making (designing) these chips is located just 200 km north from here, but they charge almost 20€+postage for just the chip!

While waiting, I am thinking about to use the MCP4822 DAC as a temporary sound output device. Run immediately into problems!

> option list
WebMite MMBasic Version 5.08.00RC2
OPTION WIFI HuaHuaNisse, ***********, PICOE6616408439
> option audio spi gp0,gp1,gp2,gp3
Error : Syntax
>


I understood that the audio should be declared as:
OPTION AUDIO SPI CSpin, LDACpin, SCKpin, SDIpin
GP2 is a vlid SPI CLK pin and GP3 is a valid SPI TX pin.
What do I do wrong?

Suppose that I will get the DAC operational, can I then use Peter's program (top page of this thread) and output the datastream with
WEB TCP CLIENT STREAM q$, buff%(), r%, w%


It is very silent in thebackshed today! Free beer somewhere? Did I miss something?

Thanks

Pluto
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6787
Posted: 12:59pm 04 Jan 2024
Copy link to clipboard 
Print this post

Just ground LDAC - don't include it in the OPTION AUDIO arguments. The SPI channel has to be dedicated to the DAC too. The PWM channel used for the SCLK will also be set as audio PWM IIRC.

Have fun. :)
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
Pluto
Guru

Joined: 09/06/2017
Location: Finland
Posts: 358
Posted: 01:13pm 04 Jan 2024
Copy link to clipboard 
Print this post

Thanks Mick!
I came one step forward...but
> option list
WebMite MMBasic Version 5.08.00RC2
OPTION WIFI HuaHuaNisse, ***********, PICOE6616408439
OPTION AUDIO SPI GP1,GP2,GP3', ON PWM CHANNEL 1
> RUN
[21] Play stream buff%(), r%, w%
Error : Only available with VS1053 audio
>


I think I have arrived at the end of this road. Which means I have to be patient and wait for a mailbag from China.
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6787
Posted: 01:49pm 04 Jan 2024
Copy link to clipboard 
Print this post

Ah... yes.... well.....   :(

At least you can play with the MCP4822 for something else while you wait. All is not lost. :)
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9115
Posted: 02:09pm 04 Jan 2024
Copy link to clipboard 
Print this post

The data received from an internet radio station is an mp3 or aac stream. Sending it to a DAC unprocessed would not achieve much other than noise. The VS1053 includes multiple codecs which is what makes it so clever
 
Pluto
Guru

Joined: 09/06/2017
Location: Finland
Posts: 358
Posted: 02:19pm 04 Jan 2024
Copy link to clipboard 
Print this post

Thanks Peter.  
This means that I will have a free evening and time to heat the sauna.

Pluto
 
Pluto
Guru

Joined: 09/06/2017
Location: Finland
Posts: 358
Posted: 10:30am 05 Jan 2024
Copy link to clipboard 
Print this post

Is there a command to CLOSE the TCP STREAM?

After running WEB OPEN TCP STREAM a$,80 about 6...8 times I get this message

[138] WEB open tcp stream a$,80  '
Error : failed to create pcb
>


Probably because too many TCP connections are open. But how to close the connections that are not needed?

Pluto
 
Pluto
Guru

Joined: 09/06/2017
Location: Finland
Posts: 358
Posted: 10:17pm 06 Jan 2024
Copy link to clipboard 
Print this post

I think I found a solution:

Last part of Peter's code above:
' Open the internet radio site
WEB open tcp stream a$,80

' Send the request to start the stream using the circular buffer specified
WEB TCP CLIENT STREAM q$, buff%(), r%, w%

'sit back and listen
Do
Pause 500
Loop


If you do not want to sit and listen forever and want to change channel, then it is good to put
WEB CLOSE TCP CLIENT
before you switch to next channel.

At least my test program can make >100 channel changes without any problems.

Pluto

> option list
WebMite MMBasic Version 5.08.00RC2
OPTION AUTORUN  ON
OPTION CPUSPEED  252000 'KHz
OPTION WIFI HuaHuaNisse, ***********, PICOE6616408439
OPTION TCP SERVER PORT 80
>
 
homa

Guru

Joined: 05/11/2021
Location: Germany
Posts: 351
Posted: 03:01pm 07 Jan 2024
Copy link to clipboard 
Print this post

  Pluto said  I think I found a solution:
At least my test program can make >100 channel changes without any problems.

Hello,
does that mean you have 100 radio stations in your test programme? That would interest me! Would you like to share?

Matthias
 
Pluto
Guru

Joined: 09/06/2017
Location: Finland
Posts: 358
Posted: 03:31pm 07 Jan 2024
Copy link to clipboard 
Print this post

Matthias,
at the moment I have only 11 stations in my program. I am just scrolling through this set several times.
And a more important remark: I have not yet got the VS1053 module. The only idication of successful operation is done by commenting out the VS1053 Play command, that would give error without the module attached.
' Configure the VS1053 and tell it to play from the circular buffer
'
'*********************************************************
'Following line is commented out until I get VS1053:
' Play stream buff%(), r%, w%
'*********************************************************


By printing the circular buffer read r% and write w% pointers I can see if there is some activity.

Peter's demo program is now in a SUB:

SUB OpenRadioChannel Chan%
' create the request for the radio site e.g.(ClassicFM)
' https://ice-the.musicradio.com/ClassicFMMP3
?""
?"--------------"
?"Channel nbr:";Chan%
?name$(Chan%)
a$=host$(Chan%)
q$="GET "
Inc q$,page$(Chan%)
Inc q$," HTTP/1.1\r\n"
Inc q$,"Host: "
Inc q$,a$
Inc q$,"\r\nConnection: close\r\n\r\n"
?"q$=";q$
' Configure the VS1053 and tell it to play from the circular buffer
'
'*********************************************************
'Following line is commented out until I get VS1053:
' Play stream buff%(), r%, w%
'*********************************************************

' Open the internet radio site
ON ERROR SKIP 1
WEB open tcp stream a$,80 '
IF mm.errno=16 then WEB open tcp stream a$,80:?"**SECOND ATTEMPT TO OPEN TCP**"
PRINT "mm.ERRNO=";mm.errno
IF MM.ERRNO=16 THEN PRINT "CPU RESTART"
IF MM.ERRNO=16 THEN CPU RESTART
' Send the request to start the stream using the circular buffer specified
' r%, w% are read and write pointers
WEB TCP CLIENT STREAM q$, buff%(), r%, w%

'sit back and listen
n%=0
Do
Pause 500
?"Read:";r%   'to check for streaming activity
?"Write:";w%
n%=n%+1
Loop until n%>2 'check for a few seconds, then return to main
'This is just for testing. Later the return from the sub will be activated
'e.g. by TOUCH or pin-interrupt.
WEB CLOSE TCP CLIENT 'Close the connection before opening a new one!
'You can only have 8 open connections at the same time.
'Even if you stop the program and restart, the connections will remain open
'until Pico is powered down. => CLOSE CONNECTION WHEN NOT NEEDED ANYMORE!

end sub


The station info is simply stored as:
name$(2)="Absolute Classic Rock"
host$(2)="edge-bauerall-01-gos2.sharp-stream.com"
page$(2)="/absoluteclassicrock.mp3"


When I finally get the VS1053 and get it tested, I can publish the whole thing including the list of stations I have confirmed working.

Pluto
 
Pluto
Guru

Joined: 09/06/2017
Location: Finland
Posts: 358
Posted: 02:20pm 18 Jan 2024
Copy link to clipboard 
Print this post

Finally got VS1053 module today. Got it to play web-radio stations.  
BUT, when I change station I get this error:
[112] Play stream buff%(), r%, w%
Error : Sound output in use for STREAM


Obviously there is a need to STOP the
PLAY STREAM buff%(), r%, w%

before the next web-radio station is started.
Tried PLAY STOP and PLAY HALT, but it did not help.
How can I solve this problem?
option list
WebMite MMBasic Version 5.08.00RC2
OPTION SYSTEM SPI GP18,GP19,GP16
OPTION AUTORUN  ON
OPTION CPUSPEED  252000 'KHz
OPTION LCDPANEL ILI9341, LANDSCAPE,GP17,GP14,GP13
OPTION WIFI HuaHuaNisse, ***********, PICOE6616408433
OPTION TCP SERVER PORT 80, 10000
OPTION TOUCH GP0,GP1
GUI CALIBRATE 0, 3894, 3948, -904, -634
OPTION AUDIO VS1053 GP10,GP11,GP12,GP9,GP8,GP7,GP6', ON PWM CHANNEL 5
>


Pluto
 
Pluto
Guru

Joined: 09/06/2017
Location: Finland
Posts: 358
Posted: 03:51pm 18 Jan 2024
Copy link to clipboard 
Print this post

Problem solved. Tried with PLAY STOP again and now it is OK!  
 
     Page 1 of 3    
Print this page
© JAQ Software 2024