MZ [MZ]Change Title Screen Music with a Plugin or Variable.

I've been using RPG MAKER MZ for almost a year now, and I can't seem to find this solution. I've been making a horror rpg game where the title screen music is upbeat and happy at the start, and as you progress, the music will get darker and scarier. I wanted to know if there was a variable,switch or plugin that I can use to help me complete this. Thanks!


-GAMEMONKEI
Hello, this is the method that call the title music:
Code:
Scene_Title.prototype.playTitleMusic = function() {
    AudioManager.playBgm($dataSystem.titleBgm);
    AudioManager.stopBgs();
    AudioManager.stopMe();
};

You could edit the method and copy it in any plugin you have (or make it a plugin on its own):

Code:
Scene_Title.prototype.playTitleMusic = function() {
    const baseMusic = $dataSystem.titleBgm // title music from data base
    const secondMusic = {name: 'music name', volume: 100, pitch: 100, pan: 0}
    const currentMusic = $gameSwitches.value(x) ? secondMusic : baseMusic;
    AudioManager.playBgm(currentMusic);
    AudioManager.stopBgs();
    AudioManager.stopMe();
};
Once switch X is ON, the tilte music will be secondMusic (replace 'music name' by the actual name of the bgm and set the volume, pitch, pan as you like)

This is to change the music once in the game, but the same process could be use with a variable to select from several different musics...

*EDIT: hum... come to think of it. That probably wouldn't work cause it use a game switch in the Title Scene. I'll come back with something else later, unless someone else suggest something.

**EDIT: I made a plugin: TSR_TitleMusic

Regards
Thank you so much for your help!
SO by just having this plugin ACTIVE it WILL sense it BEFORE the title screen plays then?
So.. does this only take affect AFTER the initial title screen is played? Or if you enable the plugin it just autoreplaces it BEFORE ? I am not understanding if this will actually RID my game of that AWFUL title screen music BEFORE the game starts? Do you get what I'm asking here?

Original thread: https://forums.rpgmakerweb.com/threads/mz-change-title-screen-music-with-a-plugin-or-variable.146814/