© Liz Clark 2019
Liz ClarkPractical Tinker Boardhttps://doi.org/10.1007/978-1-4842-3826-4_9

9. Project 3: Stream Music to the Tinker Board with Volumio

Liz Clark1 
(1)
Boston, MA, USA
 

Our third project will be the final one that focuses on media consumption and a specialized operating system. We’ll be using Volumio to set up the Tinker Board as an audio streaming device.

But what is Volumio? Volumio is a specialized Linux distribution built on Debian for audio playback for a variety of file formats. It can play files that are stored locally or on a network drive, and even stream them from another device. It’s meant to be used as a headless device, meaning that it shouldn’t have a display or keyboard attached. Instead, Volumio is controlled remotely through a browser interface. It can also be accessed via SSH, which we explored in both the Lakka and Kodi projects.

With Volumio, you can use a variety of different outputs on the Tinker Board for playback. You can use the native outputs of either the headphone jack or HDMI, of course, but you can also use a USB-powered DAC or an I2S-based audio HAT (“Hardware attached on top”) that sits on the GPIO pins. The ability to use I2S is a big reason to use Volumio for your audio. I2S (inter-IC sound) is a serial bus interface that enables PCM audio data to be communicated between integrated circuits. Because of how the sound data is transmitted with separate clock and data feeds, I2S results in high-quality audio.

Support for the Tinker Board

Unlike the last two operating systems that we looked at, Volumio has an official release for the Tinker Board that is fully supported. As a result, we can easily download the ISO for it from Volumio’s web site. We can also check for any updates and peruse the forums for any issues people are having. Additionally, there are supported I2S audio DAC HATs that can be used with the Tinker Board, specifically the HiFiBerry series of I2S DACs and the IQaudIO DAC Plus, which also utilizes I2S.

We’ll be looking at the HiFiBerry+ DAC and the IQaudIO DAC Plus for use with Volumio on the Tinker Board. The HiFiBerry+ has only RCA connectors for audio output, as shown in Figure 9-1.
../images/465130_1_En_9_Chapter/465130_1_En_9_Fig1_HTML.jpg
Figure 9-1

The HiFiBerry+ RCA DAC HAT

Even though it has a spot for a 3.5mm headphone jack to be added to the board, further modification is needed to support the circuit fully.1 The IQaudIO DAC Plus has both RCA and a headphone jack for outputs, which you can see in Figure 9-2.
../images/465130_1_En_9_Chapter/465130_1_En_9_Fig2_HTML.jpg
Figure 9-2

The IQaudIO DAC Plus HAT. Notice that it has both RCA and headphone outputs.

Both HATs have headers that just clear the stock Tinker Board heatsink, so both can be used without modification or stacking headers. Which one you choose will depend on your audio needs and personal preference. You can see a side-by-side comparison of both HATs in Figure 9-3.
../images/465130_1_En_9_Chapter/465130_1_En_9_Fig3_HTML.jpg
Figure 9-3

The HiFiBerry+ RCA DAC HAT and the IQaudIO DAC Plus HAT. The main differences between the two are in the audio output options.

Installing the Volumio Disk Image

As previously stated, there is an official Volumio release for the Tinker Board, which means that we can go directly to the Volumio web site and download the disk image. Navigate to www.volumio.org and click the Download tab at the top of the page. This will bring you to the disk image downloads page, where disk images are available for multiple platforms. Select ASUS Tinker Board from the list and then click the Download icon as shown in Figure 9-4.
../images/465130_1_En_9_Chapter/465130_1_En_9_Fig4_HTML.jpg
Figure 9-4

The Volumio disk image that is available for download for the Tinker Board

After downloading the ISO file, prepare your storage as outlined previously in Chapter 3 and open Etcher to burn the Volumio ISO to your chosen storage device, either an SD card or the eMMC on the Tinker Board S, as shown in Figure 9-5.
../images/465130_1_En_9_Chapter/465130_1_En_9_Fig5_HTML.jpg
Figure 9-5

