Squeezelite Documentation

repository·master·Indexed 18 days ago

https://github.com/ralph-irving/squeezelite

A lightweight, high-performance client for Logitech Media Server (LMS) designed to turn hardware into audio players. Squeezelite supports DSD via dsd2pcm and the Daphile Project DSD patch, server-side upsampling for PCM streams, and integration with FFmpeg and OpenSSL. It features a command-line interface for configuring audio output devices (ALSA, PortAudio, MacOS, Windows), managing SoX Resampler settings, controlling logging levels, and handling hardware power via GPIO or scripts.

Tokens
3.7K
Snippets
9
Records
10
Agent score
55%

What's inside Squeezelite

  1. Overview of Squeezelite

    master

    Squeezelite is a software player designed to act as a client for Logitech Media Server (LMS). It is distributed under the GNU General Public License version 3.

    Key features and dependencies include:

    • Support for DSD via the dsd2pcm library and the Daphile Project DSD patch.
    • Server-side upsampling for PCM streams (via the -W option, originally from squeezelite-R2).
    • Integration with FFmpeg libraries for media processing.
    • Support for OpenSSL for secure communications.
  2. How GPIO and Power Scripts work in Squeezelite

    master

    Squeezelite can control hardware (like an amplifier relay) based on power commands received from the Logitech Media Server (LMS). There are two ways to handle this:

    1. Direct GPIO Control (-G): Specify a GPIO chip and line number. You must also specify if the signal is Active High (H) or Active Low (L).
    2. Power Scripts (-S): Provide an absolute path to a script. Squeezelite will execute this script when power commands are received.

    Note: You cannot use -G and -S at the same time.

    # Use GPIO to trigger a relay on chip 0, line 18, Active High
    squeezelite -G 0:18:H
    
    # Use a custom script for power management
    squeezelite -S /home/pi/scripts/power_control.sh
  3. Configure upsampling and resampling with -u / -R

    master

    Squeezelite uses the SoX Resampler library for audio upsampling. Enable it using -u or -R. The argument follows a specific colon-delimited recipe format:

    <recipe>:<flags>:<attenuation>:<precision>:<passband_end>:<stopband_start>:<phase_response>

    Recipe Flags

    • v, h, m, l, q: Quality (Very High, High, Medium, Low, Quick). Default is hL.
    • L, I, M: Phase (Linear, Intermediate, Minimum).
    • s: Change resampling bandwidth from 95% to 99%.
    • E: Exception - avoid resampling if the device supports the rate natively.
    • X: Asynchronous resampling to the maximum device rate.

    Argument Components

    • flags: Hex values from isoxr.h (e.g., 2 for SOXR_ROLLOFF_NONE, 16 for SOXR_DOUBLE_PRECISION).
    • attenuation: Attenuation in dB (e.g., ::0 disables the default -1db attenuation; ::6 applies -6db).
    • precision: Internal bit precision (e.g., :::28 for 28-bit).
    • passband_end: Percentage of Nyquist frequency (default 91.3).
    • stopband_start: Percentage of Nyquist frequency (default 100).
    • phase_response: 0-100 scale (0=Minimum, 25=Intermediate, 50=Linear).
    squeezelite -u vLs
    squeezelite -u hMX
    squeezelite -u hL:2
    squeezelite -u ::6
    squeezelite -u ::::98
  4. List and select audio output devices

    master

    Use the -l option to list all available audio output devices to stdout and exit. Once you have identified the desired device name, use the -o option to specify it for playback. If no device is specified, Squeezelite defaults to default.

    squeezelite -l
    squeezelite -o "Your Device Name"
  5. Configure Squeezelite Output Devices

    master

    You can specify where the audio is sent using the -o flag. By default, it uses the system's "default" device. To output raw audio samples to stdout, use -o -. To see a list of available output devices on your system, use the -l flag.

    If using the ALSA backend, you can further refine output using:

    • -a <b>:<p>:<f>:<m>: Specify buffer time, period count, sample format (16|24|24_3|32), and mmap usage.
    • -O <mixer device>: Specify a specific mixer device.
    • -L: List volume controls for the output device.
    • -V <control>: Use a specific ALSA control for volume adjustment.
    • -X: Use linear volume adjustments instead of dB (for hardware volume control).
    # Output to stdout
    squeezelite -o - -a 16
    
    # List available devices
    squeezelite -l
  6. Configure Squeezelite Logging Levels

    master

    Logging can be controlled via the -d flag using the format <log>=<level>. You can target specific subsystems or use all to set the level for everything.

    Available Loggers:

    • all
    • slimproto
    • stream
    • decode
    • output
    • ir (if IR support is enabled)

    Available Levels:

    • info
    • debug
    • sdebug
    # Set all logs to debug
    squeezelite -d all=debug
    
    # Set only slimproto and output to info
    squeezelite -d slimproto=info -d output=info
  7. Set logging levels and categories

    master

    Use the -d <category>=<level> option to control logging. You can repeat this option to set different levels for different categories.

    Categories: all, slimproto, stream, decode, output, ir Levels: info, debug, sdebug

    To redirect logs to a file instead of stdout/stderr, use -f <logfile>.

    squeezelite -d slimproto=debug -d output=info -f /var/log/squeezelite.log
  8. Configure audio output parameters with -a

    master

    The -a <params> option allows you to pass specific parameters to the audio backend when opening a device. The format depends on the operating system:

    ALSA

    Format: <b>:<p>:<f>:<m>:<d>

    • <b>: Buffer time in ms (default 40) or size in bytes.
    • <p>: Period count (default 4) or size in bytes.
    • <f>: Sample format (16, 24, 24_3, or 32).
    • <m>: Use mmap (0 or 1).
    • <d>: Open ALSA output device twice (0 or 1).

    Linux PortAudio

    Format: <l>

    • <l>: Target latency in milliseconds.

    MacOS

    Format: <l>:<r>

    • <l>: Target latency in milliseconds.
    • <r>: Mode (0 for Pro Mode, 1 for Play Nice).

    Windows

    Format: <l>:<e>

    • <l>: Target latency in milliseconds.
    • <e>: Use WASAPI exclusive mode (0 or 1).

    Standard Output

    Format: <bits>

    • Denotes sample size in bits (16, 24, or 32). Little Endian only.
    squeezelite -o hw:CARD=USB,DEV=0 -a 40:4:24:1:0
  9. Reference: Squeezelite Command Line Options

    master

    A complete list of command-line options available for Squeezelite.

    -?                Show a summary of the available command-line options.
    -s <server>[:<port>] Connect to the specified Lyrion Music Server.
    -o <output device> Specify the audio output device.
    -l                 List available audio output devices to stdout and exit.
    -a <params>        Specify parameters used when opening an audio output device.
    -b <stream>:<output> Specify internal stream and output buffer sizes in KB.
    -c <codec1>,...    Restrict codecs to those specified.
    -C <timeout>       Close the output device after <timeout> seconds of idle.
    -d <category>=<level> Set logging level.
    -e <codec1>,...    Explicitly exclude native support of one or more codecs.
    -f <logfile>       Send logging output to a log file.
    -G <GPIO Chip>:<GPIO#>:<H/L> Specify kernel gpio chip, Line#, and H/L state.
    -i [<filename>]    Enable LIRC remote control support.
    -m <mac addr>      Override the player's MAC address.
    -M <modelname>     Override the player's hardware model name.
    -n <name>          Set the player name (mutually exclusive with -N).
    -N <filename>      Allow server to set player name via file (mutually exclusive with -n).
    -O <mixer device>  Specify mixer device.
    -p <priority>      Set real time priority of output thread (1-99).
    -P <filename>      Write the process ID (PID) number to a file.
    -r <rates>[:<delay>] Specify sample rates supported by the output device.
    -S <power script> Absolute path to script for power commands.
    -u|-R [params]     Enable upsampling of played audio.
    -D [delay][:format] Output device supports DSD over PCM (DoP) or native.
    -v                 Enable visualiser support.
    -W                 Read wave and aiff format from header.
    -L                 List available volume controls (ALSA only).
    -U <control>      Unmute and set ALSA <control> to full volume.
    -V <control>      Use ALSA <control> for volume adjustment.
    -X                 Use linear volume adjustments instead of dB.
    -z                 Run as a daemon.
    -Z <rate>          Report max sample rate to server in helo.
    -t                 Display version and license information.
  10. Squeezelite CLI Reference

    master

    Squeezelite is a lightweight headless squeezebox emulator. It is controlled via command-line arguments. Below is a comprehensive list of available options. Note that availability of certain flags depends on how the binary was compiled (e.g., ALSA, PortAudio, DSD, GPIO, etc.).

    # Core Connectivity and Output
    -s <server>[:<port>]    Connect to specified server, otherwise uses autodiscovery
    -o <output device>      Specify output device, default "default", - = output to stdout
    -l                       List output devices
    -b <stream>:<output>    Specify internal Stream and Output buffer sizes in Kbytes. Default is %d:%d
    
    # Codec and Sample Rate Control
    -c <codec1>,<codec2>    Restrict codecs to those specified; known codecs: [LIST_OF_CODECS]
    -e <codec1>,<codec2>    Explicitly exclude native support of one or more codecs
    -r <rates>[:<delay>]    Sample rates supported (e.g., <maxrate> or <minrate>-<maxrate> or <rate1>,<rate2>); delay = optional delay switching rates in ms
    -W                       Read wave and aiff format from header, ignore server parameters
    -Z <rate>                Report rate to server in helo as the maximum sample rate supported
    
    # Player Identity
    -m <mac addr>            Set mac address, format: ab:cd:ef:12:34:56
    -M <modelname>           Set the squeezelite player model name sent to the server
    -n <name>                Set the player name
    -N <filename>           Store player name in filename for sharing between servers
    
    # Logging and Debugging
    -d <log>=<level>         Set logging level. Logs: all|slimproto|stream|decode|output|ir. Levels: info|debug|sdebug
    -f <logfile>            Write debug to logfile
    
    # Advanced Audio and Resampling
    -a <params>              Specify output device parameters (syntax varies by backend: ALSA, PortAudio, etc.)
    -R -u [params]           Resample. params = <recipe>:<flags>:<attenuation>:<precision>:<passband_end>:<stopband_start>:<phase_response>
    -D [delay][:format]     DSD support: delay = optional delay switching between PCM and DSD/DoP; format = dop, u8, u16le, u16be, u32le, u32be, dop24, dop24_3
    
    # System and Hardware
    -z                       Daemonize
    -P <filename>            Store the process id (PID) in filename
    -G <chip>:<line>:<H/L>   GPIO: Specify chip, line, and Active High (H) or Low (L) for Amp Power Relay
    -S <Power Script>       Absolute path to script to launch on power commands from LMS
    -i [<filename>]         Enable lirc remote control support