3

The Raspberry Pi is notorious for outputting slightly dodgy sound. This only affects the analogue sound output, not sound carried over HDMI for example.

So what would cause the background noise for the analogue sound output, and why does the same problem not occur for USB or HDMI sound?

  • You might find this useful: raspberrypi.stackexchange.com/questions/24476/… -> I never tried because the pi analogue sound system is so crap I prefer to just avoid using it as much as possible, but if you have a spare cable, some strippers and 1/2 hour it may be worth it WRT whatever problem this relates to. – goldilocks May 21 '16 at 16:51
5

Raspberry Pi's core micro (BCM2835) doesn't have any audio outputs per se. Yes, it has the HDMI audio output, but the stereo 3.5mm jack outputs are forged using a pair of PWM generators rather than audio quality DACs.

DAC is "Digital to Analog Converter". There are at least 3 key ways to output an analog voltage from a micro. By comparison, PWM (Pulse Width Modulation) is fairly inexpensive in terms of hardware. It operates on a principle that you output a square wave, but you vary the length of time the output is "high" vs. the length of time it's "low". The average output, then, is the voltage. Different levels of voltage are required to push and pull the speaker core to different positions with different speeds to create different audio amplitudes and frequencies.

The problem with using a PWM as an audio DAC is that it's switching on and off quite rapidly and this, in itself, creates a frequency. Not something you want when you're outputting sound. So, you try to smooth (average) it by grounding it through a resistor and capacitor in parallel. Even then, the greater the ratio between "mark" (on time) and "space" (off time), the less "smooth" this average can be. The more "off" time there is (i.e. the lower the volume) the less smooth the average.

The RC network values need to be optimised for some selected range. My finding is that the RPI's audio tends to work quite well at levels of 75% and above, but is otherwise abysmal.

I'm sure there are electronics buffs who would dispute this interpretation, but this is my attempt to pitch what I know to make the answer as useful as possible to as broad an audience as possible.

My advice? Buy a $4 USB audio DAC off your favourite internet auction site. They're very well supported with pre-installed kernel options.

  • Neat! I didn't know about PWN generators before. Here's a nice article from 2006 about PWN / Class D amplifiers. Subjectively, my RPi1B's analog out sounds just fine to me. I keep it around 65%. – Hydraxan14 May 27 '16 at 13:44
  • Aaahh... Now, you're making the right comments. This invites me to point out that the 75% volume I suggested assumes the particular impedance of my speakers! Of course, putting an impedance (non-electronicists can read "resistance") across the output completely changes the characteristics of the RC smoothing network. If you're connecting an amplifier, its input circuitry also becomes part of the calculation (nominally a higher impedance than connecting speakers direct). – KDM May 27 '16 at 20:36
  • My trusty old Altec Lansing 2421 system isn't exactly audiophile-grade. XD. C-net lists its nominal/input impedance as 8 ohms. – Hydraxan14 May 28 '16 at 21:07
  • I can say that a pair of 3ohm speakers sounds awful below 75%. – KDM May 28 '16 at 21:46
1

There is low quality audio out of the Raspberry Pi because of the way they generate the sound. If you read my post here, it has a look at the audio schematic of the Pi and discusses why digital noise is so readily available through the analogue jack. The long and the short of it is that there doesn't seem to be great analogue separation from the digital power supply. Apart from that, there is no mid voltage analogue ground.

To get great quality sound,you need isolation between the digital and analogue systems in some way. Whether you use a USB sound card or an HDMI solution, they still rely on good analogue and digital isolation. They most likely use dedicated circuits designed for higher quality sound. Personally I am not a fan of USB sound cards because of the delay (latency) they introduce into the audio path.

You can get high quality sound cards which sit on the GPIO header pins, see here for a (non comprehensive) list. Most of these sound cards will use audio codecs which are specifically designed to have much better analogue and digital separation.

Matt

  • Could you please include some specific detail in your answer, link only answers are generally discouraged. – Darth Vader Sep 3 '16 at 8:36
  • Thanks for your feedback Darth. I have included more information on digital noise and why it seeps into the analogue path. – Matt Sep 4 '16 at 11:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.