You are not logged in.

#1 2016-01-06 08:54:26

tedbell
Member
Registered: 2012-08-04
Posts: 167

Is MPD converting the sample rate properly? (OSS related)

I need to find a way to verify if mpd is converting to the sample rate supported by my sound device.

I am using OSS (better quality) and mpd-git using the soxr sample rate converter.

Here's the relevant section in my mpd.conf:

audio_output {
    type            "oss"
    name            "OSS"
#    device        "/dev/oss/oss_hdaudio0/pcm0"
    device          "/dev/dsp1"
    format          "192000:32:2"    # optional
#    auto_resample "no"    
}

samplerate_converter "soxr very high"

I have vmix disabled and everything works as it should but my mpd verbose log indicates that the oss driver is stuck on 16bit:

Jan 06 03:36 : playlist: play 0:"Music/Classical/Albums/Beethoven - Symphonies Nos.1-9 (Paavo Järvi) [VINYL 24-96]/34 - Symphony No.9 in D minor, Op.125 - I. Allegro ma non troppo un poco maestoso.flac"
Jan 06 03:36 : client: [1] command returned 0
Jan 06 03:36 : client: [1] process command "idle"
Jan 06 03:36 : client: [1] command returned 1
Jan 06 03:36 : decoder_thread: probing plugin flac
Jan 06 03:36 : decoder: audio_format=96000:24:2, seekable=true
Jan 06 03:36 : client: [1] process command "status"
Jan 06 03:36 : soxr: soxr engine 'double-precision'
Jan 06 03:36 : soxr: samplerate conversion ratio to 2.00
[b]Jan 06 03:36 : output: opened plugin=oss name="OSS" audio_format=192000:16:2[/b]
Jan 06 03:36 : output: converting from 96000:24:2
Jan 06 03:36 : soxr: soxr engine 'double-precision'
Jan 06 03:36 : soxr: samplerate conversion ratio to 0.46
Jan 06 03:36 : output: opened plugin=fifo name="my_fifo" audio_format=44100:16:2
Jan 06 03:36 : output: converting from 96000:24:2

The MPD documentation site says mpd might not be recognizing the proper sample rate?

To verify if MPD converts the audio format, enable verbose logging, and watch for these lines:

decoder: audio_format=44100:24:2, seekable=true
output: opened plugin=alsa name="An ALSA output" audio_format=44100:16:2
output: converting from 44100:24:2

This example shows that a 24 bit file is being played, but the sond chip cannot play 24 bit. It falls back to 16 bit, discarding 8 bit.

However, this does not yet prove bit-perfect playback; ALSA may be fooling MPD that the audio format is supported. To verify the format really being sent to the physical sound chip, try:

cat /proc/asound/card*/pcm*p/sub*/hw_params
access: RW_INTERLEAVED
format: S16_LE
subformat: STD
channels: 2
rate: 44100 (44100/1)
period_size: 4096
buffer_size: 16384

Obey the "format" row, which indicates that the current playback format is 16 bit (signed 16 bit integer, little endian).

But the output of ossinfo reveals my sound card supports 16 and 32 bit only:

ossinfo -v9

----------------------

Version info: OSS 4.2 (b 2011/201501280728) (0x00040100) TRIAL
Platform: Linux/x86_64 4.3.3-2-ARCH #1 SMP PREEMPT Wed Dec 23 20:09:18 CET 2015 (GORFTUX)

Number of audio devices:	4
Number of audio engines:	4
Number of MIDI devices:		0
Number of mixer devices:	1


Device objects
 0: osscore0 OSS core services
 1: oss_hdaudio0 Intel HD Audio
    HD Audio controller Intel HD Audio
    Vendor ID    0x80868c20
    Subvendor ID 0x10250781
     Codec  0: Unknown (0x10ec0282/0x10250781)
 2: oss_usb0 USB audio core services

MIDI devices (/dev/midi*)

Mixer devices
 0: High Definition Audio 0x10ec028 (Mixer 0 of device object 1)
    Device file /dev/oss/oss_hdaudio0/mix0, Legacy device /dev/mixer0
    Priority: 10
    Caps: 
    Device handle: PCI07811025-0000:00:1b.0-mx01
    Device priority: 10


