[Bug 271559] [sound] [snd_uaudio] Creative Katana V2X garbled audio

From: <bugzilla-noreply_at_freebsd.org>
Date: Tue, 23 May 2023 21:53:46 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=271559

--- Comment #10 from Florian Walpen <dev@submerge.ch> ---
(In reply to Emanuel Haupt from comment #8)

Ok, this is what I think is happening.
Your device expects 6 (5.1) channels of 24bit samples at 48kHz:

> uaudio1: <Creative Technology Ltd SB Katana V2X, class 239/2, rev 2.00/10.10, addr 7> on usbus5
> uaudio1: Play[0]: 48000 Hz, 6 ch, 24-bit S-LE PCM format, 2x8ms buffer.
> uaudio1: Record[0]: 48000 Hz, 2 ch, 24-bit S-LE PCM format, 2x8ms buffer.

The default pcm vchanformat (man sound) is set to 2 channel 16bit at 48kHz:

> dev.pcm.8.play.vchanformat: s16le:2.0
> dev.pcm.8.play.vchanrate: 48000
> dev.pcm.8.play.vchanmode: fixed

And the default vchan conversion path looks good to me:

> {userland} -> feeder_mixer(0x00200010) -> feeder_format(0x00200010 -> 0x00201000) -> feeder_matrix(2.0 -> 5.1) -> feeder_format(0x08601000 -> 0x08610000) -> {hardware}

Which means 2 channel 16bit goes into volume mixer, format conversion to 32bit,
matrix expansion from 2 to 5.1 channels, format conversion to 24bit, then to
the hardware.

The conversion chain for your MP3 playback has a problem:

> {userland} -> feeder_root(0x00200010) -> feeder_volume(0x00200010) -> feeder_rate(0x00200010 q:1 44100 -> 48000) -> {hardware}

There's sample rate conversion from 44.1kHz to 48kHz, but no expansion to 5.1
channels, and no format conversion to 24bit.


Things you could try before going the virtual_oss route:
 * Play something at 48kHz sample rate, like most videos. It may use the
default vchan conversion.
 * Play 32bit samples, it simplifies conversion for matrix expansion. Like "mpv
--audio-format=s32 file.mp3".
 * Set "sysctl dev.pcm.8.play.vchanformat=s32le:2.0".
 * Set "sysctl dev.pcm.8.play.vchanformat=s32le:5.1" or even "sysctl
dev.pcm.8.play.vchanformat=s24le:5.1".

You can check /dev/sndstat again for the conversion chain. Invoking players
from CLI usually prints sample rate and format used. I'm not sure how well they
cope with 5.1 channels though.

-- 
You are receiving this mail because:
You are the assignee for the bug.