MP3 player on Odroid

Place code snippets and demo code here
Post Reply
pdurys
Posts: 3
Joined: Fri Jan 06, 2023 12:57 pm

MP3 player on Odroid

Post by pdurys »

Hi there,

Before swithing to this Forum there was short tread about this here: https://groups.google.com/g/annex_wifi_ ... K5HhRUAgAJ

I have seen also running app on this video: https://youtube.com/shorts/CjtQZA1rq_s?feature=share

Can someone CioccioCB? help me with flashing Odroid and use as internet radio, please?

Thanks
pdurys
User avatar
cicciocb
Site Admin
Posts: 1889
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 405 times
Been thanked: 1261 times
Contact:

Re: MP3 player on Odroid

Post by cicciocb »

Hi,
this is a simple project I did some time ago, just to demonstrate what is possible to do with Annex using GUI, events and buttons.

Luckily I found a backup of the project on my old disk.

So, you'll find here a .zip file containing all the files for the project.

Probably the list of the web radio must be updated as this project is around 2 years old.

This is the source of the program (that is also included in the .zip)

Code: [Local Link Removed for Guests]

'Annex Web radio Player demo by cicciocb 2020
''''''''''''''''''''''''''''''''''''''

'data "Galaxie Radio", "https://listen.radioking.com/radio/15684/stream/29075"
data "Beatles Radio", "http://www.beatlesradio.com:8000/stream/1/"
data "Radio Funky", "http://streaming.hotmixradio.fm/hotmixradio-funky-128.mp3"
data "Classis Rock", "http://classicrock.stream.ouifm.fr/ouifm3.mp3"
data "Blue Rock", "http://bluesnrock.stream.ouifm.fr/ouifmbluesnrock-128.mp3"
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 "Radio Marte", "http://onair18.xdevel.com:8212/"
data "Rai Radio 1", "http://icestreaming.rai.it/1.mp3"
data "Funky", "http://allzic08.ice.infomaniak.ch/allzic11.mp3"
data "Italo Disco", "http://streams.80s80s.de/italohits/mp3-192/streams.80s80s.de/"
data "end"

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 Marte", "http://onair18.xdevel.com:8212/"
data "Radio Zeta", "http://shoutcast.rtl.it:3030/" 'high rate 320 and https
data "Africa 1", "https://african1paris.ice.infomaniak.ch/african1paris-128.mp3"
data "Radio Pooh", "http://audio4.nemostream.tv:8011/autodj"
data "Rire et Chansons", "https://scdn.nrjaudio.fm/audio1/fr/30401/mp3_128.mp3"
data "NRJ Radio", "https://scdn.nrjaudio.fm/audio1/fr/30001/mp3_128.mp3"
data "end"


' pin for odroid GO

'IO36 Battery ADC
'IO39 BTN START
'IO34 BTN-AXIS X
'IO35 BTN-AXIS Y
'IO32 BTN A
'IO33 BTN B
'IO27 BTN SELECT
'IO13 BTN MENU
'IO00 BTN VOLUME
pin.mode 32, input, pullup ' BTN A
pin.mode 33, input, pullup ' BTN B

pin.mode 39, input, pullup ' BTN START
pin.mode 27, input, pullup ' BTN SELECT
pin.mode 13, input, pullup ' BTN MENU
pin.mode 00, input, pullup ' BTN VOLUME

'neo.setup 27, 1 ' set the neo rgb led on the pin 27
'neo.pixel 0, 12345
play.setup 0, 32 'use external DAC
pause 500
pin.mode 25, output ' full enable the audio amplifier
pin(25) = 1
brightness = 128
tft.brightness brightness
'neo.setup 12, 32 ' strip of 16 leds on pin 12
'neo.strip 0, 15, 0 ' clears all the led

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, "/img/landscapes/landscape6.jpg"

'main buttons
gui.box 0, 177, 320, 64, black, black, black
rew = gui.buttonimage   0, 177, 64, 64, "/icons/player/first2.bmp", "/icons/player/first.bmp", momentary, 0, black
ply = gui.buttonimage   70, 177, 64, 64, "/icons/player/play2.bmp", "/icons/player/play.bmp", momentary, 0, black
stp = gui.buttonimage  187, 177, 64, 64, "/icons/player/stop2.bmp", "/icons/player/stop.bmp", momentary, 0, black
ffw = gui.buttonimage  257, 177, 64, 64, "/icons/player/last2.bmp", "/icons/player/last.bmp", momentary, 0, black

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

' volume
gui.textline 270, 5, 50, 14, "VOLUME"
vol = gui.slider 280, 20, 30, 150, 50, 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, 0 ' no touch

timer0 50, update_vu

timer1 100, update_buttons
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), 30000, 1
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

pos_change:
play.seek gui.getvalue(pos)
return

play_event:
pause 100
m$ = play.message$
print m$

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_slider:
gui.setvalue pos, play.pos
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
l = log(play.VU_L/300 + 1)* 4 - 1
'neo.strip 0, 16, 0, 1
'neo.strip 0, l, neo.rgb(rnd(32), rnd(32), rnd(32))

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


update_buttons:

gui.setvalue rew, 1 - pin(13)
gui.setvalue ply, 1 - pin(00)
gui.setvalue stp, 1 - pin(27)
gui.setvalue ffw, 1 - pin(39)

'volume with arrows up/down
y = adc(35)
if y > 0 then
  v =  gui.getvalue(vol)
  if y < 4000 then 
     v = v - 1
  else
     v = v + 1
  end if
  if v > 100 then v = 100
  if v < 0 then v = 0
  gui.setvalue vol, v
  play.volume v
end if

'brightness with arrows left/right
x = adc(34)
if x > 0 then
  v = brightness 
  if x < 4000 then 
     v = v + 5
  else
     v = v - 5
  end if
  if v > 255 then v = 255
  if v < 5 then v = 5
  brightness = v
  tft.brightness brightness 
end if

return

You do not have the required permissions to view the files attached to this post.
pdurys
Posts: 3
Joined: Fri Jan 06, 2023 12:57 pm

Re: MP3 player on Odroid

Post by pdurys »

Thanks, going to flash Odroid. Will keep you updated how it went.

Yes list of radio stations will be updated.
pdurys
Posts: 3
Joined: Fri Jan 06, 2023 12:57 pm

Re: MP3 player on Odroid

Post by pdurys »

Hi there again.

It was not dificult to flash Odroid with Annex and then have Internet radio up and running.
But I have very frequently resets and sound was terrible.

For others whom wish to try.
Please remember to select the right options on local web page.
There should be unit ODROID Go and correct screen orientation.
I have also disabled SD card as well. I did that to have other program examples visible in File Manager
I have not found a way to copy whole structure of icons and backgroud picture at once. I have had to create folders manually and then upload multiple files at once.

Apart of that Annex seems to be interesting platform to play with Odroid
User avatar
cicciocb
Site Admin
Posts: 1889
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 405 times
Been thanked: 1261 times
Contact:

Re: MP3 player on Odroid

Post by cicciocb »

I suggest you to install the latest version that you can find here :

[Local Link Removed for Guests]

This version is without BLE so it gives more RAM available and contains a fix for the sound.
User avatar
cicciocb
Site Admin
Posts: 1889
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 405 times
Been thanked: 1261 times
Contact:

Re: MP3 player on Odroid

Post by cicciocb »

[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Sat Jan 07, 2023 11:04 am
I have not found a way to copy whole structure of icons and backgroud picture at once. I have had to create folders manually and then upload multiple files at once.
For that you can use the function "File Upload" available in the AnnexToolkit
Post Reply