OpenWRT - Cheap MP3 player & Wi-Fi Internet stereo radio

sezione dedicata ai sistemi operativi alternativi Open Source

Re: OpenWRT - Cheap MP3 player & Wi-Fi Internet stereo radio

Messaggio da leggereda root » 16/02/2015, 15:18

I successfully tested this USB audio device:

Immagine

Only 6 buttons of 7 are recognized by Triggehappy:

KEY_NEXTSONG
KEY_PREVIOUSSONG
KEY_PLAYPAUSE
KEY_VOLUMEDOWN
KEY_VOLUMEUP
KEY_MIN_INTERESTING (key Headset-Mute)

Key Microphone-Mute is not recognized (or not working on my device :( )

--------------------------------------------------------

and this other:

Card: C-Media USB Headphone Set
Chip: USB Mixer
Item: PCM [dB gain: -26.88, -26.88]

Immagine

the three buttons on this device are recognized by Triggerhappy, so you can avoid using a USB keyboard/Keypad to control the Internet radio, instead you can use "Vol +" and "Vol -" buttons to control audio volume and the other large button to change radio stations or MP3 song (with MPD player playlist).

This is what Triggerhappy sees when you press the three buttons:

root@OpenWrt:~# thd --dump /dev/input/event*
EV_KEY KEY_VOLUMEDOWN 1 /dev/input/event1
# KEY_VOLUMEDOWN 1 command
EV_KEY KEY_VOLUMEDOWN 0 /dev/input/event1
# KEY_VOLUMEDOWN 0 command
EV_KEY KEY_VOLUMEUP 1 /dev/input/event1
# KEY_VOLUMEUP 1 command
EV_KEY KEY_VOLUMEUP 0 /dev/input/event1
# KEY_VOLUMEUP 0 command
EV_KEY KEY_MIN_INTERESTING 1 /dev/input/event1
# KEY_MIN_INTERESTING 1 command
EV_KEY KEY_MIN_INTERESTING 0 /dev/input/event1
# KEY_MIN_INTERESTING 0 command
Maurizio
Avatar utente
root
Amministratore
 
Messaggi: 390
Iscritto il: 10/04/2012, 10:55
Località: Turin

Re: OpenWRT - Cheap MP3 player & Wi-Fi Internet stereo radio

Messaggio da leggereda root » 16/02/2015, 15:18

A simple way to create a web page to control the Openwrt Internet Radio is to use cgi scripts, by using CGI you don't need to install additional packages.

1) create 'n' cgi scripts named "canalen" (canale1, canale2, etc.) with the following code inside:

#!/bin/ash
/bin/echo ''
/bin/echo ''
/usr/bin/killall madplay mpd ; /bin/sleep 1 ; /usr/bin/wget -O - http://icestreaming.rai.it/1.mp3 | /usr/bin/madplay - &
/bin/echo 'Internet Radio Name'


note: obviously change the "radio streaming URL" and "Internet Radio Name" for each script

save them in /www/cgi-bin directory then give chmod 755 permissions

2) create "radio.html" file in /www directory:

Internet Radio
<p>
<FORM ACTION="/cgi-bin/canale1.cgi">
<INPUT TYPE=SUBMIT VALUE="canale 1">
</FORM>
<FORM ACTION="/cgi-bin/canale2.cgi">
<INPUT TYPE=SUBMIT VALUE="canale 2">
</FORM>
<FORM ACTION="/cgi-bin/canale3.cgi">
<INPUT TYPE=SUBMIT VALUE="canale 3">
</FORM>
<FORM ACTION="/cgi-bin/canale4.cgi">
<INPUT TYPE=SUBMIT VALUE="canale 4">
</FORM>
<FORM ACTION="/cgi-bin/canale5.cgi">
<INPUT TYPE=SUBMIT VALUE="canale 5">
</FORM>
<FORM ACTION="/cgi-bin/canale6.cgi">
<INPUT TYPE=SUBMIT VALUE="canale 6">
</FORM>
<FORM ACTION="/cgi-bin/canale7.cgi">
<INPUT TYPE=SUBMIT VALUE="canale 7">
</FORM>
<FORM ACTION="/cgi-bin/canale8.cgi">
<INPUT TYPE=SUBMIT VALUE="canale 8">
</FORM>
<FORM ACTION="/cgi-bin/canale9.cgi">
<INPUT TYPE=SUBMIT VALUE="canale 9">
</FORM>
<FORM ACTION="/cgi-bin/canale10.cgi">
<INPUT TYPE=SUBMIT VALUE="canale 10">
</FORM>
<FORM ACTION="/cgi-bin/canale11.cgi">
<INPUT TYPE=SUBMIT VALUE="canale 11">
</FORM>


The url of the web control page is http://ip_address_of_your_router/radio.html

After selecting a channel, use the "Go Back" button of you browser to go back to the main selection page.

