Text bleeps callback won't stop in menus [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.
Message
Author
User avatar
tomotomo
Regular
Posts: 32
Joined: Thu May 28, 2015 2:01 pm
Tumblr: tomatomagica
Location: Russia
Contact:

Text bleeps callback won't stop in menus [SOLVED!]

#1 Post by tomotomo »

*sigh* yet me again.
This issue popped awhile ago and i tried to fix it by various ways but didn't succeed so here i am.
The problem is that text bleeps callbacks won't stop when going to other menus in the middle of currently typing text.
For example, if character is speaking and didn't finished their sentence yet but i clicked to save button and went to save menu the sound of typing text is still going on.
Here's the code i'm using:

Code: Select all

# Callback
init -1 python:
    
    renpy.music.register_channel("callbacksnd", mixer= "sfx")

init python:
    
    def callback1(event, **kwargs):
        if event == "show":
            renpy.music.play("m:/-renpy/Father/Music/callback1.ogg", channel="callbacksnd")
        elif event == "slow_done" or event == "end":
            renpy.music.stop(channel="callbacksnd")
init python:
    def callback2(event, **kwargs):
        if event == "show":
            renpy.music.play("m:/-renpy/Father/Music/callback2.ogg", channel="callbacksnd")
        elif event == "slow_done" or event == "end" or:
            renpy.music.stop(channel="callbacksnd")
I think i should probably write something down into elif event == "slow_done" or event == "end": but i don't know what exactly
Last edited by tomotomo on Tue Jun 02, 2015 1:02 pm, edited 1 time in total.

User avatar
tomotomo
Regular
Posts: 32
Joined: Thu May 28, 2015 2:01 pm
Tumblr: tomatomagica
Location: Russia
Contact:

Re: Text bleeps callback won't stop when going to other menu

#2 Post by tomotomo »

I'll try to put it a little different
can i pause text/game when switching to a menu?

User avatar
tomotomo
Regular
Posts: 32
Joined: Thu May 28, 2015 2:01 pm
Tumblr: tomatomagica
Location: Russia
Contact:

Re: Text bleeps callback won't stop when going to other menu

#3 Post by tomotomo »

update
i tried to change a channel="callbacksnd" back to channel="sound"
and the sound of typing text does indeed stopped when i changed screen to the load menu, but the 3 lines of text were still going on for some time (text speed is not all that fast) and when i quickly went back to the game screen the sound of typing text didn't started over
so the question about pausing game remains

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

Re: Text bleeps callback won't stop when going to other menu

#4 Post by SinnyROM »

I had the same problem when I tried to add those sounds, and couldn't find a reasonable way to stop them from playing in the menus. The closest I got was stopping the channel when the navigation screen shows. If you returned to the game quick enough, the sounds continue, but at least they stop while on the menus.

Code: Select all

screen navigation():
    on "show" action Stop(channel="blip")
    # ...
I guess you can place this line in its own screen and then use it in any screen you like.

Code: Select all

screen stop_blips():
    on "show" action Stop(channel="blip")

screen preferences():
    use stop_blips
    # ...

screen save():
    use stop_blips
    #...
My channel definition is slightly different than yours but here it is if you want to compare:

Code: Select all

init python:
    # Blips
    sfx_blip = "sfx/blip.wav"
    renpy.music.register_channel("blip", mixer="blip", loop=True, tight=False)
    def callback_blip(event, **kwargs):
        if event == "show":
            renpy.music.play(sfx_blip, channel="blip")
        elif event == "slow_done" or event == "end":
            renpy.music.stop(channel="blip")

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

Re: Text bleeps callback won't stop when going to other menu

#5 Post by trooper6 »

For my clock audio, I do something similar in concept. Rather than a screen I have a function that stops my audio and I have the various menus call that function.

But...it seems to me the larger problem is not that you've got bleeps happening when you are in menus...but than people are able to exit your game in the middle of text showing up. Maybe there is a way to stop that from happening?
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
tomotomo
Regular
Posts: 32
Joined: Thu May 28, 2015 2:01 pm
Tumblr: tomatomagica
Location: Russia
Contact:

Re: Text bleeps callback won't stop when going to other menu

#6 Post by tomotomo »

people are able to exit your game in the middle of text showing up. Maybe there is a way to stop that from happening?
yes, i guess if we manage to solve this problem, the others would disappear as well

SinnyROM, thanks for the help, i tried to adapt those codes for my own but new problem appeared. Yes, the sound stops when i go to menus, but now when i go back to my main game screen, even if text already fully done showing, the sound still goes on, as if text is still being typed.

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

Re: Text bleeps callback won't stop when going to other menu

#7 Post by trooper6 »

I'm not sure it is a problem per se...I'm sure that it is considered more player friendly to let people go to a menu in the middle of slow text happening.

But if you want to stop people from being able to access the game menus while slow text is happening...that is pretty easy. This code will do it:

Code: Select all

define e = Character('Eileen', color="#c8ffc8", what_slow_cps=20, what_slow_abortable=False, 
    stop_on_mute=False, callback=clicks)

