You are not logged in.

#1 2009-07-12 21:28:22

lost eden
Member
Registered: 2008-01-01
Posts: 62

[SOLVED] alsa disable 44.1KHz --> 48KHz resampling

I have recently bought an expensive USB DAC capable of both 44.1KHz & 48KHz sampling rates. It is reported as a Burr-Brown Japan PCM2702. At the moment it seems that most of my programs that output sound (mpd, smplayer, vlc, aplay, etc.) all result in 44.1KHz music being resampled to 48KHz. For example, the following is playing a 44.1KHz wav file using aplay;

[cj@yuzuki ~]$ aplay array_new/media/unfiled/udial.wav 
Playing WAVE 'array_new/media/unfiled/udial.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo

aplay correctly identifies the file as 44.1KHz, but alsa is sending 48KHz to the DAC;

[cj@yuzuki ~]$ cat /proc/asound/card0/pcm0p/sub0/hw_params 
access: MMAP_INTERLEAVED
format: S16_LE
subformat: STD
channels: 2
rate: 48000 (48000/1)
period_size: 1024
buffer_size: 16384

However if I add the -Dhw:0,0 to aplay, alsa sends 44.1KHz to the DAC, so I know that it is possible to get what I want.

[cj@yuzuki ~]$ aplay -Dhw:0,0 array_new/media/unfiled/udial.wav 
Playing WAVE 'array_new/media/unfiled/udial.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
[cj@yuzuki ~]$ cat /proc/asound/card0/pcm0p/sub0/hw_params 
access: RW_INTERLEAVED
format: S16_LE
subformat: STD
channels: 2
rate: 44100 (44100/1)
period_size: 5513
buffer_size: 22050

I can achieve something similar with smplayer's GUI Options-->Preferences-->General-->Audio as the 'Output driver' drop-down list offers me several options; if I select alsa it resamples to 48KHz, however if I select alsa (0.0 - Burr-Brown Japan PCM2702 it outputs 44.1KHz.

So my question is this - what is the simplest/cleanest way to disable resampling & get alsa to output the original audio to the DAC? I've spent hours trawling the web & reading all sorts of wikis & howtos about .asoundrc/asound.conf, but I have failed to find anything that directly addresses this problem, which should be a simple fix!

Last edited by lost eden (2009-07-12 21:55:57)

Offline

#2 2009-07-12 21:34:30

Themaister
Member
From: Trondheim, Norway
Registered: 2008-07-21
Posts: 652
Website

Re: [SOLVED] alsa disable 44.1KHz --> 48KHz resampling

Dmix resamples audio to 48000Hz by default afaik (can be changed). If it supports hardware mixing you should use that instead of dmix. Can you post the output of aplay -l ? Basically, if nothing is specified, dmix is activated, if hw:0,0 is used, the sound is sent directly to the hardware (mixing wont work, but if you have several subchannels, you can utilize real hardware mixing big_smile)

Last edited by Themaister (2009-07-12 21:36:10)

Offline

#3 2009-07-12 21:40:54

lost eden
Member
Registered: 2008-01-01
Posts: 62

Re: [SOLVED] alsa disable 44.1KHz --> 48KHz resampling

I've just discovered that if I add the following to my mpd.conf it plays at the desired 44.1KHz;

audio_output {
        type    "alsa"
        name    "default"
        device  "hw:0,0"
}

The important bit I think is the device line, because it uses hw to bypass the plughw devices? Is there a way I can do this globally in /etc/asound.conf, something like the following maybe?

pcm.!default hw:0,0

Can you post the output of aplay -l ?

[cj@yuzuki ~]$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: PCM2702 [Burr-Brown Japan PCM2702], device 0: USB Audio [USB Audio]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
[cj@yuzuki ~]$ aplay -L
default:CARD=PCM2702
    Burr-Brown Japan PCM2702, USB Audio
    Default Audio Device
front:CARD=PCM2702,DEV=0
    Burr-Brown Japan PCM2702, USB Audio
    Front speakers
surround40:CARD=PCM2702,DEV=0
    Burr-Brown Japan PCM2702, USB Audio
    4.0 Surround output to Front and Rear speakers
surround41:CARD=PCM2702,DEV=0
    Burr-Brown Japan PCM2702, USB Audio
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=PCM2702,DEV=0
    Burr-Brown Japan PCM2702, USB Audio
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=PCM2702,DEV=0
    Burr-Brown Japan PCM2702, USB Audio
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=PCM2702,DEV=0
    Burr-Brown Japan PCM2702, USB Audio
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=PCM2702,DEV=0
    Burr-Brown Japan PCM2702, USB Audio
    IEC958 (S/PDIF) Digital Audio Output
null
    Discard all samples (playback) or generate zero samples (capture)

Last edited by lost eden (2009-07-12 21:41:20)

Offline

#4 2009-07-12 21:47:14

Themaister
Member
From: Trondheim, Norway
Registered: 2008-07-21
Posts: 652
Website

Re: [SOLVED] alsa disable 44.1KHz --> 48KHz resampling

Hmm, I guess you have no additional subdevices...

This should work for the pure sound wink

pcm.!default{
type hw
card 0
}

However, with this, only one app can play sound at a time. Which most often is just fine smile

Last edited by Themaister (2009-07-12 21:48:29)

Offline

#5 2009-07-12 21:54:04

lost eden
Member
Registered: 2008-01-01
Posts: 62

Re: [SOLVED] alsa disable 44.1KHz --> 48KHz resampling

I literally just found that near exact same fix as you posted it! Found it over here --> http://alsa.opensrc.org/index.php/FAQ026

I did;

pcm.!default{
 type hw
 card 0
 device 0
}

I'm not sure whether the device line is required, as you say there are no additional subdevices, but I find it easier to think of it as 0,0 so I'll keep it that way. Which works an absolute treat! Cheers!

Offline

Board footer

Powered by FluxBB