This is just an example, I'm sure this method could be improved a lot :)
Maurizio
Avatar utente
root
Amministratore
 
Messaggi: 390
Iscritto il: 10/04/2012, 10:55
Località: Turin

Re: OpenWRT - Cheap MP3 player & Wi-Fi Internet stereo radio

Messaggio da leggereda root » 16/02/2015, 15:19

I tested the Radio Web Interface package @ http://www.formare.ro/download/nmsradio.zip and worked very well!

Install instructions (very easy) are inside the zip package, basically:

1. create "/www/cgi-bin/nmsradio" directory: mkdir /www/cgi-bin/nmsradio
2. give chmod 755 permissions to "nmsradio" directory: chmod 755 /www/cgi-bin/nmsradio
3. cd to "cgi-bin" directory: cd /www/cgi-bin
4. download the file: wget http://www.formare.ro/download/nmsradio.zip
5. unzip the "nmsradio.zip" file in "/www/cgi-bin/": unzip nmsradio.zip (opkg install unzip)
6. copy the following 4 files in "/www/cgi-bin/nmsradio": play.cgi, alarm.cgi, setalarm.sh, changechannel.sh
7. give chmod 755 permissions to the above files
8. copy the following 2 files in /etc/config: posturi, radio
9. eventually edit "/etc/config/posturi" to add more radio stations.

To access the Radio web interface type in browser: http://routerIP/cgi-bin/nmsradio/play.cgi.

Note: there is also a web interface to program multiple timers (crontab) to switch on and off radio stations at preset times.
Wake up with your favorite stations! :)

!Be carefull radio crontab will erase all your current crontabs!
Maurizio
Avatar utente
root
Amministratore
 
Messaggi: 390
Iscritto il: 10/04/2012, 10:55
Località: Turin

Re: OpenWRT - Cheap MP3 player & Wi-Fi Internet stereo radio

Messaggio da leggereda root » 16/02/2015, 15:19

This a list of radio streaming URLs to use in "/etc/config/posturi" of the previous post, but you can use the URLs also for other applications.

config playlist
list post STOP

list post http://stream.hoerradar.de:80/sunshinelive-mp3-192
list post http://shoutcast.unitedradio.it:1109
list post http://shoutcast.unitedradio.it:1301
list post http://46.37.20.205:8000/rdsmp3
list post http://mp3.kataweb.it:8000/RadioDeejay
list post http://mp3.kataweb.it:8000/M2O
list post http://icestreaming.rai.it/2.mp3
list post http://icestreaming.rai.it/1.mp3
list post http://icestreaming.rai.it/4.mp3
list post http://streaming.radionomy.com/1000-HITS-Sweet-Radio
list post http://streaming.radionomy.com/cumbias-inmortales
list post http://streaming.hotmix-radio.net/hotmixradio-lounge-128.mp3
list post http://streaming.radionomy.com/always-80s
list post http://streaming.radionomy.com/Hit-s-My-Music-Pop-Rock
list post http://streaming.streamonomy.com/BeGoodPop
list post http://streaming.radionomy.com/Cafe-Romantico-Radio
list post http://traditionalmanele1.zapto.org:3750/
list post http://b.fmradiomanele.ro:8044/
list post http://streaming.radionomy.com/Radio-Quelite
list post http://streaming.radionomy.com/PassionLoveRadio
list post http://streaming.radionomy.com/CristalRelax
list post http://streaming.radionomy.com/GOLDEN-SIXTIES-SEVENTIES-EIGHTIES-RADIO
list post http://streaming.radionomy.com/A-Better-Love-Songs-Station
list post http://streaming.radionomy.com/R-E-T-R-OF-M
list post http://streaming.radionomy.com/radio-accordeon
list post http://streaming.radionomy.com/HappyChristmasradio
list post http://streaming.radionomy.com/ChristmasWonderlandRadio
list post http://streaming.radionomy.com/TheChristmasStation
list post http://streaming.radionomy.com/100-HIT-radio
list post http://streaming.radionomy.com/colombiaromantica
list post http://streaming.radionomy.com/Ambiance-Reggae
list post http://streaming.radionomy.com/Fm-Tropical-Shad-972
list post http://streaming.radionomy.com/NashvilleEdge
list post http://streaming.radionomy.com/101countryradio
list post http://streaming.radionomy.com/SMOOTH-RIVIERA
list post http://streaming.radionomy.com/ChristmasClassics2014
list post http://streaming.radionomy.com/VivaLaNavidadRadio
list post http://streaming.radionomy.com/CountryChristmas
list post http://streaming.radionomy.com/chd--radio-country
list post http://streaming204.radionomy.com:80/100-CHILL
list post http://streaming.radionomy.com/1-Radio-Dance
list post http://streaming.radionomy.com/Acoustic-FM
list post http://streaming.radionomy.com/ABC-Love
list post http://streaming.radionomy.com/Radio-Nostalgia
list post http://andromeda.shoutca.st:8634/stream
list post http://streaming.radionomy.com/RadioArdeal
list post http://91.121.164.186:8600
list post http://streaming.radionomy.com/DanceRO
list post http://streaming.radionomy.com/jamaican-roots-radio
list post http://205.164.62.20:8010/
list post http://streaming.radionomy.com/radio-oldies-and-rock--n--roll
list post http://92.48.107.35:8000
list post http://nebula.shoutca.st:9273/stream
list post http://streaming.radionomy.com/The-Buffalo
list post http://streaming.radionomy.com/VWClassicRock
list post http://str30.creacast.com/r101_thema4
list post http://107.155.111.234:8710
list post http://stream.srg-ssr.ch/m/rsc_it/mp3_128
list post http://stream.srg-ssr.ch/m/rsp/mp3_128
list post http://stream.srg-ssr.ch/m/rsj/mp3_128
list post http://srv6.karadio.biz:20474/
list post http://205.164.62.15:9010/
list post http://37.48.81.130:9530
list post http://144.76.106.52:7000/chillout.mp3
list post http://69.60.119.117:8000/
list post http://radionova128.media.vistatec.ie:80
list post http://stream-sd.radioparadise.com:8056
list post http://icecast2.rte.ie/ieradio1
list post http://listen.radionomy.com/the-smooth-lounge
list post http://85.214.96.78:8000/stream
Maurizio
Avatar utente
root
Amministratore
 