Audio devices
HD Audio play pcm1                /dev/oss/oss_hdaudio0/pcm0  (device index 0)
    Legacy device /dev/dsp0
    Caps: TRIGGER MMAP 
    Modes: OUTPUT 
      Out engine  1: 0/HD Audio play pcm1
                     Available for use 
    Input formats (0x00001010):
      AFMT_S16_LE	- 16 bit signed little endian
      AFMT_S32_LE	- 32 bit signed little endian
    Output formats (0x00001010):
      AFMT_S16_LE	- 16 bit signed little endian
      AFMT_S32_LE	- 32 bit signed little endian
    Device handle: PCI07811025-0000:00:1b.0-au01
    Related mixer dev: 0
    Sample rate source: 0
    Preferred channel configuration: Not indicated
    Supported number of channels (min - max): 2 - 8
    Native sample rates (min - max): 44100 - 192000 (44100,48000,96000,192000)
    HW Type: Not indicated.
    Minimum latency: Not indicated

HD Audio play pcm2                /dev/oss/oss_hdaudio0/pcm1  (device index 1)
    Legacy device /dev/dsp1
    Caps: TRIGGER MMAP 
    Modes: OUTPUT 
      Out engine  1: 1/HD Audio play pcm2
                     Available for use 
    Input formats (0x00001010):
      AFMT_S16_LE	- 16 bit signed little endian
      AFMT_S32_LE	- 32 bit signed little endian
    Output formats (0x00001010):
      AFMT_S16_LE	- 16 bit signed little endian
      AFMT_S32_LE	- 32 bit signed little endian
    Device handle: PCI07811025-0000:00:1b.0-au02
    Related mixer dev: 0
    Sample rate source: 0
    Preferred channel configuration: Not indicated
    Supported number of channels (min - max): 2 - 2
    Native sample rates (min - max): 44100 - 192000 (44100,48000,96000,192000)
    HW Type: Not indicated.
    Minimum latency: Not indicated

HD Audio rec mix5                 /dev/oss/oss_hdaudio0/pcmin0  (device index 2)
    Legacy device /dev/dsp2
    Caps: TRIGGER MMAP 
    Modes: INPUT  
      In engine   1: 2/HD Audio rec mix5
                     Available for use 
    Input formats (0x00001010):
      AFMT_S16_LE	- 16 bit signed little endian
      AFMT_S32_LE	- 32 bit signed little endian
    Output formats (0x00001010):
      AFMT_S16_LE	- 16 bit signed little endian
      AFMT_S32_LE	- 32 bit signed little endian
    Device handle: PCI07811025-0000:00:1b.0-au03
    Related mixer dev: 0
    Sample rate source: 0
    Preferred channel configuration: Not indicated
    Supported number of channels (min - max): 2 - 2
    Native sample rates (min - max): 44100 - 192000 (44100,48000,96000,192000)
    HW Type: Not indicated.
    Minimum latency: Not indicated

HD Audio rec mix4                 /dev/oss/oss_hdaudio0/pcmin1  (device index 3)
    Legacy device /dev/dsp3
    Caps: TRIGGER MMAP 
    Modes: INPUT  
      In engine   1: 3/HD Audio rec mix4
                     Available for use 
    Input formats (0x00001010):
      AFMT_S16_LE	- 16 bit signed little endian
      AFMT_S32_LE	- 32 bit signed little endian
    Output formats (0x00001010):
      AFMT_S16_LE	- 16 bit signed little endian
      AFMT_S32_LE	- 32 bit signed little endian
    Device handle: PCI07811025-0000:00:1b.0-au04
    Related mixer dev: 0
    Sample rate source: 0
    Preferred channel configuration: Not indicated
    Supported number of channels (min - max): 2 - 2
    Native sample rates (min - max): 44100 - 192000 (44100,48000,96000,192000)
    HW Type: Not indicated.
    Minimum latency: Not indicated


