Permalink
Browse files

do not let sounds "played in the player's head" interrupt each other

@BCG2000 please test with your use cases, thanks!
  • Loading branch information...
fabiangreffrath committed Jan 9, 2019
1 parent 7d55ed9 commit 0fb71651ba96e68407c9a848203ba41e64fd03e4
Showing with 3 additions and 0 deletions.
  1. +3 −0 src/doom/s_sound.c
@@ -597,7 +597,10 @@ void S_StartSound(void *origin_p, int sfx_id)
pitch = Clamp(pitch);

// kill old sound
if (!crispy->soundfull || origin)
{
S_StopSound(origin);
}

// try to find a channel
cnum = S_GetChannel(origin, sfx);

13 comments on commit 0fb7165

@BCG2000

This comment has been minimized.

Copy link

BCG2000 replied Jan 10, 2019

Worked perfectly, thanks!

@JNechaevsky

This comment has been minimized.

Copy link
Collaborator

JNechaevsky replied Jan 10, 2019

@fabiangreffrath, @BCG2000,

Hold up for a second, the thing happens which I was afraid of. Try to do this (with "full length sounds feature"), but please, before doing, reduce your sound volume or remove headphones. This is dangerous for both ears and stereo system, I'm not kidding here.

  • Stand near the Romero's head.
  • Make a point blank SSG shot. Extremely loud sound will be performed.
  • Make another SSG shot. Another extremely loud sound will be performed, which will cover actual death sound.

Well, normally this case will never happen in Doom II, but some mods may have such a feature - to don't kill Icon of Sin by rockets, but by any other possible way. Ceiling crusher comes to mind, here's a testing map.

@BCG2000

This comment has been minimized.

Copy link

BCG2000 replied Jan 10, 2019

Oh yea, damn. But this doesn't happen only with Romero's Head, it's with any sound that plays multiple times at the same time (i.e. seesounds). Kinda like how a crowd shouting makes a much louder noise compared to a single person. It's just that Romero's Head happens to be the loudest one. I wasn't noticing this because I have Loudness Equalization enabled on Windows (for movie watching), which counters the problem pretty well.

From what I know this is a sound mixing problem where when you mix multiple identical sounds at the same time, they come out as the same sound but extremely loud. I don't know exactly how to fix this as currently I'm pretty clueless when it comes to audio engineering.

You could possibly detect when multiple identical sounds are playing in the same tic and then play just one or do something like Windows' Loudness Equalization (probably too complex). Another solution I remember seeing somewhere is delaying when each sound starts playing randomly (maybe a bit unclean, but I think this would probably be the best).

Of course, Romero's Head has priority here, I don't think its pain sound should play multiple times like that.

@fabiangreffrath

This comment has been minimized.

Copy link
Owner

fabiangreffrath replied Jan 10, 2019

Hm, I don't understand this. As I see it, both sounds (pain and death) are emitted only once and I see no reason why they should add up in volume if I don't allow them to interrupt each other.

@BCG2000

This comment has been minimized.

Copy link

BCG2000 replied Jan 10, 2019

So it plays only once? Weird how it comes out very loud then...

@fabiangreffrath

This comment has been minimized.

Copy link
Owner

fabiangreffrath replied Jan 10, 2019

Well, once each four tics, that is.

I have patched the sources a bit:

--- a/src/doom/p_enemy.c
+++ b/src/doom/p_enemy.c
@@ -1939,6 +1939,7 @@ void A_BrainAwake (mobj_t* mo)
 void A_BrainPain (mobj_t*      mo)
 {
     S_StartSound (NULL,sfx_bospn);
+    printf("%d brainpain\n", gametic);
 }
 
 
@@ -1964,6 +1965,7 @@ void A_BrainScream (mobj_t*       mo)
     }
        
     S_StartSound (NULL,sfx_bosdth);
+    printf("%d brainscream\n", gametic);
 }

This is what happens in @JNechaevsky's crusher map:

