Text beep plays during the game menu

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
Tayruu
Regular
Posts: 141
Joined: Sat Jul 05, 2014 7:57 pm

Text beep plays during the game menu

#1 Post by Tayruu »

So the "godawful beeping noise" in the Cookbook and documentation is great and all, but I cannot find anything to deal with the fact that the sound plays when you open the menu. The sound will continue to play until you close the menu again.

The sound will also start and continue to play if the player opens and closes the menu just as dialogue ends. Even though the dialogue has stopped, the sound starts playing again.

Code: Select all

    old_entermenu = _enter_menu
    def _enter_menu():
        old_entermenu()
        renpy.music.stop(channel="text")
This code does stop the sound when the player enters the menu, but not in the case of the latter situation (end of line), the sound replays when the menu is closed, and keeps restarting whenever I close the menu. In the case of the former (during text playing out), closing the menu can result in a single 'blip' if text ceased typing while the menu was open.

I would like it if I could halt the text type while the menu was open. Even without a menu background I can't see what the text box is doing. Not that I want to - but in the case of testing, since I don't know what dialogue is doing, I'm not really sure what the cause is.

Really, I would like to halt text entirely during the menu. I know it's still playing out when the menu is open and I'm not sure I want that design. This isn't what's causing the looping sound, mind you. That's the fact the channel loops. (If the channel doesn't loop, the beep only plays once. I also cannot queue up the beep to repeatedly play with no loop, as far as I can tell.)

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Text beep plays during the game menu

#2 Post by xela »

It's working just fine for me (I may not be understanding the question correctly), post your code please.
Like what we're doing? Support us at:
Image

User avatar
Tayruu
Regular
Posts: 141
Joined: Sat Jul 05, 2014 7:57 pm

Re: Text beep plays during the game menu

#3 Post by Tayruu »

Oh no the text beep itself works fine, the problem is that it will play through the menu. The above code stops it fine, but in select instances it will replay (on repeat or once) when closing the menu. Stopping the channel in my "close menu" code - as the "enter menu" code does... doesn't seem to work?

This is not counting the last paragraph where I'd want to stop text during the menu, as it'll type out in the background. This wouldn't stop the bug at hand unless the callback could refer to every time an individual letter is printed.

Code: Select all

    def CloseMenu(func=None, gallery=False, sound=False):
        if sound:
            renpy.play(config.exit_sound)
        if func == "title" or (main_menu and not gallery):
            Show("main_menu")()
            renpy.transition(Dissolve(0.2), always=True, force=True)
        elif main_menu and gallery:
            Show("gallery_menu")()
            renpy.transition(Dissolve(0.2), always=True, force=True)
        else:
            return [Return(), ToggleSkip(True)]
            
    CloseMenu = renpy.curry(CloseMenu)
Last edited by Tayruu on Sat Aug 16, 2014 7:11 am, edited 1 time in total.

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Text beep plays during the game menu

#4 Post by xela »

I have no idea of what the problem is and what that class is supposed to be doing. By menu people usually mean choice menu in Ren'Py, you have a variable there called main_menu, which I'd expect to reference the label/screen you start the game from.

From your initial post I got the following:

- You use renpy.say or Ren'Py script equivalent and use callback to play beeping sound.
- When the game enters choice menu, sound is being played, which is undesirable.
- When you exit the menu, sound is played again. (also not intended).

So I tried it in a fresh project (never used these callbacks before) and it worked just fine... So either it is me misunderstanding your issue or we did something differently when defining the callback it self...


Figured out the problem*
*Partly

I've mitigated it to a great degree simply by adding:

Code: Select all

on "show" action Stop("text")
to the navigation screen.

That seems to have covered most of the issues, however all ideas that I have on how to actually pause say while in the menu are too hard to implement without potentially wasting hours on the problem.

