sudo-mount-ntfs

Streaming Media with JustBoom Audio HATs


JustBoom Audio Cards

We’ve recently taken delivery of some excellent new digital audio HATs and accessories for the Raspberry Pi from JustBoom. So, when I was challenged to make use of some of these items to come up with a media streaming solution for our office, I was more than happy to take up the challenge.

The JustBoom range of digital audio cards include the following HATs which are all compatible with Raspberry Pi A+, B+, 2B and 3B:-

  • DAC Audio HAT – HAT with 2 RCA audio outputs for connection to stereo audio amplifier
  • Digital Audio HAT – HAT with S/PDIF output over TOSLink (Optical) and RCA for connection to digital audio amplifier
  • Audio Amplifier HAT – HAT with built in class D amplifier for connection to 2 x 55W speakers

Additionally, there are similar HATs which are designed specifically to work with the Pi Zero. The JustBoom range of audio cards also include a dedicated amplifier module which can sit directly on top of the DAC Audio HAT, and also a standalone digital audio converter module.

As well as the HATs and audio cards, there are also a range of enclosures for various combinations of the cards and HATs.

Raspberry Pi Media Server

The first stage of the overall solution was to set up a media server. This is fairly straightforward with the Raspberry Pi, and there are a number of different options for doing this, as described in the article ‘3 Ways to Set Up Your Raspberry Pi as a Media Server’. From the options described in this article, I opted for the ReadyMedia (MiniDLNA) server option, as it would provide good compatibility for a variety of streaming clients; including the Raspberry Pi based clients that we would be using as part of our media streaming solution.

The set up for the ReadyMedia (miniDLNA) Pi Media server is exactly as described in the article. The server software is installed over a standard Raspbian install; for example NOOBs. If you’re not sure about how to do this, check out our Getting started with NOOBS on the Raspberry Pi guide.

However, before installing and setting up the miniDLNA server, I wanted to set up a USB drive which would be the source of the media (music and videos) that I wanted to be able to serve from our media server.

Setting Up a USB Hard Drive

Setting up the USB hard drive is a fairly simple process. The first step is to simply connect the USB hard drive into one of the USB ports on the Raspberry Pi. Once connected, the hard drive should show up as a device when you issue the command:-

sudo blkid

sudo-blkid

Our device showed up as being /dev/sda1, and I wanted to mount this to a specific folder; in this case /media/mediadrive. Also, I wanted to mount our media drive as NTFS, so i first installed ntfs-3g file support using the following commands:-

sudo apt update
sudo apt install ntfs-3g

I next created a folder using the mkdir command, and then set the necessary permissions for the folder using the sudo chmod command. Finally, I attempted to mount the hard drive to the folder by using the mount command:-

sudo mkdir /media/mediadrive
sudo chmod 775 /media/mediadrive
sudo mount -t ntfs-3g /dev/sda1 /media/mediadrive

The last of these 3 commands (the mount command) failed because the hard drive was already mounted; as shown in the image below:-

sudo-mount-ntfs

This is because the file manager application will automatically mount USB drives when they are connected to the Raspberry Pi. In order to mount the USB drive to a specific folder however, I needed to be able to manually mount the USB drive to a specific mount point. To prevent the file manager application from automatically mounting the USB drive, it is necessary to unset the relevant auto-mount options in the file manager application, as shown in the image below:-

pcmanfm

After changing these auto-mount options it is necessary to reboot the Pi using the command:-

sudo reboot

Following reboot the USB drive should not be automatically mounted, so issuing the mount command should result in the USB drive being successfully mounted to the required mount point:-

sudo mount -t ntfs-3g /dev/sda1 /media/mediadrive

In order for the drive to be automatically mounted to this mount point after a reboot, however, it is now necessary to edit the file /etc/fstab, and add the required configuration line to cause the drive to be mounted. The file may be edited using the command:-

sudo nano /etc/fstab

In this file, it is then necessary to add the configuration line:-

/dev/sda1 /media/mediadrive ntfs-3g defaults 0 0

sudo-nano-fstab

Pressing control-o will save the changes to the file, and pressing control-x will exit the nano editor.

Now is a good time to reboot the Pi again to check that the USB drive is correctly mounted to the required mount point. Reboot the Pi by issuing the command:-

sudo reboot

On restart, issue the command:-

ls /media/mediadrive

This should hopefully give a list of the folders and files on the USB drive:-

sudo-ls

Setting a Static IP Address

In order that our media clients can reliably locate our media server, it is also necessary to ensure that our media server retains a static IP address. Depending on your router, it may be possible to do this by means of an IP address reservation on the router; whereby the IP address is assigned to the MAC address of your Raspberry Pi. However, not all routers will support this, so it may be necessary to configure the Pi to have a static IP address. This IP address should be outside the range of the router’s DHCP addresses. Our router’s DHCP Server has an address range of 192.168.2.100 to 192.168.2.200, so I have set our Pi media server to have an IP address of 192.168.2.201 for the wired network, and 192.168.2.202 for the wireless network. To force the Pi to have a static IP address, I edited the file /etc/dhcpcd.conf, as shown below:-

