Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

mpf-gmc 0.1.3 - error while switching music between modes

55 views
Skip to first unread message

Samuel Chauviere

unread,
Jan 18, 2025, 9:15:03 AMJan 18
to MPF Users
Hi there,

I upgraded to mpf-gmc's 0.1.3 version and have some issues with mode's music switching. I did not have this behaviour with 0.1.0.

Basically I have one main music for base mode and another one for my_mode.

In my_mode, I'm using

sound_player:
  mode_my_mode_started:
    mb_1:
      bus: music
      fade_in: 500ms
      fade_out: 500ms
      loops: -1
  mode_my_mode_will_stop:
    mb_1:
      bus: music
      action: stop

And in base I'm going like this

event_player:
  mode_base_started: start_main_music
  mode_my_mode_stopped: start_main_music

sound_player:
  start_main_music:
    main_1:
      bus: music
      fade_out: 500ms
      loops: -1

When my_mode starting, swithing music is working fine, but at the end of my_mode, I'm not able to go back to main music and MPF-GMC is throwing this error :

15:03:00.476 : INFO [EventManager] Event: ======'mode_my_mode_stopped'====== Args={}
15:03:00.476 : INFO [EventManager] Event: ======'clear'====== Args={'key': 'my_mode'}
15:03:00.477 : INFO [EventManager] Event: ======'start_main_music'====== Args={'priority': 0}
15:03:00.488 : INFO : Bus<music> : Playing sound 'res://sounds/music/main_1.ogg'
SCRIPT ERROR: Invalid call. Nonexistent function 'stop_all' in base 'Tween'.
          at: GMCBus._find_available_channel (res://addons/mpf-gmc/scripts/audio/GMCBus.gd:281)

I can provide more details or code test case if needed.

Thanks.

Samuel

Anthony van Winkle

unread,
Jan 18, 2025, 2:45:55 PMJan 18
to MPF Users
Thanks for the bug report! I see that Godot updated its tween class and removed the stop_all() method and just uses stop() now, I'm not sure why or how come this didn't surface earlier. I've just pushed a fix up to the mpf-gmc repo that replaces the stop_all() call with just stop(), please let me know if that fixes it for you!

Samuel Chauviere

unread,
Jan 18, 2025, 3:33:14 PMJan 18
to MPF Users
Well error log is fixed, and Godot says the sound is playing, however I can't ear it :-(

21:27:39.536 : INFO [EventManager] Event: ======'mode_my_mode_starting'====== Args={}
21:27:39.536 : INFO [Mode.my_mode] Started. Priority: 100
21:27:39.536 : INFO [EventManager] Event: ======'modes_active_modes_changed'====== Args={}
21:27:39.536 : INFO [EventManager] Event: ======'mode_my_mode_started'====== Args={}
21:27:39.548 : INFO : Bus<music> : Playing sound 'res://sounds/music/mb_1.ogg'
21:27:39.882 : INFO [EventManager] Event: ======'my_mode_stop'====== Args={'_from_bcp': True}
21:27:39.882 : INFO [EventManager] Event: ======'mode_my_mode_will_stop'====== Args={}
21:27:39.882 : INFO [EventManager] Event: ======'mode_my_mode_stopping'====== Args={}
21:27:39.882 : INFO [Mode.my_mode] Stopped.
21:27:39.883 : INFO [EventManager] Event: ======'modes_active_modes_changed'====== Args={}
21:27:39.883 : INFO [EventManager] Event: ======'mode_my_mode_stopped'====== Args={}
21:27:39.883 : INFO [EventManager] Event: ======'clear'====== Args={'key': 'my_mode'}
21:27:39.883 : INFO [EventManager] Event: ======'start_main_music'====== Args={'priority': 0}
21:27:39.899 : INFO : Bus<music> : Playing sound 'res://sounds/music/main_1.ogg' <-- NO SOUND THO

Anthony van Winkle

unread,
Jan 18, 2025, 4:08:14 PMJan 18
to MPF Users
Mmm, might be an issue with the volume level if the fade out is persisted and the volume isn't resetting. I'll look into it. There is a check to reset the volume of a channel if no fade_in value is supplied, so that should take care of it.

Can you set your godot sound player to Debug logs (GMC panel > Show All Loggers > Sound Player) for some additional context?

One thing to note is that you shouldn't need to manually stop the mode music, it's played within the context of the mode so when the mode stops all media in that context will be removed (like for example, how a mode's slides automatically disappear when the mode ends). I'm not sure that will affect the bug here, but you should get the same desired result without calling stop on the mb music.

Anthony van Winkle

unread,
Jan 18, 2025, 4:11:28 PMJan 18
to MPF Users
What *might* be happening is that your mode is stopping so fast (350ms after starting) that the base sound hasn't finished fading out yet, and so GMC still thinks that it's playing and therefore lets it keep playing. If that's the case (and the logs should reveal) then I can look into some stronger checks there, but also it doesn't seem likely that a mode would actually start and stop in less than a second in a real-world scenario.

Samuel Chauviere

unread,
Jan 18, 2025, 4:31:39 PMJan 18
to mpf-...@googlegroups.com
You're right Anthony ! Thanks !

I've toggled comment on fade_in/fade_out and everything's working like
it should, I've also suppressed the manual stop of the mode music.

So with the fade_in/fade_out still there, and the manual stop of the
mode music commented, the test case still plays mode music when mode
stopped. Althought godot log tells main music is playing, as you can
see in the log file.

Tell me if you need more tests or info.

Le sam. 18 janv. 2025 à 22:11, Anthony van Winkle
<anthonyv...@gmail.com> a écrit :
> --
> You received this message because you are subscribed to a topic in the Google Groups "MPF Users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/mpf-users/0LfJc60e3mE/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to mpf-users+...@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/mpf-users/f2187e2a-2034-49ad-a315-6329c8af29c2n%40googlegroups.com.
new1.log

Anthony van Winkle

unread,
Jan 18, 2025, 4:50:38 PMJan 18
to MPF Users
Coolcool, thanks for the logs. It's exactly as I suspected.

GMC has built-in logic so that if it receives a request to play a sound and it's already got that sound playing, it ignores the new request. This prevents jumpy/glitchy audio if a game has multiple triggers for a sound or multiple events using the same sound. What's happening is that after your main music is fading out, it's technically still "playing" so GMC sees that the main music is playing and ignores the new request. I thought this might occur because the mode was stopping so quickly after it started so the fade-out was still happening, but in the new log there's plenty of time and it's still happening. There must be a bug with the fade out where after it fades out it's not stopping the track, so the main music is continuing to play at zero volume.

I'll dig into this and work on a fix, thanks for catching it and providing logs! In the meantime, you can disable the fade out and keep on flipping :) 

Anthony van Winkle

unread,
Jan 18, 2025, 8:40:31 PMJan 18
to MPF Users
I got it! It was a sneaky bug  wherein the triggering event's settings were passed to the action handler. This is good behavior usually, but in the case of music (or any SOLO-type bus) the triggering settings are to play, not stop. So GMC thought it was "fading in" the music to zero volume, instead of fading it out, and therefore was not stopping the track when the fade finished.

I've pushed a fix for this so when one music track stops another, the event settings are NOT passed to the stop handler. Fade outs still work because without event settings, GMC falls back to the original settings sent with the sound's play event.

I've copied your above configs into a test project and validated that playback resumes as expected, so let me know how it goes for you!

Samuel Chauviere

unread,
Jan 19, 2025, 4:13:33 AMJan 19
to MPF Users
It goes pretty well so far ! Very nice fixing job, thanks Anthony.
Reply all
Reply to author
Forward
0 new messages