JS calls to change volume settings?

It's possible to adjust the settings for each volume type (SE, BGM, etc.) in the game menu, but I can't seem to find any JS calls to adjust them through other means.

Is there a means of doing this through JS calls? Thanks in advance. 🙂

EDIT: I'm guessing something close to "AudioManager.bgmVolume(value);" but I'm not certain...
This line of code seems to dictate a method of changing it, though I'm not familiar with the syntax it uses

Code:
Object.defineProperty(AudioManager, 'bgmVolume', {
    get: function() {
        return this._bgmVolume;
    },
    set: function(value) {
        this._bgmVolume = value;
        this.updateBgmParameters(this._currentBgm);
    },
    configurable: true
});
This line of code seems to dictate a method of changing it, though I'm not familiar with the syntax it uses

Code:
Object.defineProperty(AudioManager, 'bgmVolume', {
    get: function() {
        return this._bgmVolume;
    },
    set: function(value) {
        this._bgmVolume = value;
        this.updateBgmParameters(this._currentBgm);
    },
    configurable: true
});

Yeah, I saw that but my understanding of JS is still limited at best right now. :\
if nothing else you could just do a script call with

Code:
AudioManager._bgmVolume = value;
        AudioManager.updateBgmParameters(AudioManager._currentBgm);

and see if that works. You could even add your own AudioManager code in a short plugin like this


Code:
AudioManager.setBGMVol = function(value) {
this._bgmVolume = value;
        this.updateBgmParameters(this._currentBgm);
}

and make the scriptcalls like this
Code:
AudioManager.setBGMVol(x)

where x is the volume you want
I might just make a plugin that includes all the volumes, but I feel like there should be a direct way to change it as is, since it's in the options menu.
Code:
Window_Options.prototype.setConfigValue = function(symbol, volume) {
    ConfigManager[symbol] = volume;
};

This is the code the options menu ends up executing to cause a change, the symbols for the various volumes are these

'bgmVolume'
'bgsVolume'
meVolume'
and 'seVolume'

So of you wanted to change sound effect volume you could call
Code:
Window_Options.prototype.setConfigValue('seVolume', 50)

or even
Code:
ConfigManager['seVolume'] = 50
or even
Code:
ConfigManager['seVolume'] = 50

This works, but one more question...

I can save the BGM to a variable, but how would I go about recalling it later?

For example:

$gameVariables.setValue(13,AudioManager.bgmVolume);

Will save the current BGM setting to variable 13, but how would I recall it?

I ask because I'm not saving my game itself, just a few variables and switches via an addon and I'd use that to load the volume settings on bootup each time.
Code:
$gameVariables.value(x)

Where x is the Id number of the Variable

Should return the number
Code:
$

Where x is the Id number of the Variable

Should return the number

I'm sorry, I phrased that poorly.

I meant to ask how would I instruct:

ConfigManager['seVolume'] = 50

...to load a value from a game variable?

I assume it would be something like:

ConfigManager['seVolume'] = gameVariables.value(x)

But that permutation doesn't seem to work.
it needs to be $gameVariables so this should work
Code:
ConfigManager['seVolume'] = $gameVariables.value(x)

the "$" annotates a global variable.
it needs to be $gameVariables so this should work
Code:
ConfigManager['seVolume'] = $gameVariables.value(x)

the "$" annotates a global variable.

*facepalm*

I actually removed the "$" before trying it the first time, derp....

In any case, this works perfectly! Thank you SO much! 😀

Original thread: https://forums.rpgmakerweb.com/threads/js-calls-to-change-volume-settings.74560/