HCP #3 Turn your Raspberry Pi into a broadcasting audio stream

profile picture

HCP #3 Turn your Raspberry Pi into a broadcasting audio stream

What I was attempting to do here, is to use my Pi to access the musics stored on my NAS (Synology), and play the music files, in order to stream the audio flux to an Icecast Server.

Now, you may of course need the Icecast Server, and I personally use an OVH dedicated server where I installed Icecast (which is really easy, just check online).

In the previous HCP tutorial, we already managed to access our files from the Pi. Now we need to play the songs and stream the flux on the web.

It seems to be a pretty common thing to do, but I spent hours to finally get to a working solution.

After being logged into your pi as root, here are the steps :

Install MPD and MPC

MPD is an audio player server. This application will manager all your configurations.

MPC is the client that will interact with MPD. MPC will manage your songs, playlists, and typical commands like 'play', 'stop', 'next', etc.

So quickly run apt-get install mpd mpc

MPD Config File

With your favorite editor, edit /etc/mpd.conf

There are a lot of things here, and you can let the default values for most of them. Just have a look at :

  • music_directory
  • playlist_directory
  • bind_to_address should be "any"
  • Audio Outputs

In Audio Outputs, you already have an example for Icecast. Simply uncomment the lines and set your configuration values, and it should be good :)

Now restart mpd with /etc/init.d/mpd restart

Add songs to playlist

From now on you can basically play with the mpc client and start playing songs, adding them to the playlist, etc.

All available commands are explained here : http://linux.die.net/man/1/mpc

Basically you will do :

  • mpc clear to clear anything in the list and get fresh
  • mpc add your_songs.mp3 this will add a song into the playlist
  • mpc status to check the playlist content
  • mpc play to start playing (now go to your Icecast stream and check it out !)

Note that I didn't find a way to read pre-created .m3u playlist yet. I think that the playlists generated by my Synology does not have the right content formatting and mpc can't read them well...

That's it ! Now if you enable the repeat option, you will have a non-stop playing radio, that will come from your pi !

Enjoy your local music anywhere in the world as a radio :)

2019 My Dynamic Production SPRL All rights Reserved.