Fix audio glitches with Intel HDA Realtek 887-VD

7,314

Solution 1

Ok, I've solved it... The answer was:

1) Buy a new sound card (in my case a Soundblaster Live)

2) Install Jack Audio (jackd)

sudo apt-get install jackd qjackctl

3) Install the Jack-Pulseaudio bridge (pulseaudio-module-jack)

sudo apt-get install pulseaudio-module-jack

4) Fire up jack (I used qJackctl) with Soundblaster-friendly settings:

Driver: alsa

Realtime

Frames/Period: 2048

Periods/Buffer: 2

Input Device: hw:Live

Output Device: hw:Live

5) Make sure the Jack connections are patching PulseAudio JACK Sink to System Playback

jack_connect 'PulseAudio JACK Sink:front-left' 'system:playback_1'
jack_connect 'PulseAudio JACK Sink:front-right' 'system:playback_2'

6) Make sure PulseAudio is using Jack Sink as it's output

pacmd set-default-sink "jack_out" && pacmd set-default-source "jack_in"

7) Restart Spotify / VLC or whatever you are using to play sound... it will work!

It's an absolute fudge of a workaround, but that's because the intel HDA audio drivers in Linux are shoddy as hell. The problem lies with the DMA Position Pointer reporting (a known problem: https://www.kernel.org/doc/Documentation/sound/alsa/HD-Audio.txt).

Linux audio is a mess. I've been using Ubuntu since 2010 and in the past 6 years it is the audio clusterf##k that has consistently given me the biggest headaches. PulseAudio might have a lovely desktop widget, but it causes so many problems. Jack is poorly documented and qjackctl doesn't give you much of a leg up. Only ALSA seems to behave, but alas, nobody has written a nice desktop widget nor an interface to control the programs that have binded to it.

The take-home messages are:

Don't use intel HDA on-board audio if running Linux.

Linux audio is a mess. If it's not working correctly out of the box, you're in for a whole world of pain!

Solution 2

The Linux device driver called snd-hda-intel has been apparently causing huge amounts of aggravation since at least November 2010 when one aggravated user wrote a PulseAudioMicrophoneGuide.pdf.

Here is what I have figured out so far: PulseAudio is a software layer that runs on top of Alsa. Alsa is a software layer that loads a large number of driver software packages. Alsa is not just drivers for the electronic signals. Alsa loads several different little pieces of software for each electrical signal, like a mixer and like the software that reads bytes from a microphone or writes bytes to a headphone amplifier.

My 2015 Lenovo S21e laptop has a "no sound from the built in microphone" problem and as a result neither Skype or GoogleHangouts Chat works with the built in microphone.

The short term fix for me is to plug in a Webcam with microphone or use a Plantonics USB headset.

Here is what I think needs to be done. I am not a C programmer (just Python, Perl and Arduino). Inside the device driver that is talking to the hardware find the location in the source code where the audio data is being copied from the microphone memory location. One of the output channels, Right or Left is being inverted somehow in the software. My guess is they did a signal inversion hoping to cancel out some kind of noise from the signal. So the trick is to figure out why the original programmer forced an inversion. If nothing else, remove the inversion and see if that makes the Right and Left Channels OK.

Share:
7,314

Related videos on Youtube

michaeljtbrooks
Author by

michaeljtbrooks

Medical doctor, technology entrepreneur and award-winning broadcaster. Based in Cambridge, UK. [I don't care about reputation.]

Updated on September 18, 2022

Comments

  • michaeljtbrooks
    michaeljtbrooks over 1 year

    I've just self-build a beefy new desktop, with a Gigabyte Z97P-D3 mobo, intel i7-4790K, 16GB RAM. I am using the on-board sound hardware intel HDA (Realtek ALC887-VD) for audio output. I'm running Ubuntu 14.04 LTS.

    Every few minutes I can hear a short skip in audio playing, almost as though one frame is being dropped. It's incredibly annoying and happens regardless of the source (VLC / Spotify / Chromium browser). In the brief moment during a skip, the Sound Preferences > Output tab's list of devices gets greyed out, and the volume control indicator briefly flashes as though it is muted, before all flicking back to normal.

    ALSAmixer also similarly glitches during the skips with the volume bars all disappearing for a fraction of a second.

    I've tried the following workarounds (none of which work for me):

    1) /etc/modprobe.d/alsa-base.conf: Position_fix setting

    options snd-hda-intel model=generic position_fix=1
    

    2) PulseAudio /etc/pulse/default.pa: Turning off tsched

    load-module module-udev-detect use_ucm=0 tsched=0
    

    3) PulseAudio /etc/pulse/default.pa: Adjusting defaults (all sorts of combinations and values of the below)

    default-fragments = 2
    default-fragment-size-msec = 250
    default-sample-rate = 48000
    realtime-scheduling = yes
    realtime-priority = 5
    

    4) Reinstalling PulseAudio

    5) Upgrading the kernel to the latest stable (4.4.2)

    6) Using Jack2 instead of PulseAudio

    7) Buying a new sound card (SoundBlaster Live), which doesn't seem to work with various applications like Spotify.

    Output of cat /proc/asound/card*/codec* | grep Codec:

    Codec: Intel Generic

    Codec: Realtek ALC887-VD

    Codec: Nvidia GPU 60 HDMI/DP

    Output of cat /proc/asound/card*

    0 [HDMI ]: HDA-Intel - HDA Intel HDMI HDA Intel HDMI at 0xf7914000 irq 33

    1 [PCH ]: HDA-Intel - HDA Intel PCH HDA Intel PCH at 0xf7910000 irq 32

    2 [NVidia ]: HDA-Intel - HDA NVidia HDA NVidia at 0xf7080000 irq 17

    It's card #1 that I'm using.

    Output of uname -a:

    Linux alnitak 4.4.2-040402-generic #201602171633 SMP Wed Feb 17 21:35:10 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

    I suspect this has something to do with the intel HDA drivers seeing as Pulse, ALSA and Jack are all affected.

    Are there any fixes I'm missing?

  • nik gnomic
    nik gnomic over 4 years
    soundblaster live and later cards Audigy/Audigy2 is fairly complex audio device great for multi-channel capture/playback with correct settings in jack. not a good workaround for most general users. complaints about shortcomings of Linux audio system do not help resolve problem. Lack of knowledge of how to configure Pulseaudio properly is a problem because many old-school Linux users are still hating on Pulseaudio for shortcomings in the past, so pool of users who know how to configure Pulseaudio is smaller than for other elements of Linux environment