Home of the Squeezebox™ & Transporter® network music players.
Results 1 to 4 of 4
  1. #1
    Senior Member
    Join Date
    Mar 2006
    Location
    London
    Posts
    531

    Squeezelite -a <b>:<p>:<f>:<m> - can anyone explain this option?

    Hi - running SqueezeLite and LMS 8.1.2 (latest versions) on my Pi4 I found there was serious rebuffering on my Pi and SB3s earlier this year when playing FLACs unless I specified "-a :::0". More recently I noticed some background/popping noise on the Pi's headphone jack unless I specified "-a 120:4::0".

    The wiki says the following about the -a option: "-a <b>:<p>:<f>:<m> Specify ALSA params to open output device, b = buffer time in ms or size in bytes, p = period count or size in bytes, f sample format (16|24|24_3|32), m = use mmap (0|1)
    https://www.max2play.com/en/wiki/com...r-squeezelite/

    Frankly I have no idea what this means!
    - which buffer is affected and how do I know if the specified numbers are in ms or bytes?
    - what is "period count"
    - which sample format? Surely the FLAC is what it is?
    - what is mmap?

    Any insights, or just a reference page, would be much appreciated so I can understand more as to what is going on.

    R
    SB3 -> Quad 909 -> Quad Electrostatic speakers, Quad 405 -> TBI subwoofer
    3 x SB3s + SB Radio
    LMS on Raspbian on a Pi4
    Rotel RSP1068 surround processor, Quad 707 -> B&W surround

  2. #2
    Senior Member
    Join Date
    Apr 2005
    Location
    UK/London
    Posts
    4,771
    There is a bit more explanation on Ralphy's github page

    "For ALSA, the format <b>:<p>:<f>:<m>:<d> is used where

    <b> is the buffer time in milliseconds (values less than 500) or size in bytes (default 40ms);

    <p> is the period count (values less than 50) or size in bytes (default 4 periods);

    <f> is the sample format (possible values: 16, 24, 24_3 or 32);

    <m> is whether to use mmap (possible values: 0 or 1).

    <d> open ALSA output device twice. (possible values: 0 or 1)."

    https://ralph-irving.github.io/squeezelite.html

    ALSA mmap
    https://www.alsa-project.org/alsa-do...___direct.html
    Paul Webster
    http://dabdig.blogspot.com
    Author of "Now Playing" plugins covering Radio France (FIP etc), PlanetRadio (Bauer - Kiss, Absolute, Scala, JazzFM etc), KCRW, ABC Australia, CBC/Radio-Canada and RTE Ireland
    and, via the extra "Radio Now Playing" plugin, AllZIC Radio, Caroline Flashback, Cesky rozhlas, Frequence3, JukeRadio, KlassikRadio.de, Linn Radio, Mother Earth, Naim Radio, Nova.fr, RadioBlues Flac, Radio Espace, Somehow Jazz, Supla Finland

  3. #3
    Senior Member
    Join Date
    Oct 2005
    Location
    Ireland
    Posts
    20,801
    my basic understanding.

    PCM Audio is sent via ALSA interface to ALSA device driver.

    Audio samples are put into a ring buffer.
    The ring buffer size is controlled by the buffer parameter.
    The ring buffer is processed in terms of periods (i.e there x periods in the whole buffer).
    A period the number of frames per h/w interrupts (edit: corrected from first post)
    I don't know how samples are fitted into frames.

    The audio samples can either be copied into buffer using API Read/write or the buffer can be memory mapped into calling process memory so no additional copying of audio data.

    These are all hardware paramaters and so valid values are dependent on the audio device.

    edit:

    Found an explanation of frames and periods.
    A frame is equivalent of one sample being played, irrespective of the number of channels or the number of bits. e.g.

    1 frame of a Stereo 48khz 16bit PCM stream is 4 bytes.
    1 frame of a 5.1 48khz 16bit PCM stream is 12 bytes.

    A period is the number of frames in between each hardware interrupt. The poll() will return once a period.

    The buffer is a ring buffer. The buffer size always has to be greater than one period size. Commonly this is 2*period size, but some hardware can do 8 periods per buffer. It is also possible for the buffer size to not be an integer multiple of the period size.

    Now, if the hardware has been set to 48000Hz , 2 periods, of 1024 frames each, making a buffer size of 2048 frames. The hardware will interrupt 2 times per buffer. ALSA will endeavor to keep the buffer as full as possible. Once the first period of samples has been played, the third period of samples is transfered into the space the first one occupied while the second period of samples is being played. (normal ring buffer behaviour).
    https://www.alsa-project.org/main/in.../FramesPeriods

    edit 2:

    Working link to writing-an-alsa-driver.pdf https://www.ibr.cs.tu-bs.de/theses/k...lsa-driver.pdf
    Last edited by bpa; 2021-07-19 at 03:13.

  4. #4
    Senior Member
    Join Date
    Mar 2006
    Location
    London
    Posts
    531
    Quote Originally Posted by bpa View Post
    my basic understanding.

    PCM Audio is sent via ALSA interface to ALSA device driver.

    Audio samples are put into a ring buffer.
    The ring buffer size is controlled by the buffer parameter.
    The ring buffer is processed in terms of periods (i.e there x periods in the whole buffer).
    A period the number of frames per h/w interrupts (edit: corrected from first post)
    I don't know how samples are fitted into frames.

    The audio samples can either be copied into buffer using API Read/write or the buffer can be memory mapped into calling process memory so no additional copying of audio data.

    These are all hardware paramaters and so valid values are dependent on the audio device.

    edit:

    Found an explanation of frames and periods.


    https://www.alsa-project.org/main/in.../FramesPeriods

    edit 2:

    Working link to writing-an-alsa-driver.pdf https://www.ibr.cs.tu-bs.de/theses/k...lsa-driver.pdf
    That's great and it makes a lot more sense now. Thanks very much!
    SB3 -> Quad 909 -> Quad Electrostatic speakers, Quad 405 -> TBI subwoofer
    3 x SB3s + SB Radio
    LMS on Raspbian on a Pi4
    Rotel RSP1068 surround processor, Quad 707 -> B&W surround

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •