IllagerCaptain / BetterBubbles

Improves the oxygen bar on the hotbar!
Other
1 stars 0 forks source link

pop sound plays more than once at a high framerate #1

Open Novaenia opened 1 month ago

Novaenia commented 1 month ago

steps to reproduce:

  1. uncap your framerate
  2. get enough frames
  3. go swimming
IllagerCaptain commented 1 month ago

When you say more than once, do you mean twice, three times, every frame? It's hard for me to test this particular issue myself because my computer is a potato.

Novaenia commented 1 month ago

it sounds like a new instance of the pop sound is being made every frame that a bubble's half-popped sprite is visible

pajicadvance commented 1 week ago

This most likely happens because playSound is called in a mixin to a rendering method which runs every frame.

https://github.com/IllagerCaptain/BetterBubbles/blob/cd9dec5eaae9e7c1a414e22bc5708c73eb75c4ec/src/client/java/com/betterbubbles/mixin/client/InGameHudMixin.java#L58

This condition is probably true during multiple frames so the sound plays once for each frame. You need to somehow make sure that the sound only plays in the first frame when the condition is true and not in the frames that come after.