How to stop a sound through interaction?

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
Jo'ogn
Veteran
Posts: 398
Joined: Sat Jul 12, 2008 1:31 pm
Projects: Kassiopeia [iVN]
Location: Deutschland
Contact:

How to stop a sound through interaction?

#1 Post by Jo'ogn »

Rephrased question:
How can I make a sound behave like the voice object? i.e. replay stops when the player skips, or fast-forwards lines.

"voice" uses the config.interact_callbacks, how is it properly used for that purpose?

~

Original Post:
The "voice" statement has a few features the ordenary "play" has not. E.g. voice is stopped when the player skips a line (interact).

Is there a parameter to make play behave in the same way. Or perhaps adding channels to "voice" to get that behaviour?
Last edited by Jo'ogn on Wed Sep 16, 2009 12:48 pm, edited 4 times in total.
Audio Plays: [original] The White Feathers Directive - [Star Wars] Through Flame and Shadow
Ren'Py: Kassiopeia [very interactive VN] work in progress - looking for proof reader english

User avatar
jack_norton
Lemma-Class Veteran
Posts: 4084
Joined: Mon Jul 21, 2008 5:41 pm
Completed: Too many! See my homepage
Projects: A lot! See www.winterwolves.com
Tumblr: winterwolvesgames
Contact:

Re: More than one "voice" statement at a time?

#2 Post by jack_norton »

Remember that if player is in skip mode though, and the voice is still played full length, the result could be quite "cacophonic" :lol:
follow me on Image Image Image
computer games

User avatar
killdream
Veteran
Posts: 325
Joined: Wed Nov 05, 2008 1:05 pm
Projects: EVūL (WIP), insilo (WIP), Cute Demon Crashers!
Deviantart: robotlolita
Github: robotlolita
Location: World's End (aka Brazil)
Contact:

Re: More than one "voice" statement at a time?

#3 Post by killdream »

jack_norton wrote:Remember that if player is in skip mode though, and the voice is still played full length, the result could be quite "cacophonic" :lol:
Hm, I guess he was talking about making the play statement behave like the voice statement, and not the other way around.

You can try registering a new channel using voice mixer, although I didn't test it and have no idea if it'll work or not xD

User avatar
jack_norton
Lemma-Class Veteran
Posts: 4084
Joined: Mon Jul 21, 2008 5:41 pm
Completed: Too many! See my homepage
Projects: A lot! See www.winterwolves.com
Tumblr: winterwolvesgames
Contact:

Re: More than one "voice" statement at a time?

#4 Post by jack_norton »

Ah yes I read badly sorry :oops:
The only solution I can think of would be to put a stop command after each line with play, but isn't really a good solution...
follow me on Image Image Image
computer games

Jo'ogn
Veteran
Posts: 398
Joined: Sat Jul 12, 2008 1:31 pm
Projects: Kassiopeia [iVN]
Location: Deutschland
Contact:

Re: More than one "voice" statement at a time?

#5 Post by Jo'ogn »

killdream wrote:You can try registering a new channel using voice mixer, although I didn't test it and have no idea if it'll work or not xD
This is what I am doing atm. That's why I am asking if it's possible to stop a sound played when skipping or clicking away lines. Using the voice mixer alone does no inherit the same behaviour to the new channel.
Audio Plays: [original] The White Feathers Directive - [Star Wars] Through Flame and Shadow
Ren'Py: Kassiopeia [very interactive VN] work in progress - looking for proof reader english

User avatar
killdream
Veteran
Posts: 325
Joined: Wed Nov 05, 2008 1:05 pm
Projects: EVūL (WIP), insilo (WIP), Cute Demon Crashers!
Deviantart: robotlolita
Github: robotlolita
Location: World's End (aka Brazil)
Contact:

Re: More than one "voice" statement at a time?

#6 Post by killdream »

You can hook Ren`Py function to show dialogs.

Code: Select all

init -1 python:
    def custom_display_say(who, what, who_args={}, what_args={}, window_args={},
                     image=False, side_image=None, two_window=False,
                     two_window_vbox_properties={},
                     who_window_properties={},
                     say_vbox_properties={},
                     variant=None,
                     **kwargs):
        # stop any current playing sound
        renpy.music.stop(channel="sound")
        
        # displays the dialog
        return renpy.show_display_say(who, what, who_args, what_args, window_args,
                     image, side_image, two_window,
                     two_window_vbox_properties,
                     who_window_properties,
                     say_vbox_properties,
                     variant,
                     **kwargs)
Then you just need to create characters that uses your custom display function instead of Ren'Py default one. You can even redefine the narrator character to use this function too.

Code: Select all

init python:
    engel = Character("Engel", show_function=custom_display_say)
    
    # with this you can change the default Ren'Py narrator :D
    narrator = Character(None, show_function=custom_display_say)

Jo'ogn
Veteran
Posts: 398
Joined: Sat Jul 12, 2008 1:31 pm
Projects: Kassiopeia [iVN]
Location: Deutschland
Contact:

Re: How to stop a sound through interaction?

#7 Post by Jo'ogn »

Thanks killdream, but it seems too complicated to change an entire say behaviour if all I want is to stop a sound from playing. Stopping sounds through interactions could also be desired on other occasions.


I rephrased my question in my first post, I figured out by reading through the source code that "voice" is an object using a callback to prevent the playback, but I don't know how to make it work for, say, a dedicated channel I want to behave in the same way.
Audio Plays: [original] The White Feathers Directive - [Star Wars] Through Flame and Shadow
Ren'Py: Kassiopeia [very interactive VN] work in progress - looking for proof reader english

Post Reply

Who is online

Users browsing this forum: Google [Bot], konimyun