doveman
Posts: 174
Joined: Wed Dec 07, 2011 11:52 am

Popping noise on analog output (solved)

Mon Feb 25, 2013 4:07 pm

There's a severe problem with the analog output, when starting playing a video or skipping forward, it makes a loud popping noise, twice when skipping as it does it once when going into the skip and again when coming out of it.

I haven't got round to trying the music playback yet but apparently it affects that as well. pitt has found a workaround for that by using the pulseaudio driver but I'm hoping a proper fix can be found for both music and video playback http://forum.stmlabs.com/showthread.php ... 8#pid58438

ski522
Posts: 394
Joined: Sun Sep 30, 2012 2:22 pm

Re: Popping noise on analog output

Mon Feb 25, 2013 10:59 pm

Not happening until someone fixes the PI's sound driver for the analog port which is getting little attention right now. For music your only option is to go with a USB sound card which will solve the problem, Video is another thing because the omxplayer doesn't support ALSA so you can't direct the sound out of a USB sound card.

A more expensive solution is get a something that extracts the sound from HDMI signal into analog which go for about $30.

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 11551
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Popping noise on analog output

Mon Feb 25, 2013 11:09 pm

a cheap high quality solution that may become available in the future, and that uses no USB bandwidth, is an audio converter (codec) that can be plugged into the new P5 connector. Its the main reason P5 was added to the revision 2 boards. for more information search the forum for "I2S".

doveman
Posts: 174
Joined: Wed Dec 07, 2011 11:52 am

Re: Popping noise on analog output

Mon Feb 25, 2013 11:16 pm

