diff options
author | aap <aap@papnet.eu> | 2020-05-07 17:31:32 +0200 |
---|---|---|
committer | aap <aap@papnet.eu> | 2020-05-07 17:31:32 +0200 |
commit | 3ae10c93acbf223675e032dc4b1b1193d2bc41fc (patch) | |
tree | 64998f82fb659ae343ebf6b8da75350a0a8de10f /src/audio | |
parent | got rid of superfluous enum; update librw (diff) | |
parent | Fix looping collision sound (diff) | |
download | re3-3ae10c93acbf223675e032dc4b1b1193d2bc41fc.tar re3-3ae10c93acbf223675e032dc4b1b1193d2bc41fc.tar.gz re3-3ae10c93acbf223675e032dc4b1b1193d2bc41fc.tar.bz2 re3-3ae10c93acbf223675e032dc4b1b1193d2bc41fc.tar.lz re3-3ae10c93acbf223675e032dc4b1b1193d2bc41fc.tar.xz re3-3ae10c93acbf223675e032dc4b1b1193d2bc41fc.tar.zst re3-3ae10c93acbf223675e032dc4b1b1193d2bc41fc.zip |
Diffstat (limited to '')
-rw-r--r-- | src/audio/AudioCollision.cpp | 143 | ||||
-rw-r--r-- | src/audio/AudioManager.cpp | 60 | ||||
-rw-r--r-- | src/audio/AudioManager.h | 10 |
3 files changed, 116 insertions, 97 deletions
diff --git a/src/audio/AudioCollision.cpp b/src/audio/AudioCollision.cpp index 0e060568..ecd0299c 100644 --- a/src/audio/AudioCollision.cpp +++ b/src/audio/AudioCollision.cpp @@ -117,58 +117,54 @@ cAudioManager::GetCollisionRatio(float a, float b, float c, float d) const } uint32 -cAudioManager::SetLoopingCollisionRequestedSfxFreqAndGetVol(cAudioCollision *audioCollision) +cAudioManager::SetLoopingCollisionRequestedSfxFreqAndGetVol(const cAudioCollision &audioCollision) { - uint8 surface1 = audioCollision->m_bSurface1; - uint8 surface2 = audioCollision->m_bSurface2; + uint8 surface1 = audioCollision.m_bSurface1; + uint8 surface2 = audioCollision.m_bSurface2; int32 vol; float ratio; if(surface1 == SURFACE_GRASS || surface2 == SURFACE_GRASS || surface1 == SURFACE_HEDGE || surface2 == SURFACE_HEDGE) { - ratio = GetCollisionRatio(audioCollision->m_fIntensity2, 0.0001f, 0.09f, 0.0899f); + ratio = GetCollisionRatio(audioCollision.m_fIntensity2, 0.0001f, 0.09f, 0.0899f); m_sQueueSample.m_nSampleIndex = SFX_RAIN; m_sQueueSample.m_nFrequency = 13000.f * ratio + 35000; vol = 50.f * ratio; + } else if(surface1 == SURFACE_PUDDLE || surface2 == SURFACE_PUDDLE) { + ratio = GetCollisionRatio(audioCollision.m_fIntensity2, 0.0001f, 0.09f, 0.0899f); + m_sQueueSample.m_nSampleIndex = SFX_BOAT_WATER_LOOP; + m_sQueueSample.m_nFrequency = 6050.f * ratio + 16000; + vol = 30.f * ratio; + } else if(surface1 == SURFACE_DIRT || surface2 == SURFACE_DIRT || surface1 == SURFACE_DIRTTRACK || + surface2 == SURFACE_DIRTTRACK || surface1 == SURFACE_SAND || surface2 == SURFACE_SAND) { + ratio = GetCollisionRatio(audioCollision.m_fIntensity2, 0.0001f, 0.09f, 0.0899f); + m_sQueueSample.m_nSampleIndex = SFX_GRAVEL_SKID; + m_sQueueSample.m_nFrequency = 6000.f * ratio + 10000; + vol = 50.f * ratio; + } else if(surface1 == SURFACE_FLESH || surface2 == SURFACE_FLESH) { + return 0; } else { - if(surface1 == SURFACE_PUDDLE || surface2 == SURFACE_PUDDLE) { - ratio = GetCollisionRatio(audioCollision->m_fIntensity2, 0.0001f, 0.09f, 0.0899f); - m_sQueueSample.m_nSampleIndex = SFX_BOAT_WATER_LOOP; - m_sQueueSample.m_nFrequency = 6050.f * ratio + 16000; - vol = 30.f * ratio; - - } else { - if(surface1 == SURFACE_DIRT || surface2 == SURFACE_DIRT || surface1 == SURFACE_DIRTTRACK || - surface2 == SURFACE_DIRTTRACK || surface1 == SURFACE_SAND || surface2 == SURFACE_SAND) { - ratio = GetCollisionRatio(audioCollision->m_fIntensity2, 0.0001f, 0.09f, 0.0899f); - m_sQueueSample.m_nSampleIndex = SFX_GRAVEL_SKID; - m_sQueueSample.m_nFrequency = 6000.f * ratio + 10000; - vol = 50.f * ratio; - } else { - if(surface1 == SURFACE_FLESH || surface2 == SURFACE_FLESH) { return 0; } - ratio = GetCollisionRatio(audioCollision->m_fIntensity2, 0.0001f, 0.09f, 0.0899f); - m_sQueueSample.m_nSampleIndex = SFX_SCRAPE_CAR_1; - m_sQueueSample.m_nFrequency = 10000.f * ratio + 10000; - vol = 40.f * ratio; - } - } + ratio = GetCollisionRatio(audioCollision.m_fIntensity2, 0.0001f, 0.09f, 0.0899f); + m_sQueueSample.m_nSampleIndex = SFX_SCRAPE_CAR_1; + m_sQueueSample.m_nFrequency = 10000.f * ratio + 10000; + vol = 40.f * ratio; } - if(audioCollision->m_nBaseVolume < 2) vol = audioCollision->m_nBaseVolume * vol / 2; + if(audioCollision.m_nBaseVolume < 2) vol = audioCollision.m_nBaseVolume * vol / 2; return vol; } void -cAudioManager::SetUpLoopingCollisionSound(cAudioCollision *col, uint8 counter) +cAudioManager::SetUpLoopingCollisionSound(const cAudioCollision &col, uint8 counter) { - if(col->m_fIntensity2 > 0.0016f) { + if(col.m_fIntensity2 > 0.0016f) { uint8 emittingVol = SetLoopingCollisionRequestedSfxFreqAndGetVol(col); if(emittingVol) { - m_sQueueSample.m_fDistance = Sqrt(col->m_fDistance); + m_sQueueSample.m_fDistance = Sqrt(col.m_fDistance); m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, CollisionSoundIntensity, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_nVolume) { m_sQueueSample.m_nCounter = counter; - m_sQueueSample.m_vecPos = col->m_vecPosition; + m_sQueueSample.m_vecPos = col.m_vecPosition; m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 7; @@ -189,22 +185,43 @@ cAudioManager::SetUpLoopingCollisionSound(cAudioCollision *col, uint8 counter) } } } +static const int32 gOneShotCol[] = {SFX_COL_TARMAC_1, + SFX_COL_TARMAC_1, + SFX_COL_GRASS_1, + SFX_COL_GRAVEL_1, + SFX_COL_MUD_1, + SFX_COL_TARMAC_1, + SFX_COL_CAR_1, + SFX_COL_GRASS_1, + SFX_COL_SCAFFOLD_POLE_1, + SFX_COL_GARAGE_DOOR_1, + SFX_COL_CAR_PANEL_1, + SFX_COL_THICK_METAL_PLATE_1, + SFX_COL_SCAFFOLD_POLE_1, + SFX_COL_LAMP_POST_1, + SFX_COL_HYDRANT_1, + SFX_COL_HYDRANT_1, + SFX_COL_METAL_CHAIN_FENCE_1, + SFX_COL_PED_1, + SFX_COL_SAND_1, + SFX_SPLASH_1, + SFX_COL_WOOD_CRATES_1, + SFX_COL_WOOD_BENCH_1, + SFX_COL_WOOD_SOLID_1, + SFX_COL_GRASS_1, + SFX_COL_GRASS_1, + SFX_COL_VEG_1, + SFX_COL_TARMAC_1, + SFX_COL_CONTAINER_1, + SFX_COL_NEWS_VENDOR_1, + SFX_TYRE_BUMP, + SFX_COL_CARDBOARD_1, + SFX_COL_TARMAC_1, + SFX_COL_GATE}; void -cAudioManager::SetUpOneShotCollisionSound(cAudioCollision *col) +cAudioManager::SetUpOneShotCollisionSound(const cAudioCollision &col) { - static const int32 gOneShotCol[] = { - SFX_COL_TARMAC_1, SFX_COL_TARMAC_1, SFX_COL_GRASS_1, - SFX_COL_GRAVEL_1, SFX_COL_MUD_1, SFX_COL_TARMAC_1, - SFX_COL_CAR_1, SFX_COL_GRASS_1, SFX_COL_SCAFFOLD_POLE_1, - SFX_COL_GARAGE_DOOR_1, SFX_COL_CAR_PANEL_1, SFX_COL_THICK_METAL_PLATE_1, - SFX_COL_SCAFFOLD_POLE_1, SFX_COL_LAMP_POST_1, SFX_COL_HYDRANT_1, - SFX_COL_HYDRANT_1, SFX_COL_METAL_CHAIN_FENCE_1, SFX_COL_PED_1, - SFX_COL_SAND_1, SFX_SPLASH_1, SFX_COL_WOOD_CRATES_1, - SFX_COL_WOOD_BENCH_1, SFX_COL_WOOD_SOLID_1, SFX_COL_GRASS_1, - SFX_COL_GRASS_1, SFX_COL_VEG_1, SFX_COL_TARMAC_1, - SFX_COL_CONTAINER_1, SFX_COL_NEWS_VENDOR_1, SFX_TYRE_BUMP, - SFX_COL_CARDBOARD_1, SFX_COL_TARMAC_1, SFX_COL_GATE}; int16 s1; int16 s2; @@ -216,21 +233,21 @@ cAudioManager::SetUpOneShotCollisionSound(cAudioCollision *col) for(int32 i = 0; i < 2; i++) { if(i) { - s1 = col->m_bSurface2; - s2 = col->m_bSurface1; + s1 = col.m_bSurface2; + s2 = col.m_bSurface1; } else { - s1 = col->m_bSurface1; - s2 = col->m_bSurface2; + s1 = col.m_bSurface1; + s2 = col.m_bSurface2; } - ratio = GetCollisionOneShotRatio(s1, col->m_fIntensity1); - if(s1 == SURFACE_METAL6 && s2 == SURFACE_FLESH) ratio = 0.25f * ratio; + ratio = GetCollisionOneShotRatio(s1, col.m_fIntensity1); + if(s1 == SURFACE_METAL6 && s2 == SURFACE_FLESH) ratio /= 4.0f; if(s1 == SURFACE_METAL6 && ratio < 0.6f) { s1 = SURFACE_BILLBOARD; ratio = Min(1.f, 2.f * ratio); } emittingVol = 40.f * ratio; if(emittingVol) { - m_sQueueSample.m_fDistance = Sqrt(col->m_fDistance); + m_sQueueSample.m_fDistance = Sqrt(col.m_fDistance); m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, CollisionSoundIntensity, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_nVolume) { @@ -288,7 +305,7 @@ cAudioManager::SetUpOneShotCollisionSound(cAudioCollision *col) m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 16); m_sQueueSample.m_nCounter = counter++; if(counter >= 255) counter = 28; - m_sQueueSample.m_vecPos = col->m_vecPosition; + m_sQueueSample.m_vecPos = col.m_vecPosition; m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 11; @@ -311,13 +328,13 @@ void cAudioManager::ServiceCollisions() { int i, j; - bool someArr1[NUMAUDIOCOLLISIONS]; - bool someArr2[NUMAUDIOCOLLISIONS]; + bool abRepeatedCollision1[NUMAUDIOCOLLISIONS]; + bool abRepeatedCollision2[NUMAUDIOCOLLISIONS]; m_sQueueSample.m_nEntityIndex = m_nCollisionEntity; for (int i = 0; i < NUMAUDIOCOLLISIONS; i++) - someArr1[i] = someArr2[i] = false; + abRepeatedCollision1[i] = abRepeatedCollision2[i] = false; for (i = 0; i < m_sCollisionManager.m_bCollisionsInQueue; i++) { for (j = 0; j < NUMAUDIOCOLLISIONS; j++) { @@ -327,17 +344,17 @@ cAudioManager::ServiceCollisions() && (m_sCollisionManager.m_asCollisions1[index].m_bSurface1 == m_sCollisionManager.m_asCollisions2[j].m_bSurface1) && (m_sCollisionManager.m_asCollisions1[index].m_bSurface2 == m_sCollisionManager.m_asCollisions2[j].m_bSurface2) ) { - someArr1[index] = true; - someArr2[j] = true; + abRepeatedCollision1[index] = true; + abRepeatedCollision2[j] = true; m_sCollisionManager.m_asCollisions1[index].m_nBaseVolume = ++m_sCollisionManager.m_asCollisions2[j].m_nBaseVolume; - SetUpLoopingCollisionSound(&m_sCollisionManager.m_asCollisions1[index], j); + SetUpLoopingCollisionSound(m_sCollisionManager.m_asCollisions1[index], j); break; } } } for (i = 0; i < NUMAUDIOCOLLISIONS; i++) { - if (!someArr2[i]) { + if (!abRepeatedCollision2[i]) { m_sCollisionManager.m_asCollisions2[i].m_pEntity1 = nil; m_sCollisionManager.m_asCollisions2[i].m_pEntity2 = nil; m_sCollisionManager.m_asCollisions2[i].m_bSurface1 = SURFACE_DEFAULT; @@ -351,9 +368,9 @@ cAudioManager::ServiceCollisions() for (i = 0; i < m_sCollisionManager.m_bCollisionsInQueue; i++) { int index = m_sCollisionManager.m_bIndicesTable[i]; - if (!someArr1[index]) { + if (!abRepeatedCollision1[index]) { for (j = 0; j < NUMAUDIOCOLLISIONS; j++) { - if (someArr2[j]) { + if (!abRepeatedCollision2[j]) { m_sCollisionManager.m_asCollisions2[j].m_nBaseVolume = 1; m_sCollisionManager.m_asCollisions2[j].m_pEntity1 = m_sCollisionManager.m_asCollisions1[index].m_pEntity1; m_sCollisionManager.m_asCollisions2[j].m_pEntity2 = m_sCollisionManager.m_asCollisions1[index].m_pEntity2; @@ -362,8 +379,8 @@ cAudioManager::ServiceCollisions() break; } } - SetUpOneShotCollisionSound(&m_sCollisionManager.m_asCollisions1[index]); - SetUpLoopingCollisionSound(&m_sCollisionManager.m_asCollisions1[index], j); + SetUpOneShotCollisionSound(m_sCollisionManager.m_asCollisions1[index]); + SetUpLoopingCollisionSound(m_sCollisionManager.m_asCollisions1[index], j); } } @@ -393,7 +410,7 @@ cAudioManager::ReportCollision(CEntity *entity1, CEntity *entity2, uint8 surface v2 = entity2->GetPosition(); } CVector pos = (v1 + v2) * 0.5f; - distSquared = GetDistanceSquared(&pos); + distSquared = GetDistanceSquared(pos); if(distSquared < SQR(CollisionSoundIntensity)) { m_sCollisionManager.m_sQueue.m_pEntity1 = entity1; m_sCollisionManager.m_sQueue.m_pEntity2 = entity2; diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index a417e077..be68d40f 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -2951,10 +2951,10 @@ cAudioManager::GetCurrent3DProviderIndex() const } float -cAudioManager::GetDistanceSquared(CVector *v) const +cAudioManager::GetDistanceSquared(const CVector &v) const { const CVector &c = TheCamera.GetPosition(); - return sq(v->x - c.x) + sq(v->y - c.y) + sq((v->z - c.z) * 0.2f); + return sq(v.x - c.x) + sq(v.y - c.y) + sq((v.z - c.z) * 0.2f); } int32 @@ -3625,14 +3625,14 @@ cAudioManager::ProcessActiveQueues() m_asActiveSamples[i].m_nEntityIndex = AEHANDLE_NONE; } } - for (int32 i = 0; i < m_SampleRequestQueuesStatus[m_nActiveSampleQueue]; ++i) { + for (uint8 i = 0; i < m_SampleRequestQueuesStatus[m_nActiveSampleQueue]; ++i) { tSound &sample = m_asSamples[m_nActiveSampleQueue][m_abSampleQueueIndexTable[m_nActiveSampleQueue][i]]; if (!sample.m_bIsProcessed && !sample.m_bLoopEnded && m_asAudioEntities[sample.m_nEntityIndex].m_bIsUsed && sample.m_nSampleIndex < NO_SAMPLE) { if (sample.m_nCounter > 255 && sample.m_nLoopCount && sample.m_nLoopsRemaining) { --sample.m_nLoopsRemaining; sample.m_nReleasingVolumeDivider = 1; } else { - for (int32 j = 0; j < m_nActiveSamples; ++j) { + for (uint8 j = 0; j < m_nActiveSamples; ++j) { if (!m_asActiveSamples[j].m_bIsProcessed) { if (sample.m_nLoopCount) { v28 = sample.m_nFrequency / m_nTimeSpent; @@ -3747,7 +3747,7 @@ cAudioManager::ProcessAirportScriptObject(uint8 sound) default: return; } - float distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos); + float distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos); if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) { m_sQueueSample.m_fDistance = Sqrt(distSquared); m_sQueueSample.m_nVolume = ComputeVolume(110, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); @@ -3970,7 +3970,7 @@ cAudioManager::ProcessBridge() if (CBridge::pLiftRoad) { m_sQueueSample.m_vecPos = CBridge::pLiftRoad->GetPosition(); - dist = GetDistanceSquared(&m_sQueueSample.m_vecPos); + dist = GetDistanceSquared(m_sQueueSample.m_vecPos); if (dist < 202500.0f) { CalculateDistance(distCalculated, dist); switch (CBridge::State) { @@ -4206,7 +4206,7 @@ cAudioManager::ProcessCinemaScriptObject(uint8 sound) default: return; } - float distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos); + float distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos); if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) { m_sQueueSample.m_fDistance = Sqrt(distSquared); rand = m_anRandomTable[0] % 90 + 30; @@ -4246,7 +4246,7 @@ cAudioManager::ProcessCrane() if (crane->m_nCraneStatus == CCrane::ACTIVATED) { if (crane->m_nCraneState != CCrane::IDLE) { m_sQueueSample.m_vecPos = crane->m_pCraneEntity->GetPosition(); - distSquared = GetDistanceSquared(&this->m_sQueueSample.m_vecPos); + distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos); if (distSquared < SQR(intensity)) { CalculateDistance(distCalculated, distSquared); m_sQueueSample.m_nVolume = ComputeVolume(100, 80.f, m_sQueueSample.m_fDistance); @@ -4306,7 +4306,7 @@ cAudioManager::ProcessDocksScriptObject(uint8 sound) default: return; } - distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos); + distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos); if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) { m_sQueueSample.m_fDistance = Sqrt(distSquared); rand = m_anRandomTable[0] % 60 + 40; @@ -4510,7 +4510,7 @@ cAudioManager::ProcessExplosions(int32 explosion) } pos = CExplosion::GetExplosionPosition(i); m_sQueueSample.m_vecPos = *pos; - distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos); + distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos); if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) { m_sQueueSample.m_fDistance = Sqrt(distSquared); m_sQueueSample.m_nVolume = ComputeVolume(maxVolume, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); @@ -4541,7 +4541,7 @@ cAudioManager::ProcessFireHydrant() static const int intensity = 35; m_sQueueSample.m_vecPos = ((CEntity *)m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_pEntity)->GetPosition(); - distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos); + distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos); if (distSquared < SQR(intensity)) { CalculateDistance(distCalculated, distSquared); m_sQueueSample.m_nVolume = ComputeVolume(40, 35.f, m_sQueueSample.m_fDistance); @@ -4611,7 +4611,7 @@ void cAudioManager::ProcessFires(int32) m_sQueueSample.m_nReleasingVolumeModificator = 8; } m_sQueueSample.m_vecPos = gFireManager.m_aFires[i].m_vecPos; - distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos); + distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos); if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) { m_sQueueSample.m_fDistance = Sqrt(distSquared); m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); @@ -4875,7 +4875,7 @@ cAudioManager::ProcessGarages() continue; m_sQueueSample.m_vecPos = entity->GetPosition(); distCalculated = false; - distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos); + distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos); if (distSquared < 6400.f) { state = CGarages::aGarages[i].m_eGarageState; if (state == GS_OPENING || state == GS_CLOSING || state == GS_AFTERDROPOFF) { @@ -5021,7 +5021,7 @@ cAudioManager::ProcessHomeScriptObject(uint8 sound) default: return; } - dist = GetDistanceSquared(&m_sQueueSample.m_vecPos); + dist = GetDistanceSquared(m_sQueueSample.m_vecPos); if (dist < SQR(m_sQueueSample.m_fSoundIntensity)) { m_sQueueSample.m_fDistance = Sqrt(dist); rand = m_anRandomTable[0] % 30 + 40; @@ -5173,7 +5173,7 @@ cAudioManager::ProcessLaunderetteScriptObject(uint8 sound) default: return; } - float distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos); + float distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos); if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) { m_sQueueSample.m_fDistance = Sqrt(distSquared); m_sQueueSample.m_nVolume = ComputeVolume(45, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); @@ -5804,7 +5804,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) return; } - distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos); + distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos); if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) { m_sQueueSample.m_fDistance = Sqrt(distSquared); m_sQueueSample.m_nVolume = ComputeVolume(emittingVolume, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); @@ -5914,7 +5914,7 @@ cAudioManager::ProcessMissionAudio() if (m_sMissionAudio.m_bPredefinedProperties) { SampleManager.SetStreamedVolumeAndPan(80, 63, 1, 1); } else { - distSquared = GetDistanceSquared(&m_sMissionAudio.m_vecPos); + distSquared = GetDistanceSquared(m_sMissionAudio.m_vecPos); if (distSquared >= 2500.f) { emittingVol = 0; pan = 63; @@ -6017,14 +6017,14 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) case SCRIPT_SOUND_INJURED_PED_MALE_OUCH_L: male.m_pPed = nil; male.m_bDistanceCalculated = false; - male.m_fDistance = GetDistanceSquared(&m_sQueueSample.m_vecPos); + male.m_fDistance = GetDistanceSquared(m_sQueueSample.m_vecPos); SetupPedComments(&male, SOUND_INJURED_PED_MALE_OUCH); return; case SCRIPT_SOUND_INJURED_PED_FEMALE_OUCH_S: case SCRIPT_SOUND_INJURED_PED_FEMALE_OUCH_L: female.m_pPed = nil; female.m_bDistanceCalculated = false; - female.m_fDistance = GetDistanceSquared(&m_sQueueSample.m_vecPos); + female.m_fDistance = GetDistanceSquared(m_sQueueSample.m_vecPos); SetupPedComments(&female, SOUND_INJURED_PED_FEMALE); return; case SCRIPT_SOUND_GATE_START_CLUNK: @@ -6186,7 +6186,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_bIs2D = false; emittingVolume = m_anRandomTable[2] % 20 + 30; - distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos); + distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos); if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) { m_sQueueSample.m_fDistance = Sqrt(distSquared); m_sQueueSample.m_nVolume = ComputeVolume(emittingVolume, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); @@ -6231,7 +6231,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) return; } - distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos); + distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos); if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) { m_sQueueSample.m_fDistance = Sqrt(distSquared); m_sQueueSample.m_nVolume = ComputeVolume(emittingVolume, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); @@ -6261,7 +6261,7 @@ cAudioManager::ProcessPed(CPhysical *ped) // params.m_bDistanceCalculated = false; params.m_pPed = (CPed *)ped; - params.m_fDistance = GetDistanceSquared(&m_sQueueSample.m_vecPos); + params.m_fDistance = GetDistanceSquared(m_sQueueSample.m_vecPos); if (ped->GetModelIndex() == MI_FATMALE02) ProcessPedHeadphones(¶ms); ProcessPedOneShots(¶ms); @@ -7458,7 +7458,7 @@ cAudioManager::ProcessPoliceCellBeatingScriptObject(uint8 sound) default: return; } - distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos); + distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos); if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) { m_sQueueSample.m_fDistance = Sqrt(distSquared); if (m_FrameCounter & 1) @@ -7545,7 +7545,7 @@ cAudioManager::ProcessPornCinema(uint8 sound) default: return; } - distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos); + distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos); if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) { m_sQueueSample.m_fDistance = Sqrt(distSquared); if (sound != SCRIPT_SOUND_MISTY_SEX_S && sound != SCRIPT_SOUND_MISTY_SEX_L) { @@ -7622,7 +7622,7 @@ cAudioManager::ProcessProjectiles() m_sQueueSample.m_fSpeedMultiplier = 4.0f; m_sQueueSample.m_nReleasingVolumeDivider = 3; m_sQueueSample.m_vecPos = CProjectileInfo::ms_apProjectile[i]->GetPosition(); - float distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos); + float distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos); if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) { m_sQueueSample.m_fDistance = Sqrt(distSquared); m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); @@ -7762,7 +7762,7 @@ cAudioManager::ProcessSawMillScriptObject(uint8 sound) default: return; } - distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos); + distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos); if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) { m_sQueueSample.m_fDistance = Sqrt(distSquared); m_sQueueSample.m_nVolume = ComputeVolume(30, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); @@ -7835,7 +7835,7 @@ cAudioManager::ProcessShopScriptObject(uint8 sound) default: return; } - distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos); + distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos); if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) { m_sQueueSample.m_fDistance = Sqrt(distSquared); m_sQueueSample.m_nVolume = ComputeVolume(30, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); @@ -7980,7 +7980,7 @@ cAudioManager::ProcessVehicle(CVehicle *veh) m_sQueueSample.m_vecPos = veh->GetPosition(); params.m_bDistanceCalculated = false; - params.m_fDistance = GetDistanceSquared(&m_sQueueSample.m_vecPos); + params.m_fDistance = GetDistanceSquared(m_sQueueSample.m_vecPos); params.m_pVehicle = veh; params.m_pTransmission = nil; params.m_nIndex = 0; @@ -8990,7 +8990,7 @@ void cAudioManager::ProcessWaterCannon(int32) for (int32 i = 0; i < NUM_WATERCANNONS; i++) { if (CWaterCannons::aCannons[i].m_nId) { m_sQueueSample.m_vecPos = CWaterCannons::aCannons[0].m_avecPos[CWaterCannons::aCannons[i].m_nCur]; - float distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos); + float distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos); if (distSquared < SOUND_INTENSITY) { m_sQueueSample.m_fDistance = Sqrt(distSquared); m_sQueueSample.m_nVolume = ComputeVolume(50, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); @@ -9136,7 +9136,7 @@ cAudioManager::ProcessWorkShopScriptObject(uint8 sound) default: return; } - distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos); + distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos); if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) { m_sQueueSample.m_fDistance = Sqrt(distSquared); m_sQueueSample.m_nVolume = ComputeVolume(30, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index ccef42ff..0d0c5d91 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -317,7 +317,7 @@ public: float GetCollisionLoopingRatio(uint32 a, uint32 b, float c) const; // not used float GetCollisionOneShotRatio(int32 a, float b) const; float GetCollisionRatio(float a, float b, float c, float d) const; - float GetDistanceSquared(CVector *v) const; + float GetDistanceSquared(const CVector &v) const; int32 GetJumboTaxiFreq() const; bool GetMissionAudioLoadingStatus() const; int8 GetMissionScriptPoliceAudioPlayingStatus() const; @@ -438,15 +438,15 @@ public: void SetEffectsFadeVolume(uint8 volume) const; void SetEffectsMasterVolume(uint8 volume) const; void SetEntityStatus(int32 id, uint8 status); - uint32 SetLoopingCollisionRequestedSfxFreqAndGetVol(cAudioCollision *audioCollision); + uint32 SetLoopingCollisionRequestedSfxFreqAndGetVol(const cAudioCollision &audioCollision); void SetMissionAudioLocation(float x, float y, float z); void SetMissionScriptPoliceAudio(int32 sfx) const; void SetMonoMode(uint8); // todo (mobile) void SetMusicFadeVolume(uint8 volume) const; void SetMusicMasterVolume(uint8 volume) const; void SetSpeakerConfig(int32 conf) const; - void SetUpLoopingCollisionSound(cAudioCollision *col, uint8 counter); - void SetUpOneShotCollisionSound(cAudioCollision *col); + void SetUpLoopingCollisionSound(const cAudioCollision &col, uint8 counter); + void SetUpOneShotCollisionSound(const cAudioCollision &col); bool SetupCrimeReport(); bool SetupJumboEngineSound(uint8 vol, int32 freq); bool SetupJumboFlySound(uint8 emittingVol); @@ -468,6 +468,8 @@ public: // only used in pc void AdjustSamplesVolume(); uint8 ComputeEmittingVolume(uint8 emittingVolume, float intensity, float dist); + + void DebugShit(); }; //dstatic_assert(sizeof(cAudioManager) == 19220, "cAudioManager: error"); |