Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MPF.Media.Sounds supporting looping of audiostreamrandomiser? #15

Closed
DorusvdLinden opened this issue Sep 13, 2024 · 6 comments
Closed

Comments

@DorusvdLinden
Copy link

DorusvdLinden commented Sep 13, 2024

Dear all,

I love the new setup, but i have one issue:
In my previous iteration I was looping multiple sounds in attract mode randomly, to create a dynamic background.

Now in Godot, the individual wav files can loop, but the audiostreamrandomiser stops after 1 sound played.

Using loops: -1, 3 or true gives an error in the MPF.Media.Sounds code (GMCChannel.gd) in mpf-gmc/scripts/)
Screenshot 2024-09-14 153948

Screenshot 2024-09-14 153751

code:

sound_player:
  mode_attract_started:
    SlowMusic:
      bus: music
      loops: 3

without the loops it runs fine.
Could be my mistake.
Kind regards
Dorus

@avanwinkle
Copy link
Contributor

Thanks for opening this issue! There were some challenges with getting loops to behave "MPF style" in GMC, and I set that work aside to finish out other features. I've been thinking on it and your notes here have given me an idea on how to implement loops in a better way, so I'll keep you updated with how it goes!

@DorusvdLinden
Copy link
Author

DorusvdLinden commented Sep 22, 2024

Thank you @avanwinkle, for the update.
Loops: 3 works now on AudioStreamRandomizer.
Loops: -1 gives an error:
image
Not sure if AudioStreamRandomizer supports "self.stream.loop=true"

would it be an option to use the same approach as in _on_loop until overwritten by a state change?

PS: my machine configuration is on: https://github.com/DorusvdLinden/PortalPinball-V4.0

@avanwinkle
Copy link
Contributor

That's a curious error, because AudioStreamRandomizer inherits from AudioStream, as do AudioStreamOggVorbis and AudioStreamMP3, but the randomizer does not inherit from either of those so it shouldn't be entering this code block if self.stream is a randomizer.

There's an argument to be made for always doing the manual looping instead of relying on the Ogg/MP3/Wav built-in method, but I'll investigate a little more first.

@avanwinkle
Copy link
Contributor

Okay, my bad. I had a shorthand in the condition that was always returning true and trying to treat the resource as an Ogg/Wav. Fixed that and verified that AudioStreamRandomizer now can loop indefinitely.

@DorusvdLinden
Copy link
Author

Great to hear. I will test it in the weekend. Thank you for the fast response. Ps: I really like the new setup.

@DorusvdLinden
Copy link
Author

Thank you so much, the loop: -1 now also works.
Great to see how fast this evolves.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants