Home of the Squeezebox™ & Transporter® network music players.
Page 1 of 2 12 LastLast
Results 1 to 10 of 45

Hybrid View

  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; Today 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
    739
    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
    739
    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
    The dithered volume control is server-side (SoX) so I think it could work with other clients.

    Re: VolumeLock plugin please see post 2.
    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).
    So it is the very fact that the player volume is fixed to 100 which necessitates the use of VolumeLock plugin, for protection.

    What "controller" exactly shows %? I'd assume any percentage is another way of stating 0-100 i.e. 0.5dB increments as stated.

    Note that after some investigation, the use of TPDF dither has been confirmed as correct. This is the best kind of dither if further processing is going to happen. Since most of us use upsampling DACs (some with ASRC too) this is recommended. People using NOS DACs might want to experiment with shaped dither ("dither" becomes "dither -S" in convert.conf) but TPDF is going to be fine even for them.
    Last edited by darrenyeats; 2017-01-01 at 09:28.
    Check it, add to it! http://www.dr.loudness-war.info/

    SB Touch

  9. #9
    Senior Member pippin's Avatar
    Join Date
    Oct 2007
    Location
    Berlin
    Posts
    14,141

    Dithered volume control for Squeezebox

    It's not in the firmware, it's in SqueezePlay. Both technically and really. It's in Playback.lua which is the player code.
    It's not overridden per device which came as a surprise to me because I had considered the Touch might have a different curve from Radio or Controller. This is actually the curve originally coming from the Boom. I believe SB3 and Transporter have different curves.
    Last edited by pippin; 2015-11-20 at 04:05.
    ---
    learn more about iPeng, the iPhone and iPad remote for the Squeezebox and
    Logitech UE Smart Radio as well as iPeng Party, the free Party-App,
    at penguinlovesmusic.com
    New: iPeng 9, the Universal App for iPhone, iPad and Apple Watch

  10. #10
    Senior Member
    Join Date
    Mar 2007
    Location
    UK
    Posts
    1,293
    Pippin,
    Sorry for the twenty questions. Where can I find Playback.lua?

    I can see it's referred to in ./Slim/Utils/OS/SqueezeOS.pm but I can't find Playback.lua in slimserver repo from github - nor even on my file system where LMS is installed. Where should I look?

    Thanks, Darren
    Last edited by darrenyeats; 2015-11-20 at 13:35.
    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
  •