Adaptive battle music [SOLVED]

hello again,
i was wondering if there was a way to smoothly transition to battle music from the non-battle bgm (similar to Zenless Zone Zero or FF7 remake)
In theory, if you had a second track of identical length and sampling rate, you could simply start playback from the position of the currently playing track. Something like this (where newBgm is an object with the parameters of the new track you want to play):

AudioManager.playBgm(newBgm, AudioManager._currentBgm.pos)

In practice, you might discover those games are doing a little more under the hood to ensure the transitions happen at appropriate times in the song, crossfading between the two, using sound effects to mask the splice, and so on, so it may not sound too great if you just swap the tracks.
smoothly transition
no.
you'd need two channels with two tracks to fade between them.


(unless it's seamless to use a SFX channel to play music while you swap the music channel... has anything like that ever been tried?)
I recall EA has its transition system in their C&C series, they slice the tracks into second long pieces and make transition parts for various places. However you'd be at least a composer to actually do that.
In reality? Maybe you can check this thread:
no.
you'd need two channels with two tracks to fade between them.


(unless it's seamless to use a SFX channel to play music while you swap the music channel... has anything like that ever been tried?)

ok so ive tried having both tracks run at the same time where one is a BGM and the other is a BGS through a mixture of currently available free plugins and events and it worked!

ill write down what i did for future reference since this topic seems to not have a current (easier to do or find) solution:


Plugins used:
SRD_GameUpgrade (for preloader to work)
SRD_PreloaderCore (for both tracks to start at the same time)
SRD_AudioFader (for the transitions)
Capture.PNG

What I did:

1- Set the map music from the "map's properties"'menu

2- Have a parallel invisible event on the map that sets the battle music to the exact current on the map (from the "Change Battle Music" option in the battle menu when selecting an event. other methods through plugins tend to restart the song from the beginning)

3-Have another parallel event with this script so the BGS can play in battles ( from this thread ):

[COLOR=rgb(243, 121, 52)][COLOR=rgb(243, 121, 52)]BattleManager.playBattleBgm = function() {[/COLOR][/COLOR]

AudioManager.playBgm($gameSystem.battleBgm());

};



Scene_Map.prototype.stopAudioOnBattleStart = function() {

if (!AudioManager.isCurrentBgm($gameSystem.battleBgm())) {

AudioManager.stopBgm();

}

AudioManager.stopMe();

AudioManager.stopSe();


[COLOR=rgb(243, 121, 52)]};[/COLOR]

4- Have the current BGS be the alternative version of said song for battles set, and set it to 0 volume

5-use "SRD's_AudioFader"'s plugin commands in battles so you lower the volume of the bgm as the enemies spawn and increase the bgs volume as here:
Capture.PNG



And here's a showcase of the results:

thanks again for giving me the idea 🙂
and it worked!

....beat that, Yanfly.
This thread is closed due to being marked solved. Report the next one so we can find it! If you need this one reopened, report it to let us know. Thank you!

Original thread: https://forums.rpgmakerweb.com/threads/adaptive-battle-music-solved.174614/