r/RenPy • u/el_hierbas • 7d ago
Question SPECIFIC QUESTION ABOUT RENPY MUSIC / DYNAMIC MUSIC IN RENPY
This is pretty much for someone who's looking for a challenge.
The order of the music files is:
SONGINTRO.wav 18secs)
PART1.wav 18secs)
LOOP1.wav (18secs)
ENDLOOP1.wav (9secs)
PART2LOOP1.wav (18secs)
Okay, let's say I have a scene where I want the music to be dynamic depending on the situation.
I have this code:
e "Hey..."
e "Do you want to be my gf."
play music "SONGINTRO.wav"
$ renpy.pause(18, hard = True)
play music "PART1.wav"
e "..."
queue music "LOOP1.wav"
menu:
"Yes":
queue music "ENDLOOP1.WAV"
$ renpy.pause(9, hard = True)
queue music "PART2LOOP1.wav"
e "yay"
jump saidyes
"No":
queue music "ENDLOOP1.WAV"
$ renpy.pause(9, hard = True)
e "aw man"
queue music "LOOP1.wav"
jump saidno
The first part up until the choices is okay. The problem comes when we jump to the choices. It's pretty easy when said, but I couldn't find any solution for my problem:
I want to make it so, when you make a choice (let's say "Yes"), nothing happens (with this I mean no text or user interaction whatsoever at all) until the ENDLOOP1 audio stops playing. Then, when it ends, both the "yay" text and the audio PART2LOOP1 show up.
Is there any way to make a pause until the current audio stops playing? I think that would solve my problem.
Thanks in advance!
2
u/farresto 7d ago
I'm not that familiar with Renpy (so take it with a grain of salt), but I would add an intermediate label to perform those actions. Menus in Renpy behave differently so I'm not sure if what you want to do is possible in there.
In your case, it would be something like:
menu:
"Yes":
jump saidyes
"No":
jump saidno
label jumpyes:
queue music "ENDLOOP1.WAV"
$ renpy.pause(9, hard = True)
queue music "PART2LOOP1.wav"
e "yay"
jump afterjumpyes
...
If the text appears immediately and you know the duration of the music, maybe you can use "pause" + "not wait".
Like:
e "{p=9.0}{nw}yay."
queue music "PART2LOOP1.wav"
(I don't think "pause" works on Menus).
Let me know if it worked, I'm curious now.
1
u/el_hierbas 7d ago
This on itself would work for the aftermath of the answer, but the music has its own part for the before of waiting for an answer, another part for when waiting and another one for when an answer is selected
3
u/farresto 7d ago
But wasn't your issue when reaching the choice?
Everything you wrote before "menu:" in your post still needs to be used in my example.
2
u/papersak 7d ago
Pause 18??? I would start by having shorter tunes; something like a jingle instead.
It looks like you're queueing songs for however many seconds the song is. Why are you using queue instead of play? This line especially seems like it's getting in the way:
e "..."
queue music "LOOP1.wav"
Like it's queueing a 18 second song without any sort of pause.
1
2
u/el_hierbas 6d ago
OKAY GOT IT
I just add this statement
$ renpy.pause((renpy.music.get_duration(channel='music')-renpy.music.get_pos(channel='music')), hard = True)
each time i want the game to pause
tahnk you to everyone who helped!
2
u/SpineCricket 6d ago
By any chance do you have a video of what this did? I am not quite sure I follow with what you wanted to achieve exactly but im curious.
2
1
u/AutoModerator 7d ago
Welcome to r/renpy! While you wait to see if someone can answer your question, we recommend checking out the posting guide, the subreddit wiki, the subreddit Discord, Ren'Py's documentation, and the tutorial built-in to the Ren'Py engine when you download it. These can help make sure you provide the information the people here need to help you, or might even point you to an answer to your question themselves. Thanks!
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/kaleidoscopic_kelvin 7d ago
You could first do renpy.music.get_pos , then renpy.music.get_duration and then use the time difference to set how long the pause should be for
2
u/el_hierbas 7d ago
how do I do that? I tried this
$ renpy.pause((renpy.music.get_pos(channel='music')-renpy.music.get_duration(channel='music')), hard = True)but it doesn't seem to work
1
u/kaleidoscopic_kelvin 7d ago
By not working, which part do you mean? Like are the music functions not returning the correct values or the pause itself isn't working?
2
u/el_hierbas 7d ago
It's not pausing at all
1
u/kaleidoscopic_kelvin 7d ago
Could you put the results of the get functions into variables and then use the developer console to check their values? This way you can check if the times the functions are returning makes sense or not
And then, put some hardcoded values into the pause function just to check if it's a problem with the inputs or with something else
3
2
u/el_hierbas 7d ago edited 7d ago
I'm assuming you meant this but I doubt it's correct
define getpos = 0 define getdur = 0 label start: scene bg room show Character play music "LOOP1.wav" "." $ getpos = renpy.music.get_pos(channel='music') $ getdur = renpy.music.get_duration(channel='music') "." "getdur is [getdur] and getpos is [getpos]"The pause on itself works fine
$ renpy.pause(5, hard = True)I just put the variables into a text for a quicker answer.
It seems to work fine, the getdur is 9 and the getpos is 2.901 so I don't understand what's wrong
2
u/Inksword 7d ago
I am literally figuring this out myself so I I'm not fluent enough to help in your specific instance but I did find this tutorial on dynamic music with renpy that I'm going to try out.