Jay's Variable Mix BGM Manager Version 1.0.2

HeroicJay

Veteran
Veteran
Joined
Jun 23, 2014
Messages
321
Reaction score
175
First Language
English
Primarily Uses
RMMV
Many commercial video games have what is known as a "variable mix". What this means is that the game can pick a track that matches what is going on - but the tracks typically have the same (or similar) melodies and can flow from one to the other. For examples, look at Rare's Nintendo 64 games, or The Legend of Zelda: Skyward Sword's marketplace, or even Mario games that let you ride Yoshi.


Does that sound like something you want? Well, the first thing is... you'll need the tracks. That's on you, I'm writing enough music for my own game, thanks. Here are the recommendations for the tracks: They don't need to be the same tempo, but they should correspond. Same relative length (in measure count), repeat the same way to the same point, and so on. If the tempo of one track changes, the tempo of the other track should change proportionally. If one track is longer than the other (even ignoring tempo differences), it will try to find the most appropriate place to loop back to when you switch to the shorter one in the part that doesn't exist in the shorter one, which can work in some cases, but don't push it. You shouldn't hit any major errors, but the transition will sound weird if you're not careful.


Also, you will need to play all variable mix tracks at pitch 100 for technical reasons.


So play the first track normally. Ahead of time (before! you need it!), with this plugin installed, call the following plugin command:


LoadVariableMixBGM nameOfTrack [tempoRatio] [volume] [pan]


This is the track you will be switching to. Hopefully, you should be able to figure out nameOfTrack, volume, and pan. The most notable one here is tempoRatio. You need to put the ratio of the tempo of the track that is currently playing to the tempo of the track you are switching to. Fractions (like "2/3") are okay!


So if the CURRENT track has a tempo of 144 bpm, and the REPLACEMENT track is 120 bpm, you want to put 144/120 (or 6/5, which is the same fraction). When you go the other direction, make it 120/144 (or 5/6).


If you don't define the three optional parameters, tempoRatio will be 1 (meaning it's assuming they're the same tempo), and volume and pan will simply match the track that is currently playing.


Once you've loaded the replacement track, you can switch to it with:


PlayVariableMixBGM


