📜 ⬆️ ⬇️

Pi-Sonos v2.0 or the evolution of Internet radio on the Raspberry Pi

image As you know, there is no limit to perfection. Even for homemade portable acoustics, whose user audience includes only one person. A very demanding and in some places manically stubborn person. After the release of the first post about Pi-Sonos almost 5 months have passed. During this time, the software inside this acoustics has changed dramatically twice. The reason for the changes were both useful tips habravchan and own UX.

A bit of history for those who are too lazy to read or who have already forgotten the first article.
Pi-Sonos is a self-made compact acoustics, the creation of which was inspired by Sonos Play 1. The task of this acoustics, first of all, was to play music from Internet radio stations. When creating it, I put minimalism and convenience at the forefront: I plugged it into an outlet, and then, at any place at home, control the music from a smartphone / computer / tablet.

What is this article about
First of all, about perseverance and curiosity on the path to the ideal. Under the cut, username , there will be neither the solution of a global problem, nor a description of a new unique technology. The article just presents a comparison of popular media centers for the Raspberry Pi, reveals their advantages and disadvantages, as well as my personal vision of the optimal framework for an Internet radio. In fact, while working through my own software for the column, I only partially repeated the path of the creators of Volumio, simply implementing from zero only one of its functions (read: “invented the next bicycle”).
Despite the fact that the article covers the topic of software development, there is no code in it, because the purpose of the article is to describe the idea and functionality, and not the process of its implementation. If the topic of the code will be interesting to habravchanam, I will try to master a separate article describing the development process.

Initially, the soft-stuffed acoustics was OSMC , but wise people in the comments noticed that Kodi (aka OSMC) is too fat as “brains” for an Internet radio station. Too smart and big, only Volumio is better suited for audio projects. Actually, everything turned out well. Volumio is lighter, sharpened by a web interface and has a more advanced and easy-to-use API. There is also no need for an HDMI cable sticking out of the back, since Volumio is fully customizable in any browser.

However, Volumio also discovered a couple of important flaws that prompted me to further research. This is, firstly, the download time, and secondly, the lack of autoplay. After studying the official documentation (from which it can be understood that Volumio is an add-on for mpd (Music Player Daemon)), I decided that it was time to write my own wrapper called RPi-Radio on js that would solve these problems. The server part of it works on Node.js, and the client part (GUI) that uses React.js has been ready since the days of using OSMC, it only needed to be tweaked a bit. So it looks on the screen of the smartphone at the moment:


Below is a table that clearly shows the advantages and disadvantages of each of the frameworks.
CriterionOSMCVolumioRPi-Radio
Load time35 sec45 seconds20 sec
Autoplay on launchnot*not*Yes
Number of tapes from the home screen of the “native” GUI on the smartphone to select a radio station from the Favorite list **5 + 1 scrollfourone
The need for a monitor, keyboard and mouse ***Yesnotnot
Web managementpartialfullpartial
Edit station listso-sothe normso-so
Easy initial setupso-sofinemediocre
Integration with my GUI to control from a smartphonewith crutcheswith crutchesfrom the box
Ease of daily use☆☆☆☆☆
* in fact, yes, but you need to make a crutch and slip its autoloading Raspbian; in the case of OSMC, the crutch is written in python, and in the case of Volumio, it is written in js or bash. But in both cases, it still does not work as desired.
** for OSMC and Volumio, these are very important parameters, because all these tapas-scrolls must be made each time the column is turned on. For RPi-Radio, this parameter, although minimal, is still not so important, since the column starts playing itself when turned on.
*** meaning the physical connection of the monitor, keyboard and mouse to the Raspberry Pi itself, i.e. those cases where there is no way to get by with the built-in web interface or ssh connection.

Under this spoiler a detailed explanation of each comparison item is hidden.
A boot time of 20 seconds is, in my opinion, the minimum that can be achieved without plunging into the wilds of optimizing Raspbian for this project. This is exactly the time it takes for the Malinka to load the OS and start the mpd service. Probably, this result can be improved by replacing microSDHC with microSDXC with a faster read / write speed (I’ll check if possible). Surprisingly, Volumio, pretending to be easy and nimble, loads longer than the monster-combine OSMC. 45 seconds of waiting are beyond the threshold of comfortable operation, and this was the main reason for leaving Volumio.

Autoplay is present in mpd out of the box, I did not have to do anything to activate it - convenient! In Volumio, although it is a mpd wrapper, this function has been stifled for the sake of a beautiful greeting sound. As I already wrote, you can make a script and put it into autoload. The situation is similar with OSMC.

At OSMC, most of the user interaction occurs through the monitor: there is a beautiful interface, the ability to watch videos, pictures, read news and watch the weather - a lot of things that my column will never do in my life.

But OSMC's web management is very limited, and you cannot even remotely set up a list of favorite stations in the Radio plugin - only through the monitor. In Volumio, on the contrary, everything is only through a web interface. It is most convenient to edit the station list in the browser on the desktop / laptop, but you can also on the smartphone if you wish. With RPi-Radio via the web interface, you can only select a station and adjust the sound. The list of stations, and indeed everything else should be done through the console via ssh. The list of stations is the most difficult: if OSMC and Volumio have their own extensive libraries of Internet radio stations, then at RPi-Radio I had to manually fill in the addresses of my favorite stations in JSON format. It is inconvenient, but only one (or several) times in a life.

With the initial setup, the OSMC is the worst. First you need to connect a monitor to the “raspberry” and configure the Radio plugin, then you also need to configure the audio output to the external IQAudio DAC via the console or via ssh (the one on the Suptronics X400 board). At RPi-Radio, the DAC setup is the same, but at least everything else is done by ssh too. The leader in this category, of course, is Volumio - to output sound through an external DAC, simply select the appropriate item from the drop-down list in the settings menu. There is a comparison even on the official website of Suptronics (http://www.suptronics.com/xseries/x400.html)

The RPI-Radio GUI is a simple webpage implemented on React.js. The server part, which is responsible for the interaction between the client GUI and mpd, runs on Node.js and is a simple HTTP- and WebSocket-server based on the Socket.io + http + express bundle. It runs on Raspbian as a service when the system is turned on immediately after starting the mpd service and uses the mpc-js module to control mpd. The client GUI is available to any browser in my home network simply by ip or the hostname of the “raspberry”. Perfect.

RPi-Radio sources are published on Github . In the same repository, in the corresponding branches, you can find both GUI adaptations for working with OSMC and Volumio.

The result of my Exercises, RPi-Radio, goes beyond a simple addition to a single column that exists in a single copy. This is a kind of ready-made solution that turns into an Internet radio not only the Raspberry Pi, but also any device with audio output, Internet access and the ability to run mpd and Node.js. The main advantage of such a system is the absence of everything superfluous. Actually, as it is done in Sonos, in the ideal that I strive to achieve.

Source: https://habr.com/ru/post/410227/