OpenWrt Forum Archive

Topic: [HowTo] Openwrt cheap Digital Stereo WiFi Internet Radio & MP3 Player

The content of this topic has been archived between 7 Apr 2018 and 5 May 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

cgchris99 wrote:

pilovis, did you think the Raspberry Pi is a better option now?

Definitely yes now that they have resolved the poor audio quality on the analog output.

Raspberry is faster, more versatile, more expandable, more powerfull, well documented and probably cheaper than a new router with OpenWRT.

I've developped dozen of OpenWRT projects, but now that I tested Rasperry Pi2 and Pi3, I have no more doubts.
Forget about Openwrt and buy a Raspberry, except if you have an old router to play with.

Don't put Openwrt on Raspberry, it is a waste, too many missing features and packages, and too slow, use raspbian instead wink

OpenWrt was a lot of fun, but it's time to change.

(Last edited by pilovis on 24 Apr 2017, 15:18)

pilovis wrote:
cgchris99 wrote:

pilovis, did you think the Raspberry Pi is a better option now?

Definitely yes now that they have resolved the poor audio quality on the analog output.

Raspberry is faster, more versatile, more expandable, more powerfull, well documented and probably cheaper than a new router with OpenWRT.

I've developped dozen of OpenWRT projects, but now that I tested Rasperry Pi2 and Pi3, I have no more doubts.
Forget about Openwrt and buy a Raspberry, except if you have an old router to play with.

Don't put Openwrt on Raspberry, it is a waste, too many missing features and packages, and too slow, use raspbian instead wink

OpenWrt was a lot of fun, but it's time to change.

Thanks for the information. Looks like another fun project to try. Been wanting to get a Pi3 anyway.

cgchris99 wrote:

Just getting into this project. I've seem posts that say bad USB sound adapters pop & click. Anyone have a recommendation. I already have a router coming.  Thanks for any advice.

I'm using a gl.inet mini router and usb powered speakers and you get some noise on the speaker which AFIAK is due to a ground path going via the audio cable.

solution is to power the speakers from a separate power source or use an isolation transformer to power your speakers

ebay.com/itm/401051811156

Those things have a min. load of 20ma, so just put a suitable resistor across the output and make sure your speakers don't draw more than 180ma@5v

I made a little USB pass-through dongle but you could wire it in to a hub or the speakers

I've seen some say that the USB sound cards don't always have capacitors on the output, just direct links and you can cut the link and place a capacitor in series but that made no difference for me

(Last edited by expo on 2 May 2017, 11:53)

pilovis

bought logitech S150.
I chose them because they 100 years on the market and IMHO must be compatible with everything
As far as I understand this is USB speakers with built-in sound-card
IMG link(I am not able to publish any links for some reason)
secure.logitech.com/assets/20147/20147.png

HW 160NL with 10.03.1
SW wget + madplay (works well)

There are 3 buttons on S150 which I decided to use as
<prev> | <start/stop> | <next>

Unfortunatelly in 10.03.1 no /etc/rc.button/ exists so I installed triggerhappy but it also useless because under /dev/input/ only event0 which is WPS

From other hand

~# amixer info
Card default 'default'/'USB  AUDIO   at usb-ar71xx-ehci-1.4, full speed'
  Mixer name    : 'USB Mixer'
  Components    : 'USB1130:1620'
  Controls      : 2
  Simple ctrls  : 1

I suppose:
Controls      : 2 <= edge buttons
Simple ctrls  : 1 <= center button

Of course it makes sense to upgrade to 15.05.1 and look into /etc/rc.button/ but I am not sure whether it would be a solution.

Question:
Lets say I have 3 .sh for each of button but how to feed these scripts to the buttons(which are visible in amixer
at least).
Do you have any experience?

sqr wrote:

pilovis

bought logitech S150.
There are 3 buttons on S150 which I decided to use as
<prev> | <start/stop> | <next>

Unfortunatelly in 10.03.1 no /etc/rc.button/ exists so I installed triggerhappy but it also useless because under /dev/input/ only event0 which is WPS

