Ubuntu

ALSA SPDIF Digital output clipping / crackling during playback

Reported by larson.eric.d@gmail.com on 2009-04-10
44
This bug affects 9 people
Affects Status Importance Assigned to Milestone
alsa-driver (Ubuntu)
Undecided
Unassigned

Bug Description

When playing sound in Jaunty out of my HDA Intel SPDIF out, loud sounds clip. This is audible because from the strong distortion it produces, which I have seen some people characterize as "crackling". For example, if I go to system->preferences->sound and play the test sound, the sinusoid is audibly clipping. I have all of my sliders in alsamixer zeroed except for master (@100) and IEC958 (@100). Note that if I turn down the volume of the master and/or the IEC958, the clipping is still present---I've gone as low as -21dB (64/100) on both sliders simultaneously, and the clipping is still there.

I looked around for solutions, this sounds similar to my problem:
https://bugs.launchpad.net/ubuntu/+source/alsa-driver/+bug/285866

However, as I noted, I've tried reducing my levels, and my PCM mixer level is all the way at 0 (-58.50 dB) anyway. Not to mention that these are digital outputs, so having them at the 0dB gain position (100% for the master and IEC958 sliders) should be fine...

Yes I am certain it's not my speakers clipping.

Oddly enough, at one point I was able to get it not to clip in the gnome sound settings control by going through some sequence of trying different backends (various options for ALSA, for OSS, etc.). I have not been able to reliably reproduce the non-clipping, but I will keep trying.

For some reason, I hear the clipping when I listen to music using gnome-listen, but not when using Amarok using Xine as the backend.

Please help me stop the clipping.

ProblemType: Bug
Architecture: amd64
ArecordDevices:
 **** List of CAPTURE Hardware Devices ****
 card 0: Intel [HDA Intel], device 0: AD198x Analog [AD198x Analog]
   Subdevices: 2/2
   Subdevice #0: subdevice #0
   Subdevice #1: subdevice #1
AudioDevicesInUse: Error: command ['fuser', '-v', '/dev/dsp', '/dev/snd/controlC0', '/dev/snd/pcmC0D0c', '/dev/snd/pcmC0D0p', '/dev/snd/pcmC0D1p', '/dev/snd/seq', '/dev/snd/timer', '/dev/sequencer2', '/dev/sequencer'] failed with exit code 1:
Card0.Amixer.info:
 Card hw:0 'Intel'/'HDA Intel at 0xfe020000 irq 17'
   Mixer name : 'Analog Devices AD1984'
   Components : 'HDA:11d41984,17aa20d7,00100400'
   Controls : 30
   Simple ctrls : 19
DistroRelease: Ubuntu 9.04
Package: alsa-base 1.0.18.dfsg-1ubuntu8
PackageArchitecture: all
ProcEnviron:
 LANG=en_US.UTF-8
 SHELL=/bin/bash
SourcePackage: alsa-driver
Uname: Linux 2.6.28-11-generic x86_64
---
AlsaVersion: Advanced Linux Sound Architecture Driver Version 1.0.21.
Architecture: amd64
ArecordDevices:
 **** List of CAPTURE Hardware Devices ****
 card 0: Intel [HDA Intel], device 0: AD198x Analog [AD198x Analog]
   Subdevices: 2/2
   Subdevice #0: subdevice #0
   Subdevice #1: subdevice #1
AudioDevicesInUse:
 USER PID ACCESS COMMAND
 /dev/snd/controlC0: edlarson 1435 F.... pulseaudio
Card0.Amixer.info:
 Card hw:0 'Intel'/'HDA Intel at 0xfe020000 irq 17'
   Mixer name : 'Analog Devices AD1984'
   Components : 'HDA:11d41984,17aa20d7,00100400'
   Controls : 29
   Simple ctrls : 18
Card29.Amixer.info:
 Card hw:29 'ThinkPadEC'/'ThinkPad Console Audio Control at EC reg 0x30, fw 7KHT24WW-1.08'
   Mixer name : 'ThinkPad EC 7KHT24WW-1.08'
   Components : ''
   Controls : 1
   Simple ctrls : 1
Card29.Amixer.values:
 Simple mixer control 'Console',0
   Capabilities: pswitch pswitch-joined penum
   Playback channels: Mono
   Mono: Playback [on]
DistroRelease: Ubuntu 10.04
InstallationMedia: Ubuntu 10.04 "Lucid Lynx" - Beta amd64 (20100318)
Package: alsa-driver (not installed)
ProcEnviron:
 LANG=en_US.utf8
 SHELL=/bin/bash
