Build your own music server with your Raspberry Pi

A multi-room audio system costs a lot of money. You can also use your existing audio set to stream music anywhere in the house. For this we set up a streaming music server with a Raspberry Pi and the software Mopidy and Snapcast. You connect this server to your audio equipment so that you can simply play Spotify, Google Play Music, SoundCloud or your own music library on your old-fashioned equipment, anywhere in the house.

1 Supplies

For your own multi-room audio system you need a Raspberry Pi (see also the box 'Which Raspberry Pi?') per playback device. One of the Raspberry Pis runs the music server Mopidy, which pulls and plays music from your local storage, your NAS or online music streaming services such as Spotify, Google Play Music or SoundCloud. This Raspberry Pi also runs Snapserver, the server part of the multi-room software Snapcast. All Raspberry Pis run Snapclient, the client part of Snapcast. All Snap clients synchronize their audio with the Snapserver, so that all your playback devices come out with the same sound. Just like a Sonos system, but cheaper!

2 Install Raspbian

Install on any Raspberry Pi Raspbian Stretch Lite. Download the zip file and write it to a micro SD card using Etcher. After that, open the boot partition on the micro sd card through your PC and create an empty file on it named ssh. Safely disconnect the micro SD card, plug it into your Pi, connect a network cable, speaker cable, and finally a power cable, and wait for your Pi to boot. Look in the dhcp leases of your router which IP address your Pi has and log in to it via the program PuTTY, with the username pi and password raspberry.

Which Raspberry Pi?

The Raspberry Pi running Mopidy, Snapserver and Snapclient is under the heaviest load. So you choose at least a Raspberry Pi 2 for that. The other Pis in your multi-room audio system may be less powerful models, after all, they only run Snapclient to pass the audio to the connected speakers. Even a Raspberry Pi Zero W is enough for that. The standard audio output of a Raspberry Pi is not of very good quality, by the way. For high-quality audio, it is best to purchase an expansion board such as the HifiBerry, which comes in various versions. The Raspberry Pi and accessories are for sale in web stores such as Kiwi Electronics and SOS Solutions.

3 Preparing Raspbian

Once you are logged in, open the terminal and run the Raspbian configuration utility with the command sudo raspi-config. Change user's password pi and set Localization Options time zone correctly. below Advanced Options are you going to Expand Filesystem and choose you at Memory Split how many megabytes of ram does the gpu get. Because your Pi is only for audio and doesn't need a screen, you set the minimum value here 16 in. In the advanced settings you can also force the audio output over HDMI or the 3.5mm jack. After all changes go to Finish. Depending on your changes, your Pi will prompt you to reboot. Then choose yes and then log in again.

4 Install Mopidy

On one Pi we now install Mopidy. Check first with the command aplay /usr/share/sounds/alsa/Front_Center.wav if your audio is working: if all is well, you will hear a voice say 'Front Center'. If that works, add the Mopidy developers gpg key with wget -q -O - // | sudo apt-key add -. Then add Mopidy's repository to your repositories: sudo wget -q -O /etc/apt/sources.list.d/mopidy.list // Update your repositories with sudo apt-get update and install Mopidy with sudo apt-get install mopidy.

5 Share music from your nas

First, we'll give your Pi access to music that you share on your Windows network, for example on your NAS. Install the necessary packages with sudo apt-get install smbclient samba-common-bin. Open the mount configuration file with sudo nano /etc/fstab and add the following line to it:

//servername/sharename /var/lib/mopidy/media cifs username=username,password=password,iocharset=utf8 0 0

Enter the correct server name, share name, username and password. Save the file with Ctrl+O and exit nano with Ctrl+X. Mount the share with sudo mount -a.

6 Add music from your nas

Open the Modipy configuration file with sudo nano /etc/mopidy/mopidy.conf and check under the heading [local] the directory /var/lib/mopidy/media is set as media directory. Change the directory if necessary. Then scan the music in your media directory with sudo mopidyctl local scan. Please note: if you have an extensive music collection, this may take a while. If you ever add music files to your media directory later, scan them again and then restart Mopidy with sudo systemctl restart mopidy.

7 Configure MPD Server

In the configuration file you need to add two more lines to access Mopidy over the network. Open the file again with sudo nano /etc/mopidy/mopidy.conf and add the lines [mpd] and hostname = :: come on. Save your changes with Ctrl+O and exit nano with Ctrl+X. Then enable Mopidy with sudo systemctl enable mopidy and start it with sudo systemctl start mopidy. After that, we need an MPD client. For example, install the Android app M.A.L.P. Click on the plus sign at the top, give the profile a name, enter the IP address of your Pi and press the diskette icon at the top right to save the profile.

8 Using MPD Client

After that, you can browse the music from your nas on your Android phone and play the songs on your Pi. To do this, go to . in the app Library for all your music and to playlists for your playlists. You can search by artist, title and so on. The M.A.L.P. has all the basic functions you would expect from a music streaming server remote, including adding tracks to the playlist, shuffling playlists, and so on. Incidentally, Mopidy is compatible with all MPD clients, so your music streaming server can also be controlled with other apps or even with MPD software on your PC.

9 Link Spotify account

What if you don't want to play local music via Mopidy, but music from Spotify? This is possible with a Spotify Premium account. If you created your Spotify account with a Facebook account instead of an email address, you'll need to create an app-specific password for Mopidy. Go to Facebook to do so Settings / Security & Login / App Passwords / Application Passwordsto generate. This now acts as your Spotify user password in Mopidy. In any case, you must also give Mopidy permission to access your Spotify account. Visit this site and click Sign in with Spotify.

Recent Posts

$config[zx-auto] not found$config[zx-overlay] not found