Nodes
  /dev/dsp -> /dev/oss/oss_hdaudio0/pcm0
  /dev/dsp_in -> /dev/oss/oss_hdaudio0/pcm0
  /dev/dsp_out -> /dev/oss/oss_hdaudio0/pcm0
  /dev/dsp_mmap -> /dev/oss/oss_hdaudio0/pcm0
  /dev/dsp_multich -> /dev/oss/oss_hdaudio0/pcm0

I get this error in dmesg every time I boot, could this have something to do with it?

[   13.570231] oss_hdaudio: HDA codec 0x10ec0282 not known yet
[   13.579662] oss_hdaudio: HDA codec 0x10ec0282 not known yet

Is MPD actually converting to my specified format or is something standing in the way? I checked the sox resampler site and 32bit is supported by that resampler.

I used a custom oss samplerate converter I found in the OSS forum with DeadBeef audio player (MPD doesn't seem to support custom plugins) and I have it configured to use 32bit 192000 and the output to terminal confirms I can play back 32 bit.


Thanks for any help.

Offline

#2 2016-01-06 15:33:35

tom.ty89
Member
Registered: 2012-11-15
Posts: 897

Re: Is MPD converting the sample rate properly? (OSS related)

No idea about OSS, but apparently at least soxr doubled the sampling rate to 192kHz as you specified and mpd open the device at that rate as well. It's just mpd somehow does not open the device with 32bit sample size.

tedbell wrote:

(better quality)

FWIW, it's really silly to resample the audio source yourself instead of passing it untouched to your device (unless you have some shitty sound card that doesn't handle 44.1kHz well, then resampling it to 48kHz may help). It is arguable that padding the signal to 32bit is good, or at least harmless, though. I also doubt that whether OSS really gives you better quality...

Offline

#3 2016-01-07 13:55:29

tedbell
Member
Registered: 2012-08-04
Posts: 167

Re: Is MPD converting the sample rate properly? (OSS related)

tom.ty89 wrote:

No idea about OSS, but apparently at least soxr doubled the sampling rate to 192kHz as you specified and mpd open the device at that rate as well. It's just mpd somehow does not open the device with 32bit sample size.

tedbell wrote:

(better quality)

FWIW, it's really silly to resample the audio source yourself instead of passing it untouched to your device (unless you have some shitty sound card that doesn't handle 44.1kHz well, then resampling it to 48kHz may help). It is arguable that padding the signal to 32bit is good, or at least harmless, though. I also doubt that whether OSS really gives you better quality...

Thanks. Is there a way to turn off resampling completely in MPD? I tried building it without soxr but it falls back to the libsamplerate resampler. I have an Intel HD audio device that can handle up to 192khz 32 bit (in linux), in windows it only goes up to 24 bit.
OSS actually sounds better to my ears than alsa did with the same MPD settings. I can't really explain it.

Offline

#4 2016-01-07 16:44:00

tom.ty89
Member
Registered: 2012-11-15
Posts: 897

Re: Is MPD converting the sample rate properly? (OSS related)

It's 24bit anyway (if the spec say so). It's just (apparently) most ALSA driver use S32_LE (instead of S24_LE / S24_3LE) to do it.
I don't know about mpd, doesn't it allow you to comment out the "format" line in the conf so that it would open the device at different format while it plays different sources? If it's not possible, you should simply set it to what most your sources are. It doesn't matter what's the MAX capability of your device is, though it might matter which it performs best on...

Offline

#5 2016-01-07 19:52:03

tedbell
Member
Registered: 2012-08-04
Posts: 167

Re: Is MPD converting the sample rate properly? (OSS related)

tom.ty89 wrote:

It's 24bit anyway (if the spec say so). It's just (apparently) most ALSA driver use S32_LE (instead of S24_LE / S24_3LE) to do it.
I don't know about mpd, doesn't it allow you to comment out the "format" line in the conf so that it would open the device at different format while it plays different sources? If it's not possible, you should simply set it to what most your sources are. It doesn't matter what's the MAX capability of your device is, though it might matter which it performs best on...

When I comment out the line, it still converts when I play a song, for example, that is 96000:24:2 or 192000:24:2 to 96000:16:2 192000:16:2. In other words, mpd can only play 16 bit and nothing higher with OSS.

Offline

Board footer

Powered by FluxBB