No parameters here. You can only keep one track loaded at a time (but you can switch it any time you like. Just remember to give it some time before you play! On my computer, a second is plenty of time. But without that second, there's a bit of sound skipping.)


BTW, you absolutely can call the exact same track as what is currently playing with different volume and pan settings. This isn't as useless as it might seem; the fadein/fadeout effect will make it more fluid than if you just called "Play BGM" with the different settings.


EXAMPLE USAGE:


You have the track "TownTheme", with a tempo of 160 bpm, and the similar "TownThemeIndoors", with a tempo of 120 bpm. (120/160 = 3/4.) You want to play TownTheme when outdoors, and TownThemeIndoors when indoors.


On the map, put an autostart event with the commands:


Plugin Command: LoadVariableMixBGM TownThemeIndoors 4/3
Erase Event


On the doors to the inside of the buildings:

Code:
Transfer Player: (whatever)
Plugin Command: PlayVariableMixBGM
Inside each building, put another autostart event, similar to the one you put outdoors:


Plugin Command: LoadVariableMixBGM TownTheme 3/4
Erase Event


And on the doors leading back out:


Transfer Player: (the outdoor map)
Plugin Command: PlayVariableMixBGM


(SIDE NOTE: For this example, you do not want to define map music for any of the maps involved; play the music from another map or an event.)


If you're REALLY confident that the transition time will cover the load time (and on my computer, it does) then you can just put the load at the beginning of the transfer events and ignore the autostart events.


THE PLUGIN:


http://pastebin.com/Wq8SzNs5


This plugin is free for non-commercial and commercial use, but please credit Jason R. Godding if you use it. Thank you.


NOTE: In development of this, I had a memory leak at one point. I am 98% sure I killed it, but there's still that little 2% doubt. If you're hitting one (and it's definitely variable mixes at fault), let me know.
 
Last edited by a moderator:

mjshi

Jack of Most Trades
Veteran
Joined
Feb 16, 2013
Messages
943
Reaction score
764
First Language
English
Primarily Uses
N/A
Woah, this looks really amazing, and certainly very unique.


Now I have the urge to implement this into a game, somewhere, somehow...
 

HeroicJay

Veteran
Veteran
Joined
Jun 23, 2014
Messages
321
Reaction score
175
First Language
English
Primarily Uses
RMMV
Edit: Never mind. Was reporting a bug in my own plugin that wasn't really a bug, just a mistake in setup.

(SIDE NOTE: For this example, you do not want to define map music for any of the maps involved; play the music from another map or an event.)


Way to follow your own rule, me.
 
Last edited by a moderator:

Kilgore Trout

Veteran
Veteran
Joined
Oct 16, 2015
Messages
55
Reaction score
34
First Language
English
Primarily Uses
N/A
This is fantastic! Looks like exactly what I need for my project.


One little thing I came across is that you've written in the instructions:


  1.  * And then, later, to actually play the track, call

  2.  *

  3.  * PlayVariableMixBgm

 


 


You need to use "PlayVariableMixBGM" (note the capitalisation on "BGM".)


 


This tripped me up for about half an hour before I figured it out haha.
 

HeroicJay

Veteran
Veteran
Joined
Jun 23, 2014
Messages
321
Reaction score
175
First Language
English
Primarily Uses
RMMV
Oops! Sorry about that. Easy mistake to make, and sometimes I forgot what is and isn't case-sensitive. Well, as long as you figured it out.
 

HeroicJay

Veteran
Veteran
Joined
Jun 23, 2014
Messages
321
Reaction score
175
First Language
English
Primarily Uses
RMMV
Thanks for that. This is something impossible to screenshot, and at the time I created this plugin, I was keeping my own game under wraps. (It is used in Marillo in my game demo, but you use a different track for each building from the sound of things, which is better for a demo of the plugin.)
 

HeroicJay

Veteran
Veteran
Joined
Jun 23, 2014
Messages
321
Reaction score
175
First Language
English
Primarily Uses
RMMV
Here's a little trick you can do. Write an alternate version of the track that is just a loop of the track's intro. Then use the Variable Mix BGM Manager to switch over to the main track at a suitably cinematic time, and it won't matter how much the player dawdles on their way through the maps or dialogue scenes beforehand!
 
Last edited by a moderator:

gizzmito

Villager
Member
Joined
Jan 4, 2016
Messages
20
Reaction score
13
First Language
spanish
Oh, nice plugin! I've just tried the trick you said. I'm using the same base loop with different melodies. It's fantastic. Thanks!
 

Harken_W

Veteran
Veteran
Joined
Oct 13, 2015
Messages
80
Reaction score
22
First Language
English
Primarily Uses
N/A
Awesome plugin! Is it also possible to use this plugin within battles to alter/fade/transition the battle music depending on whether you're losing or winning the battle? 
 

HeroicJay

Veteran
Veteran
Joined
Jun 23, 2014
Messages
321
Reaction score
175
First Language
English
Primarily Uses
RMMV
I don't see why not. The plugin doesn't care whether it's called during battle or not. You could define some condition that counts as "winning" or "losing" the battle, check for that condition each turn, and LoadVariableMixBGM once the condition is met.


The biggest thing to worry about: since it sounds like you want two alternate tracks, you might have to get a little creative with covering load times, since this plugin (to save on memory concerns) only loads one alternate track at a time. Loading a music track doesn't take that long (at least not on my computer), but you want to make sure to give it a few moments. (If you were only using one alternate track, you could load it at the beginning of battle without a problem.) That's not impossible to deal with, though.
 

Harken_W

Veteran
Veteran
Joined
Oct 13, 2015
Messages
80
Reaction score
22
First Language
English
Primarily Uses
N/A
Perfect, thank you! Going to go give it a try :)
 

OKIComputer

Villager
Member
Joined
Mar 20, 2016
Messages
16
Reaction score
5
First Language
English
Primarily Uses
Wow, this is really great, as an amateur musician this is exactly what I was hoping for. A really valuable niche plugin.
 

HeroicJay

Veteran
Veteran
Joined
Jun 23, 2014
Messages
321
Reaction score
175
First Language
English
Primarily Uses
RMMV
[This post deleted by user]
 
Last edited:

Leon_Artmann

Veteran
Veteran
Joined
Jan 23, 2019
Messages
43
Reaction score
7
First Language
Portuguese
Primarily Uses
RMMV
Hello Jay! This is truly awesome and gave me hope after some time looking for preloaders and anti-lag plugins to make my dymamic music work. Do you still support this plugin? if so, I was wondering if there is any way for me to control the transition time between tracks (the time it takes for the new track to finish kicking in after the PlayVariableMixBGM command). I've been trying to make the transition happen as close as possible to the start of the bar using wait commands but the problem is that I don't know for sure how many frames the transition takes. Thanks!
 

HeroicJay

Veteran
Veteran
Joined
Jun 23, 2014
Messages
321
Reaction score
175
First Language
English
Primarily Uses
RMMV
Strictly speaking, I don't support this plugin so much as its successor (which I have been instructed not to link directly to on this forum, as it's not a free plugin.) For reference, the name of the successor plugin is "Soundtrack Manager".

You're still allowed to use the Variable Mix BGM Manager as it exists here, I just won't be updating it any longer.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

I decided to rework my main character's portrait and logo at the same time....


Honestly I was going to use a lot more yellow in the game along with red and white to represent characters.... But yellow really is just like.... the ugliest color in the color pie. So er... I'm going to use blues/purples in place of it. :LZSwink:
XwwX OMG! Only 4 more weeks till I can leave my crappy job and never ever go back! I am SO freaking excited!!!
Sometimes, it's so hard to resist
"this boss is too easy, what if I add more gimmicks". Then I remember most of my players might be already dying fighting the boss.
You certainly should show love and recognition to teammates who have achieved great success! Congrats Eli!
Just 2 Days of no Internet and I made more Progress in my Game than last 2 Weeks combined. Now I know, Internet makes me a Lazy person.. :D

Forum statistics

Threads
98,076
Messages
949,098
Members
129,358
Latest member
AbidNaga
Top