The Volumio ISO being burned to a storage device with Etcher

First Boot

Before you power up your Tinker Board with Volumio for the first time, it’s incredibly important to first attach all the necessary peripherals. You’ll of course need your power supply, but you will also need to attach your chosen audio playback method and a wired Ethernet connection for Internet connectivity.

During the first boot, the file system for Volumio is resized, and it looks for connected peripherals to the Tinker Board to configure settings. For example, if you attach an HDMI cable during the first boot, but not your audio HAT, Volumio will think that you want to utilize the HDMI output for audio and it will also disable the on-board headphone jack, which will make changing settings using the browser controller a bit difficult.

The wired Internet connection is needed because all control for Volumio takes place via a browser GUI interface. Here you can set up a wireless connection, which we’ll go over shortly, but that wired connection is needed to start. Once all these connections are ready, you can power-on the Tinker Board to begin using Volumio.

Once again, that first boot will take longer than usual to finish because of the file system resizing process that takes place; an event that we’ve experienced with other operating systems as well. Once it finishes booting, you can navigate to volumio.local in a browser on a device that is connected to the same network as the Tinker Board. You should see a GUI control interface for Volumio, as shown in Figure 9-6. If you don’t see it, then either it hasn’t finished booting yet or there’s a problem, such as a disconnected network connection or, more rarely, a corrupt install of Volumio.
../images/465130_1_En_9_Chapter/465130_1_En_9_Fig6_HTML.jpg
Figure 9-6

The landing page for the Volumio browser GUI

Configure Playback and Wi-Fi

From volumio.local, we’re going to finish the setup for Volumio, specifically connecting to Wi-Fi and configuring our playback device. Then we’ll reboot the system before beginning general use. Both the network and playback options are located under Settings, which can be accessed via the cog icon in the top-right corner. After you click it, a dropdown menu as shown in Figure 9-7 will appear with all the various settings available.
../images/465130_1_En_9_Chapter/465130_1_En_9_Fig7_HTML.jpg
Figure 9-7

The Settings menu. Most options can be accessed through this menu.

For Wi-Fi setup, select Network from the Settings dropdown. This will bring you to all the available Network settings. If you scroll to the middle of the page you’ll see a list of available wireless networks, as shown in Figure 9-8. Select your network and then click Connect. You’ll then be prompted for your password and be able to click Connect again. After this, you should be connected to your Wi-Fi network.
../images/465130_1_En_9_Chapter/465130_1_En_9_Fig8_HTML.jpg
Figure 9-8

The available wireless networks under Network settings

Volumio functions well with Wi-Fi, since streaming music does not require as much bandwidth as video streaming. However, if your goal with Volumio is to stream music with a high bit rate and depth, then you may want to consider continuing a wired connection. This will also help to prevent any connectivity issues that can happen with Wi-Fi streaming.

Next, we need to set up our audio output. In the Settings menu, select Playback Options. At the very top of that page you’ll see the Audio Output options. From the first dropdown menu, select the type of device you’re using.

If you are using I2S, you’ll also need to toggle the I2S DAC option to On and then select your DAC HAT from the second dropdown menu, as shown in Figure 9-9.
../images/465130_1_En_9_Chapter/465130_1_En_9_Fig9_HTML.jpg
Figure 9-9

The I2S DAC options under playback

After selecting your options, reboot the Tinker Board via volumio.local by going back to Settings and selecting Shutdown toward the bottom of the list. This will open a pop-up style window with options for Power Off and Restart, as well as an option to Cancel, as shown in Figure 9-10. Select Restart and after about a minute you’ll be able to log in to Volumio via volumio.local again.
../images/465130_1_En_9_Chapter/465130_1_En_9_Fig10_HTML.jpg
Figure 9-10

The power options that are available after selecting Shutdown

