View previous topic :: View next topic |
Author |
Message |
NathanZachary Moderator
Joined: 30 Jan 2007 Posts: 2605
|
Posted: Thu Feb 09, 2017 7:00 pm Post subject: ALSA resampling everything to 48kHz |
|
|
Hello all,
I have a USB DAC that I just noticed is resampling everything I play to 48kHz. I'm guessing that ALSA is favouring dmix here, and that's what causing the problem. For instance, when playing a 24-bit/192kHz file with aplay, I see the following:
Code: |
$ aplay Downloads/2L38_01_192kHz.wav
Playing WAVE 'Downloads/2L38_01_192kHz.wav' : Signed 24 bit Little Endian in 3bytes, Rate 192000 Hz, Stereo
$ cat /proc/asound/card2/pcm0p/sub0/hw_params
access: MMAP_INTERLEAVED
format: S32_LE
subformat: STD
channels: 2
rate: 48000 (48000/1)
period_size: 1024
buffer_size: 16384
$ cat /proc/asound/Ego/stream0
Emotiva Emotiva Big Ego at usb-0000:01:00.0-1, high speed : USB Audio
Playback:
Status: Running
Interface = 1
Altset = 1
Packet Size = 64
Momentary freq = 47998 Hz (0x5.fff0)
Feedback Format = 16.16
Interface 1
Altset 1
Format: S32_LE
Channels: 2
Endpoint: 1 OUT (ASYNC)
Rates: 44100, 48000, 88200, 96000, 176400, 192000, 352800, 384000
Data packet interval: 125 us
Interface 1
Altset 2
Format: S16_LE
Channels: 2
Endpoint: 1 OUT (ASYNC)
Rates: 44100, 48000, 88200, 96000, 176400, 192000, 352800, 384000
Data packet interval: 125 us
Interface 1
Altset 3
Format: SPECIAL
Channels: 2
Endpoint: 1 OUT (ASYNC)
Rates: 44100, 48000, 88200, 96000, 176400, 192000, 352800, 384000
Data packet interval: 125 us
|
More information on my setup can be found in my blog post:
http://z-issue.com/wp/usb-uac2-dac-in-linux-the-emotiva-big-ego-with-gentoo-linux/
Basically, my /etc/asound.conf has the following (which works, but is resampling):
Code: |
$ cat /etc/asound.conf
defaults.pcm.!card Ego
defaults.pcm.!device 0
defaults.ctl.!card Ego
defaults.ctl.!device 0
|
By the way, if I make changes to /etc/asound.conf, a simple /etc/init.d/alsasound restart should cause it to take effect, correct?
Any suggestions on getting this DAC to not resample?
Code: |
$ aplay -L
null
Discard all samples (playback) or generate zero samples (capture)
default:CARD=Intel
HDA Intel, ALC892 Analog
Default Audio Device
sysdefault:CARD=Intel
HDA Intel, ALC892 Analog
Default Audio Device
front:CARD=Intel,DEV=0
HDA Intel, ALC892 Analog
Front speakers
surround21:CARD=Intel,DEV=0
HDA Intel, ALC892 Analog
2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=Intel,DEV=0
HDA Intel, ALC892 Analog
4.0 Surround output to Front and Rear speakers
surround41:CARD=Intel,DEV=0
HDA Intel, ALC892 Analog
4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=Intel,DEV=0
HDA Intel, ALC892 Analog
5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=Intel,DEV=0
HDA Intel, ALC892 Analog
5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=Intel,DEV=0
HDA Intel, ALC892 Analog
7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=Intel,DEV=0
HDA Intel, ALC892 Digital
IEC958 (S/PDIF) Digital Audio Output
hdmi:CARD=NVidia,DEV=0
HDA NVidia, HDMI 0
HDMI Audio Output
hdmi:CARD=NVidia,DEV=1
HDA NVidia, HDMI 0
HDMI Audio Output
default:CARD=Ego
Emotiva Big Ego, USB Audio
Default Audio Device
sysdefault:CARD=Ego
Emotiva Big Ego, USB Audio
Default Audio Device
front:CARD=Ego,DEV=0
Emotiva Big Ego, USB Audio
Front speakers
surround21:CARD=Ego,DEV=0
Emotiva Big Ego, USB Audio
2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=Ego,DEV=0
Emotiva Big Ego, USB Audio
4.0 Surround output to Front and Rear speakers
surround41:CARD=Ego,DEV=0
Emotiva Big Ego, USB Audio
4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=Ego,DEV=0
Emotiva Big Ego, USB Audio
5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=Ego,DEV=0
Emotiva Big Ego, USB Audio
5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=Ego,DEV=0
Emotiva Big Ego, USB Audio
7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=Ego,DEV=0
Emotiva Big Ego, USB Audio
IEC958 (S/PDIF) Digital Audio Output
|
Thank you preemptively!
Cheers,
Nathan Zachary _________________ “Truth, like infinity, is to be forever approached but never reached.” --Jean Ayres (1972)
---avatar cropped from =AimanStudio--- |
|
Back to top |
|
|
audiodef Watchman
Joined: 06 Jul 2005 Posts: 6639 Location: The soundosphere
|
|
Back to top |
|
|
Wallsandfences Guru
Joined: 29 Mar 2010 Posts: 378
|
Posted: Fri Feb 10, 2017 4:20 pm Post subject: |
|
|
I'd try to explicitly route the aplay output to hw(0,0), this way, dmix is ruled out. Not at my box at the moment, man pages should guide you to the correct syntax. |
|
Back to top |
|
|
Wallsandfences Guru
Joined: 29 Mar 2010 Posts: 378
|
Posted: Fri Feb 10, 2017 4:24 pm Post subject: |
|
|
you made me curious, man aplay shows there's a --disable-resampling switch, this should do. |
|
Back to top |
|
|
NathanZachary Moderator
Joined: 30 Jan 2007 Posts: 2605
|
Posted: Fri Feb 10, 2017 5:35 pm Post subject: |
|
|
I think that part of the problem here is that the device supports only S16_LE, S32_LE, and SPECIAL formats, but this particular file is S24_3LE:
Code: |
$ aplay -D hw:2,0 --disable-resample -f S32_LE Downloads/2L38_01_192kHz.wav
Warning: format is changed to S24_3LE
Playing WAVE 'Downloads/2L38_01_192kHz.wav' : Signed 24 bit Little Endian in 3bytes, Rate 192000 Hz, Stereo
aplay: set_params:1299: Sample format non available
Available formats:
- S16_LE
- S32_LE
- SPECIAL
|
That being said, I guess I'm okay with having ALSA convert the format, but not the sample rate. Ideally, though, I would like everything to just hit the USB DAC and to have no mixing, but it seems like that might not be possible given that the only formats available to the DAC are those three:
Code: |
$ cat /proc/asound/Ego/stream0
Emotiva Emotiva Big Ego at usb-0000:01:00.0-1, high speed : USB Audio
Playback:
Status: Stop
Interface 1
Altset 1
Format: S32_LE
Channels: 2
Endpoint: 1 OUT (ASYNC)
Rates: 44100, 48000, 88200, 96000, 176400, 192000, 352800, 384000
Data packet interval: 125 us
Interface 1
Altset 2
Format: S16_LE
Channels: 2
Endpoint: 1 OUT (ASYNC)
Rates: 44100, 48000, 88200, 96000, 176400, 192000, 352800, 384000
Data packet interval: 125 us
Interface 1
Altset 3
Format: SPECIAL
Channels: 2
Endpoint: 1 OUT (ASYNC)
Rates: 44100, 48000, 88200, 96000, 176400, 192000, 352800, 384000
Data packet interval: 125 us
|
Any other thoughts? I would be willing to play around with something like JACK, but I would prefer to just use vanilla ALSA without further complicating the audio routing.
Cheers,
Nathan Zachary _________________ “Truth, like infinity, is to be forever approached but never reached.” --Jean Ayres (1972)
---avatar cropped from =AimanStudio--- |
|
Back to top |
|
|
swanson Tux's lil' helper
Joined: 04 Jun 2004 Posts: 147 Location: Edinburgh, Scotland
|
Posted: Wed Feb 22, 2017 5:15 pm Post subject: |
|
|
Documentation for ALSA can certainly be quite unclear but outputting directly to hw:2,0 should have bypassed dmix and allowed the application to choose the sample rate...unless it is maybe done as part of the format conversion from S24_3LE?!? Dmix only runs a single rate and format, usually 48000 and S16 for standard devices, but you can force the rate and format in dmix with something like the following (mine just sets the dmix rate to 44100);
Code: | pcm.!default {
type plug
slave.pcm "dmixer"
}
ctl.!default {
type hw
card Ego
}
pcm.dmixer {
type dmix
ipc_key 1024
slave {
pcm "hw:2,0"
channels 2
rate 44100
format S32_LE
}
} |
Would have been nice if the application opening an unused dmix pcm device got to the choose the rate and format that any subsequent streams were mixed into but hey ho. _________________ Alan. |
|
Back to top |
|
|
NathanZachary Moderator
Joined: 30 Jan 2007 Posts: 2605
|
Posted: Thu Feb 23, 2017 2:15 am Post subject: |
|
|
Thanks for posting your ALSA configuration. I figured out that, in Audacious, I can set it to hw output/32 (instead of float), and that fixes the problem. However, I obviously then lose any type of mixing (so I'm limited to one stream at a time). So, it's a toss-up on what's better. I personally could barely hear a difference (especially at the relatively low volume at which I typically listen), so I think that just leaving it with the default mixer might be the way to go for my needs.
Cheers,
Nathan Zachary _________________ “Truth, like infinity, is to be forever approached but never reached.” --Jean Ayres (1972)
---avatar cropped from =AimanStudio--- |
|
Back to top |
|
|
Wallsandfences Guru
Joined: 29 Mar 2010 Posts: 378
|
Posted: Thu Feb 23, 2017 9:14 am Post subject: |
|
|
NathanZachary wrote: | However, I obviously then lose any type of mixing (so I'm limited to one stream at a time
|
Think of it as a feature regarding high quality audio listening. I mean, who wants to hear his mail chiming in during one's favourite klingon opera? |
|
Back to top |
|
|
Akkara Bodhisattva
Joined: 28 Mar 2006 Posts: 6702 Location: &akkara
|
Posted: Thu Feb 23, 2017 10:15 am Post subject: |
|
|
Does your USB card really go up that high? Most that I've seen cap out at 96K. EDIT: nevermind, just read your link, wow, it seems that one goes to 384K!
NathanZachary wrote: | However, I obviously then lose any type of mixing (so I'm limited to one stream at a time |
Among other reasons, your second source is probably not sampled at 192KHz. I don't think desktop bloops and bleeps are recorded at that high a resolution
The thing I always wished dmix would do, but I've never been able to figure out how to configure, is when transitioning from nothing playing to some sound playing, configure the card to use whatever native sampling rate that first thing playing is at, so no conversion is necessary. If a second sound then comes in before the first one is finished playing, it gets re-sampled to the first's sampling rate, if the sampling rate is different.
Doing it that way (were it possible) would ensure that the primary sound always sounds as good as possible, while any ancillary sounds (desktop bloops, etc) getting resampled to match. _________________ Many think that Dilbert is a comic. Unfortunately it is a documentary. |
|
Back to top |
|
|
Ant P. Watchman
Joined: 18 Apr 2009 Posts: 6920
|
Posted: Fri Feb 24, 2017 10:20 pm Post subject: |
|
|
That's a thing pulseaudio provides, though it's limited to only two sample rates set at startup (the default is CDDA+48kHz). I also note it doesn't seem to work with common programs and resamples in software anyway... |
|
Back to top |
|
|
dimko Apprentice
Joined: 12 Feb 2006 Posts: 196
|
Posted: Tue Feb 12, 2019 10:24 pm Post subject: i am gonna necropoke the topic |
|
|
Alsa by default sets sample rate to 48K.
You need to modify .asoundrc
So those were bad news.
More bad news.
Firefox and Chrome dont like anything above 48K in sample rate and refuse to work.
There is nothing we can do about it, as Firefox officially dropped support for alsa and only support hated pulseaudio.
So only ugly workaround - to switch off browser if if you want to use above 48k sample rate. _________________ Just a user. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|