Posts: 82
Joined: Thu Sep 01, 2011 3:40 pm

Web radio distro?

Thu Oct 31, 2013 1:39 pm

I saw the article about Radio Lollipop. It got me to thinking, Is there a small Linux distro for the Raspberry Pi that boots into a program/script that will auto play a stream? Here are my thoughts on how this would work:
  • When the SD card is installed with the distribution a text or XML file is placed into a FAT32 area. That way anyone can edit with having to load up a full shell on the Pi.
  • The setting file lets you put in up to 10 stream locations that are bound to the numeric keys on the keyboard (stream would be the #1, stream 10 would the number zero)
  • The volume key would be 'Q' for volume up and 'A' for volume down
  • The 'S' key would be stop action that acts like power off -OR- resume last stream. If nothing has been played since power on then play stream #1
  • Autoplay would the number of the corresponding stream. If not set or it points to a blank stream do nothing.
  • If some hits a button that corresponds to a stream that isn't set do not stop the current stream, just ignore the key press event.
I've seen more robust radio projects but I'm looking for something simple that can be hooked up and Aurdino for keyboard input and built in a couple of hours. Most radio's don't need a LED display, just power, tuning and volume buttons. I figured a general distribution that anyone can use would be best.

Posts: 4459
Joined: Thu Jan 24, 2013 8:43 am

Re: Web radio distro?

Thu Oct 31, 2013 2:10 pm

to get a mp3 radio stream is easy (have a look on
mpg123 works fine for mp3

No keyboard for me : a IR receiver on a broken box with its remote control.
I use lirc for that.

The RPi can tell me what he is doing
chaine=<what you want to say>
mpg123 $URL"$chaine"

And the RPi can tell me the time : chaine=$(date +%A%-d%B%-kheure%-M)

For audio I built an amplifier (sorry soldering is mandatory) but you can use an external amplifier.

A bash script binds the whole together.

I add a 7 segments display but it's for fun.

The whole is in a Speaker box.

I missed to say I'm WiFi connected to my local network. I use an old RPi (R1 version with 256M)

Posts: 82
Joined: Thu Sep 01, 2011 3:40 pm

Re: Web radio distro?

Thu Oct 31, 2013 3:52 pm

Thanks for the suggestion. I was hoping for a simple solution that can use mostly off-shelf parts. Something anyone could take an SD card format it, open a file in notepad and set it up for what you need, then reboot an test it with a keyboard. The setup of the Aurdino as a keyboard with be a later project.

I figured a general purpose solution would be useful to everyone.

Posts: 4459
Joined: Thu Jan 24, 2013 8:43 am

Re: Web radio distro?

Thu Oct 31, 2013 7:26 pm

I figured a general purpose solution would be useful to everyone.
It was a solution for my pleasure :-)
I join the bash script : feel free to adapt. There is a file specifiing the name/URL og mp3 streaming radios.
An USB keyboard and an external amplifier will do the job. That's a hardware free solution.

Forme the webradio is very useful : on the top of the kitchen cupboard powered all the day long.
(and muted at night) with remote control behind the coffee machine.

Posts: 14
Joined: Mon Jun 04, 2012 11:05 pm

Re: Web radio distro?

Fri Nov 15, 2013 5:03 am

I got one of mine working pretty well for a single-URL web radio.

I just used Raspian, which is pretty much my "reference" for doing anything quick and custom as it has a nice big software repository.

A unique thing I did is that upon boot-up, it checks to see if a HDMI display is connected to it, if there is, then it assumes I want to use the RPI for something else and boots into the default LXDE GUI desktop. If it senses that there is no display it then shuts down the GUI and runs a script that goes something like this:

Code: Select all

while true ; do
  omxplayer -o local http://<insert your web radio url here>
So yes, you can use omxplayer for web streams and it might use the GPU for decoding the audio.

I need to improve this because I have the customized "boot mode" decision happening in /etc/rc.local which happens AFTER all the GUI and other services are started up that I don't need, so therefore it takes a lot longer to boot up than it should. What I should do is create a separate sysV "run level" for it (say run level 3, where 2 is the default GUI mode) that then makes this decision out of "rcS" and avoids loading up all the stuff I don't need, only to shut a lot of it back down.

Oh and I have "espeak" announcing what WiFi network it connected to and its IP address before it enters the above web radio infinite loop.

In my case have one of those tiny USB Wifi adapters often sold as "compatible RPI accessories" from RPI dealers plugged into a model A, then powered by a cheap DC-DC converter that is then slaved off the 12-volt battery that is already in my home-made "boom box" portable amplified stereo speaker system, so the thing is totally wireless and portable within my WiFi range. For most people simply plugging the RPI into a set of amplified "computer speakers" may serve their needs.

When I first got my first RPI (I was in the 2nd batch made, 1st batch of 10,000), the firmware was too young such that the audio out of this thing was terrible. Now it sounds fine to me despite others claiming that it may only have 11-bits of dynamic range.

I've also substituted the above script for one (more messy) script that uses the clever "pi-fm" program to then rebroadcast the stream on an FM-Broadcast channel so I can then just use a normal FM radio to hear it. This works amazingly well too (other than very occasional "glitches" in the audio), but it only broadcasts a mono signal.

Anyway if you need more details on how I did any of this, let me know, maybe I'll have the more efficient "sysV run level" version of it running by then.

Return to “General discussion”