screen no_game():
    key "game_menu" action NullAction()
    
init -1 python:
    renpy.music.register_channel("Chan1", mixer= "sfx", loop=True)
    
    def clicks(event, **kwargs):
        if event == "show" or event == "begin":
            renpy.music.play("click.wav", channel="Chan1")
            renpy.show_screen("no_game")
        if event == "slow_done" or event == "end":
            renpy.music.stop(channel="Chan1")
            renpy.hide_screen("no_game")

# The game starts here.
label start:

    e "You've created a new Ren'Py game."

    e "Once you add a story, pictures, and music, you can release it to the world!"

    return
Though...I've been able to have audio turn on and off in my game using a function...there should be a way to just mess with audio rather than the suspend game_menu option. Let me experiment on this some more.
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
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Text bleeps callback won't stop when going to other menu

#8 Post by trooper6 »

Okay, I now did a version of answering your question that still allows the user to go to menus. It uses a function to start and stop the audio and uses that same function to pause the audio when in one of the menus.

Code: Select all

# Declare characters used by this game.
define e = Character('Eileen', color="#c8ffc8", what_slow_cps=20, what_slow_abortable=False, 
    stop_on_mute=False, callback=clicks)
    
init -1 python:
    renpy.music.register_channel("Chan1", mixer= "sfx", loop=True)
            
    def clack_play(on=False):
        if on:
            renpy.music.play("click.wav", channel="Chan1")
        else:
            renpy.music.stop(channel="Chan1")
            
    
    def clicks(event, **kwargs):
        if event == "show" or event == "begin":
            clack_play(True)          
        if event == "slow_done" or event == "end":
            clack_play(False)

# The game starts here.
label start:
    
    e "You've created a new Ren'Py game."

    e "Once you add a story, pictures, and music, you can release it to the world!"

    return

Okay, to make this work, you also have to add this line to your screens code:

Code: Select all

    on "show" action Function(clack_play)
Where do you add it? Three places.

In the save, load screen area, add it twice:

Code: Select all

screen save():

    # This ensures that any other menu screen is replaced.
    tag menu

    use navigation
    use file_picker
    on "show" action Function(clack_play)
        
screen load():

    # This ensures that any other menu screen is replaced.
    tag menu

    use navigation
    use file_picker
    on "show" action Function(clack_play)
Right under that, in the preferences area add it under use navigation:

Code: Select all

screen preferences():

    tag menu

    # Include the navigation.
    use navigation
    on "show" action Function(clack_play)
That works for me as a way to deal with your audio, but also allow your players to go to the game menus while a slow text is on. I use a version of this method to make sure the tick tock of my clock CCD stops clicking when you go to the menu.
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
tomotomo
Regular
Posts: 32
Joined: Thu May 28, 2015 2:01 pm
Tumblr: tomatomagica
Location: Russia
Contact:

Re: Text bleeps callback won't stop when going to other menu

#9 Post by tomotomo »

trooper6, okay so here's what i got now

Code: Select all

screen no_game():
    key "game_menu" action NullAction()

# Callback
init -1 python:
    renpy.music.register_channel("Chan1", mixer= "sfx", loop=True)
            
    def clack_play(on=False):
        if on:
            renpy.music.play("m:/-renpy/Father/Music/callback1.ogg", channel="Chan1")
        else:
            renpy.music.stop(channel="Chan1")

    def clicks(event, **kwargs):
        if event == "show" or event == "begin":
            clack_play(True)          
        if event == "slow_done" or event == "end":
            clack_play(False)
            
# names
define cha = Character(u"Шарлотта", show_two_window=True, what_slow_cps=20, stop_on_mute=False, callback=clicks)
define dan = Character(u"Даниэлла", show_two_window=True, what_slow_cps=20, stop_on_mute=False, callback=clicks)
define doll = Character(u"Далия", show_two_window=True, what_slow_cps=20, stop_on_mute=False, callback=clicks)
and this in screens:

Code: Select all

   on "show" action Function(clack_play)
Everything works just fine, thanks
The question now is how do i make more different callbacks for different characters like i had in my first code? It is essential, since there will be at least 5 different beep sounds for different character's "voices"

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

Re: Text bleeps callback won't stop when going to other menu

#10 Post by trooper6 »

You don't need the no_game screen in your code since you never call it. That screen was for the option where you can't go to the menu while the slow text is running...but you aren't using that option, you are using the function option--so you don't need the screen.

To answer your question about having a bunch of different beeping sounds, you can achieve this by having a keyword variable in your callback to distinguish the different characters, pass that variable to the function and have an if statement in there that decides what beep to play based on the variable:

Code: Select all

