music queues (fixed)

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
iichan_lolbot
Veteran
Posts: 206
Joined: Tue Dec 30, 2008 9:18 am
Projects: iichan erogame
Contact:

music queues (fixed)

#1 Post by iichan_lolbot » Wed Dec 31, 2008 9:47 am

Our composer found a strange thing related with music queues.
We wanted to make a track that would have an intro part and looped main part.
So, we wrote:

Code: Select all

    $ renpy.music.play (pla_intro, loop=False)
    $ renpy.music.queue (pla_play, loop=True)
BUT, this code started looped pla_play at once, without pla_intro.

We tried to insert pause between them, and found out, that THIS construction works just as we want:

Code: Select all

    $ renpy.music.play (pla_intro, loop=False)
    $ renpy.pause(0.0)
    $ renpy.music.queue (pla_play, loop=True)
Is that normal?.. Is it a bug or a feature? =)

By the way, "pass" statement doesn't have the proper effect of renpy.pause(X) with any X.
Last edited by iichan_lolbot on Sat Jan 03, 2009 9:04 am, edited 1 time in total.

User avatar
PyTom
Ren'Py Creator
Posts: 15893
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: music queues

#2 Post by PyTom » Wed Dec 31, 2008 11:20 am

Yes, what you're seeing is normal behavior, at least in the rarefied air of the seamless soundtrack. Basically, Ren'Py has three things its considering when it's playing music:

* The currently playing track.
* A list of queued tracks. (the "queue")
* A list of tracks that will be added to the queue if it ever gets empty. (the "loop")

When you call renpy.music.play:
* the currently playing track is stopped
* the queue is cleared out
* your track is added to the queue
* the loop is set to a list containing your track

When you call renpy.music.queue:
* the queue is optionally cleared out
* your track is added to the queue
* the loops is set to a list containing your track

Due to the way Ren'Py is implemented, tracks only start playing while inside an interaction. Whenever we're in an interaction with no currently playing track, we take the first one in the queue, remove it from the queue, and play it. If the queue is empty and the loop is not, we add the loop to the end of the queue.

So what's happening with your code is that the old music is stopped, the queue is cleared out, pla_intro is added to the queue, the queue is cleared out again, pla_play is added to it, and only then does an interaction occur, causing pla_play to start playing.

What you want to do is to disable the clearing of the queue as part of the queue statement, which you can do by setting clear_queue=False. So something like this:

Code: Select all

$ renpy.music.play(pla_intro)
$ renpy.music.queue(pla_play, clear_queue=False)
will do what you want.

The pass statement isn't equivalent to renpy.pause... it's simply a control flow statement that never causes an interaction to occur.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

Post Reply

Who is online

Users browsing this forum: No registered users