11

I recently got an external soundcard/DAC (Fiio E17) and am currently trying to properly configure it on my Ubuntu 12.04 installation. When plugging it in via USB, it's immediately recognized and shows up as a new device in the audio settings. Playback works mostly fine as well (except for some minor volume-related issues, which are beyond the scope of this question).

However, when trying to test the 24 bit/96 kHz playback by playing such an audio file with mplayer, I encountered a small issue:

Opening audio decoder: [pcm] Uncompressed PCM audio decoder
AUDIO: 96000 Hz, 2 ch, s24le, 4608.0 kbit/100.00% (ratio: 576000->576000)
Selected audio codec: [pcm] afm: pcm (Uncompressed PCM)
==========================================================================
AO: [pulse] 96000Hz 2ch s16le (2 bytes per sample)

As can be seen from the output, even though the played file does contain 24 bit/96 kHz audio, it's resampled to 16 bit before playback. Playing the same file with aplay shows the reason:

Playing WAVE 'sr003-02-2496.wav' : Signed 24 bit Little Endian in 3bytes, Rate 96000 Hz, Stereo
aplay: set_params:1081: Sample format non available
Available formats:
- U8
- S16_LE
- S16_BE
- S32_LE
- S32_BE
- FLOAT_LE
- FLOAT_BE
- MU_LAW
- A_LAW

However, /proc/asound/card1/stream0 confirms that the hardware does support 24 bit:

FiiO FiiO USB DAC-E17 at usb-0000:00:1a.0-1.1, full speed : USB Audio

Playback:
  Status: Running
    Interface = 3
    Altset = 1
    Packet Size = 388
    Momentary freq = 44100 Hz (0x2c.199a)
  Interface 3
    Altset 1
    Format: S16_LE
    Channels: 2
    Endpoint: 3 OUT (ADAPTIVE)
    Rates: 32000, 44100, 48000, 96000
  Interface 3
    Altset 2
    Format: S24_3LE
    Channels: 2
    Endpoint: 3 OUT (ADAPTIVE)
    Rates: 32000, 44100, 48000, 96000

At this point I noticed that in the hardware tab of the sound settings, I can select two different profiles for the sound card: Digital Stereo (IEC958) and Analog Stereo. Switching between these two doesn't result in any changes though, as far as I can tell.

Specifying the ALSA device does help though (that is, aplay -Dhw:1,0 sr003-02-2496.wav works just fine and plays the file without resampling). But since Pulseaudio only shows one Fiio device/sink in the sound settings, I'm not sure how I'd tell Pulseaudio to use ALSA device hw:1,0. Adding load-module module-alsa-source device=hw:1,0 to /etc/pulse/default.pa results in Pulseaudio aborting with module.c: Failed to load module "module-alsa-source" (argument: "device=hw:1,0"): initialization failed. during startup.

So, that's the introduction, here's my actual questions:

  • How do I figure out which ALSA device Pulseaudio actually uses when I select the Fiio E17 in the sound settings?
  • How do I tell Pulseaudio to use ALSA device hw:1,0 when selecting the Fiio E17 in my sound settings?

Some more (hopefully helpful) debug information:

4
  • What are the mplayer and aplay command lines?
    – CL.
    May 13, 2013 at 7:44
  • @CL. I run mplayer -ao alsa:device=hw=1.0 sr003-02-2496.wav and aplay -Dhw:1,0 sr003-02-2496.wav to use the correct device, if that's what you're asking.
    – tmnt
    May 13, 2013 at 13:17
  • I was asking about the calls that did not work. And do you want to use PulseAudio or not?
    – CL.
    May 13, 2013 at 13:57
  • @CL. Ah, sorry, those are just normals calls without any flags, that is aplay sr003-02-2496.wav and mplayer sr003-02-2496.wav. And yes, I would like to use PulseAudio if possible.
    – tmnt
    May 13, 2013 at 13:58

6 Answers 6

8

Answering the two questions:

You can select the default device in PulseAudio with a GUI like the GNOME volume control, pavucontrol, or from the command line using pacmd set-default-sink.