init -1 python:
    #Register Audio Channel
    renpy.music.register_channel("Chan1", mixer= "sfx", loop=True)

    #Play Audio Function            
    def clack_play(on=False, char=1):
        if on:
            if char==1:
                renpy.music.play("click.wav", channel="Chan1")
            if char==2:
                renpy.music.play("pong_beep.wav", channel="Chan1")
        else:
            renpy.music.stop(channel="Chan1")

    #Callback
    def clicks(event, char=1, **kwargs):
        if event == "show" or event == "begin":
            clack_play(True, char)    
        if event == "slow_done" or event == "end":
            clack_play(False, char)
            
# names
define cha = Character(u"Шарлотта", show_two_window=True, what_slow_cps=20, stop_on_mute=False, callback=clicks, cb_char=1)
define dan = Character(u"Даниэлла", show_two_window=True, what_slow_cps=20, stop_on_mute=False, callback=clicks, ch_char=2)
I have to say, though...all those clicks for the entire game might annoy your player. Perhaps you should add an option to turn all those clicks off?
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
tomotomo
Regular
Posts: 32
Joined: Thu May 28, 2015 2:01 pm
Tumblr: tomatomagica
Location: Russia
Contact:

Re: Text bleeps callback won't stop when going to other menu

#11 Post by tomotomo »

trooper6, thanks again, it works perfectly!
as for this:

Code: Select all

I have to say, though...all those clicks for the entire game might annoy your player. Perhaps you should add an option to turn all those clicks off?
I already have a slider in the preference menu to change volume for typing text sound
though personally i like them, it kinda grew on me after playing ace attorney and professor layton and it feels almost lonely without them :,)
And as i said before, it will make it possible to tell what kind of voice character have without having to voice over them

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

Re: Text bleeps callback won't stop when going to other menu

#12 Post by trooper6 »

For me, there is an aesthetic disconnect. The typewriter in Ace Attorney worked for me because you were in an office setting and you could imagine what you were reading being typed out for a law file. Also, typewriter clicks are less harsh on the ear than electronic beeps. Also, what are your beeps representing? Are your characters all robots? How do the beeps make sense within the game concept? It is some sort of sci-fi futuristic thing where the beeps are the sounds made by their computers that copy down what they are saying?

I could imagine muffled or warped vocal sounds like Charlie Brown to have a sense of voicing work...but even then, the muffled vocal sounds in Charlie Brown were only given to the adults.

Anyway, do whatever you like! I just prefer choices to make some sort of in game sense.
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
tomotomo
Regular
Posts: 32
Joined: Thu May 28, 2015 2:01 pm
Tumblr: tomatomagica
Location: Russia
Contact:

Re: Text bleeps callback won't stop when going to other menu

#13 Post by tomotomo »

trooper6, well, actually i'm using marimba samples as beep sounds, personally i don't think they qualify as "harsh electronic beeps"
Here, you can test it by yourself http://picosong.com/jDKV/
I think it sounds nice with background music as it is a musical instrument sound itself
I understand that not everybody will like it, so sure, they can just mute it if they want, it's not all that hard to do
As for what they represent - they represent a tone of character's voice
For example, i'm planning on having a character who is a pre-op transgender woman, so it would be nice to show that her voice is pretty deep, it would give a certain impression to the reader

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

Re: Text bleeps callback won't stop when going to other menu

#14 Post by trooper6 »

tomotomo wrote:trooper6, well, actually i'm using marimba samples as beep sounds, personally i don't think they qualify as "harsh electronic beeps"
Here, you can test it by yourself http://picosong.com/jDKV/
I think it sounds nice with background music as it is a musical instrument sound itself
I understand that not everybody will like it, so sure, they can just mute it if they want, it's not all that hard to do
As for what they represent - they represent a tone of character's voice
For example, i'm planning on having a character who is a pre-op transgender woman, so it would be nice to show that her voice is pretty deep, it would give a certain impression to the reader
Marimba sounds that work with the instrumental music sounds awesome. And those marimba sounds are much nicer than some of the harsh electronic beeps I've heard before.

One note. A trans woman's voice (unlike a trans man's voice) is not effected by op status...or hormones actually. Trans women regardless of op or hormone status can train to have a higher sounding voice, or choose not to. I'd caution against going the "deep voice/trans woman" thing...it would give a certain impression to the reader...but depending on the reader that impression might be the transphobic one that trans women are "really" men.
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
tomotomo
Regular
Posts: 32
Joined: Thu May 28, 2015 2:01 pm
Tumblr: tomatomagica
Location: Russia
Contact:

Re: Text bleeps callback won't stop when going to other menu

#15 Post by tomotomo »

One note. A trans woman's voice (unlike a trans man's voice) is not effected by op status...or hormones actually. Trans women regardless of op or hormone status can train to have a higher sounding voice, or choose not to. I'd caution against going the "deep voice/trans woman" thing...it would give a certain impression to the reader...but depending on the reader that impression might be the transphobic one that trans women are "really" men.
ahh i'm really sorry i didn't meant to sound transphobic in any way
the thing is that i based my choice on my friend's experience who became much braver after operation and were finally able to gradually adjust her voice to match her gender

Post Reply

Who is online

Users browsing this forum: Dark79, Majestic-12 [Bot]