Ren'Py [concluded] Paused audio bug v.7.4.10

Lou111

Active Member
Jun 2, 2018
538
680
** Bug confirmed:
PauseAudio()
renpy.music.set_pause()
using the pause function then showing a video results in playing the audio again while Ren'Py continues to function under the assumption that the channel is still paused.
If you need a work-around, there is a possible solution posted here.

Update:
I am told that this will be fixed in the next patch. If you have this issue make sure you're up to date. (y)




I play a song on a channel named "two":
Python:
label start:
    play two "audio/song.ogg"

Using an imagebutton I open the character screen
Because I don't know when music will be playing, nor which song will be playing I use PauseAudio("two", True)
I've tried putting the pause in a million places but the two functional places were on 'show' or as an action in the imagebutton:
Python:
screen character_screen():
    modal True
    zorder 99
    imagebutton:
        idle "images/characters/Samantha/Samantha.jpg"
        hover "images/characters/Samantha/Samantha.jpg"
        hovered SetVariable("name_Samantha_hover", True)
        unhovered SetVariable("name_Samantha_hover", False)
        # Play a different song on channel named "seven"
        action [Show("Samantha_status_screen"), Play("seven", "audio/other song", False)]

    # Pauses the song
    on 'show' action PauseAudio("two", True)

I unpause it as I exit back the game. It works. I give myself a pat on the back and sip my coffee.
Until:
Python:
screen Samantha_status_screen():
    modal True
    zorder 99

    imagebutton:
        xpos 50
        ypos 200
        idle  "images/characters/Samantha/sides/Samantha status.png"
        hover  "images/characters/Samantha/sides/Samantha status.png"
        hovered SetVariable("image_Samantha_hover", True)
        unhovered SetVariable("image_Samantha_hover", False)
        action NullAction()
    if image_Samantha_hover:
        add getattr(store, "video/status/Samantha status.webm"):
            xpos 50
            ypos 200


When I hover the imagebutton the movie plays, and the game completely forgets that the music paused. This means I get a movie and two songs playing, like a party at a frat house without all the piss covering the walls.
Here's the audio channels:
Python:
init python:
    renpy.music.register_channel("two", mixer="music", loop=True)
    renpy.music.register_channel("seven", mixer="music", loop=False)
    renpy.music.register_channel("status_movie", mixer="voice", loop=False, movie=True)

I can't for the life of me figure out the correlation between adding a video and ren'py forgetting that a variable is false...
Solutions I've found involve returning a bunch of information from the track and resuming from the point while being as incomprehensible as possible.
Thing is, the pause works fine up until I add a video on the screen. I couldn't find anything involving "unpausing" issues... I'm hoping for a solution or an alternative.
Please and thank you!
 
Last edited:

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,369
15,284
Python:
    # Pauses the song 
    on 'show' action PauseAudio("two", True)
I can be wrong (not my best day), but wrote as this, the pause should automatically stop when the screen isn't shown anymore.

Personally I would try this:
Python:
screen Samantha_status_screen():
[...]

    if image_Samantha_hover:
        $ renpy.music.set_pause( "two", True )  # <-
        add getattr(store, "video/status/Samantha status.webm"):
            xpos 50
            ypos 200
    else:   #  <-
        $ renpy.music.set_pause( "two", False )  # <-
It should pause the channel if the video is displayed, and unpause it if the video isn't displayed


This being said, are you sure about your getattr ? Here you're telling Python to give you the value stored in the variable named store.video/status/Samantha status.webm and I have some doubts.
 
  • Love
Reactions: Lou111

Lou111

Active Member
Jun 2, 2018
538
680
Hi and thanks!
I just tried the code you posted and it's doing the same thing. :(

This being said, are you sure about your getattr ? Here you're telling Python to give you the value stored in the variable named store.video/status/Samantha status.webm and I have some doubts.
That's something I can be absolutely sure of. The video is playing just fine. Just when I hover the image it unpauses channel two for some reason. I'm trying to pause the audio as soon as the status screen is accessed, not when the video is displayed. The menu has different music is all. However, when that imagebutton is hovered everything goes to hell.
The behavior is similar to when I try playing a second video and the first video changes to the second because they're on the same channel but in this case I'm pretty sure it's not possible.

Something funky is going on because this doesn't even pause the music for some reason:

Python:
label start:
    play two "audio/picture.ogg"
    "The music is playing."
    $ renpy.music.set_pause( "two", True )
    "The music is still playing."
It's 1pm and I haven't slept yet. I'm trying to post what could possibly cause this before I crash but all I see is how it's impossible for it not to work right now... :LOL: ahhh.

Here's the setattr just incase:
Python:
init python:
    for f in renpy.list_files():
        if not f.startswith("video/status"): continue
        setattr(store, f, Movie(size=(400,560), play="{}".format(f), channel="status_movie"))
 
Last edited:

