Can you change the settings volume levels trough the events?

I need to change system value, not the current BGM track's value, but overall BGM value setting.

I found this post - https://forums.rpgmakerweb.com/index.php?threads/help-changing-volume-of-current-bgm.76824/
But when i use that method i am getting "syntax error - unexpected token".

If anything, my code looks like this -


RPG::BGM.last.volume = 80

Audio.bgm_play("Audio/BGM/#{RPG::BGM.last.name}", RPG::BGM.last.volume, RPG::BGM.last.pitch, RPG::BGM.last.pos)
Do you know the filename of the music playing at that moment? In that case you can do this:

Code:
AudioManager.playBgm( { name: "Battle1", volume: 45, pitch: 100, pan: 0 } );

The code you got didn't work, because that isn't for RPG maker MV

Edit: Replace "Battle1" with the title of the song that is playing, but you do need to include the quotes.
Do you know the filename of the music playing at that moment? In that case you can do this:

Code:
AudioManager.playBgm( { name: "Battle1", volume: 45, pitch: 100, pan: 0 } );

The code you got didn't work, because that isn't for RPG maker MV

Edit: Replace "Battle1" with the title of the song that is playing, but you do need to include the quotes.
reference error - disco1 is not defined.

Update -
I also tried simillar script that is used to change tracks between location while not resstarting track from the beginning:


AudioManager.playBgm({

name: 'disco1',

volume: 80,

pitch: 100,

pan: 0

}, AudioManager._bgmBuffer.seek());


And it does not work (but no error).

Update 2 - there is also a scipt that checks the current BGM volume level -

ConfigManager.bgmVolume == 0

Maybe it's possible to somehow modify it to change that level instead of checking?
I don't know what audiomanager._bgmBuffer.seek does. What is that supposed to do? And why did you not first try if the code works the way I showed you?

Without that part it works for me (I tested), so it should work for you too, at least if the name is spelled correctly.

The spelling of the name should be the same, and is caps-sensitive. So if the name is Disco1.ogg, then that is why it doesn't work.
Just to put it out there - this is bad practice. You shouldn't do this.

The whole point of having this setting in the options menu for the player to adjust is so that it's under their control. You changing the volume level in an event means you might be making it too loud for the player or too soft, depending on what they originally set it to and what their system volume is.

And that can get into areas of physical safety, in terms of eardrums.

