TechTalk: Streaming services, file types and HiFiBerry sound cards
Sometimes users ask if one of our boards supports FLAC, Spotify or Bluetooth. The answer is: The HiFiBerry boards doesn’t even know what streaming services or file format you’re playing. There are different layers in music playback and the HiFiBerry sound card is just the hardware. There are more layers on top of this that are responsible for things like streaming services and file formats. Let’s have a look at these layers:
The HiFiBerry DAC, Digi or Amp is a piece of hardware that received a digital audio data stream and converts it either to an analogue (DAC, Amp) or digital (Digi) audio signal. The data stream is basically just a stream of ones and zeros and some data about sample rate (how many samples per seconds are used) and sample format (e.g. 16bit or 24bit).
Operating system driver
To allow applications to use the hardware, there is a driver in Linux that implements the ALSA API. ALSA offers two kinds of interfaces: one to send a continous stream of sound data and a so-called mixer API that’s used to control parameters of the hardware, e.g. the playback volume. On this level, there are no file formats or streaming services.
To implement playback of music from a local file (e.g. a FLAC file), a streaming service or even a Bluetooth interface, a software is needed that implements these features and uses the ALSA API to send data to the HiFiBerry sound card. This software is completely independent from the HiFiBerry sound card. It could be a simple command line tool like sox, a tools with a graphical user interface like Audacity or a distribution like HiFiBerryOS that combines multiple tools. There is a huge number of these applications and distributions available for completely different use cases. The good news: most of these are open-source software. You can not just use it for free, but developers can also adapt these to their own needs. You’re not a developer? No problem, many of these applications are designed for end users and can just be used without the need to dig too deep into the internals. Just try different applications and/or distributions and check out what works best for you. Often users ask us, what’s the best software. There is no “best”. Different users have different preferences. Therefore, we recommend to just try different tools and experiment with them.
If you think now, that’s easy to understand, it can still become a bit more complicated. Some systems integrate some audio middleware that sits between the hardware and the low-level ALSA API and the application software. A tool that’s often used is PulseAudio. While these tools have been created to make some things easier (e.g. to automatically change audio settings if a headphone is being connected), they add complexitiy and sometimes make things more difficult. Most audio-oriented distributions don’t use these tools. However, the full version of Raspberry Pi OS is one of the more popular distributions that comes with it. If you’re distribution is using stuff like this, you should also have a look at the documentation of these.
August 20, 2022