Skip to content
Roderick van Domburg edited this page Sep 27, 2021 · 52 revisions
Type Short Long Description Hint
Option h help Print a list of options and flags.
Option c cache Path to a directory where files will be cached. PATH
Option system-cache Path to a directory where system files (credentials, volume) will be cached. Can be different from cache option value. PATH
Option cache-size-limit Limits the size of the cache for audio files. It's possible to use suffixes like K, M or G. SIZE
Flag disable-audio-cache Disable caching of the audio data.
Option n name Device name NAME
Option device-type The displayed device type in Spotify clients: unknown, computer, tablet, smartphone, speaker, tv, avr (Audio/Video Receiver), stb (Set-Top Box), audiodongle. Defaults to speaker. TYPE
Option b bitrate Bitrate (kbps): 96, 160, 320. Defaults to 160. BITRATE
Option onevent The path to a script that gets run when one of librespot's events is triggered. PROGRAM
Flag emit-sink-events Run program set by onevent before sink is opened and after it is closed.
Option V version Display librespot version string.
Flag v verbose Enable verbose output PROGRAM
Option u username Username to sign in with. USERNAME
Option p password Password PASSWORD
Option proxy Use a proxy for HTTP requests. Proxy should be an HTTP proxy in the form http://ip:port, and can also be passed using the all-lowercase http_proxy environment variable. URL
Option ap-port Connect to AP with specified port. If no AP with that port are present fallback AP will be used. Available ports are usually 80, 443 and 4070. PORT
Flag disable-discovery Disable discovery mode
Option backend Audio backend to use. Use '?' to list options NAME.
Option device Audio device to use. Use '?' to list options (Only with the rodio/portaudio/alsa backends) NAME
Option format Output format: F64, F32, S32, S24, S24_3, S16. Defaults to S16. FORMAT
Option dither Dither algorithm: none, gpdf, tpdf, tpdf_hp. Defaults to tpdf for formats S16 , S24 , S24_3 and none for other formats. TYPE
Option m mixer Mixer to use: softvol, alsa. Defaults to softvol. MIXER
Option alsa-mixer-control alsa mixer control e.g PCM or Master. Defaults to PCM. NAME
Option alsa-mixer-device alsa mixer device, e.g hw:0 or similar from aplay -l. Defaults to --device if specified, default otherwise. DEVICE
Option alsa-mixer-index alsa mixer index, Index of the cards mixer. Defaults to 0. NUMBER
Option initial-volume Initial volume in % from 0-100. Default for softvol: 50. For the Alsa mixer: the current volume. VOLUME
Option zeroconf-port The port that the HTTP server advertised on zeroconf will use from 1-65535. Ports <= 1024 may require root privileges. PORT
Flag enable-volume-normalisation Enables volume normalisation for librespot
Option normalisation-method Specify the normalisation method to use: basic, dynamic. Defaults to dynamic. METHOD
Option normalisation-gain-type Specify the normalisation gain type to use: track, album. Defaults to album. TYPE
Option normalisation-pregain Pregain (dB) applied by the normalisation. Defaults to 0. PREGAIN
Option normalisation-threshold Threshold (dBFS) to prevent clipping. Defaults to -1.0. THRESHOLD
Option normalisation-attack Attack time (ms) in which the dynamic limiter is reducing gain. Defaults to 5. TIME
Option normalisation-release Release or decay time (ms) in which the dynamic limiter is restoring gain. Defaults to 100. TIME
Option normalisation-knee Knee steepness of the dynamic limiter. Default is 1.0. KNEE
Option volume-ctrl Volume control type cubic, fixed, linear, log. Defaults to log. VOLUME_CTRL
Option volume-range Range of the volume control (dB). Default for softvol: 60. For the Alsa mixer: what the control supports.
Flag autoplay Autoplay similar songs when your music ends.
Flag disable-gapless Disables gapless playback by forcing the sink to close between tracks.
Flag passthrough Pass raw stream to output, only works for pipe and subprocess backends.

Volume normalisation

librespot supports ReplayGain volume normalisation, with the ReplayGain values provided by Spotify in the Ogg streams. As of librespot 0.2.0, there are two types of volume normalisation methods available:

Basic