By default, PulseAudio opens devices for 44.1 kHz or 48 kHz, whichever leads to lower resampling effort (so 96 kHz audio would usually lead to the device being opened at 48 kHz. Also, we open the devices for S16LE by default.

Now, you have two options. If you just want to play a few files at their native format, paplay --passthrough <file> should do the job for you. You can even specify which device to use.

The other option is to globally make PA use 96/24. You can change that in /etc/pulse/default.conf (alternate-sample-rate = 96000, default-sample-format=s24-32le). This will lead to greater CPU usage, though. This is a bit of a silly situation, having to apply global configuration for all devices. We're planning to add per-device configuration at some point.

Note, after this, you should just use mplayer's PulseAudio backend rather than have mplayer talk to ALSA and then ALSA to PulseAudio. You can do that with mplayer -ao pulse ... and if you want to set it up permanently, add ao=pulse to ~/.mplayer/config.

2
  • Thank you so much for your help! pacmd set-default-sink only lets me set one of the sinks listed by pacmd list-sinks though, right? Though I guess the second part of your answer makes that question moot anyway ;) So if I understand you correctly, Pulseaudio does not support dynamically switching between 24 and 16 bit? After changing my default.conf, mplayer still seems to resample everything to 16 bit before handing it over to pulse though (see here), is that because of what CL. describes in his answer?
    – tmnt
    May 14, 2013 at 17:06
  • Oh, and paplay doesn't seem to like my audio files :) Playing the 24 bit file leads to a segfault with Code should not be reached at pulsecore/sndfile-util.c:391, function pa_sndfile_readf_function(). Aborting., and playing a 32bit file even crashes Pulseaudio.
    – tmnt
    May 14, 2013 at 17:10
5

After the update to 13.10 Pulseaudio defaulted to HDMI, probably because I have an extra monitor attached to my laptop (Lenovo T430S) thru my mini-display port. The archlinux website provided a sweet and short answer to reset or set the default:

  • login and change the default output to analog

  • Run

    $ aplay -l

and find that analog is card 0

  • Run

    $ pacmd list

and find the line:

active profile: <output:analog-stereo+input:analog-stereo>

"output:analog-stereo+input:analog-stereo" is my profile name, so add

set-card-profile 0 output:analog-stereo+input:analog-stereo

in /etc/pulse/default.pa and save

  • restart pulseaudio
2

The sample format used in the interface between applications and PulseAudio is not always directly related with the sample format that PulseAudio uses to access the hardware device.

S24_3LE is not one of PulseAudio's supported application formats (as shown in the aplay output). To allow applications with such unusual formats to run with PulseAudio, add a plugin that does automatic format conversion if need for the default PCM device in your .asoundrc:

pcm.!default {
    type linear
    slave.pcm pulse
}
3
  • Thanks for your help, but I'm afraid this didn't change anything. Even after adding this to my .asoundrc, mplayer still downsamples the audio to 16 bit (i.e. the output looks the same as the one posted in my question) and /proc/asound/card1/stream0 still shows the wrong altset being used. If it was actually a problem with PA's supported formats, shouldn't mplayer downsample the audio even when specifying the ALSA device, since it still uses Pulseaudio?
    – tmnt
    May 13, 2013 at 14:43
  • Does aplay work now? This appears to be a bug in mplayer.
    – CL.
    May 13, 2013 at 16:05
  • No, aplay still fails with the same output. I've noticed now that by setting default-sample-format = s24-32le in my .pulse/daemon.conf I can force PA to use the correct output device. However, mplayer still resamples the audio, and aplay still fails when trying to play the 24 bit audio file, so I guess this doesn't help either.
    – tmnt
    May 13, 2013 at 17:29
2

Just a quick workaround I found out using Lubuntu Trusty Tahr with my Fiio E17 connected via USB: I was also wondering about the bitrate, that's why i found this posts here. But since I listen to music on a rather old Netbook, I did not want to set it to 96/24 by default (cpu is not the fastest) However, what worked for me was to use VLC, and specify in the expert audio settings to use the ALSA module for output, and then use the following output device: "Fiio USB DAC-E17, USB Audio Direct hardware device without any conversions"

This way, i was able to output 96/24 sound to the Fiio over USB when I wanted (also shows on the little screen of the Fiio) - and i did not have to change something more fundamental in the OS. Players like audacious or the browsers still use the default pulseaudio output. Sometimes VLC says that the device is already being used - then just close any other software like audacious, that is using e.g. the pulseaudio output, and it should work.

regards, Andi

1
2

Adding load-module module-alsa-source device=hw:1,0 to /etc/pulse/default.pa is the correct approach. However, the following modules have to be unloaded to avoid device conflicts (the initialization failed error you got):

  • module-udev-detect
  • module-detect

Take a careful look of your /etc/pulse/default.pa and remove lines contain those modules. Also, in this case devices cannot be automatically detected, so you want to load module-alsa-sink to specify a sink manually as well.

1
  • Would there be a conflict detect playback (sink) if only capture (source) devices are manually loaded?
    – Lucas
    Mar 4, 2017 at 1:25
1

Here's the correct answer to this question:

From ArchWiki

Determine the ALSA hw device you want to use. Then add this to your default.pa file. (Change 0,0 to suit your device.)

load-module module-alsa-sink device=hw:0,0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .