dxx-rebirth / dxx-rebirth

Descent-Rebirth and Descent II-Rebirth
Other
501 stars 117 forks source link

Sound effects too loud #753

Open JeodC opened 10 months ago

JeodC commented 10 months ago

Description

This branches from a discussion in #711.

Sound effects like explosions are much louder in recent DXX versions than in 0.58.1. A video demonstration is attached. No .dxa addons are used.

https://github.com/dxx-rebirth/dxx-rebirth/assets/47716344/c751f3ee-dcc7-4ec7-a333-97327f7a3177

It appears explosion sound effects may play at least twice, causing the loudness. Since this issue occurs after 0.58.1, it likely occurs in D2X as well.

Other reported oddities that may be linked: weapon hit sound effects, incorrect directional audio, and sound effects randomly cutting out in water levels.

AlumiuN commented 10 months ago

This is (at least part of) the sound issue I mentioned here - https://github.com/dxx-rebirth/dxx-rebirth/issues/711#issuecomment-1880385509

A quick test confirms that it isn't because older Rebirth only plays explosion sounds on a single projectile, because it does still play it for each impact on lava or robots regardless of which projectile it is. I can't say I've heard incorrect directional audio; IIRC the position of sounds isn't recalculated after they start, which means the player turning or moving may cause the sound to effectively be in the wrong position later on, but I believe that's consistent with DOS Descent (although that could be something that's worth changing anyway).

JeodC commented 10 months ago

I am unable to build prior versions on windows for testing easily. However, I did find an old issue that looked interesting. Maybe this is an uncaught regression from #88 ?

JeodC commented 10 months ago

AlumiuN tested without sdl mixer, issue still occurs. Mixer is not the problem.

https://www.youtube.com/watch?v=ZDJ93tL2jrw&feature=youtu.be

AlumiuN commented 10 months ago

Well, SDL_mixer itself was never going to be the problem, because 0.58.1 uses it too; what it does mean is that either the issue is outside of the SDL_mixer specific path, or it was implemented on both the SDL_mixer path and the non-SDL_mixer path. I haven't had any luck finding anything obvious in either case, but there are a lot of changes to look through and I don't know what would be specifically causing this in the first place.

JeodC commented 10 months ago

Here is a second comparison, this time between DXX-Redux and current DXX-Rebirth.

https://github.com/dxx-rebirth/dxx-rebirth/assets/47716344/38fae8ac-7f23-4fb8-9bb8-6f41720abccc

AlumiuN commented 10 months ago

I believe the sound code in Redux hasn't changed since it was forked from 0.58.1, so the comparison being essentially the same would make sense.

AlumiuN commented 10 months ago

I'm probably stopping for the day, but I've found a couple of things that are likely contributing to the problem:

I haven't yet confirmed whether the sound effects cutting out in water levels is a Rebirth-specific issue; it sounds like it's most likely an issue with running out of sound channels, and I have some criteria to test with, so when I get to that I can report back on that too.

vLKp commented 10 months ago

The weapon firing sound intensity was reduced by 50% in commit 679d2fc, and I couldn't find the justification for doing so

Unfortunately, my commit message did not explain it. However, based on other issue activity around that time, and other commits, I believe I can explain the intention. For issue #559, I fixed a problem which caused remote players' sounds to be louder than the local sound (see commit 20a0166cf4e2f489f99fbc0394fe3473b12b61ab for that; which you also cite in your second bullet point). I followed up with bc210c2c05b7e9058775fd247adc5557ef83a90c to balance the scaling back to what it had been. The commit you cite, 679d2fc494ae730ae37a9b888822fe3b4e988a60, was made around the same time, and so was likely for the same purpose.

If 20a0166cf4e2f489f99fbc0394fe3473b12b61ab is causing clipping, then something needs to be done. The easiest, but least satisfying, fix would be to further scale down the intensity of those sounds, though that is inherently incomplete, since the player can still cause clipping by generating even more concurrent sound effects. A cap on the count of concurrent explosion sounds could be added, similar to the sound stacking rules for weapon cycling.

AlumiuN commented 10 months ago

For the first issue, I can confirm through testing that the ultimate result is that the player's local weapon sounds play at half volume, where they should play at full volume - more specifically, when enabling the debug message in digi_mixer_play_sound the number given for the laser firing sound was always 32768, whereas the nearby impacts of explosions (I think ~50 units away in the map I was testing with) were somewhere in the range of 55000, whereas when testing with Redux (whose behaviour is more accurate to DOS) the laser firing sound was always louder than the explosion volume (256 vs. 190-200ish if memory serves; in Redux the message is after the downshift from a fixed point number, hence the scale difference).

