Comments (4)
Hi there @DinoMC what godot version did you use to test this?
from godot-game-template.
Pretty sure this was 4.2.2 stable.
Just tried again with 4.3.beta3 and the issue is still there.
Looking at the code, it seems to me like it's not implemented, so issue should be the same in all Godot versions :
-
Audio menu calls AppSettings.set_bus_volume_from_linear which just take the slider's value and set the bus volume to that, completely ignoring the default bus value (AudioServer.get_bus_volume_db() is never used)
-
Strangely, when starting the game, AppSettings.set_audio_from_config does get the default bus volume with AudioServer.get_bus_volume_db() ... and then discard it after having done nothing with it.
Actually looking into this, I just realized there's another (bigger?) bug.
If you have any Audio Bus set to a volume that's above 0db and start the game, AppConfig will immediately set it back to 0db, so it's impossible to have any volume above 0db as long as you have Maaack Menus Template installed. Even if you skip the main menu altogether (since it's the autoload that does it).
This part is due to AppSettings.set_audio_from_config(), if the bus doesn't have a value saved in the config file (ie. the slider was never moved in option menu), then bus_volume = 1.0 (0.0db), at line 115 in AppSettings.gd
bus_volume = Config.get_config(AUDIO_SECTION, bus_name, bus_volume)
if is_nan(bus_volume):
bus_volume = 1.0
Config.set_config(AUDIO_SECTION, bus_name, bus_volume)
bus_volume_db = linear_to_db(bus_volume)
AudioServer.set_bus_volume_db(bus_iter, bus_volume_db)
from godot-game-template.
I was trying to make a pull request to fix this but I'm not sure how to go about a specific part, so instead here's some code, I hope it can help you.
For AppSettings.set_audio_from_config(), I think it can be fixed like this. I tried running a few test cases and it all seemed to work :
static func set_audio_from_config():
for bus_iter in AudioServer.bus_count:
var bus_name : String = AudioServer.get_bus_name(bus_iter).to_pascal_case()
var bus_volume_db : float = AudioServer.get_bus_volume_db(bus_iter)
var base_bus_volume : float = db_to_linear(bus_volume_db)
var bus_volume : float
bus_volume = Config.get_config(AUDIO_SECTION, bus_name, bus_volume)
if is_nan(bus_volume):
bus_volume = 1.0
Config.set_config(AUDIO_SECTION, bus_name, bus_volume)
bus_volume_db = linear_to_db(base_bus_volume * bus_volume)
AudioServer.set_bus_volume_db(bus_iter, bus_volume_db)
var mute_audio_flag : bool = is_muted()
mute_audio_flag = Config.get_config(AUDIO_SECTION, MUTE_SETTING, mute_audio_flag)
set_mute(mute_audio_flag)
Basically, multiply the new value by the default value (works well since it's linear values). So if the user set the slider to 80%, but the bus default value is already 0.8, then the final value will be 0.64.
Problem is once the config is done loading, it seems like the bus default volume is just gone, it's not saved anywhere. So when the user then move the slider again in the Audio menu, you don't have anything to multiply it with.
Possible fixes :
-
Do some maths. Change the "slider change" signal to send both the old and new value, so if the user change the slider from 0.8 to 0.6 in the above option, you can the current volume of 0.64, divide it by 0.8, multiply by 0.6 and end up with the expected final volume of 0.48
Issues : Rounding errors, and I don't know if the slider can actually send the old value. -
Something else I tried is, when the setting is changed, I load the default values back and then apply the new volume.
It's possible to set all bus to their default volume by running :
if ResourceLoader.exists(ProjectSettings.get_setting("audio/buses/default_bus_layout")):
AudioServer.set_bus_layout(load(ProjectSettings.get_setting("audio/buses/default_bus_layout")))
Problem being, it sets ALL buses to default and it doesn't seem like that can be changed. So when one slider change, you would have to loop through all buses and reapply the corresponding option.
- On project run, save all default bus values somewhere so that you can use them on slider change. Pretty easy to do, but I don't know where I should store that array in the addon's structure so I refrained. (AppSettings doesn't use any var)
Vaguely related, but I would also suggest another small change. Right now, when starting the game for the first time, all sliders are at 100%, meaning that the user can lower the volume if the default is too high, but can't raise it if it's too low.
This could be easily fixed by changing the HSlider.max_value to 1.5 rather than 1.0
from godot-game-template.
Thanks for the detailed bug report and suggested fix! I'll try working on it this week.
from godot-game-template.
Related Issues (20)
- Easier process to switch between Menus Template and Game Template HOT 2
- Fixes to ProjectMusicController
- UISoundController misc issues: unwanted initial button press sound, overlapping focus/press sounds, missing sounds HOT 1
- Suggestion: Support animating background music players in starting scenes
- Suggestion: Automating the process of propagating changes to the other repos
- Unwanted process: Credits are auto-scrolling while invisible
- Options: Controls: keys seem to always register and display international US keyboard HOT 6
- Options: Controls: Space is shown as an invisible character HOT 2
- Options: Controls: Cannot customize built-in actions (starting with "ui_")
- Pause menu isnt opening HOT 5
- Suggestion: Add documentation for custom game scene HOT 1
- Main Menu buttons not clickable except "Play" HOT 4
- Suggestion: add confirmation dialog when resetting controls
- SceneLoader path are not replaced to local scenes
- Credits don't scroll the second time HOT 2
- Suggestion: Audio Input Selection Option
- Unicode keys are invisible in input editor
- Suggestion: Delete addons/.../examples files after copying
- Errors in log
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from godot-game-template.