volume tag with 0.80 godot

57 views
Skip to first unread message

james cardona

unread,
Nov 2, 2024, 9:55:15 AMNov 2
to MPF Users
I have upgraded and so far the experience is pretty great. Really liking how much more powerful godot is and how much faster development time is with it.

A question:
under kivy we could provide a volume tag in sound_player. This doesn't seem to be part of the standard with godot, or am I missing something?
Godot seems to have a volume_db tag but I don't see where we can pass that value in from sound_player.

I do understand that volume levels can be set in a sound definition created in godot but I am trying to avoid creating those for every single sound effect that I have which is a lot. Maybe there is an easier way?

james cardona

unread,
Nov 6, 2024, 9:49:20 AMNov 6
to MPF Users
So to be clear this sound player definition with mpf/GMC does not work:
sound_player:
    foo_playSoundCall:     # call this from code to play the file
       foo_SoundFileName: # this is the name of the wav file, not a godot scene def
          bus: voice
          volume: 0.851           # this doesn't work regardless of setting
          ducking:                     # this doesn't work regardless of setting
              bus: music
              delay: 0ms
              attack: 100ms
              attenuation: 0.3
              release_point: 100ms #prior to the end of the sound
              release: 100ms

The files, whether music, voice, or SFX always play at full volume. They do indeed play, but I cannot control the volume level or ducking from sound player calls and this used to work in the old kivy MC. 

I am doing something wrong here?

Anthony van Winkle

unread,
Nov 6, 2024, 4:33:56 PMNov 6
to MPF Users
I'm sorry you're having difficulty, everything in your config looks fine. I just tested on the latest GMC and the volume definitely changed based on the value of that setting. You could try enabling debug logging on the sound player in Godot (GMC panel, "Show All Loggers") and see what the event coming from MPF looks like. Also please confirm which version of GMC you're on.

james cardona

unread,
Nov 7, 2024, 9:25:55 AMNov 7
to MPF Users
pip install mpf --pre shows me as on (0.80.0.dev4) and did not change anything. Still, I downloaded the latest mpf-gmc from github and ran a diff and there were a few slight differences so I copied in/overwrote the whole addons folder. Not sure why pip did not pick that up.
I reinstalled godot 4.3
And by the way, the plugin version says 0.1.0.dev2

Anyway, still no changes in the volume level or ducking. They always play at full volume and never duck.

The godot log files show this, set in verbose:
09:14:46.651 : INFO : Bus<music> : Playing sound 'res://sounds/music/main_B.wav'
09:14:46.651 : DEBUG : Bus<music> :  - with sound settings { "volume": 0.05, "block": false, "action": "play", "delay": <null>, "bus": "music", "ducking": {  }, "pan": <null>, "loops": 1, "priority": <null>, "start_at": <null>, "fade_in": 0.1, "fade_out": 0.1, "about_to_finish_time": -1, "max_queue_time": -1, "events_when_played": [], "events_when_stopped": [], "events_when_looping": [], "events_when_about_to_finish": [], "key": "testSound", "file": "res://sounds/music/main_B.wav", "context": "_global" }

Since something weird was going on, I tried 3 different settings to the ducking and none worked:
Ducking music by -1 over 0.1s,
Ducking music by 1 over 0.1s,
Ducking music by 0 over 0.1s,
I forgot how ducking call works -- does it lower the music BY the specified amplification or lower it TO the specified amplification?

Finally, I created an MPFsoundAsset in godot called "testSound" and tried to change the volume on it from sound_player and that didn't work either (as expected).

Any suggestions? I know I am doing something wrong - probably in godot settings or preferences, but the fact that the debugger is getting the dictionary from MPF and it still doesn't work baffles me.

james cardona

unread,
Nov 9, 2024, 11:46:15 AMNov 9
to MPF Users
more info:
I turned on debug and added more descriptive logs as well and I get this:
11:32:17.234 : INFO : Bus<music> : GMCBus->play: Playing sound 'res://sounds/music/main_BG.wav'
11:32:17.234 : DEBUG : Bus<music> : GMCBus->play: with sound settings { "volume": 0.05, "block": false, "action": "play", "delay": <null>, "bus": "music", "ducking": {  }, "pan": <null>, "loops": 1, "priority": <null>, "start_at": <null>, "fade_in": 0.1, "fade_out": 0.1, "about_to_finish_time": -1, "max_queue_time": -1, "events_when_played": [], "events_when_stopped": [], "events_when_looping": [], "events_when_about_to_finish": [], "key": "testSound", "file": "res://sounds/music/main_BG.wav", "context": "_global" }
11:32:17.234 : DEBUG : Bus<music> : GMCBus->_find_available_channel: Channel <GMCChannel:music_1:current_stream=None> has no stream, making it the available channel


11:32:17.234 : DEBUG : Bus<music> : GMCChannel->play_with_settings: playing res://sounds/music/main_BG.wav (<AudioStreamWAV#-9223371954998737527>) on <GMCChannel:music_1:current_stream=<AudioStreamWAV#-9223371954998737527>> with settings { "volume": 0.05, "block": false, "action": "play", "delay": <null>, "bus": "music", "ducking": {  }, "pan": <null>, "loops": 1, "priority": <null>, "start_at": <null>, "fade_in": 0.1, "fade_out": 0.1, "about_to_finish_time": -1, "max_queue_time": -1, "events_when_played": [], "events_when_stopped": [], "events_when_looping": [], "events_when_about_to_finish": [], "key": "testSound", "file": "res://sounds/music/main_BG.wav", "context": "_global" }


11:32:17.319 : DEBUG : Bus<music> : GMCChannel->_on_fade_complete: Fade in to 0.00 complete on channel <GMCChannel:music_1:current_stream=<AudioStreamWAV#-9223371954998737527>>.


so what I am seeing I that the volume level of 0.05 is coming in from sound_player but that on the end of the fade in that the volume is set to 0.00. Since godot uses a volume scale of -80 to +30, I am thinking that 0 is full volume, correct? so I am thinking that the fade in had a bug.

I see this line in the play function,
tween.tween_property(self, "volume_db", 0.0, fade_in).set_trans(Tween.TRANS_QUINT).set_ease(Tween.EASE_OUT)
Should it not specify the passed in volume level, not 0.0?

I haven't dug into the tween code yet so I am guessing here.

james cardona

unread,
Nov 9, 2024, 11:49:06 AMNov 9
to MPF Users
AHHH HA!
success, I turned off the fade in and fade out parameters and volume control now works. I will keep digging when I have a chance but there is definitely a bug in the fade code.

Anthony van Winkle

unread,
Nov 9, 2024, 4:45:37 PMNov 9
to MPF Users
I see what happened with the ducking, it was based on decibel values rather than percentage values, and the math got real funky with that. I've put in a change to make the attenuation a value from 0.0 to 1.0, which is in line with how MPF-MC did it, so that's good.

I'm able to see fade in and fade out work just fine with this config, so we'll have to keep investigating there.

sound_player:
mode_attract_started:
fight_theme:
bus: music
fade_in: 5
fade_out: 5

I am noticing an unfreed resource if you exit godot while a fade is happening, so I'll take a look at that as well.

james cardona

unread,
Nov 11, 2024, 9:13:16 AMNov 11
to MPF Users
WOOOOHOOO!
Thanks AVW!
Fading and ducking now work properly for me. Thank you so much for your time.

Reply all
Reply to author
Forward
0 new messages