Help in Audio

Kvitravn Dev

Making Memories / Further Education
Game Developer
Jul 1, 2020
358
3,161
I am in process of finalizing my v0.1 and its almost done it's just my Music has an issue-
When I load a save, nothing plays, but when started from the beginning, it plays fine, until- well when I have to load.

The Code
Python:
label start:
    stop music fadeout 1.0
    queue music [ "music/AK-Wanderlust.mp3", "music/Nomyn-Elsewhere.mp3", "music/Nomyn-Escape.mp3" ]

    scene p1 with dissolve..........
Any help would be greatly appreciated :)
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,561
2,183
Something else is going on.

I've just recreated a longer version of the code you provided and it works fine.

Python:
label start:

    scene black with fade

    "*** START ***"

    "before music starts to play."

    stop music fadeout 1.0
    queue music [ "music/one.mp3", "music/two.mp3", "music/three.mp3", "music/four.mp3", "music/five.mp3", "music/six.mp3" ]

    "Music has started."
    "Music continue to play."
    "Music is still playing."
    "You can save now."

    "*** THE END***"

    return

The only "issue" is that when you load a save file, the music queue resets back to the beginning and ignores where it was currently up to. But that's not the issue you're describing and is pretty much working as intended.

Only thing that comes to mind is something I did myself while testing this, start the game, load a save, open the console (SHIFT+O) then issue this command....
Code:
print renpy.music.get_loop()

It will at least tell you what the current music queue looks like, regardless of whether it is actively playing or not.
(it will return None if the queue is empty).
 

Kvitravn Dev

Making Memories / Further Education
Game Developer
Jul 1, 2020
358
3,161
I think I got it,
When I used the save POST implementation of the music, the music plays After loading, but not when loading a save PRE implementation of music.
Still would like to know how and why does this happen.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Respected User
Donor
Jun 10, 2017
10,263
15,073
Still would like to know how and why does this happen.
Hmm, really ?

Think about it a little more... Why could it be that, when you load a saved file that contain no indication of a music list, and not even an indication that some music were played, it happen that you end with no indication of a music list, and no music played ?
 

Kvitravn Dev

Making Memories / Further Education
Game Developer
Jul 1, 2020
358
3,161
Wow Anne, thanks for the insight, this was a real learning moment truly.
Maybe that's why some of the saves go incompatible after updates, I'll have to look out for that too.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Respected User
Donor
Jun 10, 2017
10,263
15,073
Maybe that's why some of the saves go incompatible after updates, I'll have to look out for that too.
Almost 99% sure that it is why.

It's a summary, but globally Ren'py speaking, when you load a save file, Ren'py will revert the game to the state it was when you made this save file. This mean that if a variables didn't exist when you saved the game, it will also not exist when you load this save. If you created it in between, then Ren'Py will forget all memory about it once the save file will be loaded.

In the case of a music list or some music being played, it's not obvious, because from your side it don't feel like you changed a variable. You said, "hey, Ren'Py, play some music", not, "hey Ren'Py, put the 'musicIsPlaying' variable to True". But behind the scene, it's what Ren'Py did, he put the 'musicIsPlaying' variable to True ; well, the variable just have a better name.
Therefore, when you load a save file made at a time there were no music played, Ren'Py will look at the variable name 'musicIsPlaying', see that it's value is False, and so not play the music. And the same with the music list, there were no music inside it when you created the save file, so it will put no music inside when you'll load this saved game.

There's few exceptions, but here isn't really the place and time to talk about them. If you want to know more, don't hesitate to read the .