Messaggi: 390
Iscritto il: 10/04/2012, 10:55
Località: Turin

Re: OpenWRT - Cheap MP3 player & Wi-Fi Internet stereo radio

Messaggio da leggereda root » 16/02/2015, 15:20

Addendum: a new function to your Internet radio :)

A Westminster chimes that play on the hour, from 08:00 AM to 11:00 PM (you may want to sleep during the night ;) )

Download this audio file: https://www.greyware.com/tryout/chimes/Westminster_Classic_Chimes.mp3 and save it to "/root" directory,

edit the file "/etc/crontabs/root" file (if it doesn't exist create it with: touch /etc/crontabs/root) and add the following line:

00 08-23 * * * /usr/bin/madplay /root/Westminster_Classic_Chimes.mp3

reboot and enjoy.

Note: when the radio is playing music, the chimes don't play.
Maurizio
Avatar utente
root
Amministratore
 
Messaggi: 390
Iscritto il: 10/04/2012, 10:55
Località: Turin

Re: OpenWRT - Cheap MP3 player & Wi-Fi Internet stereo radio

Messaggio da leggereda root » 16/02/2015, 15:20

Wake up with your favorite radio station :)

Example: if you want to wake up every day from Monday to Friday at 07:00 AM with the internet radio playing your preferred channel,

edit the file "/etc/crontabs/root" file (if it doesn't exist create it with: touch /etc/crontabs/root) and add the following line:

00 07 * * 1-5 /usr/bin/killall madplay ; /bin/sleep 2 ; /usr/bin/wget -O - http://streaming.radionomy.com/PassionLoveRadio | /usr/bin/madplay -


then reboot to make it active.
Maurizio
Avatar utente
root
Amministratore
 
Messaggi: 390
Iscritto il: 10/04/2012, 10:55
Località: Turin

Re: OpenWRT - Cheap MP3 player & Wi-Fi Internet stereo radio

Messaggio da leggereda root » 29/04/2015, 11:31

I've just tested this Infrared USB Remote Controller device with my OpenWRT Internet MP3/Radio and it works very well.
I paid it 10 Euro.
No drivers are needed, just plug it and use it (with Triggerhappy).

By using this device you can remote control your OpenWRT radio with a lot of functions, simply use Triggerhappy and configure some or all buttons of this remote controller with different functions of your Digital Radio :)

Immagine

Example of some triggerhappy commands configuration for this remote controller (please read comments):

file /etc/triggerhappy/triggers.d/example.conf