Playstorepers

Member
May 24, 2020
160
79
Hi and thanks!
I just tried the code you posted and it's doing the same thing. :(


That's something I can be absolutely sure of. The video is playing just fine. Just when I hover the image it unpauses channel two for some reason. I'm trying to pause the audio as soon as the status screen is accessed, not when the video is displayed. The menu has different music is all. However, when that imagebutton is hovered everything goes to hell.
The behavior is similar to when I try playing a second video and the first video changes to the second because they're on the same channel but in this case I'm pretty sure it's not possible.

Something funky is going on because this doesn't even pause the music for some reason:

Python:
label start:
    play two "audio/picture.ogg"
    "The music is playing."
    $ renpy.music.set_pause( "two", True )
    "The music is still playing."
It's 1pm and I haven't slept yet. I'm trying to post what could possibly cause this before I crash but all I see is how it's impossible for it not to work right now... :LOL: ahhh.
According to the documentation, True comes first followed by channel name not the other way around, but idk whether it will solve your problem.
 
  • Love
Reactions: Lou111

Lou111

Active Member
Jun 2, 2018
538
680
According to the documentation, True comes first followed by channel name not the other way around, but idk whether it will solve your problem.
Nice!
It did make it work in the script but the screen is behaving the same...
 

Playstorepers

Member
May 24, 2020
160
79
I'm not sure whether I checked the right documentation, but according to:



movies use the music channel. Of course you renamed your mainmusicchannel to "two", but just for kicks try using another mixer for your "two" channel?

Next, try out anne's solution with it, maybe that will help?

And lastly, if you haven't already done that, switch True with two in your

on 'show' action PauseAudio("two", True)

It shouldn't be the cause since it already works unless the button is hovered, but just be sure, that we observe the behaviour correctly:
The music pauses on show of the screen and it doesn't start if you don't move your mouse, right?

Then you start hovering over the imagebutton and then, ONLY THEN not before, the music continues, while you watch the video is that correct?

If so, it has something to do with the fact, that your video is looking for a music channel to use. Please double check, whether it's really the case. If so, try to mess around with the video play function to see, what alternatives you have.

That's my two cents, at least.
 
  • Love
Reactions: Lou111

Lou111

Active Member
Jun 2, 2018
538
680
I'm not sure whether I checked the right documentation, but according to:



movies use the music channel. Of course you renamed your mainmusicchannel to "two", but just for kicks try using another mixer for your "two" channel?

Next, try out anne's solution with it, maybe that will help?

And lastly, if you haven't already done that, switch True with two in your

on 'show' action PauseAudio("two", True)

It shouldn't be the cause since it already works unless the button is hovered, but just be sure, that we observe the behaviour correctly:
The music pauses on show of the screen and it doesn't start if you don't move your mouse, right?

Then you start hovering over the imagebutton and then, ONLY THEN not before, the music continues, while you watch the video is that correct?

If so, it has something to do with the fact, that your video is looking for a music channel to use. Please double check, whether it's really the case. If so, try to mess around with the video play function to see, what alternatives you have.

That's my two cents, at least.
I enjoyed your deduction process. Helped me feel that I wasn't crazy (that's important)
I removed all registered channels except for the ones in use for this scenario
I played the initial song on a different channel, also tried setting movie to false and used a different mixer too.
I also removed the channel designation for the video just for kicks.

I noticed something during this, and that is that the pause function only worked the first time
After hovering the imagebutton, the music starts again, I go back to the character screen a second time and the music keeps on playing even before interacting with the screen.
I opened the console to pause the music manually and it didn't work, however, stop two worked.
I can only assume that when I fetch the video, ren'py then assigns the paused audio to a different channel which isn't paused.
I've tried tried to locate where it's being played with no luck (hence why I removed all the audio channels)
The only thing I know is that the mixer is still music when this happens.

I also just discovered that the issue has nothing to do with hovering or interaction, I just added the video to the screen without the need for interaction and channel two unpauses
 
Last edited:

Lou111

Active Member
Jun 2, 2018
538
680
I've created a new game, it's not much but I think you'll like it:
Python:
init python:
    renpy.music.register_channel("two", mixer="music", loop=True, movie=False)
    renpy.music.register_channel("status_movie", mixer="voice", loop=False, movie=True)

init:
    image myVideo = Movie(size=(400,560), channel="status_movie", play="video/status.webm", loop=True)

label start:
    "Hi."
    play two "audio/music.ogg"
    "Great music."
    $ renpy.music.set_pause( True, "two" )
    "Oh no, where did the music go?"
    show myVideo
    "I'll just show a video to unpause it!"

    "The End"
    return
I am Betrayed.
I have to look into finding a function that returns all the information about a song that may or may not be playing at the time. Nothing is as simple as it seems. It just really bothers me that nobody else has had this problem before, perhaps a bug in the patch? Irrelevant I suppose.
 
  • Like
