Help! Changing Volume of Current BGM

When the player selects an option (through a scripted menu) for loud/medium/quiet music, I want to immediately change the volume of the BGM - without restarting it.

However, this option can be selected at any point during the game, so I have no way to know what BGM track is actually playing.

Is there any way to simply change the current BGM's volume without explicitly knowing its name? (Alternatively, is there any way to fetch the name and position of the current track?)

I can't even figure out where to begin on this one, so any help or hints would be awesome! Thanks guys!
I think volume is an attr_accessor of AudioFile where some stuff like RPG::BGM come from, so try RPG::BGM.volume = 100 , where volume's loudness is determined by 0-100.
I think volume is an attr_accessor of AudioFile where some stuff like RPG::BGM come from, so try RPG::BGM.volume = 100 , where volume's loudness is determined by 0-100.

I appreciate your help. Unfortunately, I get the following error when I try setting the volume this way (I tried it through inserting the line in a menu script; I also tried it from a simple Script call in an event. I also set the attr_accessor explicitly, just in case.):

NoMethodError occurred.
undefined method `volume=' for RPG::BGM:Class

I assume this is happening because we are trying to set a property for a class rather than an object? Or am I wrong about this? Sometimes there are structures in coding that are perfectly fine and I think they're faulty because I've never seen them before.

Is there perhaps a Singleton object of class "RPG::BGM" that we would be able to set the @volume for? 🙂
Here is an example of how you can do this 🙂:
Code:
RPG::BGM.last.volume = 50
Audio.bgm_play("Audio/BGM/#{RPG::BGM.last.name}", RPG::BGM.last.volume, RPG::BGM.last.pitch, RPG::BGM.last.pos)

Edit:
Also for the position instead of RPG::BGM.last.pos you can use Audio.bgm_pos.
(I have actually answered a very similar topic a long time ago about changing the pitch of a bgm)

Original thread: https://forums.rpgmakerweb.com/threads/help-changing-volume-of-current-bgm.76824/