fabiangreffrath / woof

Woof! is a continuation of the Boom/MBF bloodline of Doom source ports.
GNU General Public License v2.0
186 stars 32 forks source link

Chex Quest - Clicking Sound Effects #1730

Closed ak-988 closed 1 month ago

ak-988 commented 1 month ago

Reported here https://www.doomworld.com/forum/post/2809339

I can reproduce this clicking and the other observations in that thread on Windows 10. DSITEMUP is a good test candidate (scrolling a submenu.) Somehow, DSDA and PrBoomX don't have this issue. GZDoom and Woof do. Woof even has it back to early releases with SDL Mixer.

Pretty sure this abrupt drop at the end of DSITEMUP is the culprit, and Woof is just playing it faithfully:

dip

Same thing with DSBFG:

Screenshot 2024-06-07 020217

The DSITEMUP that comes with Vanilla Chex 3 doesn't have it, and doesn't pop with a current build of Woof:

https://melodic-spaceship.neocities.org/chex3v/downloads

Screenshot 2024-06-07 015702

This seems like something Woof's fading to avoid clicks could address. But, how do those other ports avoid it? I tried a quick look around and didn't find any obvious "Fix Chex sound" commits.

Edit: Just to help verify things, here's a sound replacement WAD for Chex Quest that allows it to be played in current Woof with no issues that I heard: https://www.doomworld.com/applications/core/interface/file/attachment.php?id=301455

fabiangreffrath commented 1 month ago

Looks like we need to extend FadeInMono8() to FadeInAndOutMono8() here:

https://github.com/fabiangreffrath/woof/blob/80d92fa2aeca9cab69e7c363251808bae2177a6b/src/i_oalsound.c#L613-L627

fabiangreffrath commented 1 month ago

Looks like we need to extend FadeInMono8() to FadeInAndOutMono8() here:

https://github.com/fabiangreffrath/woof/blob/80d92fa2aeca9cab69e7c363251808bae2177a6b/src/i_oalsound.c#L613-L627

fabiangreffrath commented 1 month ago

Even I can hear this and this patch fixes it for me:

--- a/src/i_oalsound.c
+++ b/src/i_oalsound.c
@@ -610,12 +610,12 @@ static boolean IsPaddedSound(const byte *data, int size)
     return true;
 }

-static void FadeInMono8(byte *data, ALsizei size, ALsizei freq)
+static void FadeInOutMono8(byte *data, ALsizei size, ALsizei freq)
 {
     const int fadelen = freq * FADETIME / 1000000;
     int i;

-    if (data[0] == 128 || size < fadelen)
+    if ((data[0] == 128 && data[size - 1] == 128) || size < fadelen)
     {
         return;
     }
@@ -623,6 +623,7 @@ static void FadeInMono8(byte *data, ALsizei size, ALsizei freq)
     for (i = 0; i < fadelen; i++)
     {
         data[i] = (data[i] - 128) * i / fadelen + 128;
+        data[size - 1 - i] = (data[size - 1 - i] - 128) * i / fadelen + 128;
     }
 }

@@ -687,7 +688,7 @@ boolean I_OAL_CacheSound(sfxinfo_t *sfx)

             // Fade in sounds that start at a non-zero amplitude to prevent
             // clicking.
-            FadeInMono8(sampledata, size, freq);
+            FadeInOutMono8(sampledata, size, freq);
         }
         else
         {
ceski-1 commented 1 month ago

Screenshot 2024-06-07 020217

This was my suspicion, thanks for investigating!

ceski-1 commented 1 month ago

Most of the Chex Quest sounds have issues: chex_sfx.txt (for comparison, doom2_sfx.txt is less severe) The range is -128 to 127, so roughly half the Chex Quest sounds have the last sample at full volume. Very poor mastering.