[Solved, kinda] Disabling ctc sound during pauses/dissolves

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
LMartinson
Newbie
Posts: 6
Joined: Sat Feb 25, 2017 3:46 pm
Contact:

[Solved, kinda] Disabling ctc sound during pauses/dissolves

#1 Post by LMartinson » Sun Nov 05, 2017 1:16 pm

I used this code found on these forums to add a ctc clicking sound when the reader clicks to advance the text:

Code: Select all

    def callbackcontinue(ctc, **kwargs):
        if ctc == "end":
            renpy.music.play("sounds/ctc_click.ogg", channel="ctc", loop=False)
For the most part it works great, except that it also adds clicking sounds every time I use a dissolve or a pause. So in this example:

Code: Select all

    show character1 at left with dissolve
    pause 0.5
    show character2 at center with dissolve
    pause 0.5
    show character3 at right with dissolve
    pause 0.5
It adds six extra clicking sounds without the reader doing anything.

Is there any way to change the original code so that the ctc sound only happens when the reader clicks at the end of a say statement, and not at any other time?
Last edited by LMartinson on Sat Nov 11, 2017 3:58 pm, edited 1 time in total.

User avatar
Divona
Miko-Class Veteran
Posts: 678
Joined: Sun Jun 05, 2016 8:29 pm
Completed: The Falconers: Moonlight
Organization: Bionic Penguin
itch: bionicpenguin
Contact:

Re: Disabling ctc sound during pauses/dissolves

#2 Post by Divona » Sun Nov 05, 2017 1:26 pm

Look like one of a solution is to register CTC sound to another sound channel and mute such channel during dissolve and pause event.
viewtopic.php?f=8&t=34754&p=389910
Completed:
Image

LMartinson
Newbie
Posts: 6
Joined: Sat Feb 25, 2017 3:46 pm
Contact:

Re: Disabling ctc sound during pauses/dissolves

#3 Post by LMartinson » Sun Nov 05, 2017 2:56 pm

Thanks for taking the time to reply!
Yeah, I actually noticed the thread you linked to before, and if I only had a couple of instances where I needed to do it I'd totally use their method.
But since my vn has more than a thousand dissolves I was hoping there was a way to automate it...

LMartinson
Newbie
Posts: 6
Joined: Sat Feb 25, 2017 3:46 pm
Contact:

Re: Disabling ctc sound during pauses/dissolves

#4 Post by LMartinson » Sat Nov 11, 2017 3:56 pm

Okay, so I kept playing around with it, and managed to cobble something together based largely on the code from the bottom of this page:
https://www.renpy.org/doc/html/modes.html

Code: Select all

init python:

    def _pause_callback(mode, old_modes):

        old = old_modes[0]
        if mode == "pause" or mode == "with":
                renpy.music.set_volume(volume=0.0, delay=0.1, channel='ctc')

        if mode == "say" or mode == "menu" or mode == "nvl" or mode == "nvl_menu" or mode == "start" or mode == "screen":
                renpy.music.set_volume(volume=1.0, delay=0.0, channel='ctc')

    config.mode_callbacks.append(_pause_callback)

    def callbackcontinue(ctc, **kwargs):
        if ctc == "end":
            renpy.music.play("sounds/ctc_click.ogg", channel="ctc", loop=False)

    renpy.music.register_channel("ctc", "sfx", None)
Note: I'm not a programmer at all, so there might be a better, more elegant way to do this. Plus it seems a bit wonky; sometimes it skips ctc sounds that should be there. So I'm sure it could be improved, but I think it's better than before when it would make a bunch of extra clicking sounds that would be distracting to the reader.

If anyone has an idea of a better way to implement this, please let me know!

Post Reply

Who is online

Users browsing this forum: Remix