FrancisTR / Rhythm-Swipe

A Repository dedicated to the 2D Game "Rhythm Swipe".
https://projectrhythmswipe.netlify.app/
GNU Affero General Public License v3.0
2 stars 0 forks source link

Audio for the Game Music is doubled #5

Closed FrancisTR closed 1 year ago

FrancisTR commented 1 year ago

It seems that the audio is not loud at first but when you play any level and return to the main menu (Regardless if you win or lose), the audio 'doubles' itself such that two of the same audio is playing at once.

FrostyNick commented 1 year ago

Doubled game audio doesn't occur on Firefox and LibreWolf (very similar to Firefox) for some reason. On Brave (Chromium-based browser), doubled audio is always present on the main menu. And before clicking Start on any difficulty, it's also doubled. The doubled music can be seen visually on the preview too. After clicking Start, no doubling music anymore.

FrancisTR commented 1 year ago

Doubled game audio doesn't occur on Firefox and LibreWolf (very similar to Firefox) for some reason. On Brave (Chromium-based browser), doubled audio is always present on the main menu. And before clicking Start on any difficulty, it's also doubled. The doubled music can be seen visually on the preview too. After clicking Start, no doubling music anymore.

Is it caused by the order of the code in the JS file? If so, how would we approach to fixing it?

FrancisTR commented 1 year ago

This is what it looks like when you first boot up the game.

Before

After playing a level (win or lose), the line is bolded. This indicates that the audio is playing twice at the same time.

After
FrostyNick commented 1 year ago

The issue on Brave browser seems somewhat different. It's not bold, there's two audios playing with a slight delay and it's visible on the oscillator. No bold line on any difficulty I tried that also.

Brave (always has doubled sound) ![image](https://github.com/FrancisTR/Rhythm-Swipe/assets/57016218/0ac0e5f2-f54f-42ec-94c4-508ad97e6fd8)
LibreWolf (no audio issues) ![image](https://github.com/FrancisTR/Rhythm-Swipe/assets/57016218/f427a4c2-3c95-447f-b29f-b8ee9f1f4d8b)
FrostyNick commented 1 year ago

After some searching, I saw two GitHub issues on p5.js-sound repository which might be related:

No simple solution I can find yet.

Probably won't work, but just in case another link I found: p5.sound.js with glitchiness fix

FrancisTR commented 1 year ago

@FrostyNick I found the issue. It seems to fix itself every time I resize my window. During the resizing, it calls "setup();" every time the window size changes. The solution is to call "setup();" on the switch case "0", which is in the main menu. Going to include that solution in my PR coming this week.

FrancisTR commented 1 year ago

@FrostyNick I found the issue. It seems to fix itself every time I resize my window. During the resizing, it calls "setup();" every time the window size changes. The solution is to call "setup();" on the switch case "0", which is in the main menu. Going to include that solution in my PR coming this week.

It seems that it works in FireFox, but not in Google Chrome. This issue still remains until otherwise.

FrancisTR commented 1 year ago

It is now fixed.

FrostyNick commented 1 year ago

The issue on Brave browser seems somewhat different. It's not bold, there's two audios playing with a slight delay and it's visible on the oscillator. No bold line on any difficulty I tried that also. Brave (always has doubled sound) LibreWolf (no audio issues)

This issue persists as of the newest commit c097aab in PR for alpha v1.0.0; at least for Brave browser. This could be be the same issue as in Microsoft Edge (#47) since both are Chromium-based browsers.