ProcVersionSignature: Ubuntu 2.6.32-21.32-generic 2.6.32.11+drm33.2
Tags: lucid
Uname: Linux 2.6.32-21-generic x86_64
UserGroups: adm admin cdrom dialout lpadmin plugdev sambashare
dmi.bios.date: 11/14/2008
dmi.bios.vendor: LENOVO
dmi.bios.version: 7LETC5WW (2.25 )
dmi.board.name: 7732CTO
dmi.board.vendor: LENOVO
dmi.board.version: Not Available
dmi.chassis.asset.tag: No Asset Information
dmi.chassis.type: 10
dmi.chassis.vendor: LENOVO
dmi.chassis.version: Not Available
dmi.modalias: dmi:bvnLENOVO:bvr7LETC5WW(2.25):bd11/14/2008:svnLENOVO:pn7732CTO:pvrThinkPadR61:rvnLENOVO:rn7732CTO:rvrNotAvailable:cvnLENOVO:ct10:cvrNotAvailable:
dmi.product.name: 7732CTO
dmi.product.version: ThinkPad R61
dmi.sys.vendor: LENOVO

I have managed to make the problem disappear. And reappear.

On a fresh reboot, if I go to menu->System->Preferences->Sound, set one of the "Sound Playback" drop boxes to be the ALSA digital output, and hit the "test" button, the sine wave is usually (if not always) distorted. If I run alsamixer in a terminal while a distorted sound is playing and mute and then unmute the digital output, the distortion disappears. In general, I can make the described distortion disappear using this method. For example when I run gnome-listen and the loud parts in the music are incorrectly distorting, muting/unmuting the digital output fixes it.

As long as the sound remains continuous, the distortion stays away. However, if I stop sound playback, and start it up later, the distortion sometimes reappears. In the sound preferences panel, this happens after an indeterminate number of hitting "test" followed by "okay". Distortion also reappears if I "fix" the disortion issue while playing test sounds in the sound settings dialog, then close that dialog and start something playing using gnome-listen, it is always distorted.

Also, once I use the sound prefs dialog or listen to "make" my sound distorted, sound playback through "aplay" is also distorted. If I then mute/unmute the digital output, "aplay" will then play undistorted sound. Seems like this proves that this is an ALSA problem, no?

So as of right now, loud passages of sound audibly distort, and the only way to "fix" it is to mute/unmute the digital output. Help?

Muting/unmuting the "master" also fixes it. Also, adding "model=thinkpad" and/or "position_fix=1 [or 2]" in /etc/modprobe.d/alsa-base.conf does not fix it.

This bug persisted in Karmic, and is still present in the current Lucid alpha.

I have managed to isolate this issue. It appears to be caused by the loading/unloading of the sound controller.

If I play a test sinusoid through gstreamer-properties, I can hear it distorting (clipping) from a fresh reboot. If I open up alsamixer while the sound is playing and mute-then-unmute the "master" channel, the sound comes back from the mute undistorted (correct!). If I stop this undistorted test sound, wait ~10 seconds, and then play the test sound again, it is fine (undistorted). If I stop the sound, wait ~20 seconds, then start the test sound again, it is distorted (incorrect!).

To summarize, this procedure is as follows:
1) Play a test sound and hear it's distorted
2) Open alsamixer while the sound plays and mute/unmute the master channel ==> sound is undistorted (correct)
3) Stop the test sound
4a) Wait ~10 seconds to start another sound ==> undistorted (correct)
4b) Wait ~20 seconds to start another sound ==> distorted (incorrect)

I noticed that the parameter "power_save" for the snd-hda-intel device is set to "15" by default. If I do "echo 0 > /sys/module/snd_hda_intel/parameters/power_save", once I "fix" the output using the mute/unmute trick, it works indefinitely (no distortion after any amount of time). Setting the power_save back to 15 makes it break after some amount of seconds again (probably 15).

Also, if I have power_save set to the default 15, if I instead set the power_save_controller attribute to "N" instead of the default "Y", there is no issue once I fix it once, either.

So it seems to me like the controller being unloaded after 15 seconds causes it to be reloaded on next sound play. During this load (and even during the first load), some setting is incorrect which causes clipping. This can be fixed by muting/unmuting the master volume.

Thoughts anyone?

I have come up with a temporary workaround. Simply add the line "options snd-hda-intel power_save_controller=N" to /etc/modprobe.d/options and then run the commands (maybe in a script) "amixer set Master mute" followed by "amixer set Master unmute" whenever you start up or resume from hibernate/suspend, and the distortion doesn't show up. This is not ideal, as it prevents the controller from going into a power save state, and it's annoying to deal with putting in these commands, but it's better than distorted sound.