Disappointing to hear there's no prospect of a fix anytime soon. I'm not looking to spend more money on a USB sound card (which as you say won't help with the videos) or a HDMI convertor.

The P5 audio convertor might be interesting but I need to get this build finished and sent to my brother soon and he won't be able to fit that or modify the case to fit it either, so the only thing that will help him is a software fix for the sound driver.

obcd
Posts: 917
Joined: Sun Jul 29, 2012 9:06 pm

Re: Popping noise on analog output

Tue Feb 26, 2013 8:22 am

I asked in the Power Users section if it was possible to connect a codec to P5 without the need for other firmware.
I am still waiting for a response so I assume no one from the foundation really is interested.
Considering that, I wouldn't expect the addon any time soon.
Even if they fix the Popping noise, there still is the problem that the system isn't true 16 bit.
I know most pieces of music don't use the full 16 bit dynamic range, but they are recorded in 16 bit.

MaxK1
Posts: 1043
Joined: Sun Aug 26, 2012 11:34 pm

Re: Popping noise on analog output

Tue Feb 26, 2013 8:24 am

Has anyone tried to "repair" the audio as suggested on http://elinux.org/RPi_Bugs ?
You are in a maze of twisty little passages, all alike.
When General Failure and Major Disaster get together, Private Parts usually suffers.

obcd
Posts: 917
Joined: Sun Jul 29, 2012 9:06 pm

Re: Popping noise on analog output

Tue Feb 26, 2013 9:08 am

The sound is produced by pulse width modulating a signal.
The zero level is at a DC potential of 3V3 / 2 = 1.65V.
When the sound system is turned off, that level will either decrease to 0V or increase to 3V3 again.
Another possible cause is the last sample being kept as level. So, if the last sample was driving the system to it's maximum, it would remain like that untill the next samples arrive. This difference in level can cause the plop between music tracks. Why it hasn't been fixed yet by leaving the audio system on or ensuring it stays at zero level when no audio should appear is still a miracle to me. Maybe it's a more serious problem. As I explained before, even if the plop is fixed, you still have the background noise and the resolution not being 16bit which can't be solved. A codec would be the better solution. If you check the roku 2 design, you will find one there.

doveman
Posts: 174
Joined: Wed Dec 07, 2011 11:52 am

Re: Popping noise on analog output

Tue Feb 26, 2013 11:02 am

I haven't tried pitt's workaround for music yet as I've been concentrating on video but assuming it works, it suggests it's not a serious problem that is very difficult to fix.

What's the reason for the background noise and lack of proper 16-bit support then? Is it just the DAC is poorly-specced? I could live with those problems for now anyway if the popping was fixed.

obcd
Posts: 917
Joined: Sun Jul 29, 2012 9:06 pm

Re: Popping noise on analog output

Tue Feb 26, 2013 1:05 pm

It's not a DAC. It's a pulse width modulated signal. The resolution of the width variation is equivalent to 12 bit if I remember well. The noise is simply present on the 3V3 supply rail. As that one is pwm modulated in the soc, you can't filter it. Codecs usually have a digital supply voltage for the digital part of the chip and an analog supply voltage for the analog part of it. You can place a small noise supression coil between the 2 supplies and you can place decoupling capacitors on the analog supply site to further eliminate supply noise.
The pwm modulated signal passes trough a low pass filter which removes the pulses from the equation.

doveman
Posts: 174
Joined: Wed Dec 07, 2011 11:52 am

Re: Popping noise on analog output

Tue Feb 26, 2013 1:54 pm

OK, that sounds complicated. Looking at the page MaxK1 linked to, I wonder if I can fit a DC blocking capacitor and a 100 ohm resistor between the analog port and the amp to protect it and reduce some of the interference noise. Otherwise, it makes me nervous about connecting it to an amp at all if it could damage it and I guess I have no choice but to wait until there's a way to use a cheap external DAC for both music and video before I can send it to my brother.

drgeoff
Posts: 9135
Joined: Wed Jan 25, 2012 6:39 pm

Re: Popping noise on analog output

Tue Feb 26, 2013 6:35 pm

obcd wrote:It's not a DAC. It's a pulse width modulated signal. The resolution of the width variation is equivalent to 12 bit if I remember well.
It is a DAC - see DAC types at http://en.wikipedia.org/wiki/Digital-to ... _converter. Even top end Hi-Fi gear has been using such techniques for years, albeit with a bit more sophistication. The RPi's problem is that because of hardware limitations it is only capable of about 11 bit performance.

The clock used to define the pulse width possibilities is 100 MHz. If the sample rate is 44.1 kHz that gives 2267 different pulse widths. That is just over 2048 which is 11 bit.

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 11551
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Popping noise on analog output

Wed Feb 27, 2013 12:07 am

MaxK1 wrote:Has anyone tried to "repair" the audio as suggested on http://elinux.org/RPi_Bugs ?
It was total bullshit! In fact I took the trouble to delete it from the wiki!

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 11551
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Popping noise on analog output

Wed Feb 27, 2013 12:17 am

the main "problem" with the PWM audio is that it only ever was intended for nothing more than producing some blips and beeps to support python programs, it was never intended as the audio output for a media player!

The clicks and pops between playbacks are because between playbacks the PWM is turned off, and that means the output voltage goes to the GND level, but when the PWM is turned on the audio signal is modulated (about half a volt) around about half the PWM power voltage (which is 3,3V), so around about 3,3/2 = 1,65V. The plop sound when the PWM is turned on comes from the output abruptly going from 0,0V to 1,65V.
The reason that the PWM isn't on all the time is because it uses a non negligible amount of energy!
When the whole device is using only a few hundred milliamps, a dozen milliamps more tends to become a bigger deal than when you are using 5A.

I guess the firmware can partly fix the problem with a delayed soft turn on, but the person(s) that could do it seem to do not give it much priority.

doveman
Posts: 174
Joined: Wed Dec 07, 2011 11:52 am

Re: Popping noise on analog output

Wed Feb 27, 2013 12:31 am

mahjongg wrote:The reason that the PWM isn't on all the time is because it uses a non negligible amount of energy!
When the whole device is using only a few hundred milliamps, a dozen milliamps more tends to become a bigger deal than when you are using 5A.

I guess the firmware can partly fix the problem with a delayed soft turn on, but the person(s) that could do it seem to do not give it much priority.
Or could the firmware be changed to enable a cmdline.txt switch to leave the PWM on all the time?

MaxK1
Posts: 1043
Joined: Sun Aug 26, 2012 11:34 pm

Re: Popping noise on analog output

Wed Feb 27, 2013 12:34 am

Thank you for confirming that it was BS!
You are in a maze of twisty little passages, all alike.
When General Failure and Major Disaster get together, Private Parts usually suffers.

obcd
Posts: 917
Joined: Sun Jul 29, 2012 9:06 pm

Re: Popping noise on analog output

Wed Feb 27, 2013 8:21 am

It's not totally BS.
The protection diodes are indeed misplaced.
If the audio level exceeds 0.7V, the protection diode to ground will start to conduct and will cause a distortion and dc offset in the signal.
Only high end amplifiers are DC coupled, and even than they should have a speaker protection circuit against dc inbalances.

User avatar
pluggy
Posts: 3635
Joined: Thu May 31, 2012 3:52 pm
Location: Barnoldswick, Lancashire,UK
Contact: Website

Re: Popping noise on analog output

Wed Feb 27, 2013 9:28 am

I think some people have a very slack interpretation of what a DAC is. PWM doesn't cut it in my book. Its a cheap fudge that doesn't need much if any hardware and can be done entirely in software. PWM is to DAC what I am to Angelina Jolie.
Don't judge Linux by the Pi.......
I must not tread on too many sacred cows......

obcd
Posts: 917
Joined: Sun Jul 29, 2012 9:06 pm

Re: Popping noise on analog output

Wed Feb 27, 2013 11:40 am

There are several ways for a cow to catch a rabbit. :)
I really don't get how 12 - 20mA would make a difference for most people, if they don't use battery power.
If the foundation would be so concerned about it, why not provide an option to turn the gpu off?
It would also reduce power consumption.
Using a switching regulator instead of a linear one would also be a good move. (But that would make things more expensive I know.)
So indeed, why not make it a setting? If people say, we have plopping noise between songs: add pcm_always_on=1 to cmdline.txt. (Won't work right now, don't try it.)
And why not place the protection diodes on the correct place. People studying the schematics for educational purpose would benefit from it. (Isn't that what it's all about?)

