[Solved] Music volume slider acting strange

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3808
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

[Solved] Music volume slider acting strange

#1 Post by Imperf3kt »

I have had this issue for many months now, but it's been low priority so I ignored it, but my volume slider appears to be scaled incorrectly.

The first ~90% of the bar will only increase the volume to 50%, with the final 50% crammed in a tenth of the slider.
It's almost like it's in logarithmic mode instead of linear.
Image
I believe this issue started when I switched to renpy 8.

The percentage is just a screen variable taken from

Code: Select all

python:
    preferences.get_volume("music")
Then I display it in the same screen above the slider that controls the volume (these are inside a larger vbox containing many more parts of the screen)

Code: Select all

hbox:
    Label _("Music Volume")
    null width(gui.pref_spacing)
    text "{:.0f}".format(music_vol*100)

hbox:
    xsize 230
    bar value Preferences("music volume")
    
Can anybody point out why it is behaving like this?
It's not just visual either, the music really is only at 50% that far along the slider.
It is the same across every project I use this in.
Last edited by Imperf3kt on Fri Oct 20, 2023 10:22 am, edited 1 time in total.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2434
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Music volume slider acting strange

#2 Post by Ocelot »

Is Preferences a typo here or is it a custom class used instead of Preference?

Some time ago RenPy switched volume control to change sound volume instead of amplitude. Previously moving volume bar didn't change anything audibly until you get to the bottom quarter or even 1/10th of the bar. So now mixers are set to work on logarithmic scale (like perceived loudness works in real life). You are accessing raw internal value through deprecated and un-documented function, so it is showing old unscaled value.

You can replace get_volume call with get_mixer, which is set to work with new sound scale.
https://www.renpy.org/doc/html/preferen ... .get_mixer
< < insert Rick Cook quote here > >

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3808
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Music volume slider acting strange

#3 Post by Imperf3kt »

Yes it was a typo, it's supposed to be Preference.

Thank you for the help, get_mixer was exactly what I needed.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

Post Reply

Who is online

Users browsing this forum: No registered users