Brad Figg (brad-figg) wrote :

The latest development release of Ubuntu is entering Beta. Please
consider taking the time to download the latest live-image from
http://cdimage.ubuntu.com/releases/lucid and see if this issue still
exists.

If the issue does still exist; in a terminal (Applications->Accessories->Terminal)
please execute the following command:
    apport-collect -p alsa-driver 359361

summary: - ALSA SPDIF Digital ourput clipping / crackling during playback
+ ALSA SPDIF Digital output clipping / crackling during playback
tags: added: clipping jaunty
Changed in alsa-driver (Ubuntu):
status: New → Incomplete
afonic (afonic) wrote :

It also affects me in 9.10 and it should be fixed.

I will try the livecd for Lucid and let you know asap.

apport information

tags: added: apport-collected
description: updated

apport information

apport information

apport information

apport information

apport information

apport information

apport information

A note on the Apport submission:

I did a new install of Lucid on my laptop. I enabled auto-login and installed some other software.

I used system->preferences->sound to change to the digital out/analog in from the default analog duplex.

I had to then open alsamixer to unmute and raise the volume on the SPDIF so it actually played sound (this step probably shouldn't be required if you do the above step of sys->pref->sound==>digital out, but that should be a different bug report...)

Once I did this, there was no "buzzing", but this essentially replicated my earlier workaround of "mute/unmute to get rid of buzz". Now when I restart, any sounds I play will buzz until I do the mute/unmute trick. I only have to do that once, however, as the driver never enters a powersave state ("cat /sys/module/snd_hda_intel/parameters/power_save" yields 0) again. If I enable power saving (a feature that should work) by changing power_save to be, say, 15, after 15 or so seconds, the buzzing will return.

If you want me to replicate this on a virgin RC or Beta CD, I can do that as well. The procedure should go something like:

1) Boot up
2) Sys->Prefs->Sound, change to be digital output instead of analog
3) Run alsamixer in a terminal, up the Master and SPDIF sliders to 100 (0dB), and unmute SPDIF.
4) Enable power saving mode by setting the power_save variable to something like 15.
5) Wait 15 or so seconds
6) Play a sound with easily heard distortion, such as the test sinusoid in gstreamer-properties

Let me know what else you'd like me to do. Afonic, if you could replicate this for them so we can get a "confirmed," that would be awesome.

xanadoo (apalmrich) wrote :

this is still an annoying issue. i'm on lucid 2.6.32-24-generic. got rid of this problem somehow in the past by deleting some alsa files and reinstalling it. tried just reinstalling now, didn't fix the distortion. perhaps this is some resampling issue? i observed that the noise is most prominent in sine waves at the pitch of a high b and c (tested that with zynaddsubfx and jack)

Given that you are the third person to say they're affected, I set the bug status to confirmed. I hope that is alright.

Changed in alsa-driver (Ubuntu):
status: Incomplete → Confirmed
xanadoo (apalmrich) wrote :

the problem seems to worsen over time. i did a fresh install of the system, no distortion whatsoever was present. the following days slight dístortion occured, by now (~ a week later) the situation is almost as bad as before. all i ever changed in that time was setting levels with alsamixer (muting analogue outputs and setting SPDIF to -0dB damping), and changing the standard device and volume using pulse. i did not play anything but 44.1kHz though, so neither alsa nor pulse should have felt the need to resample.

since this distortion accumultes over time my suggestion is that some config file must be the cause. any of you have an idea where to try deleting and recreating files that might cause this?

You could try making a .asoundrc file in your home directory, or modifying
the parameters in the alsa.conf (I think) in /etc/modprobe.d/. if you look
online for how to make your own asound.conf, you will find the alsa wiki
which has lots of info.

On Aug 21, 2010 7:31 AM, "xanadoo" <email address hidden> wrote:
the problem seems to worsen over time. i did a fresh install of the
system, no distortion whatsoever was present. the following days slight
dístortion occured, by now (~ a week later) the situation is almost as
bad as before. all i ever changed in that time was setting levels with
alsamixer (muting analogue outputs and setting SPDIF to -0dB damping),
and changing the standard device and volume using pulse. i did not play
anything but 44.1kHz though, so neither alsa nor pulse should have felt
the need to resample.

since this distortion accumultes over time my suggestion is that some
config file must be the cause. any of you have an idea where to try
deleting and recreating files that might cause this?

--
ALSA SPDIF Digital output clipping / crackling during playback
https://bugs.launchpad.net/bugs/...

Pedro Lopes (paol) wrote :

It's 10.10 and the problem is still present. I can confirm all the symptoms and workarounds.

