[GH-ISSUE #530] Config volume at 55% shows 54% in UI #302

Closed
opened 2026-03-02 23:46:21 +03:00 by kerem · 8 comments
Owner

Originally created by @Column01 on GitHub (Jul 31, 2024).
Original GitHub issue: https://github.com/aome510/spotify-player/issues/530

Describe the bug
When I set my config's volume to 55 which is comfortable for me, the app launches at 54% volume. I thought "oh well maybe it's offset for some reason" so I set it to 56 in the config, and the app launches with 56% volume... very odd indeed.

To Reproduce

  • Set config volume to 55
  • launch app
  • volume is 54%

Expected behaviour

  • Volume should be 55% in the app

Log and backtrace

spotify-player-24-07-31-17-58.zip

Screenshots

powershell_mZOMlTIhZb

Environment

  • OS: Windows 10
  • Application version: git latest (built from source at this commit)
  • Application features: image,lyric-finder,media-control built with --release on

Additional context
Add any other context about the problem here.

Originally created by @Column01 on GitHub (Jul 31, 2024). Original GitHub issue: https://github.com/aome510/spotify-player/issues/530 **Describe the bug** When I set my config's volume to `55` which is comfortable for me, the app launches at 54% volume. I thought "oh well maybe it's offset for some reason" so I set it to 56 in the config, and the app launches with 56% volume... very odd indeed. **To Reproduce** - Set config volume to 55 - launch app - volume is 54% **Expected behaviour** - Volume should be 55% in the app **Log and backtrace** [spotify-player-24-07-31-17-58.zip](https://github.com/user-attachments/files/16447557/spotify-player-24-07-31-17-58.zip) **Screenshots** ![powershell_mZOMlTIhZb](https://github.com/user-attachments/assets/c0b3ba50-b263-4e8a-9b0f-441dd202d335) **Environment** - OS: Windows 10 - Application version: git latest (built from source at [this commit](https://github.com/aome510/spotify-player/commit/fdb846e86e040b7d6ea45b0f578dd1ce7abd0008)) - Application features: `image,lyric-finder,media-control` built with `--release` on **Additional context** Add any other context about the problem here.
kerem 2026-03-02 23:46:21 +03:00
Author
Owner

@aome510 commented on GitHub (Jul 31, 2024):

Likely because how volume is set in github.com/aome510/spotify-player@fdb846e86e/spotify_player/src/streaming.rs (L171). It might be easy to tweak the calculation so that the percentage is right

<!-- gh-comment-id:2261551082 --> @aome510 commented on GitHub (Jul 31, 2024): Likely because how `volume` is set in https://github.com/aome510/spotify-player/blob/fdb846e86e040b7d6ea45b0f578dd1ce7abd0008/spotify_player/src/streaming.rs#L171. It might be easy to tweak the calculation so that the percentage is right
Author
Owner

@Column01 commented on GitHub (Aug 1, 2024):

I don't think it can be fixed due to librespot's volume needing to be a u16 number like that. It's a rounding error as 65535 * 0.55 is not a whole number

<!-- gh-comment-id:2263170134 --> @Column01 commented on GitHub (Aug 1, 2024): I don't think it can be fixed due to librespot's volume needing to be a u16 number like that. It's a rounding error as `65535 * 0.55` is not a whole number
Author
Owner

@Column01 commented on GitHub (Aug 1, 2024):

One way that could "fix" it is to display the volume percentage in the UI as whatever its set in the config lol

<!-- gh-comment-id:2263171756 --> @Column01 commented on GitHub (Aug 1, 2024): One way that could "fix" it is to display the volume percentage in the UI as whatever its set in the config lol
Author
Owner

@aome510 commented on GitHub (Aug 1, 2024):

I don't think it can be fixed due to librespot's volume needing to be a u16 number like that. It's a rounding error as 65535 * 0.55 is not a whole number

right.

One way that could "fix" it is to display the volume percentage in the UI as whatever its set in the config lol

The displayed volume is what received from Spotify API, so it cannot be changed based on the configs

<!-- gh-comment-id:2263195761 --> @aome510 commented on GitHub (Aug 1, 2024): > I don't think it can be fixed due to librespot's volume needing to be a u16 number like that. It's a rounding error as `65535 * 0.55` is not a whole number right. > One way that could "fix" it is to display the volume percentage in the UI as whatever its set in the config lol The displayed volume is what received from Spotify API, so it cannot be changed based on the configs
Author
Owner

@Column01 commented on GitHub (Aug 1, 2024):

The displayed volume is what received from Spotify API, so it cannot be changed based on the configs

Ah yes, I assume this would be a problem if you used the app to adjust the volume for other spotify devices and of course as the user changes the volume using the hotkey it wouldn't update the config's value accordingly and this would still show 55%, bummer! Not sure what to do about this then other than suck it up :P

<!-- gh-comment-id:2263199122 --> @Column01 commented on GitHub (Aug 1, 2024): > The displayed volume is what received from Spotify API, so it cannot be changed based on the configs Ah yes, I assume this would be a problem if you used the app to adjust the volume for other spotify devices and of course as the user changes the volume using the hotkey it wouldn't update the config's value accordingly and this would still show 55%, bummer! Not sure what to do about this then other than suck it up :P
Author
Owner

@Column01 commented on GitHub (Aug 1, 2024):

Actually, on this line in the client the volume is an i8, I think whats happening here is the UI is displaying this value AFAIK and instead of rounding (36044/65535 = 0.5499961852445259 rounded up would be 55%), it's chopping the decimals off making it "floor" the value and display 54% (again as far as I can tell)

github.com/aome510/spotify-player@314631f9ce/spotify_player/src/cli/client.rs (L404)

EDIT: NVM volume is u32 here so no its not flooring it here at least

<!-- gh-comment-id:2263246151 --> @Column01 commented on GitHub (Aug 1, 2024): Actually, on this line in the client the volume is an i8, I think whats happening here is the UI is displaying this value AFAIK and instead of rounding (`36044/65535 = 0.5499961852445259` rounded up would be 55%), it's chopping the decimals off making it "floor" the value and display 54% (again as far as I can tell) https://github.com/aome510/spotify-player/blob/314631f9ce74e6449c929ca94d8e0ca553dd97c1/spotify_player/src/cli/client.rs#L404 EDIT: NVM volume is u32 here so no its not flooring it here at least
Author
Owner

@Column01 commented on GitHub (Aug 1, 2024):

But I don't fully understand the is_offset check so idk what that code block does if its not offset or what constitutes that flag being set

<!-- gh-comment-id:2263253351 --> @Column01 commented on GitHub (Aug 1, 2024): But I don't fully understand the `is_offset` check so idk what that code block does if its not offset or what constitutes that flag being set
Author
Owner

@Column01 commented on GitHub (Aug 1, 2024):

Further digging revealed what you said is true (not that I doubted it, just wanted to know more). Rspotify returns the volume_percent which is a u32 meaning our decimals are lost somewhere outside our control :(

Gonna close this as afaik there is nothing that can be done to fix this

<!-- gh-comment-id:2263293982 --> @Column01 commented on GitHub (Aug 1, 2024): Further digging revealed what you said is true (not that I doubted it, just wanted to know more). Rspotify returns the `volume_percent` which is a u32 meaning our decimals are lost somewhere outside our control :( Gonna close this as afaik there is nothing that can be done to fix this
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotify-player#302
No description provided.