librespot icon indicating copy to clipboard operation
librespot copied to clipboard

Volume issues

Open moodeaudio opened this issue 8 years ago • 25 comments

Hi,

Testing with Spotify IOS app on iPhone 5 and librespot on Pi.

sudo ./librespot --name RP3spot --cache /tmp --bitrate 320 --backend alsa --device hw:0

What I experienced is as follows:

  1. Spotify IOS client set volume to 100% on first connect/play! iPhone local volume was only 30%. See attached image.
  2. Volume stepping used by Spotify IOS client is very corse, only 10 steps to full volume using the physical iPhone buttons.
  3. The slider volume control within the Spotify app behaves similarly in that it raises volume too much within the first half of the slider.
  4. No support for hardware volume yet in librespot (already covered in existing issue)

The very nice debug logging shows volume cmds being received but how to decode them to see what level the client is requesting?

DEBUG:librespot::spirc: kMessageTypeVolume "Tim's iPhone" 3496dcfbf06e2b19c74d6d5216389761aa9a4e94 4 0 DEBUG:librespot::spirc: kMessageTypeNotify "RP3spot" 8ced8e4318e14e95632409ed1898989ff295f075 10 1485738325625 DEBUG:librespot::spirc: kMessageTypeVolume "Tim's iPhone" 3496dcfbf06e2b19c74d6d5216389761aa9a4e94 5 0 DEBUG:librespot::spirc: kMessageTypeNotify "RP3spot" 8ced8e4318e14e95632409ed1898989ff295f075 11 1485738326177 DEBUG:librespot::spirc: kMessageTypeVolume "Tim's iPhone" 3496dcfbf06e2b19c74d6d5216389761aa9a4e94 6 0 DEBUG:librespot::spirc: kMessageTypeNotify "RP3spot" 8ced8e4318e14e95632409ed1898989ff295f075 12 1485738326424

spotify-connect1

Regards, Tim

moodeaudio avatar Jan 30 '17 01:01 moodeaudio

Thanks for bringing this up.

Spotify IOS client set volume to 100% on first connect/play! iPhone local volume was only 30%

This is intentional, see https://github.com/plietar/librespot/pull/43 for the reasons. The local volume on the phone does not have an impact.

Volume stepping used by Spotify IOS client is very corse, only 10 steps to full volume using the physical iPhone buttons.

I'm not sure why it was set to 10, but I've just bumped it to 64 steps in 7be9626. This is the same behaviour as the desktop client.

The slider volume control within the Spotify app behaves similarly in that it raises volume too much within the first half of the slider.

Not sure what you mean there

plietar avatar Jan 30 '17 04:01 plietar

Hi Paul,

Since its not possible for the software to know much about users audio system, assume that if client defaults to sending 100% volume that full volume will be output at speakers or headphones when play button is pressed.

Consider setting initial volume to one of the following:

  1. level that user previously set in the Spotify client app
  2. level of client device local volume that user previously set
  3. 0% (default)
  4. level specified in librespot cmd string. For example --initial-volume 10%. This would allow users that want client to always output 100% to their audio system to simply specify --initial-volume 100%.

Something like that.

-TIm

moodeaudio avatar Jan 30 '17 05:01 moodeaudio

Ignore. Volume control on Sierra macOS glitched :/

sashahilton00 avatar Feb 05 '17 04:02 sashahilton00

I'd be very interested in being able to specify an initial volume via an argument or config, or even better, have the ability to retain the previous spotify connect volume.

I'm using this with snapcast (https://github.com/badaix/snapcast/) and most of my other sources are never at 100% (e.g. airplay), so when I use spotify connect and switch sources, the volume is always too high since it's at 100%!

Thanks

pbros avatar Feb 06 '17 01:02 pbros

I agree with pbros, it would be great if we could fix this for the snapcast users (including me :)). I would be happy with an initial volume of 0 if that would make things easier.

ash-vd avatar Feb 21 '17 21:02 ash-vd

@moodeaudio

Consider setting initial volume to one of the following:

  • level that user previously set in the Spotify client app
  • level of client device local volume that user previously set

AFAIK this isn't possible, clients don't send their current level

  • 0% (default)

This is inconvenient since it requires all users to increase the volume every time, and would lead to confusion

  • level specified in librespot cmd string. For example --initial-volume 10%. This would allow users that want client to always output 100% to their audio system to simply specify --initial-volume 100%.

