linux icon indicating copy to clipboard operation
linux copied to clipboard

bcm2835 ALSA sound: pop on sound playback start/completion

Open P33M opened this issue 14 years ago • 48 comments

Hello

After doing some testing with sound onboard the Rpi, I can characterize (via oscilloscope) the conditions that result in a rather jarring click on start of playback and pop on completion of playback

Running FW 339137 Kernel Linux raspberrypi 3.2.27+ #174 PREEMPT Wed Sep 26 14:09:47

Sample command: mpg321blah.mp3 (sound plays) ^C (pop)

The rpi schematic details use of PWM channels for audio carrier generation - having read some other information on improving the rpi's sound quality, I can offer insight on to what happens when the PWM is initiated/released in playback.

On boot and in an "idle" state, the PWM output is 0V (disabled). When playback commences, the voltage measured at C20/C26 pin "2" ramps to +0.56V quite quickly, causing an audible click. This is because the output 10u AC coupling capacitor C34/C48 passes this ramp, which then saturates any input stage in a downstream amp expecting a ~700mV rms AC signal. The effect is variable depending on the input coupling used on the downstream amp.

A similar but more complex effect happens when the audio playback is interrupted or completes. On measuring C20 pin "2" the +0.56V DC biased audio signal has a brief pulse at +1.8V for 6.5ms, then 0V for 16.5ms, then a pulse back to 0.56V for 4ms, then 0V idle state [a fat pair of square pulses]. Similar to the start of playback case, this causes the pop sound on playback.

Maybe the open/close functions in ALSA need to be set so that they preserve PWM at 50% duty cycle on a) driver loading and b) start/finish of playback

P33M avatar Oct 02 '12 20:10 P33M

Hi. Same here.

Linux raspberrypi 3.1.9+ #90 Wed Apr 18 18:23:05 BST 2012 armv6l GNU/Linux

GPU (useful?): /opt/vc/bin/vcgencmd version Apr 18 2012 15:04:46 Copyright (c) 2012 Broadcom version 310376 (release)

damiencorpataux avatar Oct 17 '12 17:10 damiencorpataux

updating to the latest kernel & firmware help?

licaon-kter avatar Oct 18 '12 09:10 licaon-kter

Hi, same problem..

root@XBian:~# /opt/vc/bin/vcgencmd version Oct 19 2012 23:40:40 Copyright (c) 2012 Broadcom version 345130 (release)

Linux XBian 3.2.27+ #250 PREEMPT Thu Oct 18 19:03:02 BST 2012 armv6l GNU/Linux

If you need more information, I will be happy to deliver that.

hetsch avatar Oct 22 '12 18:10 hetsch

http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=20689 IMO It seems to be a longstanding VideoCore firmware issue (not alsa related). Pausing/starting a video in the omxplayer produces the same voltage jumps.

ghost avatar Oct 25 '12 16:10 ghost

I'm using MPD to play stuff as a workaround, since it doesn't stop/start pops between tracks.

tiagocpontesp avatar Oct 25 '12 16:10 tiagocpontesp

I haven't tried it yet, but apparently the Arch Linux doesn't have this problem

mdxe avatar Oct 29 '12 21:10 mdxe

Aye, it does! (or did)

On Mon, Oct 29, 2012 at 9:20 PM, Alex Bouchard [email protected]:

I haven't tried it yet, but apparently the Arch Linux doesn't have this problem

— Reply to this email directly or view it on GitHubhttps://github.com/raspberrypi/linux/issues/128#issuecomment-9885887.

tiagocpontesp avatar Oct 29 '12 22:10 tiagocpontesp

Arch definitely still has the problem, as well. I experience it at the start and end of tracks in pianobar when using the 3.5mm audio out port. This is with both the Raspian & Arch distros. Sound over HDMI works without a problem.

paintjob avatar Nov 06 '12 15:11 paintjob

Any news on this one? I really want to help, but still have no idea where to start...

hetsch avatar Dec 04 '12 12:12 hetsch

I can confirm this issue on both the 256 and 512mb versions of the Raspberry pi using the current Raspbian image. As paintjob noted, sound over HDMI works without a problem in both cases.

Regards

Note: the current image in this case is 2012-10-28-wheezy-raspbian

cyclooctane avatar Dec 05 '12 06:12 cyclooctane

same issue here... this is really painfull to endure :(

JstNnyms avatar Dec 05 '12 10:12 JstNnyms

I have the same problem with the 512MB version and analog output.

As a workaround I use mpd with the PulseAudio output plugin. If you disable PulseAudio's module-suspend-on-idle the pops disappear (even when switching songs in mpd) because the audio device is never closed.

dbader avatar Dec 05 '12 10:12 dbader

dbader: could you please give a further explanation how your workaround is ought to be used? im not sure what to do.

should i just comment the line "module-suspend-on-idle" in /etc/pulse/default.pa out?

edit: just commenting the line out didnt work for me.

JstNnyms avatar Dec 05 '12 10:12 JstNnyms

This gives me playback without crackling in mpd (on the latest Raspbian)

  • Install PulseAudio: sudo apt-get install pulseaudio
  • Configure mpd to use PulseAudio in /etc/mpd.conf:
audio_output {
  type   "pulse"
  name   "MPD PulseAudio Output"
}
  • Comment out load-module module-suspend-on-idle in /etc/pulse/default.pa
  • Restart PulseAudio and mpd:
sudo /etc/init.d/pulseaudio restart
sudo /etc/init.d/mpd restart

dbader avatar Dec 05 '12 10:12 dbader

thank you so far. i just need to figure out how to apply that to raspbmc... :+1:

JstNnyms avatar Dec 05 '12 10:12 JstNnyms

dbader thanks! It works (I had to reboot the system).

Tested on Pi Revision B (512MB), rasbian: pi@raspberrypi ~ $ uname -a Linux raspberrypi 3.2.27+ #250 PREEMPT Thu Oct 18 19:03:02 BST 2012 armv6l GNU/Linux pi@raspberrypi ~ $ pulseaudio --version pulseaudio 2.0 pi@raspberrypi ~ $ mpd --version mpd (MPD: Music Player Daemon) 0.16.7

andrzej-bieniek avatar Dec 08 '12 12:12 andrzej-bieniek

It also works for xmms2 with pulseaudio. I also had to reboot the system. Now, it only clicks once during start up.

Matthijss avatar Dec 11 '12 22:12 Matthijss

@dbader; is this also possible for xbian? Can you describe the steps with some more detail? I'm just a beginner ;-) and I really looking forward for a solution for the pop-on-sound.

skipper79 avatar Dec 20 '12 11:12 skipper79

I have enabled pulseaudio on my RPi with mpd, however if I pause the mpd output it fails to restart complaining about the device being suspended despite having commented out module-suspend-on-idle.

Can anyone else repeat this problem? (start playing audio using mpd, pause the output, attempt to restart. No output is possible until the RPi is rebooted).

Goofinder avatar Dec 22 '12 12:12 Goofinder

Same problem as Goofinder here, on raspbian, doing mpc play, mpc pause, mpc play. MPD logs contains:

Dec 22 16:43 : output: "My Pulse Output" [pulse] failed to play: suspended

acieroid avatar Dec 22 '12 16:12 acieroid