Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

Extended Music Room for Ren'Py

Fully featured music room with improved usability and setup for Ren'Py. · By Feniks

Custom tracks support?

A topic by Reddle0 created Jan 21, 2024 Views: 69 Replies: 2
Viewing posts 1 to 2
(5 edits)

Is it possible you could support custom tracks? Something where the music room detects tracks from a folder without having to manually define?  Maybe even checking txt or json files (containing the data) in a certain folder too potentially.

I've been implementing this into my project, and people suggested it to me. I'm already aware https://github.com/Bronya-Rand/RenPy-Universal-Player does something similar, but it relies on python packages like ost to work. However a friend of mine provided me with code that already has the ability to support custom tracks without the use of that.

def custom_music_helper(musics, folder):
         musics += [ifile for ifile in renpy.list_files() if folder in ifile and (".ogg" in ifile or ".mp3" in ifile) ]
         return musics

    def beach_music():
        musics = []
      
        musics.append("audio/music/Beach Bummin'.ogg")
        
        musics = custom_music_helper(musics, "custom_music/beach day")            
        return musics

This is an example of how I have music set up in the project, but I can't find a way to fit this into your code, so I would greatly appreciate your input here!

On an unrelated note, sorting tracks into categories would also be great, like the example above

Developer(+1)

Hello! I don't plan on adding support for automatically grabbing metadata from files directly, as that would likely require a separate Python library as you've mentioned. That said, you can run this loop if you want to get all the files declared in a specific folder:

init python:
    for i in renpy.list_files():
        if i.startswith("audio/music/"):
            print("Audio file", i, "found.")

Instead of print, you can put whatever you like in that loop (e.g. registering it to an extended music room). You might also consider checking for endswith(".ogg") or similar to only get audio files. You can check for multiple subfolders within that same loop too by adding more if/elif/else clauses. Registering a track to the music room will look the same as in all the music room examples, it'd just be inside the loop. Don't forget to set the unlock_condition="True" or else it'll be locked (since the default condition requires players to hear the song in-game for it to unlock).

As for sorting tracks into categories, that's something that the extra description field of the music room files is for. It's flexible so you can, for example, use Python list filtering based on the description field. Alternatively, you could declare one ExtendedMusicRoom instance for each category, depending on your needs, so that music room will only play songs from that category.

Hope that helps!

Thanks very much! It will