Home of the Squeezebox™ & Transporter® network music players.
Page 1 of 5 123 ... LastLast
Results 1 to 10 of 45
  1. #1
    Senior Member
    Join Date
    Mar 2007
    Location
    UK
    Posts
    1,293

    Dithered volume control for Squeezebox

    Edit: updated for V0.5.

    Note: if you are using a standard LMS/Touch set up always with volume above 40 and only 16 bit music, this mod isn't for you.

    What you get
    - Volume control via phone/tablet apps and web UI.
    - Support for FLAC - volume change is immediate though there is a small pause whilst the stream resumes server-side via SoX.
    - Support for Qobuz streaming - volume change is not immediate but takes effect on track change/restart (i.e. new internet stream).
    - Other formats work only partially (MP3, OGG Vorbis, WAV) or are in development/untested (Spotify).
    - Volume control via SoX dithered at 24 bits, no player attenuation.
    - Each volume step is 0.5dB.
    - Volume 0 is -50dB (not off).

    Notes
    - If you have 32 bit DAC with internal volume control then use that instead
    - The convert.conf is set up for 24 bit volume control
    - If you have a 16 bit DAC then you can alter the convert.conf yourself, or contact me for help
    - You must use phone/tablet apps or web UI to change volume. Using the client volume controls (touch screen or IR remote) will reset volume to maximum on the server! For this reason you must use VolumeLock plugin to protect against inevitable accidents (first step below). To avoid accidents, I recommend not using the IR remote. (If using the Display Off app [recommended] then see http://forums.slimdevices.com/showth...473#post872473.)
    - The files are patched based on 7.7.6 and 7.9. If you need a patch for a different version, PM me and I will provide them.
    - This hack is really for my use, and I only care about FLAC and Qobuz. I could keep this to myself but I'm sharing it.

    Steps (assuming Linux)
    1. Install VolumeLock via Settings > Plugins
    2. Set volume to the desired maximum (don't choose anything above 90).
    3. Set max volume level via Settings > Player > VolumeLock player settings > 'Set current volume as maximum' > Apply
    4. Set player volume level fixed to 100%
    4b. Settings > Player > Audio > Volume Control > 'Output level is fixed at 100%' > Apply
    5. For MP3 support you should install the package 'libsox-fmt-mp3'.
    6. Patch convert.conf - see below.
    7. Patch perl files – see below.
    8. Restart LMS.
    9. Verify.
    9a. Settings > Advanced > File Types
    9b. Check that FLAC-FLAC says 'flac/sox', others in the group disabled
    9c. Check that MP3-FLAC says 'sox/sox', others in the group disabled
    9d. Check that Ogg Vorbis-FLAC says 'sox/sox', others in the group disabled
    9e. Check that PCM-PCM says 'sox/sox'
    9f. Check that Spotify-FLAC says 'flac/sox' and Spotify-PCM says 'flac/sox'
    9g. Check the WAV-FLAC says 'sox/sox', others in the group disabled
    9h. Apply.
    10. After every client boot up, the volume will be at the max set by VolumeLock. Check volume before enjoying.

    Where can I get the files?
    https://www.dropbox.com/sh/adikz760h...jVehkd7Va?dl=0.

    Copy originals first!:
    - convert.conf should replace that found in /etc/squeezeboxserver
    - Spotify/custom-convert.conf should replace that found in /var/lib/squeezeboxserver/cache/InstalledPlugins/Plugins/Spotify
    - *.pm files found under the structure in Slim, should replace those found in the equivalent locations in /usr/share/perl5/Slim

    Technical problems
    PM me. If I identify common issues I'll edit or add to this thread.

    Regards,
    Darren
    Last edited by darrenyeats; 2017-10-23 at 03:58.
    Check it, add to it! http://www.dr.loudness-war.info/

    SB Touch

  2. #2
    Senior Member
    Join Date
    Mar 2007
    Location
    UK
    Posts
    1,293

    How does it work?

    Edit: updated for V3.0.

    Fixing client volume to 100 disables the attenuation on the client, however, the server-side volume can still be adjusted (it simply will not be pushed to client).

    But any time you reset the volume from the client end, the client pushes its volume (100) to the server. Same goes for system boot up. This is why client volume controls must be avoided. Also this is why VolumeLock plugin must be used - it near-instantly reduces to the set limit the server volume (but not the client volume which is always 100).

    The gain adjustment is achieved by adding to the Perl code for convert.conf a new capability, 'A', that is connected to server volume, and using this in convert.conf to control SoX gain value. Then, SoX volume changes when convert.conf is reapplied (“tokenized”) in the code. Usually this would happen only on events such as track skip or seek, but a call to tokenize has been added to the code for volume change.

    The capability 'A' can be added for other codecs and even in other 'convert.conf's, I think. Have a look at the convert.conf to get the idea.

    I developed the changes by soft linking from my LMS install into my git clone of the slimserver repo. There was no tag for 7.7.6 though by my reckoning the commit for 7.7.6 (or near enough) was 1269a64. I branched from there. So I can I patch these changes to other branches. I could even put in a pull request to the project but a hack in this form is in no fit state for that.

    Anybody got a better idea? Or does a developer want to take the idea and re-code something that's less of a hack? In my defense, I'm not a developer (though I know Perl). And I'm too busy.

    Regards,
    Darren
    Last edited by darrenyeats; 2017-05-28 at 04:09. Reason: Clarification
    Check it, add to it! http://www.dr.loudness-war.info/

    SB Touch

  3. #3
    Senior Member
    Join Date
    Apr 2010
    Posts
    743
    Quote Originally Posted by darrenyeats View Post
    Fixing client volume to 100 disables the attenuation on the client, however, the server-side volume can still be adjusted (it simply will not be pushed to client).

    But any time you reset the volume from the client end, the client pushes its volume (100) to the server. Same goes for system boot up. This is why client volume controls must be avoided. Also this is why VolumeLock plugin must be used - it near-instantly reduces to the set limit the server volume (but not the client volume which is always 100).

    The gain adjustment is achieved by adding to the Perl code for convert.conf a new capability, 'G', to control sox gain value. Also, convert.conf has to use the capability correctly. This is why volume is applied on new track, prev/next track and skipping in the track ľ this is when convert.conf is reapplied (ôtokenizedö) in the code.

    The capability G can be added for other codecs and even in other 'convert.conf's, I think. Have a look at the convert.conf to get the idea.

    I developed the changes by soft linking from my LMS install into my git clone of the slimserver repo. There was no tag for 7.7.6 though by my reckoning the commit for 7.7.6 (or near enough) was 1269a64. I branched from there. So I can I patch these changes to other branches. I could even put in a pull request to the project but a hack in this form is in no fit state for that.

    Anybody got a better idea? Or does a developer want to take the idea and re-code something that's less of a hack? In my defense, I'm not a developer (though I know Perl). And I'm too busy.

    Regards,
    Darren
    Interesting idea Darren. Does the native LMS volume control not dither?
    Will this work for any LMS platform (eg QNAP). Could you produce a version for 7.9. I'm guessing that most people are on that these days.

  4. #4
    Senior Member
    Join Date
    Mar 2007
    Location
    UK
    Posts
    1,293
    Adam,
    Quote Originally Posted by adamdea View Post
    Does the native LMS volume control not dither?
    No.
    Quote Originally Posted by adamdea View Post
    Will this work for any LMS platform (eg QNAP)
    I think so, if you're able to do the equivalent of all the listed steps.
    Quote Originally Posted by adamdea View Post
    Could you produce a version for 7.9.
    Have a look in Dropbox (post 1) there are now folders for 7.7.6 and 7.9. I renamed the capability to A (done in both) since G is used for something else in 7.9.

    The git repo doesn't have a label for 7.9.x, so I just merged onto head of public/7.9, which is the latest and greatest. Anyway I don't have 7.9 installed but give it a try.
    Darren
    Last edited by darrenyeats; 2015-11-16 at 15:21.
    Check it, add to it! http://www.dr.loudness-war.info/

    SB Touch

  5. #5
    Senior Member
    Join Date
    Mar 2007
    Location
    UK
    Posts
    1,293
    New Dropbox link in post 1. Also folder structure includes versions.
    Check it, add to it! http://www.dr.loudness-war.info/

    SB Touch

  6. #6
    Senior Member
    Join Date
    Apr 2010
    Posts
    743
    Quote Originally Posted by darrenyeats View Post
    Adam,

    No.

    I think so, if you're able to do the equivalent of all the listed steps.

    Have a look in Dropbox (post 1) there are now folders for 7.7.6 and 7.9. I renamed the capability to A (done in both) since G is used for something else in 7.9.

    The git repo doesn't have a label for 7.9.x, so I just merged onto head of public/7.9, which is the latest and greatest. Anyway I don't have 7.9 installed but give it a try.
    Darren
    Thanks Darren I'm a a bit tied up for a couple of days but will give it is try then.

  7. #7
    Senior Member Wombat's Avatar
    Join Date
    Feb 2006
    Posts
    1,120
    A simple volume change only creates an absolutely small rounding error.
    Did you check if a volume change of a 16bit file and playing the 24bit result without dither has more degration as the noise from dither. I doubt this but to be honest didn't try hard
    Transporter (modded) -> RG142 -> Avantgarde Acoustic based 500VA monoblocks -> Sommer SPK240 -> self-made speakers

  8. #8
    Senior Member
    Join Date
    Mar 2007
    Location
    UK
    Posts
    1,293
    Wombat,
    Quote Originally Posted by Wombat View Post
    A simple volume change only creates an absolutely small rounding error.
    Agreed.
    Quote Originally Posted by Wombat View Post
    Did you check if a volume change of a 16bit file and playing the 24bit result without dither has more degration as the noise from dither. I doubt this but to be honest didn't try hard
    Dither adds noise around the LSB (least significant bit) in this case 24th bit. But truncation adds distortion (very non-harmonic at that) around the same level. Noise is far more benign than any type of distortion, let alone non-harmonic distortion.

    Dither is the correct way to do digital volume control.

    A valid question, as you wrote, is can you hear it? I'm trying to side-step that because I don't want to create an argument here. For me, it's enough to know it's technically better and I can have it for free ... I love the LMS platform!
    Darren
    Last edited by darrenyeats; 2015-11-17 at 15:07.
    Check it, add to it! http://www.dr.loudness-war.info/

    SB Touch

  9. #9
    Senior Member Wombat's Avatar
    Join Date
    Feb 2006
    Posts
    1,120
    I'm still not convinced nor do i have hard numbers but SoX does by purpose not dither in such cases. I may create a delta file of the added distortion against the dither when i am bored.
    Transporter (modded) -> RG142 -> Avantgarde Acoustic based 500VA monoblocks -> Sommer SPK240 -> self-made speakers

  10. #10
    Senior Member
    Join Date
    Mar 2007
    Location
    UK
    Posts
    1,293
    True, SoX by default doesn't dither {Edit:} if at 24 bits. However, unless you attenuate by bit shifting (which is quite coarse-grained) you tend to get truncation albeit at a low level. Also, with 24 bit music it will truncate no matter what albeit at a low level.

    It seems the native Touch volume control introduces truncation below 40 with 16 bit music, and definitely it will truncate at any volume below 100 with 24 bit music.

    Dither allows any volume level and any source material to be distortion free, guaranteed. You just get a bit of noise at the LSB, and that really IS inaudible - there's no doubt dither is the correct method. Good converters (a stellar example being the Weiss DAC202) use dithered volume control.
    Last edited by darrenyeats; 2015-11-18 at 00:31.
    Check it, add to it! http://www.dr.loudness-war.info/

    SB Touch

Posting Permissions

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