If you use  thd --dump /dev/input/event1 or  thd --dump /dev/input/event2 what do you get?

(Last edited by pilovis on 13 May 2017, 19:08)

expo wrote:
cgchris99 wrote:

Just getting into this project. I've seem posts that say bad USB sound adapters pop & click. Anyone have a recommendation. I already have a router coming.  Thanks for any advice.

I'm using a gl.inet mini router and usb powered speakers and you get some noise on the speaker which AFIAK is due to a ground path going via the audio cable.

solution is to power the speakers from a separate power source or use an isolation transformer to power your speakers

ebay.com/itm/401051811156

Those things have a min. load of 20ma, so just put a suitable resistor across the output and make sure your speakers don't draw more than 180ma@5v

I made a little USB pass-through dongle but you could wire it in to a hub or the speakers

I've seen some say that the USB sound cards don't always have capacitors on the output, just direct links and you can cut the link and place a capacitor in series but that made no difference for me

What about a Powerd USB hub?

Thanks to Pilovis for the work done and the explanations given.Using talks on this forum and on the internet with the subject wifi radio I succeeded and I created a radio internet with lcd display 20x4 which I am very pleased.I have used the router HG556a which has 3 usb , Arduino nano, lcd 20x4, usb audio card, usb hub, a cheap audio system 2.1, a usb remote control all mounted in the casing of a larger router for space. It works inexpensively both radio internet and cd player for a few months.
Thanks everyone on this forum

pilovis
I have just flashed 15.05.1 and it works now.
Thx. will reread this thread to finish config.

thd --dump /dev/input/event*

EV_KEY  KEY_VOLUMEDOWN  1       /dev/input/event0
EV_KEY  KEY_VOLUMEDOWN  0       /dev/input/event0
EV_KEY  KEY_MIN_INTERESTING     1       /dev/input/event0
EV_KEY  KEY_MIN_INTERESTING     0       /dev/input/event0
EV_KEY  KEY_VOLUMEUP    1       /dev/input/event0
EV_KEY  KEY_VOLUMEUP    0       /dev/input/event0

Just a quick note how to let the router say the current date and time by using svox (pico2tts)

create the script:

nano /root/say-giorno_ora.sh

in Italian:

#!/bin/sh
# pronuncia in Italiano giorno della settimana, data, ore e minuti
data=$(LC_ALL=it_IT.utf8 date +%A%d%B%Y)
#giorno=$(echo $data | sed 's/\://g')
pico2wave -l it-IT -w /tmp/data.wav "<volume level='75'><pitch level='105'>oggi e'  "$data
ora=$(date +"%H:%M")
cadena=$(echo $ora | sed 's/\:00/e zero/g')
pico2wave -l it-IT -w /tmp/ora.wav "<volume level='75'><pitch level='105'>sono le "$cadena"minuti"
aplay -f S16_LE -D plughw:0,0 /tmp/data.wav
aplay -f S16_LE -D plughw:0,0 /tmp/ora.wav

or in English:

#!/bin/sh
# say in English date, day of the week and time
data=$(date +%d%B)
pico2wave -l en-GB -w /tmp/data.wav "<volume level='75'><pitch level='105'> today is the"$data
data1=$(date +%A)
pico2wave -l en-GB -w /tmp/data1.wav "<volume level='75'><pitch level='105'>"$data1
ora=$(date +"%H:%M")
cadena=$(echo $ora | sed 's/\:00/and zero/g')
pico2wave -l en-GB -w /tmp/ora.wav "<volume level='75'><pitch level='105'>the current time is"$cadena"minutes"
aplay -f S16_LE -D plughw:0,0 /tmp/data.wav
aplay -f S16_LE -D plughw:0,0 /tmp/data1.wav
aplay -f S16_LE -D plughw:0,0 /tmp/ora.wav

give it the right permissions:

chmod 755 /root/say-giorno_ora.sh

and execute the script (audio out):

/bin/sh /root/say-giorno_ora.sh

(Last edited by pilovis on 14 Jul 2017, 08:14)

to improve the quality of the voice of pico2tts (svox), just add two tags to the "pico2wave" command, also reduce the audio bandwidth (8 khz):

pico2wave -l en-GB -w /tmp/data.wav "<volume level='75'><pitch level='105'> decrease volume and increase pitch to improve the voice"   
aplay -r 8000 -t wav -c 2 -f S16_LE -D plughw:0,0 /tmp/text.wav

(Last edited by pilovis on 14 Jul 2017, 08:23)

Just found another big improvement of the generated voice (by svox) by using play command (of sox):

opkg update
opkg install sox

edit the script:

pico2wave -l en-GB -w /tmp/data.wav "<volume level='55'><pitch level='105'> decrease audio volume and increase pitch to improve the voice"   
# boost treble 
play -qV0 /tmp/data.wav treble 24 gain -l -5

You can install SVOX (pico2tts) also on Barrier Breaker just by manually installing the chaos calmer package.

(Last edited by pilovis on 20 Feb 2018, 09:19)

Some question to MOTARDU:
Give me please some example how   use arduino and 20X4 display in you internet radio
With regards
Andy
my e=mail: anbos@mail.com

pilovis wrote:

... and some tweakings to improve radio functionality.

32 Megabytes of Ram are just the bare minimum for this internet radio to run, every extra kilobyte available is important.

Here are some tips to stop some useless (for this application) services to save some RAM and CPU usage:

Stop ntpd service by editing "/etc/config/system" and disable it:

config timeserver 'ntp'
        option enabled '0'

...

To get the current Time without enabling the timeserver, put the following line into the /etc/rc.local file right before "exit 0":

/usr/sbin/ntpd  -q -p ntp1.ien.it

(Last edited by pilovis on 26 Dec 2017, 07:21)

Script to switch on a led when internet connection is available.

In this specific case I used a green led to indicate that internet connection is available and a red one to warn when internet connection is not available (Router ADB P.DG A4001N1), but if you have just one led, you can set a fixed light when internet is available and a flash light when it is not available.

let's create the script:

nano /root/internet-check.sh

while [ true ]; do
    /usr/bin/wget -q --spider http://google.com > /dev/null
    if [[ $? -eq 0 ]]; then
            /bin/echo "0" > /sys/devices/gpio-leds/leds/A4001N1:red:inet/brightness
            /bin/echo "1" > /sys/devices/gpio-leds/leds/A4001N1:green:inet/brightness
else
            /bin/echo "0" > /sys/devices/gpio-leds/leds/A4001N1:green:inet/brightness
            /bin/echo "1" > /sys/devices/gpio-leds/leds/A4001N1:red:inet/brightness
    fi
    sleep 15
done

note: change "/sys/devices/gpio-leds/leds/A4001N1:green:inet" with the path for your router.


then give the right permissions to the above script:

chmod 755 /root/internet-check.sh


to launch the script at the startup put the following line right before the "exit 0" line in the /etc/rc.local" file

/bin/sh /root/internet-check.sh &

(Last edited by pilovis on 7 Jan 2018, 17:17)

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.

(Last edited by pilovis on 18 Jan 2018, 19:25)

You can install SVOX (pico2tts) also on Barrier Breaker just by manually installing the chaos calmer package.

example for AR71xx:

opkg install http://archive.openwrt.org/chaos_calmer/15.05.1/ar71xx/generic/packages/packages/svox_1.0+git20130326-2_ar71xx.ipk

NOTE: svox needs a lot of disk space, you need an external overlay or at least 10 Mbytes of free space available on the internal flash.

(Last edited by pilovis on 22 Jan 2018, 11:38)

I am looking for something where I can start a media player on my laptop playing a playlist and elsewhere in the house I have a router that picks up the local wifi and plays what my laptop would somehow be streaming over a couple of amplified speakers.   Is this what this does?   Or is this a setup to play only Internet radio stations?

It would be nice to load the software on a A5-V11 but they only have 4M/32M so that might not be enough.   I currently have a small luci version of openwrt on my A5-V11.

The discussion might have continued from here.