Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Memfis

How far can the player hear?

Recommended Posts

I often use the sector merge trick to make certain floors move silently (hate that clacking sound when you walk on 3D bridges) but what distance do I need exactly? If I move the dummy sectors too far it affects the way the automap appears, which can be annoying. So it would be nice to know the safe length. Also, it is the same in all common ports? What about other sounds, such as fireballs exploding or monsters roaring?

Share this post


Link to post

1200 units in vanilla, Boom, etc. linuxdoom-1.10/s_sound.c:

// when to clip out sounds
// Does not fit the large outdoor areas.
#define S_CLIPPING_DIST (1200*0x10000)

Note the distance metric isn't quite euclidean, but a faster-to-calculate approximation (see also the annoyingly misspelled P_AproxDistance)

// From _GG1_ p.428. Appox. eucledian distance fast.
approx_dist = adx + ady - ((adx < ady ? adx : ady)>>1);

if (gamemap != 8
    && approx_dist > S_CLIPPING_DIST)
{
    return 0;
}

So the "circles" in this metric are actually octagons.

Share this post


Link to post

Thanks! So it's not that far.

 

Btw do these faraway sounds still "exist"? If a faraway cacodemon notices you and in the middle of the supposed "SSSSSH" you teleport near it, can you hear a part of the hiss?

Share this post


Link to post

No, if a sound is inaudible (as defined by S_AdjustSoundParams return value) it will be ignored by S_StartSound. Furthermore in S_UpdateSounds (called once per tic) if an existing sound becomes inaudible it will be removed - coming back into range won't start it off again.*

 

Here is a test map farsound.wad. Pick up the rocket launcher, shoot it, and then immediately go in the teleporter. You won't hear the barons and hellknights' wakeup sounds because when they were started they were inaudible. The missile, having a good sense of comic timing, arrives a moment later.

 

_______

* {,G}ZDoom probably changes all this, I haven't bothered to check

Share this post


Link to post
31 minutes ago, RjY said:

* {,G}ZDoom probably changes all this, I haven't bothered to check

Yes, it does change it. I tried it on GZDoom, and you can hear the latter halves of the Barons' wakeup sounds. Interesting.

 

I'm just curious about another thing about sounds. I guess Map08 for some reason won't have this calculation to lower the volume of the sounds or clip them out if too far? I still don't understand this.

Share this post


Link to post
20 minutes ago, rdwpa said:

A shame there's no exit. :) 

Damnit, I meant to, but never did. If I ever release a megawad of my tiny test maps (I must have made enough of them by now) this'll have an exit

 

@GarrettChan Thanks for the GZDoom test. Yeah gamemap==8 causes distance checks to be skipped so you can hear far-off sounds from wherever. The formula for distance attenuation is also a bit different, it essentially pretends the volume slider is set to at least 15 (more or less)

// volume calculation
if (approx_dist < S_CLOSE_DIST)
{
    *vol = snd_SfxVolume;
}
else if (gamemap == 8)
{
    if (approx_dist > S_CLIPPING_DIST)
        approx_dist = S_CLIPPING_DIST;

    *vol = 15+ ((snd_SfxVolume-15)
                *((S_CLIPPING_DIST - approx_dist)>>FRACBITS))
        / S_ATTENUATOR;
}
else
{
    // distance effect
    *vol = (snd_SfxVolume
            * ((S_CLIPPING_DIST - approx_dist)>>FRACBITS))
        / S_ATTENUATOR;
}

 

Share this post


Link to post

Some sounds are also played at full volume wherever they happen, iirc. Like the spiderdemon's death sound, and the IoS firing a cube. Or perhaps it's full volume but only if they occur within that aforementioned octagon?

Share this post


Link to post

No, those sounds are audible anywhere because they don't have an origin. Most sounds originate from some mobj so their position / stereo separation can be updated as the listener moves, and removed completely if he goes out of range. But level-wide sounds such as those you mentioned have their origin set to NULL. Funnily enough menu sounds also have a NULL origin, and the sound code only allows one sound at a time from the same origin. That's why, if you're tired of hearing it for the fifteen millionth time, you can silence John Romero's backwards speech by pressing Escape or an F key.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×