Once the reboot has been completed successfully, navigate back to Playback Options to confirm that your audio output settings are correct. After reboot, if you’re using an I2S DAC, your I2S DAC model will appear as the option in the first dropdown, as shown in Figure 9-11.
../images/465130_1_En_9_Chapter/465130_1_En_9_Fig11_HTML.jpg
Figure 9-11

The I2S DAC audio output fully configured after reboot

Navigating the Browser GUI

Now that your basic setup is taken care of, we can take a quick tour of volumio.local to get a feel for the controls and options that Volumio offers. The browser interface is where you’ll be able to control all the basic options for Volumio, including playback and file access options.

The default page for volumio.local is the Playback page, which will show you what audio is currently playing, or after a reboot/shutdown what the last audio played was. You’ll also have options for volume and normal media controls for play, pause, stop, and so on. At the bottom of the page are three tabs: Browse, Playback, and Queue. Playback will bring you back to the main page, and Queue allows you to queue up audio playlists for playback. The Browse tab is where you can access your available audio files, whether they are locally stored, streamed, or even Internet radio, as shown in Figure 9-12.
../images/465130_1_En_9_Chapter/465130_1_En_9_Fig12_HTML.jpg
Figure 9-12

The file options available in the Browse tab

Local and network drive files can be sorted by the entire music library, artists, albums or genres. You can also favorite tracks to create a compilation of tracks that are sorted in Volumio. For local storage, you’ll simply attach a drive via USB, as we did with Kodi and Lakka. For accessing a network drive, though, there’s a little bit more setup involved.

To configure a network drive or Network Attached Storage (NAS), you’ll need to go to Settings and then My Music. As shown in Figure 9-13, this will bring you to a page where you can name your NAS, enter its IP address, and then configure the file path to allow Volumio access to where your audio files are stored. Their files will now show-up under the Browse tab along with the locally stored files.
../images/465130_1_En_9_Chapter/465130_1_En_9_Fig13_HTML.jpg
Figure 9-13

The NAS configuration setup

UPnP and Internet Radio

There are a few more options for playing back audio as well. We discussed a couple of network streaming options in the previous chapter; and much like Kodi, Volumio supports UPnP media server streaming. You can reference the setup steps for Kodi in Chapter 8 to use them with Volumio. Better yet, if you still have your UPnP server set up from the Kodi chapter, it should appear as a Media Server option, as shown in Figure 9-14.
../images/465130_1_En_9_Chapter/465130_1_En_9_Fig14_HTML.jpg
Figure 9-14

A UPnP Media Server available in Volumio. This particular server was set up for Kodi in Chapter 8.

Volumio also has built-in access to Internet Radio stations of multiple genres, as shown in Figure 9-15.
../images/465130_1_En_9_Chapter/465130_1_En_9_Fig15_HTML.jpg
Figure 9-15

Some of the Internet Radio stations available with Volumio

These are accessed through the Web Radio option under Volumio Selection. You simply click on a station to begin streaming. A BBC station can be seen streaming in Figure 9-16.
../images/465130_1_En_9_Chapter/465130_1_En_9_Fig16_HTML.jpg
Figure 9-16

An Internet Radio station streaming with Volumio

Streaming via Airplay

One of the biggest features of Volumio is its ability to receive audio via AirPlay. This means that you can stream audio from your phone, laptop, tablet, or other device to Volumio.

But first, what is AirPlay? It is a proprietary protocol from Apple that allows you to stream between devices. Currently, AirPlay allows more than just audio streaming, but for our purposes we’ll concentrate on audio. AirPlay is a built-in feature on all Apple devices, but it is also available via secondary software for Windows PCs and Android devices. When you send a stream via AirPlay to Volumio, you simply select the Volumio device from the AirPlay menu, as shown in Figure 9-17, and it will begin streaming to the Tinker Board.
../images/465130_1_En_9_Chapter/465130_1_En_9_Fig17_HTML.jpg
Figure 9-17

An example of Volumio being available as an AirPlay device

Issues with AirPlay