sudo nano /etc/dhcpcd.conf

sudo-nano-dhcpcd

In this file, the lines:-

interface eth0
static ip_address=192.168.2.201/24
static routers=192.168.2.1
static domain_name_servers=192.168.2.1
interface wlan0
static ip_address=192.168.2.202/24
static routers=192.168.2.1
static domain_name_servers=192.168.2.1

need to be added to the file, (note that 192.168.2.1 is the IP address of our router).

Having changed this file, reboot the Pi again to ensure that it picks up its static IP address.

Installing miniDLNA

So, assuming that you have your Raspberry Pi all set up with a USB hard drive containing your media and a static IP address, you can now move on to installing miniDLNA. This involves running the following commands in a command window:-

sudo apt update
sudo apt upgrade
sudo apt install minidlna

Once installed, miniDLNA must be configured to define the name of the media server, and also the folders which will contain the media that is to be served. In order to configure these things, it is necessary to edit the configuration file /etc/minidlna.conf. This is done by entering the following command in the command window:-

sudo nano /etc/minidlna.conf

Within this configuration file, there are a couple of parameters that need to be modified. These parameters are:-

  • friendly_name
  • media_dir

The friendly_name parameter can be set to whatever you wish to use as the name for your media server; I chose the name ‘Pi Media Server’ for ours.

The media_dir parameter can be duplicated and repeated any number of times, within the configuration file, to define a list of folders which will contain the media that we wish to serve from our media server. Prefixing a parameter with a ‘A’, ‘V’, or ‘P’ allows us to restrict the media from a particular folder to either ‘Audio’, ‘Video’, or ‘Pictures’. The image below shows our settings as an example:-

sudo-nano-minidlna

Having made the necessary changes to the configuration file, pressing control-o saves the changes to the file, and control-x will exit the nano editor.

However, in order for miniDLNA to pick up the changes to the configuration file, it will be necessary to restart the miniDLNA service and then get it to re-index it’s database using the following commands:-

sudo service minidlna restart
sudo service minidlna force-reload

That’s it; our miniDLNA media server is complete.

miniDLNA Media Server

MiniDLNA Media Server

Raspberry Pi Media Client

Having successfully set up our media server, the next step is to construct the media client. In our case, the media client is a Raspberry Pi 3 running Kodi, and using a JustBoom DAC HAT for our audio output. The main items required are:-

There are some excellent guides with instructions on how to install the JustBoom products on the Raspberry Pi at the JustBoom web site.

You’ll also require a micro SD card, and a means of copying the necessary software image onto the card.

We actually tried a number of different Kodi installs, with varying degrees of success.

NOOBS OSMC

The latest version of NOOBS can be obtained from the Raspberry Pi foundation’s Web site.

Our first attempt to get Kodi running with our JustBoom audio cards was with NOOBS OSMC. Unfortunately, we were unable to get Kodi to recognise the JustBoom audio card.

At present we’re hoping that a future release of NOOBS may fix this issue.

OSMC

The latest version of OSMC can be downloaded from the OSMC Web site.

Having failed to get Kodi to recognise our JustBoom audio card using NOOBS OSMC, we next tried a straight OSMC install. Although, this did prove to be a little problematic we did eventually get it working successfully.

The steps that we needed to go through in order to get OSMC to work with the JustBoom DAC HAT are as follows:-

  • Copy OSMC image to micro SD card
  • Boot OSMC and complete initial OSMC setup – This includes making sure that Kodi is connected to the network, and that all the latest updates are applied
  • Modify the config.txt file to add the following lines of configuration
dtparam=audio=off
dtoverlay=justboom-dac

The easiest way to modify the config.txt file is to use SSH to connect to the Raspberry Pi that is running Kodi. The default username and password for logging in to Kodi are:-

username - osmc
password - osmc

Once logged in to the Pi using SSH, enter the following command to edit the config.txt file:-

sudo nano /boot/config.txt

Modify the config.txt file to add the required configuration, as described above and as shown in the image below:-

config

Save the changes, and issue a reboot. After Kodi has rebooted, it should be possible to select the JustBoom DAC as the audio output device. In order to do this, select System > Settings from the Kodi menu, then select System > Audio output:-

Audio Output Settings

From here, click on Audio output device, and you should be presented with a list of audio output devices:-

Audio Output Devices

To output to the JustBoom DAC HAT, select the snd_rpi_justboom_dac device.

LibreELEC

The latest version of LibreELEC can be downloaded from the LibreELEC web site.

