mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-26 19:50:45 +00:00
- a few more tweaks of the sound system.
* removed the distance hack for explosions and replaced it with a lowered attenuation. The distance hack combined with the rolloff hack forced these sounds to always be unattenuated, even when at the far end of a level. Now they fade, but much less than other sounds. * increased the default NearLimit to 6. For some sounds 4 is not enough and this needs a global limit that works for everything.
This commit is contained in:
parent
b38d8a6dc2
commit
a66fc98d24
1 changed files with 12 additions and 27 deletions
|
@ -156,7 +156,7 @@ int S_DefineSound(unsigned index, const char *filename, int minpitch, int maxpit
|
||||||
sndinf->priority = priority & 255;
|
sndinf->priority = priority & 255;
|
||||||
sndinf->volAdjust = clamp(distance, INT16_MIN, INT16_MAX);
|
sndinf->volAdjust = clamp(distance, INT16_MIN, INT16_MAX);
|
||||||
sfx->Volume = volume;
|
sfx->Volume = volume;
|
||||||
sfx->NearLimit = 4;
|
sfx->NearLimit = 6;
|
||||||
sfx->bTentative = false;
|
sfx->bTentative = false;
|
||||||
sfx->name = filename;
|
sfx->name = filename;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -196,27 +196,6 @@ static int S_CalcDistAndAng(int spriteNum, int soundNum, int sectNum,
|
||||||
&& !cansee(cam->x, cam->y, cam->z - (24 << 8), sectNum, SX(spriteNum), SY(spriteNum), SZ(spriteNum) - (24 << 8), SECT(spriteNum)))
|
&& !cansee(cam->x, cam->y, cam->z - (24 << 8), sectNum, SX(spriteNum), SY(spriteNum), SZ(spriteNum) - (24 << 8), SECT(spriteNum)))
|
||||||
sndist += sndist>>5;
|
sndist += sndist>>5;
|
||||||
|
|
||||||
if ((userflags & (SF_GLOBAL|SF_DTAG)) == (SF_GLOBAL|SF_DTAG))
|
|
||||||
{
|
|
||||||
boost:
|
|
||||||
int const sdist = dist_adjust ? dist_adjust : 6144;
|
|
||||||
|
|
||||||
explosion = true;
|
|
||||||
|
|
||||||
if (sndist > sdist)
|
|
||||||
sndist = sdist;
|
|
||||||
}
|
|
||||||
else if (!FURY)
|
|
||||||
{
|
|
||||||
switch (DYNAMICSOUNDMAP(soundNum))
|
|
||||||
{
|
|
||||||
case PIPEBOMB_EXPLODE__STATIC:
|
|
||||||
case LASERTRIP_EXPLODE__STATIC:
|
|
||||||
case RPG_EXPLODE__STATIC:
|
|
||||||
goto boost;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Here the sound distance was clamped to a minimum of 144*4.
|
// Here the sound distance was clamped to a minimum of 144*4.
|
||||||
// It's better to handle rolloff in the backend instead of whacking the sound origin here.
|
// It's better to handle rolloff in the backend instead of whacking the sound origin here.
|
||||||
// That way the lower end can be made customizable instead of losing all precision right here at the source.
|
// That way the lower end can be made customizable instead of losing all precision right here at the source.
|
||||||
|
@ -227,7 +206,6 @@ boost:
|
||||||
*distPtr = sndist;
|
*distPtr = sndist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (sndPos)
|
if (sndPos)
|
||||||
{
|
{
|
||||||
FVector3 sndorg = { pos->x * xmul, pos->z * zmul, pos->y * ymul };
|
FVector3 sndorg = { pos->x * xmul, pos->z * zmul, pos->y * ymul };
|
||||||
|
@ -242,7 +220,7 @@ boost:
|
||||||
else *sndPos = campos;
|
else *sndPos = campos;
|
||||||
}
|
}
|
||||||
|
|
||||||
return explosion;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -421,7 +399,7 @@ int S_PlaySound3D(int num, int spriteNum, const vec3_t* pos, int flags)
|
||||||
int32_t camsect;
|
int32_t camsect;
|
||||||
|
|
||||||
S_GetCamera(&campos, nullptr, &camsect);
|
S_GetCamera(&campos, nullptr, &camsect);
|
||||||
int const explosionp = S_CalcDistAndAng(spriteNum, sndnum, camsect, campos, pos, &sndist, &sndpos);
|
S_CalcDistAndAng(spriteNum, sndnum, camsect, campos, pos, &sndist, &sndpos);
|
||||||
int pitch = S_GetPitch(sndnum);
|
int pitch = S_GetPitch(sndnum);
|
||||||
auto const pOther = g_player[screenpeek].ps;
|
auto const pOther = g_player[screenpeek].ps;
|
||||||
|
|
||||||
|
@ -429,6 +407,8 @@ int S_PlaySound3D(int num, int spriteNum, const vec3_t* pos, int flags)
|
||||||
if (pOther->sound_pitch)
|
if (pOther->sound_pitch)
|
||||||
pitch += pOther->sound_pitch;
|
pitch += pOther->sound_pitch;
|
||||||
|
|
||||||
|
bool explosionp = ((userflags & (SF_GLOBAL | SF_DTAG)) == (SF_GLOBAL | SF_DTAG)) || ((!FURY) && (sndnum == PIPEBOMB_EXPLODE || sndnum == LASERTRIP_EXPLODE || sndnum == RPG_EXPLODE));
|
||||||
|
|
||||||
if (explosionp)
|
if (explosionp)
|
||||||
{
|
{
|
||||||
if (pOther->cursectnum > -1 && sector[pOther->cursectnum].lotag == ST_2_UNDERWATER)
|
if (pOther->cursectnum > -1 && sector[pOther->cursectnum].lotag == ST_2_UNDERWATER)
|
||||||
|
@ -455,8 +435,13 @@ int S_PlaySound3D(int num, int spriteNum, const vec3_t* pos, int flags)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now
|
// These explosion sounds originally used some distance hackery to make them louder but due to how the rolloff was set up they always played at full volume as a result.
|
||||||
float attenuation = (userflags & (SF_GLOBAL | SF_DTAG)) == SF_GLOBAL ? ATTN_NONE : ATTN_NORM;
|
// I think it is better to lower their attenuation so that they are louder than the rest but still fade in the distance.
|
||||||
|
// For the original effect, attenuation needs to be set to ATTN_NONE here.
|
||||||
|
float attenuation;
|
||||||
|
if (explosionp) attenuation = 0.5f;
|
||||||
|
else attenuation = (userflags & (SF_GLOBAL | SF_DTAG)) == SF_GLOBAL ? ATTN_NONE : ATTN_NORM;
|
||||||
|
|
||||||
if (userflags & SF_LOOP) flags |= CHAN_LOOP;
|
if (userflags & SF_LOOP) flags |= CHAN_LOOP;
|
||||||
auto chan = soundEngine->StartSound(SOURCE_Actor, &sprite[spriteNum], &sndpos, flags, sndnum+1, attenuation == ATTN_NONE? 0.8f : 1.f, attenuation, nullptr, S_ConvertPitch(pitch));
|
auto chan = soundEngine->StartSound(SOURCE_Actor, &sprite[spriteNum], &sndpos, flags, sndnum+1, attenuation == ATTN_NONE? 0.8f : 1.f, attenuation, nullptr, S_ConvertPitch(pitch));
|
||||||
return chan ? 0 : -1;
|
return chan ? 0 : -1;
|
||||||
|
|
Loading…
Reference in a new issue