drgeoff
Posts: 9135
Joined: Wed Jan 25, 2012 6:39 pm

Re: Popping noise on analog output

Wed Feb 27, 2013 5:56 pm

pluggy wrote:I think some people have a very slack interpretation of what a DAC is. PWM doesn't cut it in my book. Its a cheap fudge that doesn't need much if any hardware and can be done entirely in software. PWM is to DAC what I am to Angelina Jolie.
http://en.wikipedia.org/wiki/Delta-sigm ... conversion.

User avatar
redhawk
Posts: 3465
Joined: Sun Mar 04, 2012 2:13 pm
Location: ::1

Re: Popping noise on analog output

Wed Feb 27, 2013 6:08 pm

What would be really helpful is if the Pi on-board audio driver could indicate when it's going to start and going to finish using one of the GPIO pins.
That way an audio amplifier capable of muting like the PAM8403 could remove the unwanted clicks an pops from the audio.

Just out of curiosity how easy would it be to hack up the audio drivers for such a task (I quite fancy knocking up a DIY mute circuit for myself)??

Richard S.

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 11551
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Popping noise on analog output

Wed Feb 27, 2013 9:14 pm

obcd wrote:It's not totally BS.
The protection diodes are indeed misplaced.
If the audio level exceeds 0.7V, the protection diode to ground will start to conduct and will cause a distortion and dc offset in the signal.
True, but you forget that with the current resistor division network (270R & 150R) divides the 3,3V PWM signal to a 1,18V PWM signal! So the maximum PWM output swing would be 0,59V DC with plus or minus 0,59V swing around that DC level, in other words, unless a negative DC level is already introduced on the output, (very unlikely) after the DC cap you will only have 0,59V going below GND, not enough to make the diode conduct, even at maximum audio level! So no exceeding of the -0,7V below GND, thus no distortion, and thus no DC level shift.

Also, as a side note, the diodes are not there to clip outgoing signals (to protect what is connected to the PI's audio output), but to protect the PI against any signals that somehow enter the PI through the audio port!

Still placing the diodes on the other side of their DC blocking capacitors would not have harmed, and you could argue it would be "better", as the DC level would be well above ground, giving more "headroom", but then, the levels are designed such that that headroom is unnecessary.
Its still not a "big design error" though, as the wiki was making it out to be.

obcd
Posts: 917
Joined: Sun Jul 29, 2012 9:06 pm

Re: Popping noise on analog output

Wed Feb 27, 2013 10:28 pm

0.59V is close to the conducting voltage of the diode.
If they would have been placed before R21 and R27, They would protect the Soc output pins, and R21 and R27 would protect the diodes by reducing the current going trough them if a voltage spike was introduced on the audio jacket.
I have to agree it's a minor issue and changing it won't fix the plopping, which brings us back to the question why the pwm is switched off instead of leaving it running at 50% duty cycle. (or leaving that choice up to the user)
We only have the extra power consumption as argument which was measured by someone and seemed to be around 20 mA.

doveman
Posts: 174
Joined: Wed Dec 07, 2011 11:52 am

Re: Popping noise on analog output

Thu Feb 28, 2013 7:18 am

Would it be possible to use Audio Engine with a USB soundcard/DAC to get good quality sound for both music and video? If so, are there any cheap USB soundcards with analog outputs that are confirmed to work with the Pi?

obcd
Posts: 917
Joined: Sun Jul 29, 2012 9:06 pm

Re: Popping noise on analog output

Thu Feb 28, 2013 7:43 am

Yes it's possible and yes there are some cheap usb2audio adapters that work on the Pi
Check some of the other Forum Threads about Popping noise and background noise.
Just pick one very carefully. Pi usb has problems with streaming usb devices.
People trying such adapters on their highest 24bit quality also reported problems and distortions with some of the adapters.

doveman
Posts: 174
Joined: Wed Dec 07, 2011 11:52 am

Re: Popping noise on analog output

Thu Feb 28, 2013 8:34 am

Thanks, I'll have a look at the other threads then.

I'd be perfectly happy with decent 16-bit quality.

Return to “Troubleshooting”