As with OSMC, the steps to get up and running with LibreELEC are:-

  • Copy LibreELEC image to micro SD card
  • Boot LibreELEC and complete initial LibreELEC setup – This includes making sure that Kodi is connected to the network, and that all the latest updates are applied

Once booted and updated, select System > Settings from the Kodi menu, then select System > Audio output:-

Audio Output

From this screen, click on Audio output device, and you should be presented with a list of available audio output devices:-

Audio Output Devices

To output to the JustBoom DAC HAT, simply select the snd_rpi_justboom_dac device.

OpenELEC

The latest version of OpenELEC can be downloaded from the OpenELEC web site.

Despite spending some time trying to get OpenELEC working with the JustBoom DAC HAT, we were unable to get OpenELEC to recognise the DAC HAT audio device.

Again, we’re hoping that this issue will be fixed in a future release of OpenELEC.

Volumio

The latest version of Volumio can be downloaded from the Volumio web site.

The Volumio install and set up was fairly simple, and no additional configuration was required in order for Volumio to recognise the JustBoom DAC HAT audio device.

To get Volumio to output audio through the JustBoom DAC HAT, select “Playback Options” from the Volumio settings menu, and then select the JustBoom audio device as the output device:-

volumio-playback-options

Unfortunately, Volumio does not appear to support DLNA rendering, so in order for Volumio to read our media library, it was necessary to modify our media server to allow it to act as a NAS drive in addition to being a DLNA server. In order to do this, we installed Samba on our media server using the following command:-

sudo apt update
sudo apt install samba samba-common-bin

Having installed Samba, a small amount of configuration was needed in order to share the media drive. This was done by editing the configuration file /etc/samba/smb.conf:-

sudo nano /etc/samba/smb.conf

In the Samba configuration file, the following section of configuration was added to share only the ‘My Documents/Music’ folder of our media drive as a share called ‘Media’:-

[Media]
comment = Media Folder
path = "/media/mediadrive/My Documents/Music"
valid users = @users
force group = users
create mask = 0660
directory mask = 0771
read only = yes

After modifying the configuration file, the Samba service was restarted using the command:-

sudo /etc/init.d/samba restart

Having restarted Samba, the next step was to add a ‘media’ user account in order that the media drive could be accessed over the network. This was done using the following commands, and entering the password to be given to the account when prompted:-

sudo useradd media -m -G users
sudo passwd media

Finally, the ‘media’ user also needed to be added as a Samba user, using the following command, and again entering the password to be given to the account when prompted:-

sudo smbpasswd -a media

Once the NAS drive was setup on the Pi media server, Volumio needed to be configured to connect to the network drive:-

volumio-add-network-drive

Once this network drive had been added, Volumio started to scan the drive for media:-

volumio-my-music

Moode Audio

The latest version of Moode Audio can be downloaded from the Moode Audio web site.

The installation of Moode Audio is fairly straightforward, and basically involves formatting an SD card and writing the Moode Audio image to the SD card.

Having written the Moode Audio image to the SD card, the card needs to be inserted into the Raspberry Pi, and the Pi booted. Initially, a wired network connection is required.

Once booted, it will be necessary to determine the IP address of the Moode Audio Pi, and use a browser to open the IP address. In order to find the IP address of the Moode Audio Pi, it may be necessary to make reference to the DHCP table of your Router, or possibly use a network monitor tool such as Fing or Ping Tools.

Browsing to the IP address will give a screen like that below:-

moode-audio

From this screen, select ‘Configure’ from the menu, and then select ‘Network’ in order to configure the network options for Moode Audio.

We wanted to connect Moode Audio to our wireless network, but wanted a fixed (Static) IP address, so configured Moode Audio using the parameters shown in the image below:-

moode-audio-network

Having saved the configuration, it was necessary to reboot the Mood Audio Pi. Once rebooted, the Moode Audio Pi can be referenced using the new IP address assigned to the wireless connection; in our case 192.168.2.203.

Browsing back to the Moode Audio web page, the next step is to configure the Audio Output. The settings for this are shown in the image below:-

moode-audio-audio

After changing the Audio configuration it was necessary to reboot the Moode Audio Pi again, and after the reboot, you’re all set to go.

moode-audio-radio

As well as Internet Radio, it’s also possible to connect to a NAS drive:-

moode-audio-sources

moode-audio-library

UPnP Rendering

An alternative to connecting Moode Audio to a NAS drive to access media content, is to switch on the UPnP Rendering option within Moode Audio, and to then use a separate UPnP client (for example BubbleUPnP) to stream your media to Moode Audio. To switch on UPnP Rendering, select ‘Configure’ from the Moode Audio menu, and select ‘Audio’ from the configuration menu. From the Audio Configuration settings, set UPnP Renderer to ‘On’:-

moode-audio-upnp-rendering

Having done this, Moode UPnP should be visible as a UPnP Renderer in your DLNA client:-

DLNA Client