The volume is increased or decreased as per the average ReplayGain of that track or its album. If that would result in peaks over a certain threshold (hard-coded at 0 dBFS for librespot up to 0.1.6; -1 dBFS and configurable as of librespot 0.2.0), then the volume increase is limited so that the peak is exactly 0 dBFS. This gain is fixed for the entire duration of the track.

This is the only limiter available in librespot up to 0.1.6.

Dynamic

(as of librespot 0.2.0)

Again the volume is increased or decreased as per the average ReplayGain of that track or its album. However, if this now results in peaks over the threshold (-2 dBFS by default), the gain is dynamically reduced for the duration of that peak, then recovered to the original target gain. This length of the attack and release for this reduction and recovery from zero to full effect by default mimic the Spotify client, and are configurable.

During the attack and release period, the rate of change from zero to full effect (the "knee") has a configurable steepness. By default this is 1.0, which means a linear slope. Values above 1.0 yield softer knees with a more gentle start and end but steeper rate of change mid-way. Values below 1.0 start and stop more sharply, and are flatter in between. Values of 0.0 and below first give an impulse response, then invert the limiter, and should not be used.

The equivalent librespot options to match the volume normalisation settings in official Spotify clients are:

Loud

--enable-volume-normalisation --normalisation-pregain 3

Normal (Default)

--enable-volume-normalisation --normalisation-pregain 0

Quiet

--enable-volume-normalisation --normalisation-pregain -9

Output format

librespot up to 0.1.6 always outputs 16-bit samples, except for JACK Audio where it converts to 32-bit output after volume control.

As of librespot 0.2.0, the audio output is still 16-bit by default, but can be configured to output 32-bit floating point (F32), 32-bit integer (S32), 24-bit PCM in a 32-bit word (S24) or 24-bit integer packed as three bytes (S24_3). Software volume control and normalisation is done before sample conversion, so that there is no loss of dynamic range.

Mixer

By default, volume control will be done using the software volume mixer.

As of librespot 0.3.0, softvol and the rest of the audio sample pipeline completely works in 64-bit floating point. While some audiophiles may prefer to do volume control in hardware, a 64-bit pipeline is completely transparent and quite likely better than the 32-bit signed integer many hardware DACs work in.

There may be other valid reasons to use the alsa mixer, however:

  • Keeping the current playback volume instead of overwriting it with initial-volume (this is especially useful when you are switching back and forth librespot and other audio renderers).

  • Latching off the mute / unmute switch; librespot will toggle mute on hardware devices that support it when volume is dialed back to 0.

For the purists, you can use --mixer softvol --volume-ctrl fixed --initial-volume 100 to completely bypass volume control.

Volume control

As of librespot 0.3.0, the cubic volume control is available on both the softvol and alsa mixers (before 0.3.0, only on alsa). Cubic is like log, but has a bit more fine-grained control in the upper volume range. The specifics are documented here.

Librespot 0.3.0 also fixed the way --mixer alsa handles linear and log volume controls. Before 0.3.0, you have to set --volume-ctrl linear to get a log control; you can't get a true linear control and doing --volume-ctrl log doesn't work correctly. This is no longer the case from 0.3.0 onwards.

Note that just setting --backend alsa still uses librespot softvol. You also need to set --mixer alsa if you want to have volume control done by Alsa or in hardware. Note that softvol is recommended unless you have specific requirements. As of librespot 0.3.0, softvol works in 64-bit floating point which is better than most hardware implementations, even if you have a 32-bit DAC.

Dithering

(as of librespot 0.3.0)

librespot supports dithering to lower the requantisation errors, that is caused by converting digital (ones and zeroes) to analog audio (continuous waveforms). Doing so lowers distortion and improves audio quality.

  • On S24, S24_3 and S24, the default is to use triangular dithering. Depending on personal preference you may use Gaussian dithering instead; it's not as good objectively, but it may be preferred subjectively if you are looking for a more "analog" sound akin to tape hiss.

  • Advanced users who know that they have a DAC without noise shaping have a third option: high-passed dithering, which is like triangular dithering except that it moves dithering noise up in frequency where it is less audible. Note: 99% of DACs are of delta-sigma design with noise shaping, so unless you have a multibit / R2R DAC, or otherwise know what you are doing, this is not for you.

  • Don't dither or shape noise on S32 or F32. On F32 it's not supported anyway (there are no integer conversions and so no rounding errors) and on S32 the noise level is so far down that it is simply inaudible even after volume normalisation and control.

Clone this wiki locally