Page 1 of 1
[Solved] Disabling ctc sound during pauses/dissolves
Posted: Sun Nov 05, 2017 1:16 pm
by LMartinson
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?
Re: Disabling ctc sound during pauses/dissolves
Posted: Sun Nov 05, 2017 1:26 pm
by Divona
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
Re: Disabling ctc sound during pauses/dissolves
Posted: Sun Nov 05, 2017 2:56 pm
by LMartinson
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...
Re: Disabling ctc sound during pauses/dissolves
Posted: Sat Nov 11, 2017 3:56 pm
by LMartinson
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!
Re: [Solved, kinda] Disabling ctc sound during pauses/dissolves
Posted: Wed Jan 17, 2018 2:41 am
by LMartinson
Dunno if anyone cares, but I figured out a slightly less janky way of doing the above:
Code: Select all
init python:
def callbackcontinue(ctc, **kwargs):
if ctc == "end" and renpy.get_mode()!="pause" and renpy.get_mode()!="with":
renpy.music.play("sounds/ctc_click.ogg", channel="ctc", loop=False)
renpy.music.register_channel("ctc", "sfx", None)
define config.all_character_callbacks = [ callbackcontinue ]
Once again I'm still a very inexperienced coder, but in my preliminary tests this seemed to work.