One problem that can occur with AirPlay is that sometimes there can be delays or random pauses and glitches with the audio playback. This can be caused by a variety of factors, including Internet bandwidth, device speeds, the size of the file being streamed, and software settings.

Particularly in Volumio, one setting you can adjust is the audio buffer size. A larger buffer will mean that a larger portion of the audio file will be buffered, or loaded, and ready to play, decreasing the chance of an audio file constantly starting and stopping. It does cause a delay in a file beginning to play, but it at least increases the likelihood of a successful overall listening experience.

If, however, after checking all the variables you’re still experiencing issues, we can edit the ALSA audio settings within Volumio to fix the issues once and for all. This also gives us the opportunity to try SSH with Volumio and experience the back-end of the distro.

Connecting to Volumio with SSH

To be able to connect via SSH, we need to first enable SSH. This is done through a secondary browser interface for Volumio, which can be accessed in a browser with volumio.local/dev. This will bring you to a simplified GUI that has a lot of debugging information, as well as an option to enable SSH, as shown in Figure 9-18.
../images/465130_1_En_9_Chapter/465130_1_En_9_Fig18_HTML.jpg
Figure 9-18

The volumio.local/dev browser page. Notice the toggle for SSH.

After enabling SSH, we’re going to use either PuTTY on Windows or the terminal on macOS and Linux to access Volumio, the same way we accessed Lakka with SSH in Chapter 7. To connect, we’ll need the Tinker Board’s IP address, which can be located with volumio.local under Network Settings.

Once you connect with SSH, you’ll be prompted for a login. The default username for Volumio is volumio and the default password is also volumio, as shown in Figure 9-19.
../images/465130_1_En_9_Chapter/465130_1_En_9_Fig19_HTML.jpg
Figure 9-19

The default login via SSH for Volumio

You’ll want to change these if you plan to leave SSH enabled or be sure to disable SSH after you’re finished, for security reasons. We’re going to be editing an AirPlay configuration file2 with the nano text editor to fine-tune the ALSA audio settings to limit the latency that’s causing the AirPlay audio glitches. To do this, while connected via SSH, enter
nano /volumio/app/plugins/music_service/airplay_emulation/shairport-sync.conf.tmpl
Inside the text file, edit the following lines to read as shown:
general =
{
name = "${name}";
interpolation = "soxr";
log_verbosity = 0;
};
alsa =
{
output_device = "hw:1,0";
mixer_device = "hw:1";
mixer_control_name = "Digital";
output_format = "S32";
output_rate=44100;
period_size=4410;
buffer_size=22050;
};
sessioncontrol =
{
run_this_before_play_begins = "/usr/bin/mpc stop";
allow_session_interruption = "yes";
};

After your edits are complete, save the file and then reboot from SSH using reboot to apply the changes. To test, try streaming via AirPlay to Volumio. If the fix was successful, you should notice that any playback glitches have been eliminated.

Finishing Touches

Once you’ve gotten Volumio all set up and have tested out your preferred options for audio playback, you may want to consider a case for your Tinker Board if it will be acting as a dedicated Volumio player. If you’re utilizing a DAC HAT, there are specialized cases available for use with most HATs on the market. If you can’t find one for your DAC HAT, you can also utilize a case that is designed for use with HATs in general, as long as it has access to the top to allow for the audio output connectors.

With a Wi-Fi connection, you’ll only need to connect power to the Tinker Board, meaning that it can operate without any other peripherals attached. As mentioned at the beginning of this chapter, a computer used this way is referred to as headless. Our next two projects will also have the Tinker Board operate as headless. Being able to use the Tinker Board this way makes it very convenient for standalone applications and adds to its versatility for projects. An additional benefit to being headless is that it can be kept discretely near your speakers or inside your media center.

Conclusion

We’ve now gone over three media projects, a genre that the Tinker Board really excels at thanks to its hardware specs, community support and software development. For our final two projects, we’re going to move on and branch out to different types of projects that will bring us back to TinkerOS and integrate some Python programming.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.104.5