It is no secret that the sound quality of the onboard sound of the Raspberry Pi is not really good. Last week the Raspberry Pi foundation announced a new model B+ that is improved in some details. One aspect that was pointed out was the sound quality. It should be better with the new model. I was curious, therefore I ordered some new model B+ Raspberry Pis.
What changed on the audio section? According to the Raspberry Pi foundation, there is an additional voltage regulator for the audio output and an additional output driver to drive low-resistance loads like headphones. However it is still using pulse-width modulation (PWM), which has a major impact on sound quality. The output voltage is still very low. I’ve measured less than 0.4Vrms. But let’s see how other performance parameters changed.
The test setup is as follows: The Raspberry Pi is connected to the network with a UTP cable. This reduces noise coupled in from the Ethernet port. Total harmonic distortions + noise (THD+N) is measured by a special HP8903B audio analyzer. This specialized instrument is able to measure THD+N down to 0.002% and allows also to measure the output voltage to test the linearity of the output. The input impedance of the audio analyzer is 100kOhm. The Raspberry Pi is powered by an external linear power supply.
For THD+N measurements the measurement bandwidth is 30kHz, for the frequency response we used 80kHz bandwidth to make sure that the instrument’s filter does not impact the audible frequency range.
On the Raspberry Pi, the volume was set to the maximum volume that works without clipping:
amixer sset "PCM" 95%
Test tones were created using SoX. Note that I’m not sure if SoX itself creates optimal sine waves. Therefore a minor part of the distortions might also com from the sine generator. However they will be are in the range < 0.1%. Also, you should not compare the absolute figures here to other measurements. While the HP8903B audio analyzer is a very good instrument, lots of factors influence the result. At THD+N levels < 0.1%, slight changes in the measurement setup can have huge impact on the results.
The following diagram shows the sum of the total harmonic distortions and noise (THD+N) of the old and the new Raspberry Pi. The lower the values the better the system performs.
What happened here? The new Raspberry Pi performs even worse than the old Model B on frequencies below 1kHz. As the distortions are driven by the frequency is seems that there is much more noise at lower frequencies. Didn’t they say the audio performance was improved by an additional voltage regulator? Yes, but the old Raspberry Pi used a linear voltage regulator to provide the 3.3V to many of the components on the board while the new one uses a switching regulator. Both can perform reasonably well. However switch mode power supplies often show higher noise figures. I will have a look into this in a later article soon.
Why aren’t there data for frequencies above 15kHz? The PWM of the Raspberry Pi is not able to create a signal that is at least similar to a sine wave at these frequencies. Therefore the audio analyzer was not able to determine the base frequency and therefore could not do any measurements. Have a look how a 20kHz sine wave looks on the Raspberry Pi output:
Conclusion: Don’t buy the new Raspberry Pi just to get better onboard sound. You won’t get it. However, there are use cases were the new one is better, e.g. if you need 4 USB ports or low power consumption is important. For high-quality sound you still need an additional DAC like the HiFiBerry DAC+.
Hi Daniel,
thank you for the helpful measurement.
If I see the results, esp. 1% THD – I would think you can hear quite well. No need to measure, 1% would be audible (should sound like a power amp running at the limit).
Why an SPS should contribute low frequency noise is not clear for me. Actually, the high frequency noise should be filtered or would not be audible. A linear LDO can contribute much more noise from power rails for my feeling.
And if I see the 20KHz waveform – my impression: a Nyquist criteria violation. I cannot imagine that such a waveform can come out, except you overrun the PWM or wrong load impedance. The 20KHz might be above the PWM operation range, e.g. driver (timing) configured for 16 KHz as max. Feeding then with 20KHz can create such a “oversampled” waveform.
Or: the SPS does not have a low pass filter, cannot drive low impedance load, the switching noise goes directly to the PWM switch supply. Hard to believe that schematics have a bug or audio performance never measured on B+ model.
Or: a probe used with very low impedance (e.g. 50Ohm) but PWM out intended for high impedance power amp input (e.g. 20KOhm)?
Do you have a spectrum measurement, e.g. to see the artefacts due to SPS?
Have you tried to investigate how to get such a waveform on PWM out?
My impression: something wrong on measurement setup, e.g. low impedance load instead of nominal intended impedance.
The poor output of the PWM is well-known already from the format RPi. You can see the spectrum here: http://www.crazy-audio.com/2013/11/quality-of-the-raspberry-pi-onboard-sound/
I guess there is a simple 3db filter after the PWM. You could even look at the steps of the 1kHz sine wave to find the PWM frequency.
Nyquist/Shannon say you can reconstruct the signal, it does not say, that a real circuit will do it. For a filtered PWM like here, the post-PWM filter would need infinite steepness. With a simple 3 or 6dB filter there will be lots of artifacts with higher frequencies that result in distortions of the original signal.
As documented measurements have been done with 100kOhm load impedance. The same measurement setup with a HiFiBerry DAC shows the expected sound quality also in the measurements. Feel free to do your own measurements.
I see, thank you. 100KOhm load – still how to get such a waveform?
How can it happen that the amplitude jumps so fast from positive to negative?
What confuses me as well is: why I see quite three specific voltage level (end of cap charge/discharge), e.g. 0V seems to be one? Looks like a three- or even five-voltage-level logic. PWM should have just two voltage references, but I see at least three.
Sure, I will do measurements, just to understand how to get such a waveform out? I would never expect such one after a regular LC low pass filter for PWM.
BTW: Nyquist matters on PWM as well: Due to timing configuration, PWM device has a Nyquist criteria. It is not just for re-construction, it is there on all digital and timing related devices (PWM signal generation as well).
I am still thinking the 20KHz is out of spec (outside range for PWM generation with timers and fix point timer values). Looks like noise generated (due to out of spec. with PWM timing) plus noise from power supply added.
The full amplitude swing (Vpp) is 96mV? A quite small amplitude swing: PWM not working really anymore (too fast with 20KHz)? and just displaying two noise sources summed?
With 3.3V logic and intended for following power amp: shouldn’t we expect a 2Vrms voltage swing instead?
The PWM just uses the samples it gets from the PCM stream and converts them to a voltage. At 20kHz, there are about 2 samples per period that are at random points of the sine wave, at some waves 3 samples (not really random, but I don’t want to get into this detail as it gets quite complicated). To reconstruct the signal it now has to filter out all frequencies above 22kHz, However this does not work with a simple 3/6 or even 12dB filter. It will need a filter with infinite steepness. Therefore the resulting waveform is the sum of the original sine wave + unfiltered artefacts of frequencies > 22kHz.
Pingback: Why your new Raspberry Pi B+ still needs a HiFiBerry sound card | HiFiBerry - High quality Raspberry Pi Audio
Hi Daniel,
I understand, thank you.
Just to mention: I got my RPi B+ and tried (the audio):
To be frank: the audio quality on headphone 3.5mm is quite acceptable.
Just: the volume is so low. You have reported to see also very low audio level – I can confirm:
the level is so low that I had to turn my valve headphone amp to full level (pot to full open) just to enjoy regular volume level. Quality is quite acceptable but in terms of volume: nice to let me hear the noise of my amp (pot full open will generate much more noise). ;-)
Other issues I have:
a) If I configure HifiBerry in /etc/modules and I try to play to I2S – Rasbian (I have installed latest, 2014-06-20, “a must to do”) – system hangs after few seconds. After it complains about cache and performance – all dead (needs a hard reboot). Happens on command line as well as X-windows, never mind which app to use in order to play (mplayer, VLC, speaker-test cannot be stopped etc.).
b) The I2S does not come out. Even I think via alternative GPIOs (now ALT0 and other GPIOs)
available as I2S on GPIO connector – there is nothing really (scope does not show any signal activity on other I2S pins).
How to reuse HifiBerry on B+?
Is there a need to recompile (and change pinmux) in I2S drivers?
To be honest: what is the benefit to go with RPi B+? It is more flaky for me (and BTW: older images do not work, changing SD card from running B to B+ – it does not work, we had to setup system completely new).
Raspberry Pi B+ works with I2S, please see here:
http://www.tjaekel.com/T-DAC/raspi_Bplus.html
It needs just:
– four jumper wires (different GPIO pins now)
– AND a Kernel Patch (different pinmux)
I have it running.
Hi Torsten,
we already sent a patch to the RPi kernel developers including board autodetection. However I expect that most sound card drivers will set the GPIOs based on the board configuration in the future.
Best regards
Daniel
there should be a PiCast – hifiberry distribution. Then is would be possible to use android and the chomecast feature..perfect match.. like airplay and apple…atm you have to use offline music or some airplay root shit for android + volumio etc…not a really good option.. to much failures
The B+ does not use use a switching regulator for its PWM driver, that would indeed be a bad design choice, instead it uses the AP7115-25SEG low dop regulator with high power supply rejection ratio. It creates a noise free 2.5V for the NC7WZ16 PWM driver, the output of which is attenuated and filtered with two 100Ohm resistors, and a 100nF capacitor, so the output is 50 Ohm, and can reach 1.25Volt p/p.
The software should obviously always drive the PWM to 100% of its range, or you would worsen the dynamic range. AFAIK the Pulse Density driver code will be improved, now that the DAC hardware is better.
The output isn’t designed to drive loads < 1K Ohm, so no headsets, or even earbuds.
The B+ now also combined I2S and I2C on the same connector, making connecting a codec chip much easier.
Do you have any idea why THD+N is higher on lower frequencies than with the old model? Power supply was my guess, but maybe it is something different. Haven’t had a look at the spectrum analyzer yet. Ideas?
Nope, only thing that comes to mind that the output (DC blocking) capacitor is now a lot larger, namely 47uF instead of just 10uF, so its less of a high pass filter for low load resistances.
Did you actually turn off the video signal? Because if you did not there might still be noise injected from the video output, its “shorted” to the GND line, from an about 15 Ohm source, but the contact resistance of the short is about the same as the contact resistance between the GND of the TRRS connector and the PI’s GND. for best audio quality video should be turned off (sorry I have no idea how to do it except connecting a HDMI screen :-) Probably a config.txt entry may do it.
Some software improvements are in the works it seems, from
http://www.raspi.today/the-making-of-the-raspberry-pi-model-b-plus/
quote:
Audio improvements are just the beginning…
Another one of the bonuses of the B+ is improved analog audio quality: “We’ve fixed half of the problem with the sound,” he starts. “It’s still not super quality, but it’s much better than it was. Previously the supply to the sound output was coming directly from the digital supply on the Pi, so any noise generated by the processor when it was working away would couple into the audio. We’ve removed that so it’s got its own clean supply, but it’s still low resolution – 11-bit audio output – which is probably good enough for most people.
“We can do better. I won’t say anymore, but there might be something coming in the future that will drastically improve the sound quality. Software based… but I’ll leave that for an announcement on the blog,” Adams teased.
Sorry for a noob question. I am waiting for rasp b+ to arrive and use it as xbmc using openelec (though not sure yet) . I am planning to hook it to my Yamaha rx-475 HT using HDMI (it’s a 5.1 speaker set up). Should I be worried about the quality of sound? Many thanks.
Sound over HDMI is not affected. This is about the analog output on the board.
Thanks Daniel! :-)
Pingback: Raspberry Pi Model B+ : l’ultima evoluzione | Meccanismo Complesso
You mention in your test set-up that your Pi “is powered by an external linear power supply”.
Perhaps the “additional voltage regulator for the audio output” on the B+ only shows an advantage over the B when the Pi is powered by a ‘noisy’ switching regulator, which I assume most Pis are. Might be interesting to do another comparison with a ‘more typical’ (for non-audiophiles) PSU?
ISTR reading that the reason for the audio-specific Vreg on the B+ was so that the noise from the 5V supply didn’t filter into the audio output like it does on the Model B?
Hi Daniel,
very interesting measurements.
I am not really a fan of SPS or switching voltage regulators, if possible I always prefer linear ones for any decent audio application, and don´t mind the higher power consumption.
One thing struck me: it may be practical to replace the switching regulator of the A+ / B+ model back to a low-drop ultra-low-noise linear one.
What do you think, any suggestion what regulator type would suit best, without the need to change much of the pcb design around the PAM2306? It would be interesting to see another measurement with a linear regulator, if this mod would lead to any improvement on the noise.
I would believe so.
Pingback: RuneAudio auf RPI installieren - krannich
https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=136445
Sound quality (tested on model B) may be 16 bit instead of 11 since the february 2016.
it is enough to instert line:
audio_pwm_mode=2
into /boot/config.txt
In result (citation):
he original scheme (used since 2012 release) uses the PWM peripheral in pulse-density modulation mode at 11-bit. The input 16-bit was quantised to 11-bit and output at a sample frequency of ~48kHz
The new scheme uses duty-cycle mode at 7-bit resolution with ~16x oversampling. Benefits:
– This reduces harmonic distortion as we’re not driving GPIOs/buffers as fast (THD+N is now about -50dB versus a terrible -20dB before)
– It fits in a sweet-spot with our output RC filter that means the PWM carrier is almost completely suppressed (-38dB at the frequency of interest – one thing to note is that other DACs can have significant out-of-band emissions at several hundred kHz)
– It’s about as fast as we can afford to pump samples into the PWM FIFO due to bus latency constraints
– Quantisation noise floor now ~-93dB instead of the ~-60dB it was previously and shouldn’t vary with input signal
Pingback: RuneAudio auf RPI installieren
I use the Raspberry Pi to drive my extreme Christmas light display. The Pi audio is pretty poor, so I use a USB Sound Blaster Play 3 for audio. It is vastly superior to the built in audio, and while I have not used it, many other in my same hobby say it even sounds better than the HiFiBerry. Creative Labs knows audio, and they have been doing it for computers since the 80’s. I highly recommend anyone wanting superior audio from the Raspberry Pi get a Sound Blaster Play 3.