For the second issue, I suspect (although I haven't confirmed) that this isn't an issue unique to the explosion sound, and that a sufficient number of any sounds could also cause clipping. If that is the case, then the only reasonable solution is likely to reduce the maximum volume. I don't know if DOS has the same issue, but I suspect the issue is in the mixing itself, in which case the issue is SDL_mixer not coping with the combined volume of the sounds, which is not something that would be easily fixed otherwise.

alexstrout commented 10 months ago

Windows / 2022-09-22 release (e3faab0)

Adding an observation - lowing FX volume appears to give SFX more "headroom" to stack in volume, resulting in rather loud perceived volume when a lot of sounds play at once (such as a volley of projectile impacts).

In a similar situation at max FX volume, the sounds instead clip with audible distortion.

(I also agree player SFX like weapon firing feels like half volume, compared to any other audio - pickups, robots' weapons, etc.)

vLKp commented 10 months ago

In thinking about this, and looking again at the commit 20a0166cf4e2f489f99fbc0394fe3473b12b61ab, I think that commit is the explanation for the change, and is not inherently wrong, though I can see some users being unhappy about the changed semantics. Prior to that commit, players using SDL mixer would have their sound volume scaled down twice for some sounds, and not for others. That commit sought to fix the problem by causing all sounds to be scaled once, then subsequent commits reduced the intensity of certain hardcoded sound volumes to try to match the intensity that the double-scaling had produced. However, there are problems with this approach:

All that written, I am reconsidering the wisdom of that change. The original change sought to fix a bug where some sounds were too loud because they were only scaled once, so users who set their slider to be able to hear well the double-scaled sounds got a sound that was too loud when it was only single-scaled. I now think that I ought to revert the constant down-steps (this will make some things louder), then reintroduce the double-scaling behavior (which will now be branded an ascended glitch, not a bug), but apply it to all sounds, rather than only some sounds as happened prior to 20a0166cf4e2f489f99fbc0394fe3473b12b61ab.

AlumiuN commented 10 months ago

The problem I can see with that approach is that if the balance was correct in 0.58.1 (or at least somewhat closer, it may not be possible to get it exactly correct), it would suggest that applying the double-scaling to everything would still result in an incorrect balance. The weapon firing sounds being one of the hardcoded sounds whose volume was reduced and is now subsequently unbalanced from other sounds would suggest that there is something we're missing.

vLKp commented 10 months ago

The problem that 20a0166cf4e2f489f99fbc0394fe3473b12b61ab sought to fix was that some sounds were single-scaled, and so were too loud relative to the sounds that were double-scaled. Players set their sound output to make the double-scaled effects sound reasonable from their computer speakers, and then thought that a single-scaled effect was too loud. The ideal would be to make everything single-scaled (as it is today), for players to adjust their sound intensity down accordingly, and to reduce the various hardcoded effects to match what people heard when using double-scaling (this is hard, since double-scaling meant that different people need different down-scale factors in the code).

The only effect I know of that was wrong was weapons fire from non-local players, which was too loud. If the firing player was far enough away from the listener, the natural diminishing effect of distance made the sound acceptably quiet, even though it was louder than an equivalent sound generated by the local player and occurring at that distance. When a non-local player floated very close to the local listener and fired, then single-scaling and the lack of distance combined to make the effect too loud, which is what led to issue #559. Based on my commentary in https://github.com/dxx-rebirth/dxx-rebirth/issues/559#issuecomment-869327824 , I think restoring the double-scaling effect on remote weapons fire would return us to the 0.58.1 behavior.

alexstrout commented 8 months ago

Returned to this recently and looked up the weapon code - it looks like we are indeed firing all weapons at half volume:

/*
* similar/main/laser.cpp
* Laser_create_new
*/
if (parent == Viewer)
{
    // Make your own vulcan gun  1/2 as loud.
    digi_play_sample(weapon_info.flash_sound, weapon_type == weapon_id_type::VULCAN_ID ? (F0_5 / 2) : F0_5);
} else {
    digi_link_sound_to_pos(weapon_info.flash_sound, segnum.absolute_sibling(obj->segnum), sidenum_t::WLEFT, obj->pos, 0, F0_5);
}

Based on other calls to digi_play_sample etc. I'm willing to bet everything would probably feel a bit better at F1_0. Note that this is already the case for Omega Cannon's special do_omega_stuff further up. Might be a start!

vLKp commented 8 months ago

I think @alexstrout's changes are intended to correct this. They were merged above, and are now available in master and as artifacts from a GitHub Actions workflow at https://github.com/dxx-rebirth/dxx-rebirth/actions/runs/8317230985 . Please build master or try out the artifact, and report whether sound is now acceptable for you.

JeodC commented 8 months ago

It's definitely more balanced, but I feel like the explosion effect when lasers hit lava are much louder than when lasers hit a wall. That may be intentional--would need to examine the two sfx files used to be sure.

AlumiuN commented 8 months ago

It's definitely more balanced, but I feel like the explosion effect when lasers hit lava are much louder than when lasers hit a wall. That may be intentional--would need to examine the two sfx files used to be sure.

It's nothing to do with the sound file - it's because only one laser projectile from any shot (I forget which one exactly, outer left I think?) creates a hit sound when it hits a wall or door, but that behaviour is overridden when hitting bots or lava (possibly also water) and creates a sound on each projectile. This behaviour is accurate to the original, although mixing differences may make it more prominent.

JeodC commented 8 months ago

It's definitely more balanced, but I feel like the explosion effect when lasers hit lava are much louder than when lasers hit a wall. That may be intentional--would need to examine the two sfx files used to be sure.

It's nothing to do with the sound file - it's because only one laser projectile from any shot (I forget which one exactly, outer left I think?) creates a hit sound when it hits a wall or door, but that behaviour is overridden when hitting bots or lava (possibly also water) and creates a sound on each projectile. This behaviour is accurate to the original, although mixing differences may make it more prominent.

Does it sound normal to you now?

AlumiuN commented 8 months ago

I have yet to test it for myself, so it's possible that something may have changed with this situation, but it seems unlikely. When I get around to building an up-to-date Rebirth to test I'll report back.

alexstrout commented 8 months ago

FWIW, there's a few comparison videos in #758 of the recent changes proposed (and now merged), in case anyone's looking to see an example without booting the game themselves:

These don't demo audio hitting lava, but they do at least show hitting robots vs. walls in each build.