Sunday, September 29, 2019

Raspberry Pi 4 as a HiFi Music Server

I've bought Raspberry Pi 4 to use it as a DaaS (Desktop as a Service). I've needed a VPN server to securely connect to when I am traveling. I've needed a Cloud Server to replace Dropbox to have unlimited space. I've needed a NAS (Network-attached storage) to share files among mu laptops and computers. I've also needed a Music Player Server to manage my music files and serve as a source for my amplifier. I've also needed a media player like Apple TV to play my movies, youtube etc.

In summary Raspberry Pi as:
1. Cloud server
2. VPN server
3. NAS
4. Music server (this post)
5. Media Player




To be able to do all of the above, I think it is better to keep the original Raspbian distribution. I have not used Volumio because I have needed a full OS for doing other stuff. But if you only care about the music quality Volumio is great and it is very light weight operating system for Raspberry Pi.

I have bought Allo DigiOne HaT from here.



Why such boards are needed for enhancing the sound quality for feeding into the amplifier or DAC? When you want to transfer a digital file and you don't care about the timing, it is a fairly easy task and since sound files are all zeros and ones it's going to be transferred perfectly. However, when you want to play this file on your stereo system everything should happen in real-time. Every ones and zeros should be perfectly send in the perfect intervals. In this "real-time" situations everything matters even for a digital signal which consists of zeros and ones, from quality of wire, board connections etc. Even the noise produced by cpu can interfere with transferring signals. That is why it is claimed that RP 3 has a better sound quality compare to RP 4 using same ALLO Transport board and external linear power supply (source).

You only need to mount this HaT onto you RP and add the following to boot setting:
sudo emacs /boot/config.txt

dtoverlay=allo-digione

reboot your RP.

From Menu in Raspbian open Preferences>>Audio Device Settings

Make sure that snd_allo_digione (Alsa mixer) is selected.

Click on Select Controls and check Tx Source

Select AIF for Tx Source and click on  Make Default

Until now you configured DigiOne sound hardware.

Since I have not used Volumio I had to install MPD from scratch. 

The typical setup for a home network:
A UPnP Media Server (e.g. MinimServer, Minidlna, Mediatomb, or some commercial product),
A UPnP Control Point (e.g. Bubble UPnP running on a tablet or phone, Linn Kazoo on a PC/MAC, or upplay for Linux or Windows).
upmpdcli and MPD running on some Linux device (e.g. a Raspberry Pi hooked up to your bedroom stereo).



upmpdcli




















But I have only installed MPD:
sudo emacs /etc/mpd.conf

Change the directory MPD looks for music and
set MPD config as follows:
audio_output {
        type            "alsa"
        name            "Allo DigiOne"
        # device        "hw:0,0"                                                                                                                              
        device          "hw:sndallodigione"
#       device          "hw:0,0"        # optional                                                                                                            
#       mixer_type      "hardware"      # optional                                                                                                            
#       mixer_device    "default"       # optional                                                                                                            
#       mixer_control   "PCM"           # optional                                                                                                            
#       mixer_index     "0"             # optional                                                                                                            

}

and comment the following line:
# user                          "mpd"  


sudo systemctl enable mpd
sudo systemctl start mpd

sudo systemctl restart mpd 

For remotely controlling MPD I have used this project: