Audio crackling for certain files

Hello,
I am trying to use Sonic Pi on an old laptop. I’m running NixOS unstable and use Pipewire using the default audio configuration.

I noticed that certain samples (in particular bd_boom.flac) have a reproducible cracking when the sound is emitted from the laptop speakers but not when using headphones.

Does anyone have any suggestion on how I could diagnose what the cause of the problem could be?

One potential source of crackling I found comes from different layers of the audio stack using different sample rates. But unsure if this the case here since your headphone jack and speaker presumably get the output from the same audio card.

If it’s a certain sound only, also consider root causes in the lower layers.

The laptop sound chip might be applying DSP to the output and that can have audible artifacts such as cracking when certain sounds play.

Laptop speakers are usually garbage, so it might even be a hardware issue.

A good sanity check would be to use pulse audio instead of pipewire. If it also happens in pulse, the root cause is unlikely to be the sound server and rather the kernel driver for your sound chip, the sound chip itself or the HW.

1 Like

Switching to pulseaudio didn’t help.

I noticed something strange though.

sudo lspci -vvmmnnk -s 00:08.0
Slot:	00:08.0
Class:	Audio device [0403]
Vendor:	NVIDIA Corporation [10de]
Device:	MCP79 High Definition Audio [0ac0]
SVendor:	NVIDIA Corporation [10de]
SDevice:	Apple iMac 9,1 [cb79]
Rev:	b1
ProgIf:	00
Driver:	snd_hda_intel
Module:	snd_hda_intel

Shows SDevice: Apple iMac 9,1 [cb79] which is not correct. My laptop is a MacBook Pro 5,5. I see my model listed here.

Cirrus Logic CS4206/4207
========================
mbp55
    MacBook Pro 5,5

I tried to add:

boot.extraModprobeConfig = ''
  options snd-hda-intel model=mbp55
'';

but it didn’t help neither with the playback issue nor with the wrong model reported by lspci.

I checked dmesg and it’s not showing any error:

dmesg | grep -i snd
[   26.468837] snd_hda_intel 0000:00:08.0: enabling device (0000 -> 0002)
[   26.469181] snd_hda_intel 0000:00:08.0: Disabling MSI
[   26.777872] snd_hda_codec_cirrus hdaudioC0D0: autoconfig for CS4206: line_outs=2 (0xb/0xa/0x0/0x0/0x0) type:speaker
[   26.777894] snd_hda_codec_cirrus hdaudioC0D0:    speaker_outs=0 (0x0/0x0/0x0/0x0/0x0)
[   26.777904] snd_hda_codec_cirrus hdaudioC0D0:    hp_outs=1 (0x9/0x0/0x0/0x0/0x0)
[   26.777912] snd_hda_codec_cirrus hdaudioC0D0:    mono: mono_out=0x0
[   26.777917] snd_hda_codec_cirrus hdaudioC0D0:    dig-out=0x10/0x0
[   26.777923] snd_hda_codec_cirrus hdaudioC0D0:    inputs:
[   26.777929] snd_hda_codec_cirrus hdaudioC0D0:      Mic=0xd

That iMac misclassification is even more strange considered that I get the correct codec from:

grep Codec /proc/asound/card0/codec* 
Codec: Cirrus Logic CS4206

while the iMac 9,1 is listed under

ALC88x/898/1150/1220
imac91-vref
    Vref setup for iMac 9,1

in the document I linked above

If it also happens in pulse, your issue likely lies in driver, firmware or hardware.

If the Nvidia driver is involved, it would be my first suspect. I’d play around with different kernel and Nvidia driver versions.

Don’t stress about the hardware not being identified “correctly”, multiple generations of products frequently use the same parts.

I’m thinking to install OS X on an external drive and see if the issue reproduces there. That at least should help me figuring out if the problem is due to the hardware itself or to drivers