#
# NOTE: do not press the red power button, if you do it, the event code names will change and a restart is needed to go back to default.
# I would suggest you to remove or cut this button
#
#
## control an mpd instance - MP3/Radio Player
#
# start playing
KEY_PLAYPAUSE 1 /usr/bin/killall madplay mpd ; sleep 2 ; /usr/bin/mpd ; /usr/bin/mpc listall | /usr/bin/mpc add ; /usr/bin/mpc play
# jump to next song
KEY_NEXTSONG 1 /usr/bin/mpc next
# jump to previous song
KEY_PREVIOUSSONG 1 /usr/bin/mpc prev
#
## Audio volume controls
## IMPORTANT NOTE: You might need to change "Speaker" device name to "PCM" if you use a different USB sound card.
#
# increase volume
KEY_VOLUMEUP 1 /usr/bin/amixer -q set Speaker 1%+
# decrease volume
KEY_VOLUMEDOWN 1 /usr/bin/amixer -q set Speaker 1%-
# Stop playing
KEY_STOPCD 1 /usr/bin/killall madplay mpd
# set audio volume to minimum audible level
KEY_MIN_INTERESTING 1 amixer -q set Speaker 4
#
## Control Madplay Internet Radio by selecting four different stations with the four ABCD coloured buttons: green, orange, blue and yellow.
# note: event value generated by these four coloured buttons is 0 when pressed
#
# Obviously, more stations can be associated to other buttons, just check event names and values with "thd --dump /dev/input/event*" command
#
KEY_F1 0 /usr/bin/killall madplay ; /usr/bin/killall mpd ; sleep 2 ; /usr/bin/wget -O - http://streaming.radionomy.com/PassionLoveRadio | /usr/bin/madplay --replay-gain=audiophile --attenuate=-4 - &
KEY_F2 0 /usr/bin/killall madplay ; /usr/bin/killall mpd ; sleep 2 ; /usr/bin/wget -O - http://streaming.radionomy.com/CristalRelax | /usr/bin/madplay --replay-gain=audiophile --attenuate=-4 - &
KEY_F3 0 /usr/bin/killall madplay ; /usr/bin/killall mpd ; sleep 2 ; /usr/bin/wget -O - http://streaming.radionomy.com/Radio-Quelite | /usr/bin/madplay --replay-gain=audiophile --attenuate=-4 - &
KEY_F4 0 /usr/bin/killall madplay ; /usr/bin/killall mpd ; sleep 2 ; /usr/bin/wget -O - http://radionova128.media.vistatec.ie:80 | /usr/bin/madplay --replay-gain=audiophile --attenuate=-4 - &
Maurizio
Avatar utente
root
Amministratore
 
Messaggi: 390
Iscritto il: 10/04/2012, 10:55
Località: Turin

Re: OpenWRT - Cheap MP3 player & Wi-Fi Internet stereo radio

Messaggio da leggereda root » 18/05/2015, 19:58

If you want to record Internet Radio streams (in MP3 format) to play songs in offline mode later with Madplay, you just need to install streamripper program.

opkg update
opkg install streamripper


"cd" to the directory you want to use for saving your MP3s

example:
cd /mnt/external_flash

note: don't save MP3s into the internal router flash memory otherwise you will fill it in a second :lol:

then use this simple command:
/usr/bin/streamripper stream-url

example:
/usr/bin/streamripper http://stream.srg-ssr.ch/m/rsj/mp3_128

Note: you won't hear any audio during ripping.
To stop ripping press "Ctrl+c" otherwise Streamripper will run indefinitely.
If you want to limit the total space occupied by ripped MP3s, you can limit streamripper using "-M megabytes" option to be added to the end of the above command line, or to limit streamripper in time by fixing a maximum time for it to run, you can use "-l seconds" option.

[Optional] You may also want to fix MP3s variable bit rate with Vbrfix:
http://tuxtweaks.com/2012/03/fixing-var ... th-vbrfix/

To remove spaces from MP3 filenames in current directory and convert them to underscores (not recursive):
for f in *\ *; do mv "$f" "${f// /_}"; done

Single line command (not recursive) to play in sequence all .mp3 files present in a directory using Madplay:
/usr/bin/find /mnt/external_flash -name \*[mM][Pp]3 | /usr/bin/awk '{print "\""$0"\""}' | /usr/bin/xargs /usr/bin/madplay - &

or if you prefere playing them randomly:
/usr/bin/find /mnt/external_flash -name \*[mM][Pp]3 | /usr/bin/awk '{print "\""$0"\""}' | /usr/bin/xargs /usr/bin/madplay -z - &
Maurizio
Avatar utente
root
Amministratore
 
Messaggi: 390
Iscritto il: 10/04/2012, 10:55
Località: Turin

Messaggio da leggereda root » 22/01/2018, 12:30

just a quick note:

if you have just 32 Mbytes of RAM do not install mpd (mpd-full) package because it is too memory-hungry, use instead mpd-mini package.

If you have previously installed mpd (mpd-full), I would suggest you to do the following:

opkg update
opkg remove mpd
opkg install mpd-mini


mpd-full needs about 40 Mbytes of RAM to work flawlessly, mpd-mini needs just 22 Mbytes and there are no differences between the two for this internet radio application, so mpd-mini is the best choice anyway.
Maurizio
Avatar utente
root
Amministratore
 
Messaggi: 390
Iscritto il: 10/04/2012, 10:55
Località: Turin

Precedente

Torna a OpenWRT

Chi c’è in linea

Visitano il forum: Google [Bot] e 1 ospite

cron