Raspberry pi/CHIP Adventures pt1: HiFi Music streamer
My home theater setup always lacked a high quality source. Unlike the newer AV receivers from even the cheapest brands, my 15 year old Onkyo tx-ds696 delivers amazing sound and lacks majority of the modern features, such as Spotify, Pandora, or many network connected sources. I tried using the Xbox to stream music from my personal library of FLAC’s. Microsoft’s media player app had a sluggish interface, and required booting up the Android TV every time I wanted to browse for songs. Speaking of browsing, the Xbox seems to be incapable of browsing for music and playing a track at the same time.
For this project, I had a couple of requirements:
- stream music without turning on the TV
- Be able to browse music
- Hi-Fi Streaming, supporting FLAC, WAV, etc.
- Accepting streams from a phone (DLNA, Bluetooth etc.) would be a plus
I was browsing the web for a solution, when I came across this lovely platform:
The Media Player Daemon (mpd) protocol is cross platform, open source, and kept up to date. I had a small raspberry pi (rpi) like computer, called the C.H.I.P, collecting dust in a drawer.
Hooking up the hardware
I hooked the chip up to the TV via a 3.5mm to a ketchup/mustard cable, like the docs mentioned here. It booted up into a fairly modded copy of Debian Jessie. Like the rpi, they do provide a couple different builds, for different purposes. For possibility of faster booting up, one may wish to flash the “headless” build. The steps I took used the default “desktop” build.
The chip has a weak 5v voltage regulator. What this means is that it has trouble powering anything more than a keyboard on the usb port. To solve this, I used a powered usb hub to prevent overworking the chip. For my purposes, I would end up only needing a usb sound card connected to the port, so a hub is not necessary. This is what it ended up looking like:
I did not want the chip to be on forever, that will kill the board in no time. I connected the chip to the back of the AV receiver, there are two ac outlets there that turn on when the receiver turns on. To make sure the CHIP turns on when power is connected, put a jumper from pin PWRON to GND. This will send a signal that the power button is press. I tested holding it during power on and operation is no issue. Here is a reference to the pins.

Installing MPD
Before starting anything, connect to the network.
As with before installing any software on Linux, it is best practice to run the following command to get the latest software updates.
sudo apt-get update
The password should be “chip” without the quotes. For rpi, the password should be “pi” without the quotes. Then I need to install the mpd software. The following command should take care of that.
sudo apt-get install mpd
type “y” when it asks for a confirmation.
Mapping a network drive
Stock linux has trouble mapping network drives on bootup. I used cifs-utils to take care of this problem. To do this, install cifs-utils:
sudo apt-get install cifs-utils
After it installs, type in the following to edit the cifs configuration:
sudo nano /etc/nsswitch.conf
This will bring up something like a text editor. Change the line
hosts: files mdns4_minimal [NOTFOUND=return] dns
into
hosts: files mdns4_minimal [NOTFOUND=return] wins dns
Exit with Ctrl X and make sure to save.
To be able to see smb shares and windows hostnames, install winbind:
sudo apt-get install libnss-winbind winbind
restart the rpi/chip.
Create a location to mount the network drive. I put mine in /network/nas. Use the mkdir command to create a directory:
sudo mdkdir /network/nas
Make sure to create the subfolder, in my case “nas”, as well as it will dump the contents of the folder into the created directory. I also wanted to add my computer in as a source, so I created another directory:
sudio mkdir /network/quadcore
Right now, the linux looks like this:
/network
> /nas
> /quadcore
Create a file to store the username and password for the shares. In my case, I made two files, as there are two sources:
sudo nano ~/.quadcore_cred
sudo nano ~/.nas_cred
In each file, I put in the following, replacing the red:
username=SMB_USERNAME
password=SMB_PASSWORD
the ~/ means it places it in the home directory, /home/username. This is like the /users/yourusername folder in windows.
To mount the shares, I edited the fstab configuration:
sudo nano /etc/fstab
Add the following line below, replacing the red:
//SMB_IP_HERE/SMB_SHARE_HERE /MOUNT_FOLDER_PATH_HERE cifs credentials=/home/chip/.nas_cred,iocharset=utf8,gid=1000,uid=1000,file_mode=0777,dir_mode=0777 0 0
To get the gid and the uid, run the following command:
id chip
run the following to mount the drives:
sudo mount –a
restart the chip, make sure all files in the smb share are in the mounted directory. If the smb connection comes online after the chip has been booted, the chip will have to be rebooted – the mount initiates on boot.
Configuring MPD
There is a file called /etc/mpd.conf. This file takes care of all the configurations for mpd.
run the following command to edit it:
sudo nano /etc/mpd.conf
All the hashes ( # ) are linux’s way of commenting. Take off the hash in front of the line to make it active. Change the line “music directory” and point it to where the mounted network drive is configured. Because I haven’t figured out how to point it to multiple directories, I pointed to /network, then it will show both “nas” and “quadcore”.
Assign a static IP to the chip in the router settings. I will not go into detail on how to do this, there are lots of online tutorials. Change the line “bind_to_address” to that assigned address.
The DAC in the rpi and chip are both shit. I connected an external soundcard with digital output to use my AV receiver's dac instead. Because I am connecting an external audio card, I will also have to change the line “audio output {“. For my specific scenario, I entered in “aplay –l” into another terminal to find the name of the card. My audio output in the config looked like:
aplay –l:
**** List of PLAYBACK Hardware Devices ****
card 0: sun4icodec [sun4i-codec], device 0: CDC PCM Codec-0 []
Subdevices: 0/1
Subdevice #0: subdevice #0
card 1: DAC [USB Audio DAC], device 0: USB Audio [USB Audio]
Subdevices: 0/1
Subdevice #0: subdevice #0
mpd audio config:
audio_output {
type "alsa"
name "My ALSA Device"
device “hw:1,0”
}
The hw:1,0 with 1 being card 1, and I believe the 0 means main.
Press ctrl x to close, save. Reboot the chip.
Now to control the chip, get a mpd controller app. My favorite one is M.A.L.P. I’m not sure what’s available for IOS, there is MPDeluxe. The rating is quite low, but as we all know, they’re apple users.
In malp, press the three dashes in the upper left hand corner, click profiles, then the plus icon in the upper right hand corner. Enter a preferred name, then the IP of the chip, as set earlier. leave everything else unchanged. Go into the three dashes again, profile, then “update server database”. This take a few seconds or a while depending on how big the music library is.
And that’s it. Get familiar with the mpd app, as at least for me, this has made me listen to music in the living room a lot more.
I also made the chip capable of accepting a DLNA stream. But that’s for the next post.
Comments
Post a Comment