mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-24 16:01:00 +00:00
- fixed sound volume issues in Blood.
This commit is contained in:
parent
a7b020d1a8
commit
3ed7856f53
2 changed files with 9 additions and 6 deletions
|
@ -131,14 +131,15 @@ void sfxUpdate3DSounds(void)
|
|||
soundEngine->UpdateSounds((int)totalclock);
|
||||
}
|
||||
|
||||
FSoundID getSfx(FSoundID soundId, float &attenuation, int &pitch, int relvol)
|
||||
FSoundID getSfx(FSoundID soundId, float &attenuation, int &pitch, int &relvol)
|
||||
{
|
||||
auto udata = (int*)soundEngine->GetUserData(soundId);
|
||||
if (pitch < 0) pitch = udata ? udata[0] : 0x10000;
|
||||
|
||||
if (relvol < 0) relvol = udata && udata[2] ? udata[2] : 80;
|
||||
if (relvol > 255) relvol = 255;
|
||||
attenuation = relvol > 0 ? 80.f / relvol : 1.f;
|
||||
// Limit the attenuation. More than 2.0 is simply too much.
|
||||
attenuation = relvol > 0 ? clamp(80.f / relvol, 0.f, 2.f) : 1.f;
|
||||
return soundId;
|
||||
}
|
||||
|
||||
|
@ -153,9 +154,10 @@ void sfxPlay3DSound(int x, int y, int z, int soundId, int nSector)
|
|||
|
||||
float attenuation;
|
||||
int pitch = -1;
|
||||
sid = getSfx(sid, attenuation, pitch, -1);
|
||||
int relvol = -1;
|
||||
sid = getSfx(sid, attenuation, pitch, relvol);
|
||||
|
||||
soundEngine->StartSound(SOURCE_Unattached, nullptr, &svec, -1, CHANF_OVERLAP, sid, 0.8f, attenuation, nullptr, pitch / 65536.f);
|
||||
soundEngine->StartSound(SOURCE_Unattached, nullptr, &svec, -1, CHANF_OVERLAP, sid, (0.8f / 80.f) * relvol, attenuation, nullptr, pitch / 65536.f);
|
||||
|
||||
}
|
||||
|
||||
|
@ -176,6 +178,7 @@ void sfxPlay3DSoundCP(spritetype* pSprite, int soundId, int a3, int a4, int pitc
|
|||
|
||||
float attenuation;
|
||||
sid = getSfx(sid, attenuation, pitch, volume);
|
||||
if (volume == -1) volume = 80;
|
||||
|
||||
if (a3 >= 0)
|
||||
{
|
||||
|
@ -197,7 +200,7 @@ void sfxPlay3DSoundCP(spritetype* pSprite, int soundId, int a3, int a4, int pitc
|
|||
|
||||
}
|
||||
|
||||
soundEngine->StartSound(SOURCE_Actor, pSprite, &svec, a3, a3 == -1? CHANF_OVERLAP : CHANF_NONE , sid, 0.8f, attenuation, nullptr, pitch / 65536.f);
|
||||
soundEngine->StartSound(SOURCE_Actor, pSprite, &svec, a3, a3 == -1? CHANF_OVERLAP : CHANF_NONE , sid, volume * (0.8f / 80.f), attenuation, nullptr, pitch / 65536.f);
|
||||
}
|
||||
|
||||
void sfxPlay3DSound(spritetype* pSprite, int soundId, int a3, int a4)
|
||||
|
|
|
@ -48,7 +48,7 @@ void sfxInit(void);
|
|||
void sfxTerm(void);
|
||||
void sfxPlay3DSound(int x, int y, int z, int soundId, int nSector);
|
||||
void sfxPlay3DSound(spritetype *pSprite, int soundId, int a3 = -1, int a4 = 0);
|
||||
void sfxPlay3DSoundCP(spritetype* pSprite, int soundId, int a3 = -1, int a4 = 0, int pitch = 0, int volume = 0);
|
||||
void sfxPlay3DSoundCP(spritetype* pSprite, int soundId, int a3 = -1, int a4 = 0, int pitch = 0, int volume = -1);
|
||||
void sfxKill3DSound(spritetype *pSprite, int a2 = -1, int a3 = -1);
|
||||
void sfxKillAllSounds(void);
|
||||
void sfxUpdate3DSounds(void);
|
||||
|
|
Loading…
Reference in a new issue