I love Asceai's solution to these issues. Simply drop the entire Ren'Py game menus system and use it as proper screens inside of the games context without creating a new one and going through dozens of lines of hidden logic. You could simply create a pretty preference/save/load and etc screens that appear above the say window when called and allow users to look at the texts while showing any of the game menu screens on top.
Like what we're doing? Support us at:
Image

User avatar
Tayruu
Regular
Posts: 141
Joined: Sat Jul 05, 2014 7:57 pm

Re: Text beep plays during the game menu

#5 Post by Tayruu »

Yeah, when I'm talking about the game menu, I mean the "pause" screen. The one from pressing right-click, or escape, or something. (Is this not, like, obvious or something.)

I can stop the "text" channel fine when entering the game menu. If the menu is called when a message is about to end, then closed, the text sound will start up again and keep playing even though no text is typing out.

I've also discovered that during the action that's closing the game menu, the text channel is not playing. Something like [Return(), Stop("text")] doesn't work. I discovered this when I was trying to work out if Ren'py was even registering the sound as playing. I used [Return(), renpy.call_in_new_context("stop_text")], as well as the following:

Code: Select all

label stop_text:
    $ print renpy.music.get_playing(channel='music')
    $ print renpy.music.get_playing(channel='sound')
    $ print renpy.music.get_playing(channel='voice')
    $ print renpy.music.get_playing(channel='text')
    stop text
    return
init -150 python:      
    def soundcheck():
        ui.keymap(K_w = renpy.curried_call_in_new_context("stop_text"))
    config.overlay_functions.append(soundcheck)    
Bizarrely, if I then open the developer menu after tapping W to check the channels (and stop the sound), the sound restarts.

I think this issue is in the design of the callback. The issue also can affect a Phoenix Wright system demo around here using the same blip effect. (I checked in case, I dunno, it was something I did.)

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Text beep plays during the game menu

#6 Post by xela »

Tayruu wrote:If the menu is called when a message is about to end, then closed, the text sound will start up again and keep playing even though no text is typing out.
I couldn't replicate this when using on "hide".
Like what we're doing? Support us at:
Image

User avatar
Tayruu
Regular
Posts: 141
Joined: Sat Jul 05, 2014 7:57 pm

Re: Text beep plays during the game menu

#7 Post by Tayruu »

I found that weird that you couldn't replicate the issue, so I tried shuffling things into a fresh project. Narrowing down potential subject files, I got down to config.enter_transition. If there is no transition, there seems to be... no problem. wh.

The transition occurs in _enter_game_menu, which plays before the check for the label enter_game_menu, meaning something like

Code: Select all

label enter_game_menu:
    $ renpy.music.stop(channel="text")
    return
... doesn't work, because it seems like when returning from the menu Ren'py restores whatever was playing - and the sound was not stopped before storing that information.
Following the chain of calls leads to _invoke_game_menu, which is called by... the game_menu key. I had already replaced this code with the monstrosity that follows.

Code: Select all

    def new_game_menu():
        print "Called new game menu."
        if not renpy.context()._menu:
            renpy.music.stop(channel="text")
            renpy.call_in_new_context('_game_menu')
            
    km = renpy.Keymap(
        screenshot = _screenshot,
        developer = _developer,
        toggle_fullscreen = renpy.toggle_fullscreen,
        toggle_skip = _keymap_toggle_skipping,
        game_menu = new_game_menu,
        hide_windows = renpy.curried_call_in_new_context("_hide_windows"),
        quit = renpy.quit_event,
        )
    config.underlay = [ km ]
    del km
Putting the stop line in there works! ... but as I said, it's a monstrosity. The large Keymap array (er, hash?) there is copied from the internal keymap script, because if I use anything else*, there is a slight chance the original code (_invoke_game_menu) executes instead.

*For example, this would be much better, but it isn't always acknowledged.

Code: Select all

    def game_menu_replace():
        ui.keymap(game_menu = new_game_menu)
    config.overlay_functions.append(game_menu_replace)
