1. Welcome to VRCat! Please note that this message board is not related to VRChat in any official manner. It is run entirely by the community, and moderated by the community. Any content present has not been reviewed by VRChat moderators or staff. Your use of these forums implies understanding of this message. Thanks!
    Dismiss Notice

Need guide on setting up music in my worlds.

Discussion in 'World Building' started by BigTurbo, Sep 22, 2019.

  1. BigTurbo

    BigTurbo New Member

    Joined:
    Sep 8, 2018
    Messages:
    1
    Likes Received:
    0
    Hola, Gamers! I'm just your standard amateur seeking guidance here. As VRChat has changed up their SDK quite a lot from last year, when I was last active; I've fallen out of the loop when it comes to using Unity. To put it simply, I need one of you kind souls to give me a slick, quick tutorial on setting up a music box for my world. I'd like to understand the best methods to optimize performance, loading times, etc. I already have a rudimentary set up going, but I fear it's clunky and a little improper. Here's how it goes:

    My music box sets playlists to completely empty out. There are six playlists, and six parent gameobjects for them. Each gameobject contains a "next" button, and a "play" button. Each next button toggles the current gameobject off, and toggles the next gameobject on, to shuffle through the playlists available. Each play button toggles the respective video player on. There are six video players to match the six playlists, toggled off unless summoned by its play button. The play button also toggles every other video player off to prevent overlap. Each video player plays to the same audio source. Each video player is also configured to use the "OnNetworkReady" trigger, set to local.

    I would be very appreciative if any of you can offer me optimization tips, as well as a way to make each playlist shuffle by default using the SendRPC function.

    Thank you for your time spent reading my request. I hope you have a good day regardless if you'll help me or are just lurking.
     
  2. Iwannalookatattachments

    Joined:
    Aug 16, 2018
    Messages:
    19
    Likes Received:
    1
    Can't give much in the way of optimizations tips, but what what I have come across in the past what you have going is the standard build. The rest of the deviations such as leavings all songs loaded or only loading when each track is played either gained performance and lost reliability (Especially with multiple users and late joins) or vice versa. I think the user that made the PUG did a world write-up that included the best filetypes to use for VRC. IIRC it was ogg, but its been a while and I can't be sure on that or where that writeup was. That might be a simple way to take a bit off the top.
     
  3. Eremite

    Eremite Member

    Joined:
    Apr 12, 2018
    Messages:
    67
    Likes Received:
    14
    VRChat:
    Eremite
    I have something kinda similar set up in one of my worlds: https://github.com/Erumite/Eremite_...Eremite/Optimizations/Streaming_Local_Jukebox
    This isn't synced and requires a lot of setup and hosting the video files somewhere, but it fixes a lot of performance hit from SyncVideoPlayers since it doesn't need to call youtube-dl and convert the video in the background. You can pre-encode the video to H264/AAC and Unity is very happy with this encoding. I mainly set it up this way to have it be optional music that can be different for each player in the world.

    For the shuffle button, you could probably set up custom triggers on each playlist like:

    Play 1:
    Enable Song 1
    Disable other songs.
    Play2
    Enable Song 2
    Disable other songs.

    Then have an OnInteract trigger on the shuffle button (or whatever), with the random button checked. For actions, you'd just do ActivateCustomTrigger on the playlist object.