Tag Archives: dac

HiFiBerry DAC + Digi on the same Raspberry Pi

A HiFiBerry DAC owner asked us, if it is possible to mount the DAC and the Digi board onto the same Raspberry Pi. Sounds crazy? Cool! We thought about it. With one board running as the I2S master and the other as slave, this could work. Let’s test it:
HiFiBerry DAC and Digi
And yes, it worked!

Note: This does not mean, that you can stack any I2S sound cards on the Raspberry Pi. It works here, because one board acts as the master (the Digi) and the other as slave. Also the configuration is a bit tricky. Only the HiFiBerry Digi is configured as a sound card. Linux doesn’t know, that there is another card connected.

P.S. We’re in the last phase of the HiFiBerry Digi production tests. Everything looks good at the moment.

Hardware vs. Software Volume Control

Some users asked why the HiFiBerry DAC does not support volume control. It is true that the card itself does not come with the volume control widget that can be used by “amixer”. However, most music playback software has its own volume control. How does this work? Basically, the incoming audio samples will be scaled by dividing them by a given value. Dividing by 2 gives an output voltage reduction of 6 dB.

The following picture shows what happens. At the left side is the original, unscaled signal and on the right side a signal that has been reduced by factor 3 (which is roughly a 9db voltage reduction).


With volume control in the playback software, the software will do this scaling and feed the data on the right side to the DAC.

But many people tell me, that is bad! Why is it bad? Because you will lose some resolution. Reducing the volume by 50% means that you will lose 1 bit. The resulting resolution will be only 23 bits now. If you decrease the volume further, you will lose more bits of resolution.

Is it really that bad? Remember, that most music that is available today is still recorded with 44.1kHz and 16bit. That means you can “lose” 8 bit with volume control on the DAC without really loosing anything from your music.

There is another downside of digital volume control: signal-to-noise ratio will decrease. That might be an issue in some areas. But many modern DACs have the noise floor at -110dB or even lower. If this increases to e.g. -90dB it is still a good value.

But some DACs have a “hardware” volume control. Having a mixer control in Linux means, that your software does not have to scale down the samples. The DAC will reduce the output volume. But how does it do this? Just have a look at the datasheets of the chips used on these sound cards. You will notice, that almost all chips with integrated volume control also use digital volume control, that means reduce the volume by dividing the digital data by some number.  This is not better than doing it purely in software.

Summary: Software volume control might have an impact on the audible performance, but with modern 24bit DACs, it often works quite well. Not every “hardware” volume control is really hardware. In many cases, it means that the software scaling is done inside a chip, but works exactly like a software volume control.

Build your Squeezebox client with piCorePlayer

Steen Pedersen has updated his piCorePlayer to support our HiFiBerry DAC. piCorePlayer is a Squeezebox client based on a minimal Linux system. It boots from the SD card, but runs completely in the RAM after booting. It also supports WiFi dongles. We tested it with the small Raspberry Pi Model A, that has only a single USB port and used a small LogiLink USB WiFi adapter – it worked very well.


We can recommend piCorePlayer for all Squeezebox fans!

HiFiBerry DAC support in Raspbmc

logoSam Nazarko has released a new version of the Raspbmc distribution. There are a lot of interesting changes but one is especially exciting to us: It now has ALSA sound card support including a kernel with HiFiBerry DAC support.

We did not have the time to test it yet but we will do this soon! Did somebody test it already?

Are you interested in buying the HiFiBerry DAC – check out our HiFiBerry website. You can order the DAC kit there.

Update 29.12.: It seems that one necessary kernel module for HiFiBerry is still missing in the Rasmbmc december release.  We will check with the Raspbmc developer to see how this can be fixed.


I’ve compile the Linux 3.10 kernel with HiFiBerry support. You can download the tar file from the HiFiBerry website.  The archive includes the updated Raspberry Pi firmware for kernel version 3.10. Therefore it should work even on systems that run Linux 3.8 now. However I cannot guarantee, that it will work on all configurations. Therefore use it on your own risk.

Quality of the Raspberry Pi onboard sound