This would work.

Note that audio volume was recently refactored (#148) to support multiple mixer backends

  • When using software volume, we can add a --initial-volume flag, as well as save volume to the cache and use that when the flag isn't passed.
  • When using alsa mixing (#158), we can just use the system's volume, which is what that PR does.

I'm a bit concerned about the increasing number of command line flags, and would like to move to a more flexible config file based solution, where each audio and mixer backend can have different configuration options.

plietar avatar Mar 06 '17 17:03 plietar

For applications uses a pipe or stdout (like snapcast), alsa isn't an option. In this case, the best options would be a flag or a config file since we could always use a default initial volume when instantiating librespot. If ever the calling application can save the previous volume, then we could handle the case where we want to go back to the previous level!

pbros avatar Mar 07 '17 00:03 pbros

I am interested in this feature to put an initial volume. Is it possible ?

goguetchapuisb avatar Nov 26 '17 21:11 goguetchapuisb

@moodeaudio I have forked a recent version of librespot and added the --progressive-volume option. It icreases the volume with smaller steps at low volume and bigger steps at high volume. This gives a much more smooth volume control. Get is at: https://github.com/thekr1s/librespot/tree/progressive-voume-control

thekr1s avatar Jan 24 '18 23:01 thekr1s

@thekr1s this is awesome. thank you!

maxx avatar Jan 24 '18 23:01 maxx

@thekr1s woah there's loads of fixes in your fork there. Some I'd love to have and I've got some queue handling improvements to share. Can we advertise that as the new master repository?

kingosticks avatar Jan 24 '18 23:01 kingosticks

If you guys do choose a new master repo, could you spin it up into an organisation? That way it can be handled off over time as opposed to leading to this scenario where eveyone has a different fork :)

sashahilton00 avatar Jan 24 '18 23:01 sashahilton00

Credits go to @ComlOnline. He merged a lot of forks with fixes. That is the reason I forked that one. I intend to push te changed to ComlOnline/librespot This is my first step onto github, so try to find my way around....

thekr1s avatar Jan 24 '18 23:01 thekr1s

A librespot organisation is the way to go. Good idea

kingosticks avatar Jan 25 '18 00:01 kingosticks

Oh I love the idea of an organisation. I don't like the idea of being the only one with control over a project as big of this. I was originally just picking and choosing the fixes I wanted for myself. I just went to create an organisation called "librespot" however it was sadly taken. Anyone got some other ideas?

ComlOnline avatar Jan 25 '18 00:01 ComlOnline

This is a sight for sore eyes :-)

-Tim

moodeaudio avatar Jan 25 '18 00:01 moodeaudio

@ComlOnline Just call it librespot-org or something. Also the joy of an organisation is I believe that you can give multiple people control

sashahilton00 avatar Jan 25 '18 00:01 sashahilton00

Perfect I'll do that now, That sounds wonderful.

ComlOnline avatar Jan 25 '18 01:01 ComlOnline

Great. You might think about @herrernst and some of the other guys who frequented the PRs/commits :)

sashahilton00 avatar Jan 25 '18 01:01 sashahilton00

It is done: https://github.com/librespot-org/librespot I'll comb through the contributors now.

ComlOnline avatar Jan 25 '18 01:01 ComlOnline

Great. In the meantime, I'm going to bed :)

sashahilton00 avatar Jan 25 '18 01:01 sashahilton00

Also don't forget to drop @plietar a line, not sure if he's allowed/wants to to work on it given his signing off on the project, but it would obviously be beneficial if he is able to.

sashahilton00 avatar Jan 25 '18 01:01 sashahilton00

Sleep well, and don't worry I have already made him an owner of the org.

ComlOnline avatar Jan 25 '18 01:01 ComlOnline

@moodeaudio @maxx, do you face the same issue as I the the volume increases too much in the first half of the volume level? If so, what platform are you using? I face the issue on a Raspberry Pi with OSMC, with a hifiberry DAC.

thekr1s avatar Jan 26 '18 19:01 thekr1s

@thekr1s yes - I have the same annoyance (prior to your patch)..so I was very happy to see this. I control it mainly with the iOS app, and I pipe librespot to pulse audio (where I mix with with some other home automation text to speech stuff) and then I pipe that to snapcast out to several rooms in the house. I haven't tried your patch yet - updating librespot is the cards for this weekend.

maxx avatar Jan 26 '18 21:01 maxx