-
Notifications
You must be signed in to change notification settings - Fork 613
Audio Backends
librespot supports various audio backends. Multiple backends can be enabled at compile time by enabling the corresponding cargo feature. By default, only Rodio is enabled.
See the Compiling page for information on building specific backends into librespot.
--backend Is used to select the audio playback engine.
The following backends are currently available:
- Rodio (Default)
- Uses ALSA on linux, so development packages are required to build.
- Mac OS and Windows should work out of the box.
- ALSA
--backend alsa
- Linux build dependencies:
libasound2-dev
on Debian andalsa-lib-devel
on Fedora
- Linux build dependencies:
- PortAudio
--backend portaudio
- PulseAudio
--backend pulseaudio
- JACK
--backend jackaudio
- SDL
--backend sdl
- Pipe
--backend pipe
- Always included during compilation, will require a separate solution to play back the audio.
--device Is used to select a specific audio device. Some backends will list available audio devices when passing --device ?
.
Most backends don't require specific setup and try to have sane defaults.
The right device needs to be passed to librespot
via the --device
flag. The alsa
terminology of hw:X,Y
is used, where X
is the card number, and Y
is the device number. This can be determined by:
~/librespot$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC3234 Analog [ALC3234 Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 3: HDMI 0 [HDMI 0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 7: HDMI 1 [HDMI 1]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 8: HDMI 2 [HDMI 2]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 9: HDMI 3 [HDMI 3]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 10: HDMI 4 [HDMI 4]
Subdevices: 1/1
Subdevice #0: subdevice #0
# To determine the right mixer name for your card, try
~/librespot$ amixer --device "hw:0" --card "0" # Results truncated here
Simple mixer control 'Master',0
Capabilities: pvolume pvolume-joined pswitch pswitch-joined
Playback channels: Mono
Limits: Playback 0 - 87
Mono: Playback 64 [74%] [-17.25dB] [on]
Simple mixer control 'Headphone',0
Capabilities: pswitch
Playback channels: Front Left - Front Right
Mono:
Front Left: Playback [off]
Front Right: Playback [off]
Simple mixer control 'PCM',0
Capabilities: pvolume
Playback channels: Front Left - Front Right
Limits: Playback 0 - 255
Mono:
Front Left: Playback 2 [1%] [-50.60dB]
Front Right: Playback 2 [1%] [-50.60dB]
Thus, in this example the settings would be:
./target/release/librespot [] --backend alsa \
--device="hw:0,0" \
--mixer="alsa" --mixer-card="hw:0" --mixer-name="Master" \
NOTE: You might want to turn on --linear-volume
when utilising a hardware mixer with Librespot
The pipe back-end requires very minimal setup provided you have an audio player which can accept and process the output correctly.
The pipe outputs the data as raw stereo 16bit 44.1KHz bytes. This is true for any bitrate (quality) setting.