112 brainpain
116 brainpain
120 brainpain
124 brainpain
128 brainpain
132 brainpain
136 brainpain
140 brainpain
144 brainpain
148 brainpain
152 brainpain
156 brainpain
160 brainpain
164 brainpain
352 brainpain
356 brainpain
360 brainpain
364 brainpain
368 brainpain
372 brainpain
376 brainpain
380 brainpain
384 brainpain
388 brainpain
392 brainscream

And this happens if I shoot him in the face from point blank:

392 brainpain
392 brainpain
392 brainpain
392 brainpain
392 brainpain
392 brainpain
392 brainpain
392 brainpain
392 brainpain
392 brainpain
392 brainpain
392 brainpain
392 brainpain
392 brainpain
392 brainpain
392 brainpain
392 brainpain
392 brainpain
570 brainpain
570 brainpain
570 brainpain
570 brainpain
570 brainscream

Maybe S_SoundStartOnce() can help here?

@fabiangreffrath

This comment has been minimized.

Copy link
Owner

fabiangreffrath replied Jan 10, 2019

Yes, sounds like this is the cure:

--- a/src/doom/p_enemy.c
+++ b/src/doom/p_enemy.c
@@ -1938,7 +1938,7 @@ void A_BrainAwake (mobj_t* mo)
 
 void A_BrainPain (mobj_t*      mo)
 {
-    S_StartSound (NULL,sfx_bospn);
+    S_StartSoundOnce (NULL,sfx_bospn);
 }
 
 
@BCG2000

This comment has been minimized.

Copy link

BCG2000 replied Jan 10, 2019

What about with other sounds though (which I apologize for not catching on before due to my Loudness Equalization being enabled)? Like if you go on MAP21 of MASTERLEVELS.WAD and open the door, the Cyberdemons make an extremely loud noise when alerted. Happens with other demons too (though not as much since it's not on your head).

Other source ports actually suffer from this too... Pretty easy to replicate by putting, say, a lot of Revenants in a room and then alerting them. I admit I find it pretty hilarious but it's not easy on the ears at all. One of my suggestions was delaying each sound start randomly, just a bit, but I'm not sure if it actually works.

@fabiangreffrath

This comment has been minimized.

Copy link
Owner

fabiangreffrath replied Jan 11, 2019

Pretty easy to replicate by putting, say, a lot of Revenants in a room and then alerting them.

But this isn't connected to the "play sounds at full length" feature, right? I mean, if there are many different monsters all emitting the same sound at the same time, it will become loud, even in Vanilla.

Multiple identical sounds emitted in your head are a problem, though.

@fabiangreffrath

This comment has been minimized.

Copy link
Owner

fabiangreffrath replied Jan 11, 2019

So, what is potentially affected? I think it's spider's and cyberdemon's seesound and deathsound, respectively, and the brain's painsound. There are others, but I guess these are the most noticeable ones.

@JNechaevsky

This comment has been minimized.

Copy link
Collaborator

JNechaevsky replied Jan 11, 2019

So, what is potentially affected?

Looks likes only sounds you have mentioned: Spider, Cyberdemon, Icon of Sin. I think this it is necessary to take care of this with first priority.

As about other monsters - well, even when they are making a lots of seesounds, it's a bit safe because they are aren't NULL-sourced and the distance is accounted. It's a vanilla behavior indeed, and if I remember correctly, they are never able to make such a loud sound like point blank SSG blast to the Icon of Sin.

@fabiangreffrath

This comment has been minimized.

Copy link
Owner

fabiangreffrath replied Jan 11, 2019

Yes, right! I think I just pushed the necessary changes to take care of this. 😁

@JNechaevsky

This comment has been minimized.

Copy link
Collaborator

JNechaevsky replied Jan 11, 2019

Oh yes, I see, thank you!

The reason why I'm so worried about this - I still remember very well the effect of extremely load Icon of Sin pain sound. Back in the day of 30 Mar 2017, I was playing with my stereo+bass system on with high volume. It's hard to describe my condition after SSG blast. Good thing no one in the whole house called the police!

Please sign in to comment.