12

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:

tmnt
  • 223

6 Answers6

9

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.

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
3

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
}
CL.
  • 1,795
3

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

Andi
  • 31
3

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.

2

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
Hydranix
  • 151