Little Web Radio based on the module ESP32-2432S028

Place your projects here
Post Reply
User avatar
cicciocb
Site Admin
Posts: 2046
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 438 times
Been thanked: 1343 times
Contact:

Little Web Radio based on the module ESP32-2432S028

Post by cicciocb »

HI All,
following the integration the module ESP32-2432S028 with Annex32, I revisited an old project consisting of a little but nice WEB Radio player.

You can find the source code below, and the complete project, including all the icons, in the attached ZIP file.

Obviously, this project works with any ESP32 provided with a touch screen controller

Code: [Local Link Removed for Guests]

''Annex Web radio Player demo by cicciocb 2020
''''''''''''''''''''''''''''''''''''''
data "Beatles Radio", "http://www.beatlesradio.com:8000/stream/1/"
data "Jazz Radio Funk", "http://jazz-wr06.ice.infomaniak.ch/jazz-wr06-128.mp3"
data "Latina", "http://start-latina.ice.infomaniak.ch/start-latina-high.mp3"
data "Funky", "http://allzic08.ice.infomaniak.ch/allzic11.mp3"
data "Italo Disco", "http://streams.80s80s.de/italohits/mp3-192/streams.80s80s.de/"
data "Rai Radio 1", "http://icestreaming.rai.it/1.mp3"
data "Rai Radio 2", "http://icestreaming.rai.it/2.mp3"
data "Rai Radio 3", "http://icestreaming.rai.it/3.mp3"
data "Rai Radio 4", "http://icestreaming.rai.it/4.mp3"
data "Rai Radio 5", "http://icestreaming.rai.it/5.mp3"
data "Rai Radio 6", "http://icestreaming.rai.it/6.mp3"
data "Rai Radio 7", "http://icestreaming.rai.it/7.mp3"
data "Rai Radio 8", "http://icestreaming.rai.it/8.mp3"
data "Rai Radio 9", "http://icestreaming.rai.it/9.mp3"
data "Rai Radio 10", "http://icestreaming.rai.it/10.mp3"
data "Rai Radio 11", "http://icestreaming.rai.it/11.mp3"
data "Rai Radio 12", "http://icestreaming.rai.it/12.mp3"
data "Rai Radio 13", "http://icestreaming.rai.it/13.mp3"
data "Rai Radio 14", "http://icestreaming.rai.it/14.mp3"
data "Rai Radio 15", "http://icestreaming.rai.it/15.mp3"
data "Kiss Kiss", "http://ice07.fluidstream.net:8080/KissKiss.mp3"
data "Radio Pooh", "http://audio4.nemostream.tv:8011/autodj"
data "Jingle Programation", "http://stream.vestaradio.com:8091/RadioTeolis"
data "end"

play.setup 0, 64 'use internal DAC
vol = 50 ' default volume 50

dim radio$(100,2) ' max 100 radios
read r$
p = 0
while r$ <> "end"
  radio$(p, 0) = r$
  read radio$(p, 1)
  read r$
  p = p + 1
wend
nb_radios = p
wlog "nb radios "; nb_radios 

current_radio = 0 ' file to be played

onplay play_event 

gui.init 20
gui.image 0,0, 320, 240, "/mp3_demo/img/neptune_320.jpg"

'main buttons
gui.box 0, 177, 320, 64, black, black, black
rew = gui.buttonimage   10, 177, 64, 64, "/mp3_demo/icons/first2.bmp", "/mp3_demo/icons/first.bmp", momentary, 0, black
ply = gui.buttonimage   90, 177, 64, 64, "/mp3_demo/icons/play2.bmp", "/mp3_demo/icons/play.bmp", momentary, 0, black
stp = gui.buttonimage  170, 177, 64, 64, "/mp3_demo/icons/stop2.bmp", "/mp3_demo/icons/stop.bmp", momentary, 0, black
ffw = gui.buttonimage  250, 177, 64, 64, "/mp3_demo/icons/last2.bmp", "/mp3_demo/icons/last.bmp", momentary, 0, black

