How to enable events precisely when a song is during played?

Hey guys!I wanted to create an event that would match the tone of the screen to the song to reinforce the emotional experience in my game. For example, the climax of the song is horrific, so I would like the screen tone to turn red at that point.
But the question arises. If my player temporarily opens a web page outside of the game, or uses the z key to fast forward in the game, the parallel events are staggered with the game music.😩
Should I find a way to disable the game from fast-forwarding while the show is going on, and disable content pause when the player mouses outside the ui box?
How do I make it happen? Thanks in advance for all the replies!
Hmmm, I think you get a "position number" with AudioManager._bgmBuffer.seek()
Put that in a variable and change the tone in a parallel event depending on that number.

EDIT: Hmmm, maybe misread your question
Hmmm, I think you get a "position number" with AudioManager._bgmBuffer.seek()
Put that in a variable and change the tone in a parallel event depending on that number.

EDIT: Hmmm, maybe misread your question
Yep, this is probably the best way to do it.
Yep, this is probably the best way to do it.

Yeah, but I was zoomed in on the 'match tone to music' part. Their cutscene to music will still be messed if someone clicks outside the game and lets the music play. How to save and stop BGM if someone clicks out of the game and then replay it when going back?
Yeah, but I was zoomed in on the 'match tone to music' part. Their cutscene to music will still be messed if someone clicks outside the game and lets the music play. How to save and stop BGM if someone clicks out of the game and then replay it when going back?
Ahh yeah, good point.
To keep the audio in sync with everything else, you could:
  1. Disable the core "pause when focus is lost" behaviour, e.g. with a short plugin like this:
    JavaScript:
    /*:
     * @target MZ
     * @plugindesc The game should no longer pause when it loses focus.
     * @author Caethyril
     * @url https://forums.rpgmakerweb.com/threads/177618/
     * @help Free to use and/or modify for any project, no credit required.
     */
    // Override!
    SceneManager.isGameActive = function() { return true; };

  2. Alternatively, pause audio when the game loses focus. I have a plugin for that, called CaeF_PauseFix; it can be found in the "Fix/Patch" category here:
    If it doesn't work for you, then another plugin you're using may be conflicting, e.g.
    Got it: Plugin Manager -> EliMZ_Book -> Playtest settings -> Dev Tools Focus: false. 😮‍💨

    Save your project to apply Plugin Manager changes, then test.

    When enabled, this parameter causes the game to be always active while in playtest mode. In that case, my plugin will never see a reason to pause the audio.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-enable-events-precisely-when-a-song-is-during-played.177618/