Add volume slider for new audio channel in Menu

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
neometalero
Regular
Posts: 198
Joined: Sun Oct 23, 2016 3:51 am
Completed: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Projects: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Deviantart: neometalero
Contact:

Add volume slider for new audio channel in Menu

#1 Post by neometalero »

I defined a new audio channel like this

Code: Select all

init python:
    renpy.music.register_channel("efectos", "sfx", False)
works fine, but now I want to add a slider on the options menu so you can control the volume of this channel. How would I do this?
Working on many weird narrative games at Curse Box Studios
Image
https://www.curseboxstudios.com/

User avatar
Alex
Lemma-Class Veteran
Posts: 3093
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Add volume slider for new audio channel in Menu

#2 Post by Alex »

neometalero wrote: Fri Jun 18, 2021 2:22 pm I defined a new audio channel like this

Code: Select all

init python:
    renpy.music.register_channel("efectos", "sfx", False)
works fine, but now I want to add a slider on the options menu so you can control the volume of this channel. How would I do this?
Try to create a variable to store this channel volume, like

Code: Select all

default volume = 1.0
Then add a bar to control the volume into the preferences screen

Code: Select all

bar value VariableValue(variable='volume', range=1.0, action=renpy.music.set_volume(volume, delay=0, channel=u'efectos') )
https://www.renpy.org/doc/html/screen_a ... iableValue
https://www.renpy.org/doc/html/audio.ht ... set_volume

User avatar
neometalero
Regular
Posts: 198
Joined: Sun Oct 23, 2016 3:51 am
Completed: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Projects: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Deviantart: neometalero
Contact:

Re: Add volume slider for new audio channel in Menu

#3 Post by neometalero »

Alex wrote: Sat Jun 19, 2021 6:03 am
neometalero wrote: Fri Jun 18, 2021 2:22 pm I defined a new audio channel like this

Code: Select all

init python:
    renpy.music.register_channel("efectos", "sfx", False)
works fine, but now I want to add a slider on the options menu so you can control the volume of this channel. How would I do this?
Try to create a variable to store this channel volume, like

Code: Select all

default volume = 1.0
Then add a bar to control the volume into the preferences screen

Code: Select all

bar value VariableValue(variable='volume', range=1.0, action=renpy.music.set_volume(volume, delay=0, channel=u'efectos') )
https://www.renpy.org/doc/html/screen_a ... iableValue
https://www.renpy.org/doc/html/audio.ht ... set_volume
tks a lot, this worked great!
the only inconvenient I have now is that the new bar's looks is different than the other ones. Any idea how I can fix this?
Image
Working on many weird narrative games at Curse Box Studios
Image
https://www.curseboxstudios.com/

User avatar
Alex
Lemma-Class Veteran
Posts: 3093
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Add volume slider for new audio channel in Menu

#4 Post by Alex »

Try to apply the proper style to button (or specify it inside a Variable Value - see the link about it).

User avatar
neometalero
Regular
Posts: 198
Joined: Sun Oct 23, 2016 3:51 am
Completed: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Projects: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Deviantart: neometalero
Contact:

Re: Add volume slider for new audio channel in Menu

#5 Post by neometalero »

Alex wrote: Sat Jun 19, 2021 11:34 am Try to apply the proper style to button (or specify it inside a Variable Value - see the link about it).
Tks! I applied the slider style to it and worked just fine.
Working on many weird narrative games at Curse Box Studios
Image
https://www.curseboxstudios.com/

Post Reply

Who is online

Users browsing this forum: No registered users