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: PlayVariableMixBGMInside 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.