'set events on buttons
gui.setevent rew, 1, prev_radio
gui.setevent ply, 1, play_radio
gui.setevent stp, 1, stop_radio
gui.setevent ffw, 1, next_radio

' volume
gui.textline 270, 5, 50, 14, "VOLUME"
vol = gui.slider 280, 20, 30, 150, vol, vertical
gui.setevent vol, 3, vol_change  ' change event
gui.setstyle vol, 12, 6, 5
'vu meter
vu_L = gui.progressbar 240, 30, 10, 130, 50, 1 
vu_R = gui.progressbar 260, 30, 10, 130, 50, 1

' window with the web radio information
tt = gui.textline 120, 0, 0, 0, "Radio" , 4, White, black, black
Sitename = gui.textline 5, 22, 220, 18, "Annex32 WiFi RDS Web Radio Player", 1, cyan, black, yellow

gui.textline 120, 60, 0, 0, "       Genre       Bitrate" , 4, White, black, black
Genre   = gui.textline 5, 70, 140, 18, "by cicciocb", 1, cyan, black, yellow
Bitrate = gui.textline 155, 70, 70, 18, "2020", 1, cyan, black, yellow

gui.textline 120, 110, 0, 0, "Title Online" , 4, White, black, black
gui.rect 4, 121, 222, 36, white
title1= gui.textline 5, 122, 220, 18, "Listen Web Radios from Internet", 1, green, black, black
title2 = gui.textline 5, 138, 220, 18, "The whole code is around 100 lines!", 1, green, black, black

gui.autorefresh 50, 1
timer0 50, update_vu
wait

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
stop_radio:
play.stop
return
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
play_radio:
' set the default text in the boxes
gui.settext Sitename, radio$(current_radio, 0)  ' radio name
gui.SetText Genre, ""  'empty
gui.SetText Bitrate, "" 'empty
split_text title1, title2, "" 'empty

if (play.isPlaying = 1) or (GUI.TARGET = ply) then
  play.stop
  play.stream radio$(current_radio, 1), 20000
end if
return
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
prev_radio:
  current_radio = current_radio -1
  if current_radio < 0 then current_radio = nb_radios - 1
  gosub play_radio
return
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
next_radio:
  current_radio = current_radio + 1
  if current_radio >= nb_radios then current_radio = 0
  gosub play_radio
return
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
vol_change:
play.volume gui.getvalue(vol)
return
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
play_event:
pause 100
m$ = play.message$

SiteName$ = word.getparam$(m$, "SiteName")
Bitrate$ = word.getparam$(m$, "Bitrate") 
Genre$ = word.getparam$(m$, "Genre") 
Title$ = word.getparam$(m$, "StreamTitle") 

if SiteName$ <> "" then gui.SetText Sitename, SiteName$

if Bitrate$ <> "" then gui.SetText Bitrate, Bitrate$ + " Kbps"

if Genre$ <> "" then gui.SetText Genre, Genre$

if Title$ <> "" then split_text title1, title2, Title$

return
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
update_vu:
gui.setvalue vu_L, log(play.VU_L/300 + 1) * 26'* 24.88  computed value
gui.setvalue vu_R, log(play.VU_R/300 + 1) * 26' * 24.88
return
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
sub split_text(obj1, obj2, txt$)
  if len(txt$) < 35 then
    gui.setText obj1, txt$
    gui.setText obj2, " "
  else
    gui.setText obj1, left$(txt$, 35)
    gui.setText obj2, mid$(txt$, 36)
  end if
end sub

image.png

edit : icon file names corrected :!:
tft_gui_radio_demo.zip
You do not have the required permissions to view the files attached to this post.
User avatar
Fernando Perez
Posts: 378
Joined: Mon Feb 15, 2021 10:09 pm
Location: Santander (Spain)
Has thanked: 195 times
Been thanked: 267 times

Re: Little Web Radio based on the module ESP32-2432S028

Post by Fernando Perez »

