How to register new sound channel for CTC sounds? [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
Jae
Regular
Posts: 192
Joined: Sun Sep 13, 2015 5:41 pm
Projects: Pokémon Academy Life
Location: New York, NY
Contact:

How to register new sound channel for CTC sounds? [SOLVED]

#1 Post by Jae » Fri Oct 09, 2015 3:53 am

Solution:
Register new channel for CTC:

Code: Select all

init -1 python:
    renpy.music.register_channel("ctc", mixer="sfx", loop=False)

    def callbackcontinue(ctc, **kwargs):
        if ctc == "end":
            renpy.music.play("Audio/Button_A.wav",channel="ctc")
Sample dialogue:

Code: Select all

    r happy "I'll just go{nw}"
    $ renpy.music.set_volume(0.0, delay=0.0, channel="ctc")
    extend r surprise " this way."
    $ renpy.music.set_volume(1.0, delay=0.0, channel="ctc")
This way the CTC sound effect will not play during {nw} and will resume after the dialogue completes.





Original problem:
I currently have a sound effect that plays whenever the player clicks to continue:

Code: Select all

init python:
    def callbackcontinue(ctc, **kwargs):
        if ctc == "end":
            renpy.music.play("Audio/Button_A.wav", channel="sound")
The problem with this is that if I try use {nw} or "extend" for any dialogue, it automatically plays the CTC sound effect, which is kind of annoying.

So I thought if I could move the CTC sound to a different sound channel, I could temporarily disable the channel during the dialogue.

However, when I used:

Code: Select all

init python:
    renpy.music.register_channel("ctc", mixer="sfx", loop=None)
    def callbackcontinue(ctc, **kwargs):
        if ctc == "end":
            renpy.music.play("Audio/Button_A.wav", channel="ctc")
The CTC sound plays nonstop every time I click and will continue to play from that point forward.

Is there a way to set the CTC sound effect to a different channel so I can freely turn it on and off? I would prefer not to temporarily turn off all sound channels just for the sake of having a smooth {nw} or "extend" effect when using dialogue.
Last edited by Jae on Fri Oct 09, 2015 10:16 am, edited 4 times in total.

User avatar
trooper6
Lemma-Class Veteran
Posts: 3463
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: How to register new sound channel for CTC sounds

#2 Post by trooper6 » Fri Oct 09, 2015 8:43 am

Your problem is that you made your custom channel a music channel, and music channels loop by default...so this is why you are getting what you are getting.

So perhaps try registering a sound channel instead?

Code: Select all

 renpy.sound.register_channel("ctc", mixer="sfx" )
Note: I'm at a hotel for work, so I can't test this...but try it and see what happens.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
Jae
Regular
Posts: 192
Joined: Sun Sep 13, 2015 5:41 pm
Projects: Pokémon Academy Life
Location: New York, NY
Contact:

Re: How to register new sound channel for CTC sounds?

#3 Post by Jae » Fri Oct 09, 2015 9:13 am

Hey trooper.

I've tried that before. Ended up an error. With and without extra properties (mixer, loop, etc.).

While running game code:
File "game/script.rpy", line 1, in script
init -1 python:
File "game/script.rpy", line 2, in <module>
renpy.sound.register_channel("ctc", mixer="sfx")
AttributeError: 'module' object has no attribute 'register_channel'

-- Full Traceback ------------------------------------------------------------

Full traceback:
File "game/script.rpy", line 1, in script
init -1 python:
File "C:\Users\Downloads\renpy-6.99.5-sdk\renpy-6.99.5-sdk\renpy\ast.py", line 797, in execute
renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
File "C:\Users\Downloads\renpy-6.99.5-sdk\renpy-6.99.5-sdk\renpy\python.py", line 1448, in py_exec_bytecode
exec bytecode in globals, locals
File "game/script.rpy", line 2, in <module>
renpy.sound.register_channel("ctc", mixer="sfx", loop=None)
AttributeError: 'module' object has no attribute 'register_channel'


I never really understood the ctc definition here, so it might be due to that.

philat
Eileen-Class Veteran
Posts: 1454
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: How to register new sound channel for CTC sounds?

#4 Post by philat » Fri Oct 09, 2015 9:28 am

renpy.sound is deprecated; everything is renpy.music based. The problem is loop=None. Should be loop=False.

User avatar
Jae
Regular
Posts: 192
Joined: Sun Sep 13, 2015 5:41 pm
Projects: Pokémon Academy Life
Location: New York, NY
Contact:

Re: How to register new sound channel for CTC sounds?

#5 Post by Jae » Fri Oct 09, 2015 9:50 am

Philat saves the day again.

Thanks!

Added solution to the original post for future creators.

User avatar
trooper6
Lemma-Class Veteran
Posts: 3463
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: How to register new sound channel for CTC sound

#6 Post by trooper6 » Fri Oct 09, 2015 12:41 pm

philat wrote:renpy.sound is deprecated; everything is renpy.music based. The problem is loop=None. Should be loop=False.
Huh. Renpy.sound is still in the documentation...that should probably be changed.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

philat
Eileen-Class Veteran
Posts: 1454
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: How to register new sound channel for CTC sound

#7 Post by philat » Fri Oct 09, 2015 10:56 pm

trooper6 wrote:
philat wrote:renpy.sound is deprecated; everything is renpy.music based. The problem is loop=None. Should be loop=False.
Huh. Renpy.sound is still in the documentation...that should probably be changed.
Yeah, and renpy.sound.play still works as well, but it doesn't support other functions like register_channel and stuff. As for the documentation... sigh, you know? ;)

http://www.renpy.org/wiki/renpy/doc/ref ... sound.play

Post Reply

Who is online

Users browsing this forum: Google [Bot]