Custom channel volume setting in Preference screen (solved)

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
SinnyROM
Regular
Posts: 166
Joined: Mon Jul 08, 2013 12:25 am
Projects: Blue Birth
Organization: Cosmic Static Games
Contact:

Custom channel volume setting in Preference screen (solved)

#1 Post by SinnyROM » Thu May 01, 2014 6:17 pm

I have a channel for beep sounds to play while characters talk. How would I go about creating a Preferences option so the user can adjust the volume? Is it possible?

I declared a variable for the volume for the channel, textsound_volume, but as to having the user adjust this using a bar, I'm not sure how to proceed.

Beep channel:

Code: Select all

init -2 python:

    textsound_volume = 1.0

    renpy.music.register_channel("blip", mixer="sfx", loop=True)
    def blips(event, **kwargs):
        if event == "show":
            renpy.music.play("sfx/blip.wav", channel="blip",loop=True,fadeout=None,synchro_start=False,fadein=0,tight=True)
        elif event == "slow_done" or event == "end":
            renpy.music.stop(channel="blip")

    def Preference_textsound():
        renpy.music.set_volume(textsound_volume,delay=0,channel="blip")
Preference frame for adjusting volume of beep channel:

Code: Select all

screen preferences:
    ...
            frame:
                style_group "pref"
                has vbox

                label _("Text Sound")
                bar value Preference_textsound()
    ...
Last edited by SinnyROM on Thu May 01, 2014 7:56 pm, edited 1 time in total.

User avatar
Asceai
Eileen-Class Veteran
Posts: 1258
Joined: Fri Sep 21, 2007 7:13 am
Projects: a battle engine
Contact:

Re: Adding custom channel volume setting in Preference scree

#2 Post by Asceai » Thu May 01, 2014 6:39 pm

bar value MixerValue('blip')

User avatar
SinnyROM
Regular
Posts: 166
Joined: Mon Jul 08, 2013 12:25 am
Projects: Blue Birth
Organization: Cosmic Static Games
Contact:

Re: Adding custom channel volume setting in Preference scree

#3 Post by SinnyROM » Thu May 01, 2014 7:56 pm

Asceai wrote:bar value MixerValue('blip')
I see, for this I have to use another mixer than sfx for that particular channel. It works great now, thanks!

Post Reply

Who is online

Users browsing this forum: Ocelot