That's why RPG Maker's (and every other game's) sound system is set up the way it is, where you can determine the percentage of all sound files on the screen for the event command/system tab, but the player determines what level that percentage is based off of.

The only valid reason for doing this is if you were making your own version of an options menu via event, but it doesn't sound like you're going for that/at that level.
Just to put it out there - this is bad practice. You shouldn't do this.

The whole point of having this setting in the options menu for the player to adjust is so that it's under their control. You changing the volume level in an event means you might be making it too loud for the player or too soft, depending on what they originally set it to and what their system volume is.
And yet there are situation you can use this. For example:

I have a scene in my game where you are in a bar. When you go to the hallway or the toilet, the music will dim to 45 (that is why the example says 45) and when you enter the main room, the music goes back to 90

If the music in the options is at 10%, then this 90 will turn into 9 and the 45 will turn into 4.5

The % in the options is multiplied with the volume you put in as a dev per file. It doesn't replace it.
I need to change system value, not the current BGM track's value, but overall BGM value setting.

I found this post - https://forums.rpgmakerweb.com/index.php?threads/help-changing-volume-of-current-bgm.76824/
But when i use that method i am getting "syntax error - unexpected token".

If anything, my code looks like this -


RPG::BGM.last.volume = 80

Audio.bgm_play("Audio/BGM/#{RPG::BGM.last.name}", RPG::BGM.last.volume, RPG::BGM.last.pitch, RPG::BGM.last.pos)
Just a heads-up: that's the RGSS structure, which only works in XP/VX/VX Ace.
By the way, if the filename is static and you want to control the volume, why not just do this:

1710973022046.png


That works too. It won't restart the song, it will continue the song but at a new volume. (If the song is already playing. If it is another song, it will start from the beginning)

Edit: This does exactly the same thing as the script call I gave you. It plays Battle1 at 45%, with 100% pitch and 0 pan. Just like the script call. So if everything in the script call is known beforehand, you can just as well use the build in function.
Just to put it out there - this is bad practice. You shouldn't do this.
Please do make sure to read Turan's post. Only do this if you're lowering the volume (and later bring it back up to what it was), or are doing an evented menu. But with that disclaimer, do this:

ConfigManager['bgmVolume'] = x;, where x is a value between 0 and 100.

ConfigManager.save() to make that change permanent (this will also happen when the user enters and closes the options menu).
Please do make sure to read Turan's post. Only do this if you're lowering the volume (and later bring it back up to what it was), or are doing an evented menu.
Yeah, I agree on that one.

By default, BGM is set to 90%, if you just keep that as a standard, the player can adjust their volume to what they think is acceptable, and you will never be able to go past that by more than 11.11%.

But with that disclaimer, do this:

ConfigManager['bgmVolume'] = x;, where x is a value between 0 and 100.

ConfigManager.save() to make that change permanent (this will also happen when the user enters and closes the options menu).
If you do it like that, than you are overwriting the users preferences. I would not do that.
I would not do that.
To be clear: me neither, but that is what OP asked for.
To be clear: me neither, but that is what OP asked for.
😛 You are right, but I think they meant to ask for the volume of the current song, not actually the main settings. That is what the code they tried would have done, if they use the engine it was written for.

Your method could be useful, if you could edit the original value. Like you could multiply that with 0.4 to turn it down to 40% of the original value, and then divide it by 0.4 to set it back to it's original value, but I don't know if that that is even possible like that.

But that brings a risk with it:

Lets say you multiply the volume with 0.4, to bring it down to 40%.
Then during the scene the player thinks the low music is too low and turn his volume up by a lot.
Then you divide the volume by 0.4, which is actually the same as multiplying it by 2.5, to go back to the original volume.
The player now is deaf.
I think they meant to ask for the volume of the current song, not actually the main settings
That seems to be the opposite of what they asked for:

I need to change system value, not the current BGM track's value, but overall BGM value setting.

As to getting the value, you can just read that property instead of setting it and it will work fine.

I'm assuming this would be for something like quieting down current bgm and playing something else to replace that, but of course there are a lot of ways to use this power very wrong.
I don't know what audiomanager._bgmBuffer.seek does. What is that supposed to do? And why did you not first try if the code works the way I showed you?

Without that part it works for me (I tested), so it should work for you too, at least if the name is spelled correctly.

The spelling of the name should be the same, and is caps-sensitive. So if the name is Disco1.ogg, then that is why it doesn't work.
I tried your way first, and got an error.
Then, i tried another. I wrote about it.

> You shouldn't do this

I know. It will exist only in specific quest, where player has to turn the volume to zero to progress. But there is a sound that must be played after completion, and for that reason volume has to go up. But not on max to prevent it being too loud for certain players.

Also, i am looking for script to change volume of currently played BGM track as well, so i can make music less loud in dialogues so player can hear VO better.


Please do make sure to read Turan's post. Only do this if you're lowering the volume (and later bring it back up to what it was), or are doing an evented menu. But with that disclaimer, do this:

ConfigManager['bgmVolume'] = x;, where x is a value between 0 and 100.

ConfigManager.save() to make that change permanent (this will also happen when the user enters and closes the options menu).
Thank you, it works. Don't worry, player will be informed about the change trough dialogue, can re-adjust instantly after that, and it will only happen onces for needs of specific quest.

By the way, is there a way to "bring the volume to what it was"? That actually could be a lot better solution if there is a way to save volume level before player re-adjust it in the settings, and then return it to what it was trough the event.
I tried your way first, and got an error.
Then, i tried another. I wrote about it.

> You shouldn't do this

I know. It will exist only in specific quest, where player has to turn the volume to zero to progress. But there is a sound that must be played after completion, and for that reason volume has to go up. But not on max to prevent it being too loud for certain players.

Also, i am looking for script to change volume of currently played BGM track as well, so i can make music less loud in dialogues so player can hear VO better.
Okay, that is a good reason why you want to set the original volume to a lower volume.

The reason I was convinced you meant to change the volume of the current song (even though apparently it clearly stated you didn't) was because that is what the original code you used would do. That is why I asked if you knew the title of the currently playing song.

If you get an error with the script call I gave you, then something goes wrong. I use that call all the time. And I tested the exact call before I copied it over here. Anyhow, that doesn't matter, since you didn't need that anyway, but it is strange. Maybe if conflicts with one of your plugins or something.

---

However... I think it should be possible to find the title of the currently playing song.

If so, you might want to do this:

Code:
var Song = (call to find the title of the current song);
AudioManager.playBgm( { name: Song, volume: 45, pitch: 100, pan: 0 } );

But I don't know how to find (call to find the title of the current song)
Maybe one of the other guys knows how to find that.

That would be a better solution than overwriting the players choice.
But I don't know how to find (call to find the title of the current song)
Maybe one of the other guys knows how to find that.
A slightly simpler way of doing this would be to just change to volume of the currently playing track directly:
AudioManager._bgmBuffer.volume = AudioManager._bgmVolume * x / 10000;, where x is a value between 0 and 100.
This is also what I'd recommend doing for lowering the bgm volume during cutscenes instead of changing the user settings.

You can also get the name from AudioManager._currentBgm.name if you'd prefer it that way.

a sound that must be played after completion
Potentially an unrelated note, but I'd find it a lot funnier if there's just nothing happening, and then the characters realise that of course, they can't hear the quest completion sound now.

By the way, is there a way to "bring the volume to what it was"?
Store ConfigManager['bgmVolume'] into a variable, then read it later.

Original thread: https://forums.rpgmakerweb.com/threads/can-you-change-the-settings-volume-levels-trough-the-events.167006/