Ticket #930 (closed defect: invalid)

Opened 14 months ago

Last modified 14 months ago

Media players report 96khz, proc reports 44khz

Reported by: leafwiz Owned by: lennart
Milestone: Component: daemon
Keywords: bitperfect,24bit,audiophile,resample,resampling Cc:

Description

Hey,

I am trying to play a 96kHz/24-bit pcm file:

[2309][root@ubuntu:~]# file test.wav 
test.wav: RIFF (little-endian) data, WAVE audio, Microsoft PCM, 32 bit, stereo 96000 Hz

Which plays with full 96kHz resolution under aplay. But under any other player as VLC, mplayer, totem it plays at 44kHz reported by /proc/asound/card1/stream0, even if the player is reporting to be playing at 96kHz.

Others have reported the same problem:

 http://www.head-fi.org/forum/thread/243027/how-to-make-m-audio-transit-worn-in-ubuntu

Some people at mplayer @ irc.freenode.net encouraged me to file a bug report on this issue. Hope it is useful.

Cheers, TSLura

[2336][torstefan@ubuntu:/proc/asound/card1]$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: Intel [HDA Intel], device 0: STAC92xx Analog [STAC92xx Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: Intel [HDA Intel], device 1: STAC92xx Digital [STAC92xx Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: USB [Transit USB], device 0: USB Audio [USB Audio]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 1: USB [Transit USB], device 1: USB Audio [USB Audio #1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
[2329][root@ubuntu:~]# aplay -D plughw:1,0 test.wav Playing WAVE 'test.wav' : Signed 32 bit Little Endian, Rate 96000 Hz, Stereo

Every 0.5s: cat stream0                                                                        Sun Apr  3 23:29:28 2011

M-Audio Transit USB at usb-0000:00:1d.7-1.2.3, full speed : USB Audio

Playback:
  Status: Running
    Interface = 1
    Altset = 1
    URBs = 3 [ 8 8 8 ]
    Packet Size = 576
    Momentary freq = 96000 Hz (0x60.0000)
  Interface 1
    Altset 1
    Format: S24_3LE
    Channels: 2
    Endpoint: 3 OUT (ADAPTIVE)
    Rates: 48001 - 96000 (continuous)
  Interface 1
    Altset 2
    Format: S24_3LE
    Channels: 2
    Endpoint: 3 OUT (NONE)

[2329][root@ubuntu:~]# mplayer test.wav 
MPlayer 1.0rc4-4.4.5 (C) 2000-2010 MPlayer Team
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

Playing test.wav.
Audio only file format detected.
==========================================================================
Opening audio decoder: [pcm] Uncompressed PCM audio decoder
AUDIO: 96000 Hz, 2 ch, s32le, 6144.0 kbit/100.00% (ratio: 768000->768000)
Selected audio codec: [pcm] afm: pcm (Uncompressed PCM)
==========================================================================
AO: [pulse] 96000Hz 2ch s32le (4 bytes per sample)
Video: no video
Starting playback...
Every 0.5s: cat stream0                                                                        Sun Apr  3 23:30:40 2011

M-Audio Transit USB at usb-0000:00:1d.7-1.2.3, full speed : USB Audio

Playback:
  Status: Running
    Interface = 1
    Altset = 3
    URBs = 6 [ 4 4 4 4 4 4 ]
    Packet Size = 196
    Momentary freq = 44100 Hz (0x2c.199a)
  Interface 1
    Altset 1
    Format: S24_3LE
    Channels: 2
    Endpoint: 3 OUT (ADAPTIVE)
    Rates: 48001 - 96000 (continuous)
  Interface 1
    Altset 2
    Format: S24_3LE
    Channels: 2
    Endpoint: 3 OUT (NONE)
[2330][torstefan@ubuntu:~]$ vlc test.wav 
VLC media player 1.1.4 The Luggage (revision exported)
Blocked: call to unsetenv("DBUS_ACTIVATION_ADDRESS")
Blocked: call to unsetenv("DBUS_ACTIVATION_BUS_TYPE")
[0x9894914] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface.
Blocked: call to setlocale(6, "")
Blocked: call to sigaction(17, 0xb48ff0d4, 0xb48ff048)
Warning: call to signal(13, 0x1)
Warning: call to signal(13, 0x1)
Warning: call to srand(1302210069)
Warning: call to rand()
Blocked: call to setlocale(6, "")

(process:11503): Gtk-WARNING **: Locale not supported by C library.
	Using the fallback 'C' locale.
Warning: call to signal(13, 0x1)
Warning: call to signal(13, 0x1)
Every 0.5s: cat stream0                                                                        Sun Apr  3 23:31:17 2011

M-Audio Transit USB at usb-0000:00:1d.7-1.2.3, full speed : USB Audio

Playback:
  Status: Running
    Interface = 1
    Altset = 3
    URBs = 6 [ 4 4 4 4 4 4 ]
    Packet Size = 196
    Momentary freq = 44100 Hz (0x2c.199a)
  Interface 1
    Altset 1
    Format: S24_3LE
    Channels: 2
    Endpoint: 3 OUT (ADAPTIVE)
    Rates: 48001 - 96000 (continuous)
  Interface 1
    Altset 2
    Format: S24_3LE
    Channels: 2
    Endpoint: 3 OUT (NONE)
    Rates: 8000 - 48000 (continuous)
  Interface 1
    Altset 3
    Format: S16_LE
    Channels: 2
    Endpoint: 3 OUT (ASYNC)
    Rates: 8000 - 48000 (continuous)

Capture:
  Status: Stop
  Interface 2
    Altset 1
    Format: S24_3LE
    Channels: 2
    Endpoint: 5 IN (ASYNC)
    Rates: 48001 - 96000 (continuous)
  Interface 2
    Altset 2
    Format: S24_3LE
    Channels: 2
    Endpoint: 5 IN (ASYNC)
    Rates: 8000 - 48000 (continuous)
  Interface 2
    Altset 3
    Format: S16_LE
    Channels: 2
    Endpoint: 5 IN (ASYNC)
    Rates: 8000 - 48000 (continuous)

[2332][torstefan@ubuntu:~]$ totem test.wav 


Every 0.5s: cat stream0                                                                        Sun Apr  3 23:32:33 2011

M-Audio Transit USB at usb-0000:00:1d.7-1.2.3, full speed : USB Audio

Playback:
  Status: Running
    Interface = 1
    Altset = 3
    URBs = 6 [ 4 4 4 4 4 4 ]
    Packet Size = 196
    Momentary freq = 44100 Hz (0x2c.199a)
  Interface 1
    Altset 1
    Format: S24_3LE
    Channels: 2
    Endpoint: 3 OUT (ADAPTIVE)
    Rates: 48001 - 96000 (continuous)
  Interface 1
    Altset 2
    Format: S24_3LE
    Channels: 2
    Endpoint: 3 OUT (NONE)
    Rates: 8000 - 48000 (continuous)
  Interface 1
    Altset 3
    Format: S16_LE
    Channels: 2
    Endpoint: 3 OUT (ASYNC)
    Rates: 8000 - 48000 (continuous)

Capture:
  Status: Stop
  Interface 2
    Altset 1
    Format: S24_3LE
    Channels: 2
    Endpoint: 5 IN (ASYNC)
    Rates: 48001 - 96000 (continuous)
  Interface 2
    Altset 2
    Format: S24_3LE
    Channels: 2
    Endpoint: 5 IN (ASYNC)
    Rates: 8000 - 48000 (continuous)
  Interface 2
    Altset 3
    Format: S16_LE
    Channels: 2
    Endpoint: 5 IN (ASYNC)
    Rates: 8000 - 48000 (continuous)

System dmsg  http://pastebin.com/SmWamhja

Change History

Changed 14 months ago by coling

  • status changed from new to closed
  • resolution set to invalid

This is not a bug.

PA will use a single sample rate for all audio played. If you wish this sample rate to be 96kHz you should adjust it in /etc/pulse/daemon.conf (default-sample-rate).

Changing sample rates on the fly is not feasible as it would result in an audible "pop" or "click" or "stutter" if multiple streams are playing (e.g. consider I'm playing a 8kHz sound effect and I start playing some 96kHz audio, I'd have to change the native sample rate to 96Hz and then upsample the remainder of the 8kHz sound effect to 96kHz, mix the result and then play.

Changing mid stream would be clearly audible.

So an alternative strategy is to use the "first" sample rate. But using the same example as above, it means our nice 96kHz stream is downsampled to 8kHz.... certainly not what is desired.

So at present, we have a "native" sample rate and everything is up/down mixed to suit that. If you set it to 96kHz but most of your audio sources are 44.1kHz, then you'll obviously waste a lot of CPU upsampling, so there is always a tradeoff.

There is also an added complication, that ALSA cannot tell us what sample rates a card supports. We have to try them all at startup to "probe" the device. This obviously takes time and we already do a lot of probing at startup as it is :s

We're experimenting with a "change on suspend" approach where we can switch sample rates (if supported) when the sink is suspended, but it could easily still lead to your card playing back the 96kHz file at 44.1kHz depending on the circumstances of when you started playing. This non-deterministic behaviour feels a little ugly but it does still let people get full support under most circumstances.

So I'm going to close this because it's not a bug (and I'm being particularly brutal with closing bug reports just now as we'll shortly move ot a new tracker and I'm not convinced we'll be migrating the existing bugs - so in short, don't take this personally!!!), and is in fact the (current) intended behaviour and patches already exist that will somewhat alleviate the problem.

I hope you find this explanation sufficient for your needs.

Changed 14 months ago by ronalde

  • keywords bitperfect,24bit,audiophile,resample,resampling added

I hope you find this explanation sufficient for your needs.

Actually, having this explanation only in this bug and not in an obvious place like the wiki/FAQ draws a lot of (undeserved) negative attention and confusion with audio enthusiasts (and at the same time are not so interested in Linux knwowledge), like #293.

I would advise to dedicate a special section in the documentation to this design choice and offer some advise on alternatives.

For now maybe this link will help:  Computer Audiophile - Bit-perfect audio in Linux at 88.2 and 176.4 now possible

Note: See TracTickets for help on using tickets.