Notes:
- Of all the button icons, only the first.bmp icon appears.
Reason: the other 3 remaining have the first letter lowercase in the program and uppercase in the icons folder.
- The volume is exaggeratedly high. I'm using a small 8 ohm - 2 watt speaker and I'm still afraid of waking up the neighbors. :o
I see that the values that the slider delivers are very high. Maybe you forgot gui.SETRANGE ?
- At some point, the content of the "Title Online" exceeds the size of the text window and overwrites the controls to its right.

Otherwise, beautiful.
User avatar
cicciocb
Site Admin
Posts: 2046
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 438 times
Been thanked: 1343 times
Contact:

Re: Little Web Radio based on the module ESP32-2432S028

Post by cicciocb »

[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Fri Dec 15, 2023 11:19 pm Notes:
- Of all the button icons, only the first.bmp icon appears.
Reason: the other 3 remaining have the first letter lowercase in the program and uppercase in the icons folder.
- The volume is exaggeratedly high. I'm using a small 8 ohm - 2 watt speaker and I'm still afraid of waking up the neighbors. :o
I see that the values that the slider delivers are very high. Maybe you forgot gui.SETRANGE ?
- At some point, the content of the "Title Online" exceeds the size of the text window and overwrites the controls to its right.

Otherwise, beautiful.
Hi Fernando, thanks for your feedback.
As I use all the time an SDcard, I did not noted the file name upcase/lowcase differences (the SDcard has the FAT so don't care the cases). I'll modify the zip and reupload again to avoid this problem.
For the volume, probably you need the famous 100 ohm resistor or reduce more the gain of the amplifier ; changing the volume max value in the code is possible too but you'll have a loss in the quality of the sound because you'll reduce the dynamic range of the output, that is already at 8bits 😔.
About the title that exceed the limits, I've implemented some new gui objects for the 7" LCD that probably will be nice to transfer to the SPI TFT.
Anyway, this problem can be easily fixed sending only a substring of the whole message .... I'm sure you'll fix it 😁
Helmut_number_one
Posts: 95
Joined: Fri Dec 09, 2022 10:03 am
Has thanked: 38 times
Been thanked: 9 times

Re: Little Web Radio based on the module ESP32-2432S028

Post by Helmut_number_one »

file name upcase/lowcase differences
in zip file the imagename wrong, still
But the projekt is ok, and actually way too loud, and I also find it distorted. Hardware problem, i thing
User avatar
cicciocb
Site Admin
Posts: 2046
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 438 times
Been thanked: 1343 times
Contact:

Re: Little Web Radio based on the module ESP32-2432S028

Post by cicciocb »

[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Sat Dec 16, 2023 5:55 pm
file name upcase/lowcase differences
in zip file the imagename wrong, still
But the projekt is ok, and actually way too loud, and I also find it distorted. Hardware problem, i thing
Have a look here :

[Local Link Removed for Guests]


p.s.

I just corrected the icon file names
Helmut_number_one
Posts: 95
Joined: Fri Dec 09, 2022 10:03 am
Has thanked: 38 times
Been thanked: 9 times

Re: Little Web Radio based on the module ESP32-2432S028

Post by Helmut_number_one »

Thankyou, i will tryout
Monki
Posts: 42
Joined: Mon Feb 27, 2023 12:56 pm
Location: Berlin
Has thanked: 6 times
Been thanked: 6 times

Re: Little Web Radio based on the module ESP32-2432S028

Post by Monki »

hello Francesco,
Thank you very much for your code example, another question about the new gui objects you mentioned. Are they already included in version 7 from December 15th and how can you use them?

monki
User avatar
cicciocb
Site Admin
Posts: 2046
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 438 times
Been thanked: 1343 times
Contact:

Re: Little Web Radio based on the module ESP32-2432S028

Post by cicciocb »

[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Sun Dec 17, 2023 6:32 am hello Francesco,
Thank you very much for your code example, another question about the new gui objects you mentioned. Are they already included in version 7 from December 15th and how can you use them?

monki
No, I'm still in the experimental phase
Post Reply