A long time ago I had a look on the Raspberry Pi onboard sound on the oscilloscope. It looked really terrible. The sound also wasn’t good. That was the beginning of the HiFiBerry DAC development.
But how bad is the onboard sound really? How bad is it compared to our DAC?

Lets have a look on the oscilloscope. We played a 1kHz sine wave on both the onboard output and the HiFiBerry DAC. Check it out:


It is not hard to see, that the onboard sound (left) ist not really a sine wave. Why is it that way? The onboard sound is not using a real DAC, but a simple pulse-width modulation (PWM). While PWM is also used in good Class-D amplifiers (and works well there), the PWM circuit on the Raspberry Pi is trivial and not build for high fidelity sound.

Have a look at the distortions of both circuits:


You clearly see, that there are much more noise and distortions on the onboard sound. The onboard-sound cannot provide high quality sound. However, we’ve seen circuits that were even worse than this one.

You want to use the Raspberry Pi for high-quality audio? Use an external sound card or our HiFiBerry DAC.

Changing the output filter characteristics of the HiFiBerry Mini DAC

hifiberry-filter-jumperThe HiFiBerry Mini has a cool feature: you can switch the characteristics of the output filter by software. The DAC chip generates high output frequencies. These have to be filtered to remove all components above the audio bandwidth. There are two parts of this filtering process: a digital filter on the DAC chip itself and a first-order analog filter. You can see the analog filter between the two RCA connectors on the port.

But let’s have a look on the digital filter. It can run in IIR and in FIR mode. There are a lot of discussion, which is better. The good thing here is: you can listen to both and find out be yourself what you like more.

There is a jumper “Filter” on the board. It can be used like this:

  • no jumper – DAC runs in IIR mode (low latency)
  • jumper left – DAC runs in FIR mode (higher latency)
  • jumper right – filter can be controlled by the Raspberry Pi

But how do you control the filter settings from the Raspberry Pi? You just have to control GPIO27 of the Raspberry.


A nice program to control the state of the GPIO ports is the WiringPi toolset.

sudo gpio export 27 out
sudo gpio readall
| wiringPi | GPIO | Phys | Name   | Mode | Value |
|      0   |  17  |  11  | GPIO 0 | IN   | Low   |
|      1   |  18  |  12  | GPIO 1 | IN   | Low   |
|      2   |  27  |  13  | GPIO 2 | OUT  | Low   |
|      3   |  22  |  15  | GPIO 3 | IN   | Low   |
|      4   |  23  |  16  | GPIO 4 | IN   | Low   |
|      5   |  24  |  18  | GPIO 5 | IN   | Low   |
|      6   |  25  |  22  | GPIO 6 | IN   | Low   |
|      7   |   4  |   7  | GPIO 7 | IN   | Low   |
|      8   |   2  |   3  | SDA    | OUT  | Low   |
|      9   |   3  |   5  | SCL    | ALT0 | High  |
|     10   |   8  |  24  | CE0    | ALT0 | High  |
|     11   |   7  |  26  | CE1    | ALT0 | High  |
|     12   |  10  |  19  | MOSI   | ALT0 | Low   |
|     13   |   9  |  21  | MISO   | ALT0 | Low   |
|     14   |  11  |  23  | SCLK   | ALT0 | Low   |
|     15   |  14  |   8  | TxD    | ALT0 | High  |
|     16   |  15  |  10  | RxD    | ALT0 | High  |
|     17   |  28  |   3  | GPIO 8 | IN   | Low   |
|     18   |  29  |   4  | GPIO 9 | IN   | High  |
|     19   |  30  |   5  | GPIO10 | IN   | Low   |
|     20   |  31  |   6  | GPIO11 | IN   | Low   |

You can now toggle the port using

sudo gpio write 2 1 # low latency IIR filter
sudo gpio write 2 0 # normal latency FIR filter

Shell script

If you don’t want to install additional software, you can also use a shell script:

sudo echo "27"  > /sys/class/gpio/export
sudo echo "out" > /sys/class/gpio/gpio27/direction 
sudo echo "1" > /sys/class/gpio/gpio27/value # low latency IIR filter
sudo echo "0" > /sys/class/gpio/gpio27/value # normal latency FIR filter