alsa-lib icon indicating copy to clipboard operation
alsa-lib copied to clipboard

Missunderstanding or a BUG in reported frequencies for audio cards present in system.

Open CapSel opened this issue 10 months ago • 2 comments
trafficstars

I use ArchLinux with kernel 6.12.7 with "Zen" patches. HW is ASUS Vivobook 14X pro.

So the problem I'm having is that I can't set pipewire to 96000 sampling rate. I tried all options in pipewire. Nothing helped. But a long time ago it worked fine - I can't remember when (at most week after Baldur's Gate 3 release ;).

What I see in system: when I do cat /proc/asound/card0/pcm3p/info (no other pcm* files) I can see name: HDMI 0 - it's important. with cat /proc/asound/card0/codec#0 on top there is:

Codec: ATI R6xx HDMI
Address: 0
AFG Function Id: 0x1 (unsol 0)
Vendor Id: 0x1002aa01
Subsystem Id: 0x00aa0100
Revision Id: 0x100700
No Modem Function Group found
Default PCM:
    rates [0x70]: 32000 44100 48000
    bits [0x2]: 16
    formats [0x1]: PCM

for the other (default) audio card: cat /proc/asound/card1/pcm0p/info (there is pcm0c file too but I did not check it) gives: name: ALC294 Analog cat /proc/asound/card1/codec#0 on top:

Codec: Realtek ALC294
Address: 0
AFG Function Id: 0x1 (unsol 1)
Vendor Id: 0x10ec0294
Subsystem Id: 0x10431ab2
Revision Id: 0x100004
No Modem Function Group found
Default PCM:
    rates [0x560]: 44100 48000 96000 192000
    bits [0xe]: 16 20 24
    formats [0x1]: PCM

so as you can see:

  • hdmi supports up to 48000
  • analog supports up to 192000

I first noticed there is something wrong with alsacap program that reports:

*** Scanning for playback devices ***
Card 0, ID `Generic', name `HD-Audio Generic'
  Device 3, ID `HDMI 0', name `HDMI 0', 1 subdevices (1 available)
    2..8 channels, sampling rate 32000..192000 Hz
    Sample formats: S16_LE, S32_LE
      Subdevice 0, name `subdevice #0'
Card 1, ID `Generic_1', name `HD-Audio Generic'
  Device 0, ID `ALC294 Analog', name `ALC294 Analog', 1 subdevices (1 available)
    2 channels, sampling rate 44100..48000 Hz
    Sample formats: S16_LE, S32_LE
      Subdevice 0, name `subdevice #0'

As you can see:

  • hdmi supports up to 192000
  • analog supports up to 48000

so it's... flipped?

here is a output from cat /proc/asound/pcm:

00-03: HDMI 0 : HDMI 0 : playback 1
01-00: ALC294 Analog : ALC294 Analog : playback 1 : capture 1

To confirm this I downloaded flac file with 96000 sample rate and tried to play it with ffmpeg after pipewire,pipewire-pulse,wireplumber services are stopped. I confirmed that these programs are disabled by checking if ps ax | grep wire before and after, also I monitored logs from these services. It reported error for device "hw:1,0" because it could not set sampling rate to 96000. It did not fail on "hw:0,3" but of course I did not hear anything since external monitor is disconnected.

Replay command: ffmpeg -i yuri_korzunov-through-moon_ring-96kHz-24bit.flac -f alsa hw:1,0 the file is some random file found in internet that tested with ffprobe shows that it has sample rate of 96000. I don't want to attach it since I forgot where I found it ;)

I don't have asound.conf files in /etc/ or ~/.config.

After connecting external monitor alsacap reports max 48000 for both cards. FFmpeg reports sampling rate problem with both audio cards:

[alsa @ 0x586316542b00] sample rate 96000 not available, nearest is 48000

I had this monitor connected before and alsacap reported "flipped" results - not like now that both cards are limited to 48000.

What else can I do to discover the problem?

CapSel avatar Jan 01 '25 23:01 CapSel

The default rates may not be used for `[Audio Output]' codec nodes. You should check codec DAC rates, too. See:

Codec: Realtek ALC287
...
Default PCM:
    rates [0x560]: 44100 48000 96000 192000
    bits [0xe]: 16 20 24
    formats [0x1]: PCM
...
Node 0x02 [Audio Output] wcaps 0x41d: Stereo Amp-Out
  Control: name="Speaker Playback Volume", index=0, device=0
    ControlAmp: chs=3, dir=Out, idx=0, ofs=0
  Amp-Out caps: ofs=0x57, nsteps=0x57, stepsize=0x02, mute=0
  Amp-Out vals:  [0x38 0x38]
  Converter: stream=0, channel=0
  PCM:
    rates [0x40]: 48000
    bits [0xe]: 16 20 24
    formats [0x1]: PCM
  Power states:  D0 D1 D2 D3 EPSS
  Power: setting=D0, actual=D0

perexg avatar Jan 03 '25 17:01 perexg

All [Audio Output] nodes have only 44100 and 48000 rates. That's disappointing. In turn all [Audio Input] nodes support up to 192000. So the problem of not supporting 96000 on output is caused by audio card :( Why would anyone need 192000 on input?

CapSel avatar Jan 05 '25 14:01 CapSel