Reactions: Playstorepers

Playstorepers

Member
May 24, 2020
160
79
you can check out this thread



looks like somebody struggled with a similar crapstorm and went with a while function. Idk whether it will ultimately help you, but it could provide another insight.

Other than that, I have honestly no clue, why renpy behaves like that....
 
  • Love
Reactions: Lou111

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,369
15,284
I am Betrayed.
More than you think.

Use this as "start" label, and you'll see how far the betrayal goes:
Code:
label start:
    "Hi."
    play two "audio/music.ogg"
    "Great music."
    $ paused = renpy.game.context().music["two"].pause
    "Pause status: [paused]"
    $ renpy.music.set_pause( True, "two" )
    "Oh no, where did the music go?"
    $ paused = renpy.game.context().music["two"].pause
    "Pause status: [paused]"
    show myVideo
    "I'll just show a video to unpause it!"
    $ paused = renpy.game.context().music["two"].pause
    "Pause status: [paused]"

    "The End"
    return
It just show you the pause status of your "two" channel. And as you can see, it is still paused when the video is displayed... paused but yet you hear the music, yeah, I know :/

And to be sure, I did the same test while using the default "music" and "movie" channels, and with both the 6.99.12.4 and 7.4.10 version, with exactly the same result. Once the movie start, the music have still the "pause" status, but is clearly heard.

Congratulation, seem that you found a years old bug, you should probably report it.
 
  • Love
Reactions: Lou111

Lou111

Active Member
Jun 2, 2018
538
680
Playstorepers
Thank you for helping me isolate the issue. I envy your deductive reasoning.
anne O'nymous
Thank you for taking the time to remove the idea that this may not be a bug.

I'm both relieved that the issue has been "concluded" and torn up about how much time it took. My take-away here is that I've learned that I need to do a better job of isolating the issue further before seeking to resolve it.

If and when I find an alternative method I'll post it here.
Thanks everyone!
 
Last edited:

Playstorepers

Member
May 24, 2020
160
79
The quick and dirty solution would be to ignore the pause and instead lower the volume of the channel.
It's not the same as a pause, since the music would continue to play in the background, but with fade in and fade out it becomes a lot more cool if you ask me.
 
  • Love
Reactions: Lou111

Lou111

Active Member
Jun 2, 2018
538
680
The quick and dirty solution would be to ignore the pause and instead lower the volume of the channel.
It's not the same as a pause, since the music would continue to play in the background, but with fade in and fade out it becomes a lot more cool if you ask me.
I was going to look into that as well but, to be honest, this issue took the wind out of my sails.
That'll be the first thing I do after work. Thanks for bringing this up. This bug makes every alternative 'dirty', may as well make it quick too. Thanks!
 

Lou111

Active Member
Jun 2, 2018
538
680
My work-around for music unpausing if/when videos are shown...

This fix assumes that:
-music may or may not be playing
-only one file needs to be muted at any given time
-returning to the previously playing song/sound from the beginning is a non-issue

initial code:

Python:
init python:
    # i.e. music while playing the game
    renpy.music.register_channel("two", mixer="music", loop=True)
    # i.e. menu music
    renpy.music.register_channel("seven", mixer="music", loop=False)
    renpy.music.register_channel("status_movie", mixer="voice", loop=False, movie=True)
   
    # the "act" argument is redundant because it can function like
    # a toggle but I can't take any more bugs right now...
    audioName = ""
    def Pause(chan, act):
        global audioName
        if act == 0:
            if renpy.music.is_playing(channel=chan):
                audioName = renpy.music.get_playing(channel=chan)
                renpy.music.stop(channel=chan, fadeout=1.0)
            else:
                audioName = ""
        elif act == 1:
            if audioName != "":
                renpy.music.play("{}".format(audioName), channel=chan, fadein=1.0, tight=True)
            else:
                return
usage:

Python:
# in the script
label chain_0_0:
    play two "audio/nice jam.ogg"
    "Nice song."
    $ Pause("two", 0)
    "Music is fading."
    $ Pause("two", 1)
    "Music is coming back."
   
    return
   

# opening a menu
screen top_screen_bar():
    imagebutton:
        idle "images/assets/characters.png"
        hover "images/assets/characters.png"
        action [Function(Pause, "two", 0), Show("character_screen")]

# closing the menu
screen character_screen():
    imagebutton:
        idle "images/assets/poweroff.png"
        hover "images/assets/poweroff.png"
        action [Hide("character_screen"), Function(Pause, "two", 1)]
I understand this is a lazy fix but this issue has unmanned me. Until amazon sends me a new pair of testicles, I hope this fix helps someone in the future. Using the volume change turned out to be a little more challenging than this when pairing it with fades (for me) so I went with the stop method. Thanks everyone for helping me with this.
 
  • Like
Reactions: anne O'nymous