Is it possible to create a playlist and define it with an alias?

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
Adabelitoo
Regular
Posts: 83
Joined: Sat Apr 13, 2019 2:32 pm
Contact:

Is it possible to create a playlist and define it with an alias?

#1 Post by Adabelitoo »

I would like to use the "define audio" statement to name a playlist instead than just one song. The way I've been doing things so far is the usual

Code: Select all

define audio.daily1 = "music/morningsun.mp3"

play music daily1
I would like to define that "daily1" as a playlist with songs that loop without ever starting the playlist again. Something like this:

--- Part 1: Song 1 and 2 without drums
--- Part 2: Song 1 and 2 with drums

And loop Part 2 for ever. Ideally, I would like to split Part 2 into different tracks/songs like this:

--- Part 1: Song 1 and 2 without drums
--- Part 2:
----------- Song 1 with drums (3 times)
----------- Song 2 with drums (2 times)
----------- Song 1 with drums (2 times)
----------- Song 2 with drums (3 times)

Thanks for reading.

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2376
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Is it possible to create a playlist and define it with an alias?

#2 Post by Ocelot »

Code: Select all

define audio.daily1 = ["music/song1_no_drums.ogg", "music/song1_no_drums.ogg"]
define audio.daily2 = ["music/song1.ogg"]*3 + ["music/song2.ogg"]*2 + ["music/song1.ogg"]*2 +  ["music/song2.ogg"]*3

# . . .
play music daily1
# . . .
play music daily2
In case you wanted to play daily1 once and then loop daily2:

Code: Select all

play music daily1
queue music daily2 loop
< < insert Rick Cook quote here > >

User avatar
Adabelitoo
Regular
Posts: 83
Joined: Sat Apr 13, 2019 2:32 pm
Contact:

Re: Is it possible to create a playlist and define it with an alias?

#3 Post by Adabelitoo »

Wow, I wasn't expecting an answer so fast. That's basically what I wanted except that I would like both of those "daily"s in one statement like this

Code: Select all

define audio.playlist1 = ["music/d1intro.ogg"] + ["music/d1part1.ogg"]*3 + ["music/d1part2.ogg"]*2 + ["music/d1part1.ogg"]*2 +  ["music/d1part2.ogg"]*3
Now I would like if the songs from Part 2 can loop without playing Part 1 again, something like this

Code: Select all

define audio.playlist1 = ["music/d1intro.ogg"] + [["music/d1part1.ogg"]*3 + ["music/d1part2.ogg"]*2 + ["music/d1part1.ogg"]*2 +  ["music/d1part2.ogg"]*3]*X
Being that X something that states that it should be player for ever.

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2376
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Is it possible to create a playlist and define it with an alias?

#4 Post by Ocelot »

If you insist on storing all songs in the same variable and playing with a single statement, you would need to define custom function for that. For example:

Code: Select all

init python:
    def play_extended(tracks):
        play_once = sum(tracks[0:-1], [])
        play_loop = tracks[-1]
        renpy.music.play(play_once)
        renpy.music.queue(play_loop, loop=True)

define audio.daily1 = [
    ["music/song1_no_drums.ogg", "music/song1_no_drums.ogg"],
    ["music/song1.ogg"]*3 + ["music/song2.ogg"]*2 + ["music/song1.ogg"]*2 +  ["music/song2.ogg"]*3
]

# . . .
$ play_extended(audio.daily1)

# Alternatively:
label play_special(tracks):
    play music tracks[0]
    queue music tracks[1] loop
    return

# . . .
call play_special(audio.daily1)
< < insert Rick Cook quote here > >

User avatar
Adabelitoo
Regular
Posts: 83
Joined: Sat Apr 13, 2019 2:32 pm
Contact:

Re: Is it possible to create a playlist and define it with an alias?

#5 Post by Adabelitoo »

I see. It looks like something I could avoid. I'll talk to the musician to know what he thinks is best. Thanks for everything!

Post Reply

Who is online

Users browsing this forum: No registered users