Using this code instead, and adding print "Original game_menu." to def _invoke_game_menu(): in 00gamemenu.rpy, I am able to see that in certain instances (during a transition, when a say has just started? i don't really know), the original is used instead.

I've been messing with control over opening/closing the menu for other purposes too, so it appears. Fun. x -x

User avatar
G0RG3h
Newbie
Posts: 17
Joined: Tue Nov 02, 2021 8:59 am
Projects: Circle Head
itch: g0rg3h
Contact:

Re: Text beep plays during the game menu

#8 Post by G0RG3h »

Sorry to revive but I'm having this exact same issue with..
The sound will also start and continue to play if the player opens and closes the menu just as dialogue ends. Even though the dialogue has stopped, the sound starts playing again.
this part.

Code: Select all

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

    #Play Audio Function
    def clack_play(on=False, char=1):
        if on:
            if char==1:
                renpy.music.play("audio/bleep009.ogg", channel="Chan1")
            if char==3:
                renpy.music.play("audio/bleep027.ogg", channel="Chan1")
        else:
            renpy.music.stop(channel="Chan1", fadeout=0.1)

    #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)
and I've already placed

Code: Select all

on "show" action Function(clack_play)
under every single screen that could interrupt this function I have :?

If it helps, which I'm sure has something to do with it but this is worrying anyways, I'm using the prerelease using python 8...does this mean if I actually go ahead and use python 8 that my callbacks will stop working? It's necessary to me due to the

Code: Select all

define config.choice_empty_window = extend
that python 8 comes with so I'm especially torn. This is the only page i've been able to find someone having this problem and it's back in 2014...
<<<<damn you len>>>>>

User avatar
Syrale
Regular
Posts: 101
Joined: Sun Oct 25, 2015 10:28 am
Completed: Robot Daycare, Deep Sea Valentine, Locke(d)
Projects: Artificial Selection, Artificial Fashionista, rei_carnation
Github: kigyo
itch: kigyo
Discord: kigyodev
Contact:

Re: Text beep plays during the game menu

#9 Post by Syrale »

I actually had the same issue last year. Maybe this helps you like it helped me?
viewtopic.php?f=8&t=62820&p=545206#p545368
ImageArtificial Selection (ongoing) |ImageDeep Sea Valentine | ImageRobot Daycare (NaNo19)
| ImageArtificial Fashionista (NaNo24)

My Developer Tools: Ren'Py Minimap/Location System | Ren'Py Word Counter+

User avatar
G0RG3h
Newbie
Posts: 17
Joined: Tue Nov 02, 2021 8:59 am
Projects: Circle Head
itch: g0rg3h
Contact:

Re: Text beep plays during the game menu

#10 Post by G0RG3h »

Thank you but it does not, unfortunately. It renders the bleeps silent and the doc has no example on how to use multiple bleeps for multiple characters. I'm just going to have to just go back to renpy 7 for good or at least until this gets worked out because I have no idea what's wrong. Never had this problem on 7. Thanks for trying though!

... Was really looking forward to the auto extend :?
<<<<damn you len>>>>>

User avatar
Syrale
Regular
Posts: 101
Joined: Sun Oct 25, 2015 10:28 am
Completed: Robot Daycare, Deep Sea Valentine, Locke(d)
Projects: Artificial Selection, Artificial Fashionista, rei_carnation
Github: kigyo
itch: kigyo
Discord: kigyodev
Contact:

Re: Text beep plays during the game menu

#11 Post by Syrale »

Oh yeah, now that I checked, I can confirm I get the same error in 8 even though my beep code is different. :/
ImageArtificial Selection (ongoing) |ImageDeep Sea Valentine | ImageRobot Daycare (NaNo19)
| ImageArtificial Fashionista (NaNo24)

My Developer Tools: Ren'Py Minimap/Location System | Ren'Py Word Counter+

Post Reply

Who is online

Users browsing this forum: No registered users