I have reported this on the ALSA bug tracker, as it's clearly a driver issue:
https://bugtrack.alsa-project.org/alsa-bug/view.php?id=5186

Brian Neltner (neltnerb) wrote :

I can also verify this exact bug on my setup. I am actually amazed that anyone else had it given the uniqueness of my setup, but great =) Similar to other posters, muting the IEC958 channel in the alsa mixer removes the distortion. I am running Ubuntu 11.04 on this computer, AD198x reported as the alsa device. Thanks for the workaround at least!

Javeed Shaikh (syscrash2k) wrote :

I have uploaded a patch to https://bugtrack.alsa-project.org/alsa-bug/view.php?id=5186 which fixes the problem for me. It would be great if other people could try it out.

Sauron (fjerhammer) wrote :

Looks like the ALSA bug tracker is down. I have reuploaded syscrash2k's patch here: http://fjerhammer.dk/ad1988_spdif_crackling.patch (MD5: 105db6f90cb09c7d90aae8fda1410795)

This problem is still present in kernel 3.5. Every Linux user with a ASUS P5*/P6* motherboard that I know of has pretty much given up on digital audio due to this bug. The patch, however, fixes it for me.

I don't know if any ALSA developers are watching this bug tracker, but I cannot understand why this bug hasn't at least been looked into yet. Especially P5Q and P6T have been great sellers in the last couple of years, which means that quite a lot of computers out there are unable to use S/PDIF outputs on Linux without excessive distortion.

Brian Neltner (neltnerb) wrote :

The bug still exists in Ubuntu 12.10. I can still work around it by using "play -n" with sox in a termainal, muting and unmuting, and it seems to stay good indefinitely. Someone suggested that it may be an issue with power management mode for the audio device?

Raymond (superquad-vortex2) wrote :

you have to send the patch to alsa devel mailing list

zzecool (zzecool) wrote :

Any news on this ? It is a shame that we dont get this fixed after so much time , given that we allrdy have the patch..

Luis Henriques (henrix) wrote :

This bug is awaiting verification that the kernel for Oneiric in -proposed solves the problem (3.0.0-29.46). Please test the kernel and update this bug with the results. If the problem is solved, change the tag 'verification-needed-oneiric' to 'verification-done-oneiric'.

If verification is not done by one week from today, this fix will be dropped from the source code, and this bug will be closed.

See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you!

tags: added: verification-needed-oneiric
Luis Henriques (henrix) wrote :

This bug is awaiting verification that the kernel for Precise in -proposed solves the problem (3.2.0-35.55). Please test the kernel and update this bug with the results. If the problem is solved, change the tag 'verification-needed-precise' to 'verification-done-precise'.

If verification is not done by one week from today, this fix will be dropped from the source code, and this bug will be closed.

See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you!

tags: added: verification-needed-precise
Raymond (superquad-vortex2) wrote :

Several bug reports suggest that the forcibly resetting IEC958 status
 bits is required for AD codecs to get the SPDIF output working
 properly after changing streams.

 Original fix credit to Javeed Shaikh.

 BugLink: https://bugs.launchpad.net/ubuntu/+source/alsa-driver/+bug/359361

Luis Henriques (henrix) wrote :

Raymond, I'm not sure if I understand you're comment above (#31). Do you mean you've verified the bug is fixed? If so, which serie have you tested (Oneiric or Precise)? Thanks.

Luis Henriques (henrix) wrote :

Could anyone please verify this bug is fixed for Oneiric and for Precise, as per comments #29 and #30? We need to have this closed until the end of the week. Thanks

David Henningsson (diwic) wrote :

@luis, this one seems to have come from upstream stable, is verification really necessary?

Luis Henriques (henrix) wrote :

David, you're absolutely right. Don't know how i missed that. Thanks, I'll tag this as verified (for both series).

tags: added: verification-done-oneiric verification-done-precise
removed: verification-needed-oneiric verification-needed-precise

The verification of this Stable Release Update has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regresssions.

Luis Henriques (henrix) on 2013-01-07
tags: added: verification-done-quantal
Alberto Proano (afproano) wrote :

Thanks to everyone who has been working in a solution for the bug reported here.

I have an ASUS Maximus Formula which comes equipped with an ADI1988b sound chip, and I have been experiencing this bug no matter what Ubuntu or Linux Mint version I installed in my system. In fact, this is why I have stayed away from linux ...

Even thought some of you have mention that the patch works, I kindly ask for instructions of how to apply the patch. I am sorry, but I am a Linux newbie ...

Your help is lot appreciated.

Jaime Pérez (jaime-91) wrote :

I have this problem with Lubuntu 14.04 64bit.
I have Radeon HD 7760

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.