From af5bd951aeb43c341d5126bc4141992169e46d57 Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Wed, 31 Jul 2019 17:54:18 +0200 Subject: More audio ped --- src/audio/AudioManager.cpp | 1329 ++++++++++++++++++++++++++++++++++++++++++-- src/audio/AudioManager.h | 66 +-- src/audio/DMAudio.h | 3 + 3 files changed, 1327 insertions(+), 71 deletions(-) (limited to 'src/audio') diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index e586366d..76bfb793 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -6,6 +6,7 @@ #include "Automobile.h" #include "Camera.h" #include "DMAudio.h" +#include "Explosion.h" #include "Garages.h" #include "ModelIndices.h" #include "MusicManager.h" @@ -16,6 +17,7 @@ #include "Pools.h" #include "sampman.h" #include "Stats.h" +#include "SurfaceTable.h" #include "Vehicle.h" #include "Plane.h" #include "World.h" @@ -96,10 +98,54 @@ enum eVehicleModel { CAR159, }; -void *cAudioScriptObject::operator new(size_t sz) { return CPools::GetAudioScriptObjectPool()->New(); } -void *cAudioScriptObject::operator new(size_t sz, int handle) { return CPools::GetAudioScriptObjectPool()->New(handle); } -void cAudioScriptObject::operator delete(void *p, size_t sz) { CPools::GetAudioScriptObjectPool()->Delete((cAudioScriptObject*)p); } -void cAudioScriptObject::operator delete(void *p, int handle) { CPools::GetAudioScriptObjectPool()->Delete((cAudioScriptObject*)p); } +void +cPedComments::Add(tPedComment *com) +{ + uint8 index; + + if(nrOfCommentsInBank[activeBank] >= 20u) { + index = field_1120[activeBank][19]; + if(m_asPedComments[activeBank][index].m_bVolume > com->m_bVolume) return; + } else { + index = nrOfCommentsInBank[activeBank]++; + } + m_asPedComments[activeBank][index] = *com; + + uint32 i = 0; + if(index != 0) { + for(i = 0; i < index; i++) { + if(m_asPedComments[activeBank][field_1120[activeBank][i]].m_bVolume < + m_asPedComments[activeBank][index].m_bVolume) { + memmove(&field_1120[activeBank][i + 1], &field_1120[activeBank][i], + 19 - i); + break; + } + } + } + + field_1120[activeBank][i] = index; +} + +void * +cAudioScriptObject::operator new(size_t sz) +{ + return CPools::GetAudioScriptObjectPool()->New(); +} +void * +cAudioScriptObject::operator new(size_t sz, int handle) +{ + return CPools::GetAudioScriptObjectPool()->New(handle); +} +void +cAudioScriptObject::operator delete(void *p, size_t sz) +{ + CPools::GetAudioScriptObjectPool()->Delete((cAudioScriptObject *)p); +} +void +cAudioScriptObject::operator delete(void *p, int handle) +{ + CPools::GetAudioScriptObjectPool()->Delete((cAudioScriptObject *)p); +} cAudioManager &AudioManager = *(cAudioManager *)0x880FC0; @@ -407,9 +453,9 @@ cAudioManager::ComputeDopplerEffectedFrequency(uint32 oldFreq, float position1, float speedOfSource = (dist / field_19195) * speedMultiplier; if(speedOfSound > fabsf(speedOfSource)) { if(speedOfSource < 0.0f) { - speedOfSource = max(speedOfSource, -1.5f); + speedOfSource = Max(speedOfSource, -1.5f); } else { - speedOfSource = min(speedOfSource, 1.5f); + speedOfSource = Min(speedOfSource, 1.5f); } newFreq = (oldFreq * speedOfSound) / (speedOfSource + speedOfSound); } @@ -830,7 +876,7 @@ cAudioManager::SetupJumboFlySound(uint8 emittingVol) SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSoundIntensity = 440.0f; m_sQueueSample.field_56 = 0; - m_sQueueSample.field_48 = 4.0; + m_sQueueSample.field_48 = 4.0f; m_sQueueSample.m_bReverbFlag = 1; m_sQueueSample.field_76 = 5; m_sQueueSample.m_nLoopEnd = @@ -861,8 +907,8 @@ cAudioManager::SetupJumboRumbleSound(uint8 emittingVol) SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.field_48 = 4.0; - m_sQueueSample.m_fSoundIntensity = 240.0; + m_sQueueSample.field_48 = 4.0f; + m_sQueueSample.m_fSoundIntensity = 240.0f; m_sQueueSample.field_56 = 0; m_sQueueSample.field_76 = 12; m_sQueueSample.m_bOffset = 0; @@ -3729,7 +3775,6 @@ cAudioManager::ProcessAirBrakes(cVehicleParams *params) void cAudioManager::ProcessAirportScriptObject(uint8 sound) { - float dist; float distSquared; float maxDist; @@ -4002,68 +4047,68 @@ cAudioManager::ProcessEntity(int32 id) case AUDIOTYPE_PHYSICAL: if(!m_bUserPause) { m_sQueueSample.m_bReverbFlag = 1; - cAudioManager::ProcessPhysical(id); + ProcessPhysical(id); } break; case AUDIOTYPE_EXPLOSION: if(!m_bUserPause) { m_sQueueSample.m_bReverbFlag = 1; - cAudioManager::ProcessExplosions(id); + ProcessExplosions(id); } break; case AUDIOTYPE_FIRE: if(!m_bUserPause) { m_sQueueSample.m_bReverbFlag = 1; - cAudioManager::ProcessFires(id); + ProcessFires(id); } break; case AUDIOTYPE_WEATHER: if(!m_bUserPause) { m_sQueueSample.m_bReverbFlag = 1; - cAudioManager::ProcessWeather(id); + ProcessWeather(id); } break; case AUDIOTYPE_CRANE: if(!m_bUserPause) { m_sQueueSample.m_bReverbFlag = 1; - cAudioManager::ProcessCrane(); + ProcessCrane(); } break; case AUDIOTYPE_SCRIPTOBJECT: if(!m_bUserPause) { m_sQueueSample.m_bReverbFlag = 1; - cAudioManager::ProcessScriptObject(id); + ProcessScriptObject(id); } break; case AUDIOTYPE_BRIDGE: if(!m_bUserPause) { m_sQueueSample.m_bReverbFlag = 1; - cAudioManager::ProcessBridge(); + ProcessBridge(); } break; case AUDIOTYPE_FRONTEND: m_sQueueSample.m_bReverbFlag = 0; - cAudioManager::ProcessFrontEnd(); + ProcessFrontEnd(); break; case AUDIOTYPE_PROJECTILE: if(!m_bUserPause) { m_sQueueSample.m_bReverbFlag = 1; - cAudioManager::ProcessProjectiles(); + ProcessProjectiles(); } break; case AUDIOTYPE_GARAGE: - if(!m_bUserPause) cAudioManager::ProcessGarages(); + if(!m_bUserPause) ProcessGarages(); break; case AUDIOTYPE_FIREHYDRANT: if(!m_bUserPause) { m_sQueueSample.m_bReverbFlag = 1; - cAudioManager::ProcessFireHydrant(); + ProcessFireHydrant(); } break; case AUDIOTYPE_WATERCANNON: if(!m_bUserPause) { m_sQueueSample.m_bReverbFlag = 1; - cAudioManager::ProcessWaterCannon(id); + ProcessWaterCannon(id); } break; default: return; @@ -4071,11 +4116,88 @@ cAudioManager::ProcessEntity(int32 id) } } -WRAPPER void cAudioManager::ProcessExplosions(int32 explosion) { - EAXJMP(0x575AC0); + uint8 type; + CVector *pos; + float maxDist; + float distSquared; + + for(uint8 i = 0; i < 48u; i++) { + if(CExplosion::GetExplosionActiveCounter(i) == 1) { + CExplosion::ResetExplosionActiveCounter(i); + type = CExplosion::GetExplosionType(i); + switch(type) { + case EXPLOSION_GRENADE: + case EXPLOSION_ROCKET: + case EXPLOSION_BARREL: + case EXPLOSION_TANK_GRENADE: + maxDist = 160000.f; + m_sQueueSample.m_fSoundIntensity = 400.0f; + m_sQueueSample.m_nSampleIndex = + AUDIO_SAMPLE_WEAPON_GRENADE_EXPLOSION; + m_sQueueSample.m_nFrequency = RandomDisplacement(2000u) + 38000; + m_sQueueSample.field_16 = 0; + m_sQueueSample.m_bBankIndex = 0; + break; + case EXPLOSION_MOLOTOV: + maxDist = 40000.f; + m_sQueueSample.m_fSoundIntensity = 200.0f; + m_sQueueSample.m_nSampleIndex = + AUDIO_SAMPLE_WEAPON_MOLOTOV_EXPLOSION; + m_sQueueSample.m_nFrequency = RandomDisplacement(1000u) + 19000; + m_sQueueSample.field_16 = 0; + m_sQueueSample.m_bBankIndex = 0; + break; + case EXPLOSION_MINE: + case EXPLOSION_HELI_BOMB: + maxDist = 90000.f; + m_sQueueSample.m_fSoundIntensity = 300.0f; + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_WEAPON_ROCKET_SHOT; + m_sQueueSample.m_nFrequency = RandomDisplacement(1000u) + 12347; + m_sQueueSample.field_16 = 0; + m_sQueueSample.m_bBankIndex = 0; + break; + default: + maxDist = 160000.f; + m_sQueueSample.m_fSoundIntensity = 400.0f; + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_EXPLOSION_CAR; + m_sQueueSample.m_nFrequency = RandomDisplacement(2000u) + 38000; + if(type == EXPLOSION_HELI) + m_sQueueSample.m_nFrequency = + 8 * m_sQueueSample.m_nFrequency / 10u; + m_sQueueSample.field_16 = 0; + m_sQueueSample.m_bBankIndex = 0; + break; + } + pos = CExplosion::GetExplosionPosition(i); + m_sQueueSample.m_vecPos.x = pos->x; + m_sQueueSample.m_vecPos.y = pos->y; + m_sQueueSample.m_vecPos.z = pos->z; + distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos); + if(distSquared < maxDist) { + m_sQueueSample.m_fDistance = Sqrt(distSquared); + m_sQueueSample.m_bVolume = + ComputeVolume(maxVolume, m_sQueueSample.m_fSoundIntensity, + m_sQueueSample.m_fDistance); + if(m_sQueueSample.m_bVolume) { + m_sQueueSample.field_4 = i; + m_sQueueSample.field_48 = 2.0f; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.m_nLoopCount = 1; + m_sQueueSample.field_56 = 1; + m_sQueueSample.m_bReverbFlag = 1; + m_sQueueSample.m_bEmittingVolume = maxVolume; + m_sQueueSample.m_nLoopStart = 0; + m_sQueueSample.m_nLoopEnd = -1; + m_sQueueSample.m_bReverbFlag = 1; + m_sQueueSample.m_bRequireReflection = 1; + AddSampleToRequestedQueue(); + } + } + } + } } void @@ -5220,11 +5342,1001 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) } } -WRAPPER void -cAudioManager::ProcessPed(CPhysical *) +cAudioManager::ProcessOneShotScriptObject(uint8 sound) +{ + CPlayerPed *playerPed; + uint8 emittingVolume; + float maxDist; + float distSquared; + + cPedParams male; + cPedParams female; + + static uint8 iSound = 0; + + switch(sound) { + case SCRIPT_SOUND_INJURED_PED_MALE_OUCH_S: + case SCRIPT_SOUND_INJURED_PED_MALE_OUCH_L: + male.m_pPed = nil; + male.m_bDistanceCalculated = 0; + male.m_fDistance = GetDistanceSquared(&m_sQueueSample.m_vecPos); + cAudioManager::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 = 0; + female.m_fDistance = GetDistanceSquared(&m_sQueueSample.m_vecPos); + cAudioManager::SetupPedComments(&female, SOUND_INJURED_PED_FEMALE); + return; + case SCRIPT_SOUND_GATE_START_CLUNK: + case SCRIPT_SOUND_GATE_STOP_CLUNK: + maxDist = 1600.f; + m_sQueueSample.m_fSoundIntensity = 40.0f; + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_COLLISION_GATE; + m_sQueueSample.m_bBankIndex = 0; + if(sound == SCRIPT_SOUND_GATE_START_CLUNK) + m_sQueueSample.m_nFrequency = 10600; + else + m_sQueueSample.m_nFrequency = 9000; + m_sQueueSample.field_16 = 1; + m_sQueueSample.field_48 = 0.0f; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.m_bRequireReflection = 1; + emittingVolume = RandomDisplacement(10u) + 50; + break; + case SCRIPT_SOUND_BULLET_HIT_GROUND_1: + case SCRIPT_SOUND_BULLET_HIT_GROUND_2: + case SCRIPT_SOUND_BULLET_HIT_GROUND_3: + maxDist = 2500.f; + m_sQueueSample.m_fSoundIntensity = 50.0f; + m_sQueueSample.m_nSampleIndex = + m_anRandomTable[iSound % 5] % 3u + AUDIO_SAMPLE_BULLET_HIT_GROUND_1; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.m_nFrequency = + cSampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency >> 5); + m_sQueueSample.field_16 = 9; + m_sQueueSample.field_48 = 0.0f; + m_sQueueSample.m_bIsDistant = 0; + emittingVolume = m_anRandomTable[2] % 20 + 90; + break; + case SCRIPT_SOUND_110: + case SCRIPT_SOUND_111: + if(cSampleManager.IsSampleBankLoaded(0) != 1) return; + maxDist = 6400.f; + m_sQueueSample.m_fSoundIntensity = 80.0f; + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_389; + m_sQueueSample.m_bBankIndex = 0; + emittingVolume = 127; + m_sQueueSample.m_nFrequency = + cSampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_389); + m_sQueueSample.field_16 = 0; + m_sQueueSample.field_48 = 2.0f; + m_sQueueSample.m_bIsDistant = 0; + break; + case SCRIPT_SOUND_PAYPHONE_RINGING: + maxDist = 6400.f; + m_sQueueSample.m_fSoundIntensity = 80.0f; + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PAYPHONE_RINGING; + m_sQueueSample.m_bBankIndex = 0; + emittingVolume = 80; + m_sQueueSample.m_nFrequency = + cSampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_PAYPHONE_RINGING); + m_sQueueSample.field_16 = 1; + m_sQueueSample.field_48 = 2.0f; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.m_bRequireReflection = 0; + break; + case SCRIPT_SOUND_GLASS_BREAK_L: + maxDist = 3600.f; + m_sQueueSample.m_fSoundIntensity = 60.0f; + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_GLASS_GENERIC_BREAK; + m_sQueueSample.m_bBankIndex = 0; + emittingVolume = 70; + m_sQueueSample.m_nFrequency = + cSampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_GLASS_GENERIC_BREAK); + m_sQueueSample.field_16 = 3; + m_sQueueSample.field_48 = 0.0f; + m_sQueueSample.m_bIsDistant = 0; + break; + case SCRIPT_SOUND_GLASS_BREAK_S: + maxDist = 3600.f; + m_sQueueSample.m_fSoundIntensity = 60.0f; + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_GLASS_GENERIC_BREAK; + m_sQueueSample.m_bBankIndex = 0; + emittingVolume = 60; + m_sQueueSample.m_nFrequency = + cSampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_GLASS_GENERIC_BREAK); + m_sQueueSample.field_16 = 3; + m_sQueueSample.field_48 = 0.0f; + m_sQueueSample.m_bIsDistant = 0; + break; + case SCRIPT_SOUND_GLASS_CRACK: + maxDist = 3600.f; + m_sQueueSample.m_fSoundIntensity = 60.0f; + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_GLASS_WINDSHIELD_CRACK; + m_sQueueSample.m_bBankIndex = 0; + emittingVolume = 70; + m_sQueueSample.m_nFrequency = + cSampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_GLASS_WINDSHIELD_CRACK); + m_sQueueSample.field_16 = 3; + m_sQueueSample.field_48 = 0.0f; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.m_bRequireReflection = 1; + break; + case SCRIPT_SOUND_GLASS_LIGHT_BREAK: + maxDist = 3025.f; + m_sQueueSample.m_fSoundIntensity = 55.0f; + m_sQueueSample.m_nSampleIndex = + (m_anRandomTable[4] & 3) + AUDIO_SAMPLE_GLASS_LIGHT_BREAK_1; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.m_nFrequency = RandomDisplacement(2000u) + 19000; + m_sQueueSample.field_16 = 9; + m_sQueueSample.field_48 = 0.0f; + m_sQueueSample.m_bIsDistant = 0; + emittingVolume = RandomDisplacement(11u) + 25; + break; + case SCRIPT_SOUND_BOX_DESTROYED_1: + maxDist = 3600.f; + m_sQueueSample.m_fSoundIntensity = 60.0f; + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_BOX_DESTROYED_1; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.m_nFrequency = RandomDisplacement(1500u) + 18600; + m_sQueueSample.field_16 = 3; + m_sQueueSample.field_48 = 0.0f; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.m_bRequireReflection = 1; + emittingVolume = m_anRandomTable[2] % 20 + 80; + break; + case SCRIPT_SOUND_BOX_DESTROYED_2: + maxDist = 3600.f; + m_sQueueSample.m_fSoundIntensity = 60.0f; + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_BOX_DESTROYED_2; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.m_nFrequency = RandomDisplacement(1500u) + 18600; + m_sQueueSample.field_16 = 3; + m_sQueueSample.field_48 = 0.0f; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.m_bRequireReflection = 1; + emittingVolume = m_anRandomTable[2] % 20 + 80; + break; + case SCRIPT_SOUND_METAL_COLLISION: + maxDist = 3600.f; + m_sQueueSample.m_fSoundIntensity = 60.0f; + m_sQueueSample.m_nSampleIndex = + m_anRandomTable[3] % 5u + AUDIO_SAMPLE_COLLISION_METAL; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.m_nFrequency = + cSampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency >> 4); + m_sQueueSample.field_16 = 3; + m_sQueueSample.field_48 = 0.0f; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.m_bRequireReflection = 1; + emittingVolume = m_anRandomTable[2] % 30 + 70; + break; + case SCRIPT_SOUND_TIRE_COLLISION: + maxDist = 3600.f; + m_sQueueSample.m_fSoundIntensity = 60.0f; + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_COLLISION_RUBBER; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.m_nFrequency = + cSampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency >> 4); + m_sQueueSample.field_16 = 3; + m_sQueueSample.field_48 = 0.0f; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.m_bRequireReflection = 1; + emittingVolume = m_anRandomTable[2] % 30 + 60; + break; + case SCRIPT_SOUND_GUNSHELL_DROP: + playerPed = FindPlayerPed(); + if(playerPed) { + switch(playerPed->m_nSurfaceTouched) { + case SURFACE_GRASS: + case SURFACE_DIRT: + case SURFACE_DIRTTRACK: + case SURFACE_SCAFFOLD: + case SURFACE_FLESH: + case SURFACE_SAND: + case SURFACE_TIRE: + case SURFACE_HEDGE: + m_sQueueSample.m_nSampleIndex = + AUDIO_SAMPLE_BULLET_GUNSHELL_SOFT_DROP; + m_sQueueSample.m_nFrequency = RandomDisplacement(500u) + 11000; + m_sQueueSample.field_16 = 18; + maxDist = 400.f; + m_sQueueSample.m_fSoundIntensity = 20.0f; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.field_48 = 0.0f; + m_sQueueSample.m_bIsDistant = 0; + emittingVolume = m_anRandomTable[2] % 20 + 30; + distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos); + if(distSquared < maxDist) { + m_sQueueSample.m_fDistance = Sqrt(distSquared); + m_sQueueSample.m_bVolume = ComputeVolume( + emittingVolume, m_sQueueSample.m_fSoundIntensity, + m_sQueueSample.m_fDistance); + if(m_sQueueSample.m_bVolume) { + m_sQueueSample.field_4 = iSound++; + m_sQueueSample.m_nLoopCount = 1; + m_sQueueSample.field_56 = 1; + m_sQueueSample.m_bEmittingVolume = emittingVolume; + m_sQueueSample.m_nLoopStart = 0; + m_sQueueSample.m_nLoopEnd = -1; + m_sQueueSample.m_bReverbFlag = 1; + AddSampleToRequestedQueue(); + } + } + return; + case SURFACE_PUDDLE: return; + default: break; + } + } + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_BULLET_GUNSHELL_HARD_DROP; + m_sQueueSample.m_nFrequency = RandomDisplacement(750u) + 18000; + m_sQueueSample.field_16 = 15; + maxDist = 400.f; + m_sQueueSample.m_fSoundIntensity = 20.0f; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.field_48 = 0.0f; + m_sQueueSample.m_bIsDistant = 0; + emittingVolume = m_anRandomTable[2] % 20 + 30; + break; + case SCRIPT_SOUND_GUNSHELL_DROP_SOFT: + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_BULLET_GUNSHELL_SOFT_DROP; + m_sQueueSample.m_nFrequency = RandomDisplacement(500u) + 11000; + m_sQueueSample.field_16 = 18; + maxDist = 400.f; + m_sQueueSample.m_fSoundIntensity = 20.0f; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.field_48 = 0.0f; + m_sQueueSample.m_bIsDistant = 0; + emittingVolume = m_anRandomTable[2] % 20 + 30; + break; + default: return; + } + + distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos); + if(distSquared < maxDist) { + m_sQueueSample.m_fDistance = Sqrt(distSquared); + m_sQueueSample.m_bVolume = ComputeVolume( + emittingVolume, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); + if(m_sQueueSample.m_bVolume) { + m_sQueueSample.field_4 = iSound++; + m_sQueueSample.m_nLoopCount = 1; + m_sQueueSample.field_56 = 1; + m_sQueueSample.m_bEmittingVolume = emittingVolume; + m_sQueueSample.m_nLoopStart = 0; + m_sQueueSample.m_nLoopEnd = -1; + m_sQueueSample.m_bReverbFlag = 1; + AddSampleToRequestedQueue(); + } + } +} + +void +cAudioManager::ProcessPed(CPhysical *ped) { - EAXJMP(0x56F450); + cPedParams params; + + params.m_pPed = 0; + params.m_bDistanceCalculated = 0; + params.m_fDistance = 0.0f; + + m_sQueueSample.m_vecPos = ped->GetPosition(); + + params.m_bDistanceCalculated = 0; + params.m_pPed = (CPed *)ped; + params.m_fDistance = GetDistanceSquared(&m_sQueueSample.m_vecPos); + if(ped->m_modelIndex == MI_FATMALE02) ProcessPedHeadphones(¶ms); + ProcessPedOneShots(¶ms); +} + +void +cAudioManager::ProcessPedHeadphones(cPedParams *params) +{ + CPed *ped; + CVehicle *veh; + uint8 emittingVol; + + if(params->m_fDistance < 49.f) { + ped = params->m_pPed; + if(!(ped->m_ped_flagA20) || ped->m_bodyPartBleeding != 2) { + CalculateDistance((bool *)params, params->m_fDistance); + if(ped->bInVehicle && ped->m_nPedState == PED_DRIVING) { + emittingVol = 10; + veh = ped->m_pMyVehicle; + if(veh && veh->m_type == 0) { + for(int32 i = 2; i < 6; i++) { + if(!veh->IsDoorClosed((eDoors)i) || + veh->IsDoorMissing((eDoors)i)) { + emittingVol = 42; + break; + } + } + } + } else { + emittingVol = 42; + } + + m_sQueueSample.m_bVolume = + ComputeVolume(emittingVol, 7.f, m_sQueueSample.m_fDistance); + if(m_sQueueSample.m_bVolume) { + m_sQueueSample.field_4 = 64; + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PED_HEADPHONES; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_16 = 5; + m_sQueueSample.m_nFrequency = cSampleManager.GetSampleBaseFrequency( + AUDIO_SAMPLE_PED_HEADPHONES); + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_bEmittingVolume = emittingVol; + m_sQueueSample.m_nLoopStart = + cSampleManager.GetSampleLoopStartOffset( + m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = cSampleManager.GetSampleLoopEndOffset( + m_sQueueSample.m_nSampleIndex); + m_sQueueSample.field_48 = 4.0f; + m_sQueueSample.m_fSoundIntensity = 7.0f; + m_sQueueSample.field_56 = 0; + m_sQueueSample.field_76 = 5; + m_sQueueSample.m_bReverbFlag = 1; + m_sQueueSample.m_bRequireReflection = 0; + AddSampleToRequestedQueue(); + } + return; + } + } +} + +void +cAudioManager::ProcessPedOneShots(cPedParams *params) +{ + uint8 emittingVol; + int32 sampleIndex; + + CPed *ped = params->m_pPed; + + char processed; + int16 sound; + char noReflection; + CWeapon *weapon; + uint16 i; + float maxDist; + + static uint8 iSound = 21; + + i = 0; + weapon = nil; + while(i < m_asAudioEntities[m_sQueueSample.m_nEntityIndex].field_24) { + noReflection = 0; + processed = 0; + m_sQueueSample.m_bRequireReflection = 0; + sound = m_asAudioEntities[0].m_awAudioEvent[i + 20 * m_sQueueSample.m_nEntityIndex]; + switch(sound) { + case SOUND_STEP_START: + case SOUND_STEP_END: + if(!params->m_pPed->bIsLooking) { + emittingVol = m_anRandomTable[3] % 15u + 45; + if(FindPlayerPed() != + m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_pEntity) + emittingVol >>= 1; + maxDist = 400.f; + switch(params->m_pPed->m_nSurfaceTouched) { + case SURFACE_GRASS: + sampleIndex = + m_anRandomTable[1] % 5u + AUDIO_SAMPLE_PED_FALL_GRASS_1; + break; + case SURFACE_DIRT: + case SURFACE_DIRTTRACK: + sampleIndex = + m_anRandomTable[4] % 5u + AUDIO_SAMPLE_PED_FALL_DIRT_1; + break; + case SURFACE_METAL6: + case SURFACE_METAL_DOOR: + case SURFACE_BILLBOARD: + case SURFACE_STEEL: + case SURFACE_METAL_POLE: + case SURFACE_STREET_LIGHT: + case SURFACE_METAL14: + case SURFACE_METAL15: + case SURFACE_METAL_FENCE: + case SURFACE_METAL27: + case SURFACE_METAL28: + sampleIndex = + m_anRandomTable[0] % 5u + AUDIO_SAMPLE_PED_FALL_METAL_1; + break; + case SURFACE_SAND: + sampleIndex = + (m_anRandomTable[4] & 3) + AUDIO_SAMPLE_PED_FALL_SAND_1; + break; + case SURFACE_PUDDLE: + sampleIndex = (m_anRandomTable[3] & 3) + + AUDIO_SAMPLE_PED_FALL_IN_WATER_1; + break; + case SURFACE_WOOD: + case SURFACE_WOOD_BOX: + case SURFACE_WOOD_PLANK: + sampleIndex = + m_anRandomTable[2] % 5u + AUDIO_SAMPLE_PED_FALL_WOOD_1; + break; + case SURFACE_HEDGE: + sampleIndex = + m_anRandomTable[2] % 5u + AUDIO_SAMPLE_COLLISION_HEDGE; + break; + default: + sampleIndex = m_anRandomTable[2] % 5u + + AUDIO_SAMPLE_PED_FALL_PAVEMENT_1; + break; + } + m_sQueueSample.m_nSampleIndex = sampleIndex; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.field_4 = + m_asAudioEntities[0] + .m_awAudioEvent[i + 20 * m_sQueueSample.m_nEntityIndex] - + 28; + m_sQueueSample.m_nFrequency = cSampleManager.GetSampleBaseFrequency( + m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nFrequency += + RandomDisplacement(m_sQueueSample.m_nFrequency / 17u); + switch(params->m_pPed->m_nMoveState) { + case 2: + emittingVol >>= 2; + m_sQueueSample.m_nFrequency = + 9 * m_sQueueSample.m_nFrequency / 10u; + break; + case 3: + emittingVol >>= 1; + m_sQueueSample.m_nFrequency = + 11 * m_sQueueSample.m_nFrequency / 10u; + break; + case 4: + m_sQueueSample.m_nFrequency = + 12 * m_sQueueSample.m_nFrequency / 10u; + break; + default: break; + } + m_sQueueSample.field_16 = 5; + m_sQueueSample.field_48 = 0.0f; + m_sQueueSample.m_fSoundIntensity = 20.0f; + m_sQueueSample.m_nLoopCount = 1; + m_sQueueSample.m_nLoopStart = 0; + m_sQueueSample.m_nLoopEnd = -1; + m_sQueueSample.m_bEmittingVolume = emittingVol; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_56 = 1; + m_sQueueSample.m_bRequireReflection = 1; + goto LABEL_84; + } + break; + case SOUND_FALL_LAND: + case SOUND_FALL_COLLAPSE: + if(!ped->bIsLooking) { + maxDist = 900.f; + emittingVol = m_anRandomTable[3] % 20 + 80; + if(ped->m_nSurfaceTouched == SURFACE_PUDDLE) { + m_sQueueSample.m_nSampleIndex = + (m_anRandomTable[3] & 3) + + AUDIO_SAMPLE_PED_FALL_IN_WATER_1; + } else if(sound == SOUND_FALL_LAND) { + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PED_FALL_LAND; + } else { + m_sQueueSample.m_nSampleIndex = + AUDIO_SAMPLE_PED_FALL_COLLAPSE; + } + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.field_4 = 1; + m_sQueueSample.m_nFrequency = cSampleManager.GetSampleBaseFrequency( + m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nFrequency += + RandomDisplacement(m_sQueueSample.m_nFrequency / 17u); + m_sQueueSample.field_16 = 2; + m_sQueueSample.field_48 = 0.0f; + m_sQueueSample.m_fSoundIntensity = 30.0f; + m_sQueueSample.m_nLoopCount = 1; + m_sQueueSample.m_nLoopStart = 0; + m_sQueueSample.m_nLoopEnd = -1; + m_sQueueSample.m_bEmittingVolume = emittingVol; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_56 = 1; + m_sQueueSample.m_bRequireReflection = 1; + goto LABEL_84; + } + break; + case SOUND_21: + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PED_HIT_1; + m_sQueueSample.m_nFrequency = 18000; + goto LABEL_81; + case SOUND_22: + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PED_HIT_1; + m_sQueueSample.m_nFrequency = 16500; + goto LABEL_81; + case SOUND_23: + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PED_HIT_1; + goto LABEL_80; + case SOUND_24: + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PED_HIT_2; + m_sQueueSample.m_nFrequency = 18000; + goto LABEL_81; + case SOUND_25: + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PED_HIT_2; + m_sQueueSample.m_nFrequency = 16500; + goto LABEL_81; + case SOUND_26: + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PED_HIT_2; + goto LABEL_80; + case SOUND_WEAPON_PUNCH_ATTACK: + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PED_HIT_3; + m_sQueueSample.m_nFrequency = 18000; + goto LABEL_81; + case SOUND_28: + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PED_HIT_3; + m_sQueueSample.m_nFrequency = 16500; + goto LABEL_81; + case SOUND_29: + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PED_HIT_3; + goto LABEL_80; + case SOUND_2A: + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PED_HIT_4; + m_sQueueSample.m_nFrequency = 18000; + goto LABEL_81; + case SOUND_2B: + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PED_HIT_4; + m_sQueueSample.m_nFrequency = 16500; + goto LABEL_81; + case SOUND_2C: + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PED_HIT_4; + LABEL_80: + m_sQueueSample.m_nFrequency = 20000; + LABEL_81: + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.field_4 = iSound; + processed = 1; + ++iSound; + m_sQueueSample.field_16 = 3; + m_sQueueSample.field_48 = 0.0f; + m_sQueueSample.m_fSoundIntensity = 30.0f; + maxDist = 900.f; + m_sQueueSample.m_nLoopCount = 1; + m_sQueueSample.m_nLoopStart = 0; + emittingVol = m_anRandomTable[3] % 26 + 100; + m_sQueueSample.m_nLoopEnd = -1; + m_sQueueSample.m_bEmittingVolume = emittingVol; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_56 = 1; + m_sQueueSample.m_bRequireReflection = 1; + goto LABEL_84; + case SOUND_WEAPON_BAT_ATTACK: + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PED_HIT_BY_BAT; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.field_4 = iSound++; + processed = 1; + m_sQueueSample.m_nFrequency = RandomDisplacement(2000u) + 22000; + m_sQueueSample.field_16 = 3; + m_sQueueSample.field_48 = 0.0f; + m_sQueueSample.m_fSoundIntensity = 30.0f; + maxDist = 900.f; + m_sQueueSample.m_nLoopCount = 1; + m_sQueueSample.m_nLoopStart = 0; + m_sQueueSample.m_nLoopEnd = -1; + emittingVol = m_anRandomTable[2] % 20 + 100; + m_sQueueSample.m_bEmittingVolume = emittingVol; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_56 = 1; + if(m_bDynamicAcousticModelingStatus) + m_sQueueSample.m_bRequireReflection = 1; + else + noReflection = 1; + goto LABEL_84; + case SOUND_WEAPON_SHOT_FIRED: + weapon = &ped->m_weapons[ped->m_currentWeapon]; + switch(weapon->m_eWeaponType) { + case WEAPONTYPE_COLT45: + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_WEAPON_PISTOL_SHOT; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.field_4 = iSound++; + processed = 1; + m_sQueueSample.m_nFrequency = cSampleManager.GetSampleBaseFrequency( + AUDIO_SAMPLE_WEAPON_PISTOL_SHOT); + m_sQueueSample.m_nFrequency += + RandomDisplacement(m_sQueueSample.m_nFrequency >> 5); + m_sQueueSample.field_16 = 3; + m_sQueueSample.field_48 = 0.0f; + m_sQueueSample.m_fSoundIntensity = 50.0f; + maxDist = 2500.f; + m_sQueueSample.m_nLoopCount = 1; + m_sQueueSample.m_nLoopStart = 0; + m_sQueueSample.m_nLoopEnd = -1; + emittingVol = m_anRandomTable[1] % 10 + 90; + m_sQueueSample.m_bEmittingVolume = emittingVol; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_56 = 1; + if(m_bDynamicAcousticModelingStatus) + m_sQueueSample.m_bRequireReflection = 1; + else + noReflection = 1; + goto LABEL_84; + case WEAPONTYPE_UZI: + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_WEAPON_UZI_SHOT; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.field_4 = iSound++; + processed = 1; + m_sQueueSample.m_nFrequency = cSampleManager.GetSampleBaseFrequency( + AUDIO_SAMPLE_WEAPON_UZI_SHOT); + m_sQueueSample.m_nFrequency += + RandomDisplacement(m_sQueueSample.m_nFrequency >> 5); + m_sQueueSample.field_16 = 3; + m_sQueueSample.field_48 = 0.0f; + m_sQueueSample.m_fSoundIntensity = 80.0f; + maxDist = 6400.f; + m_sQueueSample.m_nLoopCount = 1; + m_sQueueSample.m_nLoopStart = 0; + emittingVol = m_anRandomTable[3] % 15 + 70; + m_sQueueSample.m_nLoopEnd = -1; + m_sQueueSample.m_bEmittingVolume = emittingVol; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_56 = 1; + goto LABEL_84; + case WEAPONTYPE_SHOTGUN: + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_WEAPON_SHOTGUN_SHOT; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.field_4 = iSound++; + processed = 1; + m_sQueueSample.m_nFrequency = cSampleManager.GetSampleBaseFrequency( + AUDIO_SAMPLE_WEAPON_SHOTGUN_SHOT); + m_sQueueSample.m_nFrequency += + RandomDisplacement(m_sQueueSample.m_nFrequency >> 5); + m_sQueueSample.field_16 = 3; + m_sQueueSample.field_48 = 0.0f; + m_sQueueSample.m_fSoundIntensity = 60.0f; + maxDist = 3600.f; + m_sQueueSample.m_nLoopCount = 1; + m_sQueueSample.m_nLoopStart = 0; + m_sQueueSample.m_nLoopEnd = -1; + emittingVol = m_anRandomTable[2] % 10 + 100; + m_sQueueSample.m_bEmittingVolume = emittingVol; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_56 = 1; + if(m_bDynamicAcousticModelingStatus) + m_sQueueSample.m_bRequireReflection = 1; + else + noReflection = 1; + goto LABEL_84; + case WEAPONTYPE_AK47: + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_WEAPON_CHAINGUN_SHOT; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.field_4 = iSound++; + processed = 1; + m_sQueueSample.m_nFrequency = cSampleManager.GetSampleBaseFrequency( + AUDIO_SAMPLE_WEAPON_CHAINGUN_SHOT); + m_sQueueSample.m_nFrequency += + RandomDisplacement(m_sQueueSample.m_nFrequency >> 5); + m_sQueueSample.field_16 = 3; + m_sQueueSample.field_48 = 0.0f; + m_sQueueSample.m_fSoundIntensity = 80.0f; + maxDist = 6400.f; + m_sQueueSample.m_nLoopCount = 1; + m_sQueueSample.m_nLoopStart = 0; + emittingVol = m_anRandomTable[1] % 15 + 70; + m_sQueueSample.m_nLoopEnd = -1; + m_sQueueSample.m_bEmittingVolume = emittingVol; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_56 = 1; + goto LABEL_84; + case WEAPONTYPE_M16: + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_WEAPON_M16_SHOT; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.field_4 = iSound++; + processed = 1; + m_sQueueSample.m_nFrequency = cSampleManager.GetSampleBaseFrequency( + AUDIO_SAMPLE_WEAPON_M16_SHOT); + m_sQueueSample.m_nFrequency += + RandomDisplacement(m_sQueueSample.m_nFrequency >> 5); + m_sQueueSample.field_16 = 3; + m_sQueueSample.field_48 = 0.0f; + m_sQueueSample.m_fSoundIntensity = 80.0f; + maxDist = 6400.f; + m_sQueueSample.m_nLoopCount = 1; + m_sQueueSample.m_nLoopStart = 0; + emittingVol = m_anRandomTable[4] % 15 + 70; + m_sQueueSample.m_nLoopEnd = -1; + m_sQueueSample.m_bEmittingVolume = emittingVol; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_56 = 1; + goto LABEL_84; + case WEAPONTYPE_SNIPERRIFLE: + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_WEAPON_SNIPER_SHOT; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.field_4 = iSound++; + processed = 1; + m_sQueueSample.m_nFrequency = cSampleManager.GetSampleBaseFrequency( + AUDIO_SAMPLE_WEAPON_SNIPER_SHOT); + m_sQueueSample.m_nFrequency += + RandomDisplacement(m_sQueueSample.m_nFrequency >> 5); + m_sQueueSample.field_16 = 3; + m_sQueueSample.field_48 = 0.0f; + m_sQueueSample.m_fSoundIntensity = 60.0f; + maxDist = 3600.f; + m_sQueueSample.m_nLoopCount = 1; + m_sQueueSample.m_nLoopStart = 0; + m_sQueueSample.m_nLoopEnd = -1; + emittingVol = m_anRandomTable[4] % 10 + 110; + m_sQueueSample.m_bEmittingVolume = emittingVol; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_56 = 1; + if(m_bDynamicAcousticModelingStatus) + m_sQueueSample.m_bRequireReflection = 1; + else + noReflection = 1; + goto LABEL_84; + case WEAPONTYPE_ROCKETLAUNCHER: + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_WEAPON_ROCKET_SHOT; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.field_4 = iSound++; + processed = 1; + m_sQueueSample.m_nFrequency = cSampleManager.GetSampleBaseFrequency( + AUDIO_SAMPLE_WEAPON_ROCKET_SHOT); + m_sQueueSample.m_nFrequency += + RandomDisplacement(m_sQueueSample.m_nFrequency >> 5); + m_sQueueSample.field_16 = 1; + m_sQueueSample.field_48 = 0.0f; + m_sQueueSample.m_fSoundIntensity = 90.0f; + maxDist = 8100.f; + m_sQueueSample.m_nLoopCount = 1; + m_sQueueSample.m_nLoopStart = 0; + m_sQueueSample.m_nLoopEnd = -1; + emittingVol = m_anRandomTable[0] % 20 + 80; + m_sQueueSample.m_bEmittingVolume = emittingVol; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_56 = 1; + if(m_bDynamicAcousticModelingStatus) + m_sQueueSample.m_bRequireReflection = 1; + else + noReflection = 1; + goto LABEL_84; + case WEAPONTYPE_FLAMETHROWER: + m_sQueueSample.m_nSampleIndex = + AUDIO_SAMPLE_WEAPON_FLAMETHROWER_SHOT; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.field_4 = 9; + emittingVol = 90; + m_sQueueSample.m_nFrequency = + (10 * m_sQueueSample.m_nEntityIndex & 2047) + + cSampleManager.GetSampleBaseFrequency( + AUDIO_SAMPLE_WEAPON_FLAMETHROWER_SHOT); + m_sQueueSample.field_16 = 3; + m_sQueueSample.field_48 = 4.0f; + m_sQueueSample.m_fSoundIntensity = 60.0f; + maxDist = 3600.f; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nLoopStart = + cSampleManager.GetSampleLoopStartOffset( + m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = cSampleManager.GetSampleLoopEndOffset( + m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_bEmittingVolume = 90; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_56 = 0; + m_sQueueSample.field_76 = 6; + if(m_bDynamicAcousticModelingStatus) + m_sQueueSample.m_bRequireReflection = 1; + else + noReflection = 1; + goto LABEL_84; + default: goto LABEL_100; + } + + break; + case SOUND_WEAPON_RELOAD: + weapon = &ped->m_weapons[ped->m_currentWeapon]; + switch(weapon->m_eWeaponType) { + case WEAPONTYPE_COLT45: + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_WEAPON_PISTOL_RELOAD; + emittingVol = 75; + m_sQueueSample.field_4 = iSound++; + processed = 1; + m_sQueueSample.m_nFrequency = + cSampleManager.GetSampleBaseFrequency( + AUDIO_SAMPLE_WEAPON_PISTOL_RELOAD) + + RandomDisplacement(300u); + goto LABEL_63; + case WEAPONTYPE_UZI: + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_WEAPON_UZI_RELOAD; + emittingVol = 75; + m_sQueueSample.field_4 = iSound++; + processed = 1; + m_sQueueSample.m_nFrequency = 39243; + goto LABEL_63; + case WEAPONTYPE_SHOTGUN: + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_WEAPON_CHAINGUN_RELOAD; + emittingVol = 75; + m_sQueueSample.field_4 = iSound++; + processed = 1; + m_sQueueSample.m_nFrequency = 30290; + goto LABEL_63; + case WEAPONTYPE_AK47: + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_WEAPON_CHAINGUN_RELOAD; + emittingVol = 75; + m_sQueueSample.field_4 = iSound++; + processed = 1; + m_sQueueSample.m_nFrequency = cSampleManager.GetSampleBaseFrequency( + AUDIO_SAMPLE_WEAPON_CHAINGUN_RELOAD); + goto LABEL_62; + case WEAPONTYPE_M16: + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_WEAPON_UZI_RELOAD; + emittingVol = 75; + m_sQueueSample.field_4 = iSound++; + processed = 1; + m_sQueueSample.m_nFrequency = cSampleManager.GetSampleBaseFrequency( + AUDIO_SAMPLE_WEAPON_UZI_RELOAD); + goto LABEL_62; + case WEAPONTYPE_SNIPERRIFLE: + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_WEAPON_SNIPER_RELOAD; + emittingVol = 75; + m_sQueueSample.field_4 = iSound++; + processed = 1; + m_sQueueSample.m_nFrequency = cSampleManager.GetSampleBaseFrequency( + AUDIO_SAMPLE_WEAPON_SNIPER_RELOAD); + goto LABEL_62; + case WEAPONTYPE_ROCKETLAUNCHER: + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_WEAPON_ROCKET_RELOAD; + emittingVol = 75; + m_sQueueSample.field_4 = iSound++; + processed = 1; + m_sQueueSample.m_nFrequency = cSampleManager.GetSampleBaseFrequency( + AUDIO_SAMPLE_WEAPON_ROCKET_RELOAD); + LABEL_62: + LABEL_63: + m_sQueueSample.m_nFrequency += RandomDisplacement(300u); + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.field_16 = 5; + m_sQueueSample.field_48 = 0.0f; + m_sQueueSample.m_fSoundIntensity = 30.0f; + maxDist = 900.f; + m_sQueueSample.m_nLoopCount = 1; + m_sQueueSample.m_nLoopStart = 0; + m_sQueueSample.m_nLoopEnd = -1; + m_sQueueSample.m_bEmittingVolume = 75; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_56 = 1; + m_sQueueSample.m_bRequireReflection = 1; + goto LABEL_84; + default: goto LABEL_100; + } + + break; + case SOUND_WEAPON_AK47_BULLET_ECHO: + case SOUND_WEAPON_UZI_BULLET_ECHO: + case SOUND_WEAPON_M16_BULLET_ECHO: + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_75; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.field_4 = iSound++; + processed = 1; + m_sQueueSample.m_nFrequency = + cSampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_75); + m_sQueueSample.m_nFrequency += + RandomDisplacement(m_sQueueSample.m_nFrequency >> 4); + m_sQueueSample.field_16 = 3; + m_sQueueSample.field_48 = 0.0f; + m_sQueueSample.m_fSoundIntensity = 80.0f; + maxDist = 6400.f; + m_sQueueSample.m_nLoopCount = 1; + m_sQueueSample.m_nLoopStart = 0; + m_sQueueSample.m_nLoopEnd = -1; + emittingVol = m_anRandomTable[4] % 10 + 40; + m_sQueueSample.m_bEmittingVolume = emittingVol; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_56 = 1; + if(m_bDynamicAcousticModelingStatus) + m_sQueueSample.m_bRequireReflection = 1; + else + noReflection = 1; + goto LABEL_84; + case SOUND_WEAPON_FLAMETHROWER_FIRE: + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_WEAPON_FLAMETHROWER_FIRE; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.field_4 = iSound++; + m_sQueueSample.m_nFrequency = cSampleManager.GetSampleBaseFrequency( + AUDIO_SAMPLE_WEAPON_FLAMETHROWER_FIRE); + m_sQueueSample.m_nFrequency += + RandomDisplacement(m_sQueueSample.m_nFrequency >> 4); + m_sQueueSample.field_16 = 3; + m_sQueueSample.field_48 = 4.0f; + m_sQueueSample.m_fSoundIntensity = 60.0f; + maxDist = 3600.f; + m_sQueueSample.m_nLoopCount = 1; + m_sQueueSample.m_nLoopStart = 0; + m_sQueueSample.m_nLoopEnd = -1; + emittingVol = 70; + m_sQueueSample.m_bEmittingVolume = 70; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_56 = 1; + goto LABEL_84; + case SOUND_WEAPON_HIT_PED: + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_BULLET_HIT_PED; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.field_4 = iSound++; + processed = 1; + m_sQueueSample.m_nFrequency = + cSampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_BULLET_HIT_PED); + m_sQueueSample.m_nFrequency += + RandomDisplacement(m_sQueueSample.m_nFrequency >> 3); + m_sQueueSample.field_16 = 7; + m_sQueueSample.field_48 = 0.0f; + m_sQueueSample.m_fSoundIntensity = 30.0f; + maxDist = 900.f; + m_sQueueSample.m_nLoopCount = 1; + m_sQueueSample.m_nLoopStart = 0; + emittingVol = m_anRandomTable[0] % 20 + 90; + m_sQueueSample.m_nLoopEnd = -1; + m_sQueueSample.m_bEmittingVolume = emittingVol; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_56 = 1; + goto LABEL_84; + case SOUND_SPLASH: + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_COLLISION_WATER; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.field_4 = iSound++; + processed = 1; + m_sQueueSample.m_nFrequency = RandomDisplacement(1400u) + 20000; + m_sQueueSample.field_16 = 1; + m_sQueueSample.field_48 = 0.0f; + m_sQueueSample.m_fSoundIntensity = 40.0f; + maxDist = 1600.f; + m_sQueueSample.m_nLoopCount = 1; + m_sQueueSample.m_nLoopStart = 0; + emittingVol = m_anRandomTable[2] % 30 + 70; + m_sQueueSample.m_nLoopEnd = -1; + m_sQueueSample.m_bEmittingVolume = emittingVol; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_56 = 1; + m_sQueueSample.m_bRequireReflection = 1; + LABEL_84: + if(processed && iSound > 60u) iSound = 21; + if(params->m_fDistance < maxDist) { + CalculateDistance((bool *)params, params->m_fDistance); + m_sQueueSample.m_bVolume = + ComputeVolume(emittingVol, m_sQueueSample.m_fSoundIntensity, + m_sQueueSample.m_fDistance); + if(m_sQueueSample.m_bVolume) { + if(noReflection) { + if(0.2f * m_sQueueSample.m_fSoundIntensity > + m_sQueueSample.m_fDistance) { + noReflection = 0; + } else { + m_sQueueSample.m_bIsDistant = 1; + m_sQueueSample.m_bOffset = 0; + } + } + m_sQueueSample.m_bReverbFlag = 1; + AddSampleToRequestedQueue(); + if(noReflection) { + m_sQueueSample.m_bOffset = 127; + ++m_sQueueSample.m_nSampleIndex; + if(m_asAudioEntities[0].m_awAudioEvent + [i + + 20 * m_sQueueSample.m_nEntityIndex] != + 47 || + weapon->m_eWeaponType != + WEAPONTYPE_FLAMETHROWER) { + m_sQueueSample.field_4 = iSound++; + if(iSound > 60u) iSound = 21; + } else { + ++m_sQueueSample.field_4; + } + AddSampleToRequestedQueue(); + } + } + } + break; + default: SetupPedComments(params, sound); break; + } + LABEL_100: + ++i; + } } void @@ -5396,8 +6508,8 @@ cAudioManager::ProcessSawMillScriptObject(uint8 sound) distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos); if(distSquared < maxDist) { m_sQueueSample.m_fDistance = sqrt(distSquared); - m_sQueueSample.m_bVolume = cAudioManager::ComputeVolume( - 30u, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); + m_sQueueSample.m_bVolume = ComputeVolume(30u, m_sQueueSample.m_fSoundIntensity, + m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_SAWMILL_1; m_sQueueSample.m_bBankIndex = 0; @@ -5420,7 +6532,7 @@ cAudioManager::ProcessSawMillScriptObject(uint8 sound) } time = CTimer::GetTimeInMilliseconds(); if(time > audioLogicTimers[1]) { - m_sQueueSample.m_bVolume = cAudioManager::ComputeVolume( + m_sQueueSample.m_bVolume = ComputeVolume( 70u, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_SAWMILL_2; @@ -5444,11 +6556,19 @@ cAudioManager::ProcessSawMillScriptObject(uint8 sound) } } -WRAPPER void cAudioManager::ProcessScriptObject(int32 id) { - EAXJMP(0x576070); + cAudioScriptObject *entity = (cAudioScriptObject *)m_asAudioEntities[id].m_pEntity; + if(entity) { + m_sQueueSample.m_vecPos.x = entity->m_vecPos.x; + m_sQueueSample.m_vecPos.y = entity->m_vecPos.y; + m_sQueueSample.m_vecPos.z = entity->m_vecPos.z; + if(m_asAudioEntities[id].field_24 == 1) + ProcessOneShotScriptObject(m_asAudioEntities[id].m_awAudioEvent[0]); + else + ProcessLoopingScriptObject(entity->m_wSound); + } } void @@ -5490,7 +6610,7 @@ cAudioManager::ProcessShopScriptObject(uint8 sound) SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_bReverbFlag = 1; m_sQueueSample.m_bRequireReflection = 0; - cAudioManager::AddSampleToRequestedQueue(); + AddSampleToRequestedQueue(); } time = CTimer::GetTimeInMilliseconds(); if(time > audioLogicTimers[2]) { @@ -5579,7 +6699,7 @@ cAudioManager::ProcessWorkShopScriptObject(uint8 sound) case SCRIPT_SOUND_WORK_SHOP_LOOP_S: case SCRIPT_SOUND_WORK_SHOP_LOOP_L: maxDist = 400.f; - m_sQueueSample.m_fSoundIntensity = 20.0; + m_sQueueSample.m_fSoundIntensity = 20.0f; break; default: break; } @@ -5598,7 +6718,7 @@ cAudioManager::ProcessWorkShopScriptObject(uint8 sound) m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.field_56 = 0; m_sQueueSample.field_16 = 5; - m_sQueueSample.field_48 = 2.0; + m_sQueueSample.field_48 = 2.0f; m_sQueueSample.m_bEmittingVolume = 30; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); @@ -5611,6 +6731,136 @@ cAudioManager::ProcessWorkShopScriptObject(uint8 sound) } } +void +cAudioManager::SetupPedComments(cPedParams *params, uint32 sound) +{ + CPed *ped = params->m_pPed; + uint8 emittingVol; + float maxDist; + float soundIntensity; + tPedComment pedComment; + + if(ped) { + switch(sound) { + case SOUND_AMMUNATION_WELCOME_1: + pedComment.m_nSampleIndex = AUDIO_SAMPLE_AMMUNATION_WELCOME_1; + break; + case SOUND_AMMUNATION_WELCOME_2: + pedComment.m_nSampleIndex = AUDIO_SAMPLE_AMMUNATION_WELCOME_2; + break; + case SOUND_AMMUNATION_WELCOME_3: + pedComment.m_nSampleIndex = AUDIO_SAMPLE_AMMUNATION_WELCOME_3; + break; + default: + pedComment.m_nSampleIndex = GetPedCommentSfx(ped, sound); + if(pedComment.m_nSampleIndex == NO_SAMPLE) return; + break; + } + + maxDist = 2500.f; + soundIntensity = 50.f; + + if(params->m_fDistance < maxDist) { + CalculateDistance((bool *)params, params->m_fDistance); + if(sound != SOUND_PAGER) { + switch(sound) { + case SOUND_AMMUNATION_WELCOME_1: + case SOUND_AMMUNATION_WELCOME_2: + case SOUND_AMMUNATION_WELCOME_3: emittingVol = maxVolume; break; + default: + if(CWorld::GetIsLineOfSightClear( + TheCamera.GetGameCamPosition(), + m_sQueueSample.m_vecPos, 1, 0, 0, 0, 0, 0, 0)) { + emittingVol = maxVolume; + } else { + emittingVol = 31; + } + break; + } + m_sQueueSample.m_bVolume = ComputeVolume( + emittingVol, soundIntensity, m_sQueueSample.m_fDistance); + pedComment.field_25 = 10; + if(m_sQueueSample.m_bVolume) { + pedComment.field_4 = m_sQueueSample.m_nEntityIndex; + pedComment.m_vecPos.x = m_sQueueSample.m_vecPos.x; + pedComment.m_vecPos.y = m_sQueueSample.m_vecPos.y; + pedComment.m_vecPos.z = m_sQueueSample.m_vecPos.z; + pedComment.m_fDistance = m_sQueueSample.m_fDistance; + pedComment.m_bVolume = m_sQueueSample.m_bVolume; + m_sPedComments.Add(&pedComment); + } + } + } + } else { + switch(sound) { + case SOUND_PED_HELI_PLAYER_FOUND: + maxDist = 160000.f; + soundIntensity = 400.f; + pedComment.m_nSampleIndex = + m_anRandomTable[m_sQueueSample.m_nEntityIndex & 3] % 29u + + AUDIO_SAMPLE_POLICE_HELI_FOUND_PLAYER_1; + break; + case SOUND_PED_BODYCAST_HIT: + if(CTimer::GetTimeInMilliseconds() <= audioLogicTimers[8]) return; + maxDist = 2500.f; + soundIntensity = 50.f; + audioLogicTimers[8] = CTimer::GetTimeInMilliseconds() + 500; + pedComment.m_nSampleIndex = + (m_anRandomTable[m_sQueueSample.m_nEntityIndex & 3] & 3) + + AUDIO_SAMPLE_PED_BODYCAST_HIT_1; + break; + case SOUND_INJURED_PED_MALE_OUCH: + case SOUND_8A: + maxDist = 2500.f; + soundIntensity = 50.f; + pedComment.m_nSampleIndex = + m_anRandomTable[m_sQueueSample.m_nEntityIndex & 3] % 15u + + AUDIO_SAMPLE_INJURED_PED_MALE_OUCH_1; + break; + case SOUND_INJURED_PED_FEMALE: + maxDist = 2500.f; + soundIntensity = 50.f; + pedComment.m_nSampleIndex = + m_anRandomTable[m_sQueueSample.m_nEntityIndex & 3] % 11u + + AUDIO_SAMPLE_INJURED_PED_FEMALE_OUCH_1; + break; + default: return; + } + + if(params->m_fDistance < maxDist) { + CalculateDistance((bool *)params, params->m_fDistance); + if(sound != SOUND_PAGER) { + switch(sound) { + case SOUND_AMMUNATION_WELCOME_1: + case SOUND_AMMUNATION_WELCOME_2: + case SOUND_AMMUNATION_WELCOME_3: emittingVol = maxVolume; break; + default: + if(CWorld::GetIsLineOfSightClear( + TheCamera.GetGameCamPosition(), + m_sQueueSample.m_vecPos, 1, 0, 0, 0, 0, 0, 0)) { + emittingVol = maxVolume; + } else { + emittingVol = 31; + } + break; + } + m_sQueueSample.m_bVolume = ComputeVolume( + emittingVol, soundIntensity, m_sQueueSample.m_fDistance); + pedComment.field_25 = 10; + if(m_sQueueSample.m_bVolume) { + pedComment.field_4 = m_sQueueSample.m_nEntityIndex; + pedComment.m_vecPos.x = m_sQueueSample.m_vecPos.x; + pedComment.m_vecPos.y = m_sQueueSample.m_vecPos.y; + pedComment.m_vecPos.z = m_sQueueSample.m_vecPos.z; + pedComment.m_fDistance = m_sQueueSample.m_fDistance; + pedComment.m_bVolume = m_sQueueSample.m_bVolume; + m_sPedComments.Add(&pedComment); + } + } + } + } +} + WRAPPER void cAudioManager::Service() { @@ -5663,6 +6913,8 @@ WRAPPER void cAudioManager::PreloadMissionAudio(char *) } STARTPATCHES +InjectHook(0x5755C0, &cPedComments::Add, PATCH_JUMP); + InjectHook(0x57B210, &cAudioManager::AddDetailsToRequestedOrderList, PATCH_JUMP); InjectHook(0x56AD30, &cAudioManager::AddPlayerCarSample, PATCH_JUMP); InjectHook(0x57B300, &cAudioManager::AddReflectionsToRequestedQueue, PATCH_JUMP); @@ -5842,6 +7094,7 @@ InjectHook(0x579170, &cAudioManager::ProcessBridgeWarning, PATCH_JUMP); InjectHook(0x577CA0, &cAudioManager::ProcessCinemaScriptObject, PATCH_JUMP); InjectHook(0x577E50, &cAudioManager::ProcessDocksScriptObject, PATCH_JUMP); InjectHook(0x569870, &cAudioManager::ProcessEntity, PATCH_JUMP); +InjectHook(0x575AC0, &cAudioManager::ProcessExplosions, PATCH_JUMP); InjectHook(0x578FD0, &cAudioManager::ProcessFireHydrant, PATCH_JUMP); InjectHook(0x5785E0, &cAudioManager::ProcessFrontEnd, PATCH_JUMP); InjectHook(0x577FE0, &cAudioManager::ProcessHomeScriptObject, PATCH_JUMP); @@ -5854,10 +7107,16 @@ InjectHook(0x56EC00, &cAudioManager::ProcessJumboTakeOff, PATCH_JUMP); InjectHook(0x56EA10, &cAudioManager::ProcessJumboTaxi, PATCH_JUMP); InjectHook(0x5777E0, &cAudioManager::ProcessLaunderetteScriptObject, PATCH_JUMP); InjectHook(0x576770, &cAudioManager::ProcessLoopingScriptObject, PATCH_JUMP); +InjectHook(0x5760C0, &cAudioManager::ProcessOneShotScriptObject, PATCH_JUMP); +InjectHook(0x56F450, &cAudioManager::ProcessPed, PATCH_JUMP); +InjectHook(0x56F4D0, &cAudioManager::ProcessPedHeadphones, PATCH_JUMP); +InjectHook(0x56F650, &cAudioManager::ProcessPedOneShots, PATCH_JUMP); InjectHook(0x5699C0, &cAudioManager::ProcessPhysical, PATCH_JUMP); InjectHook(0x577280, &cAudioManager::ProcessPornCinema, PATCH_JUMP); InjectHook(0x577630, &cAudioManager::ProcessSawMillScriptObject, PATCH_JUMP); +InjectHook(0x576070, &cAudioManager::ProcessScriptObject, PATCH_JUMP); InjectHook(0x577970, &cAudioManager::ProcessShopScriptObject, PATCH_JUMP); InjectHook(0x5697D0, &cAudioManager::ProcessSpecial, PATCH_JUMP); InjectHook(0x577530, &cAudioManager::ProcessWorkShopScriptObject, PATCH_JUMP); +InjectHook(0x570690, &cAudioManager::SetupPedComments, PATCH_JUMP); ENDPATCHES diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index 0d4a6f30..5b74cc16 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -51,7 +51,7 @@ public: uint8 field_91; }; -static_assert(sizeof(tActiveSample) == 0x5c, "tActiveSample: error"); +static_assert(sizeof(tActiveSample) == 92, "tActiveSample: error"); enum eAudioType : int32 { AUDIOTYPE_PHYSICAL = 0, @@ -83,11 +83,11 @@ public: int16 m_awAudioEvent[4]; uint8 gap_18[2]; float m_afVolume[4]; - uint8 field_24; + uint8 field_24; // is looping uint8 field_25[3]; }; -static_assert(sizeof(tAudioEntity) == 0x28, "tAudioEntity: error"); +static_assert(sizeof(tAudioEntity) == 40, "tAudioEntity: error"); class tPedComment { @@ -101,19 +101,21 @@ public: uint8 gap_26[2]; }; -static_assert(sizeof(tPedComment) == 0x1c, "tPedComment: error"); +static_assert(sizeof(tPedComment) == 28, "tPedComment: error"); class cPedComments { public: - tPedComment m_asPedComments[40]; - uint8 field_1120[40]; - uint8 field_1160[2]; - uint8 field_1162; + tPedComment m_asPedComments[2][20]; + uint8 field_1120[2][20]; + uint8 nrOfCommentsInBank[2]; + uint8 activeBank; uint8 gap_1163[1]; + + void Add(tPedComment *com); // test }; -static_assert(sizeof(cPedComments) == 0x48c, "cPedComments: error"); +static_assert(sizeof(cPedComments) == 1164, "cPedComments: error"); class CEntity; @@ -133,7 +135,7 @@ public: int32 m_nBaseVolume; }; -static_assert(sizeof(cAudioCollision) == 0x28, "cAudioCollision: error"); +static_assert(sizeof(cAudioCollision) == 40, "cAudioCollision: error"); class cAudioCollisionManager { @@ -146,7 +148,7 @@ public: cAudioCollision m_sQueue; }; -static_assert(sizeof(cAudioCollisionManager) == 0x354, "cAudioCollisionManager: error"); +static_assert(sizeof(cAudioCollisionManager) == 852, "cAudioCollisionManager: error"); class cMissionAudio { @@ -166,12 +168,13 @@ public: uint8 field_31; }; -static_assert(sizeof(cMissionAudio) == 0x20, "cMissionAudio: error"); +static_assert(sizeof(cMissionAudio) == 32, "cMissionAudio: error"); class cVehicleParams; class CPlane; class CVehicle; class CPed; +class cPedParams; class cAudioScriptObject { public: @@ -182,11 +185,11 @@ public: static void *operator new(size_t); static void *operator new(size_t, int); - static void operator delete(void*, size_t); - static void operator delete(void*, int); + static void operator delete(void *, size_t); + static void operator delete(void *, int); }; -static_assert(sizeof(cAudioScriptObject) == 0x14, "cAudioScriptObject: error"); +static_assert(sizeof(cAudioScriptObject) == 20, "cAudioScriptObject: error"); enum { @@ -334,7 +337,7 @@ public: bool MissionScriptAudioUsesPoliceChannel(int32 soundMission); - char* Get3DProviderName(uint8 id); + char *Get3DProviderName(uint8 id); bool SetupJumboFlySound(uint8 emittingVol); /// ok bool SetupJumboRumbleSound(uint8 emittingVol); /// ok @@ -474,7 +477,7 @@ public: void ProcessDocksScriptObject(uint8 sound); /// ok // bool ProcessEngineDamage(void *); //todo requires CVehicle void ProcessEntity(int32 sound); /// ok - void ProcessExplosions(int32 explosion); // todo requires CExplosion + void ProcessExplosions(int32 explosion); // test void ProcessFireHydrant(); /// ok void ProcessFires(int32 entity); // todo requires gFireManager void ProcessFrontEnd(); /// ok @@ -492,12 +495,12 @@ public: void ProcessLoopingScriptObject(uint8 sound); /// ok // void ProcessMissionAudio(); // void ProcessModelVehicle(void *); - // void ProcessOneShotScriptObject(uint8 sound); - void ProcessPed(CPhysical *p); // todo - // void ProcessPedHeadphones(void *); - // void ProcessPedOneShots(void *); - void ProcessPhysical(int32 id); /// ok - void ProcessPlane(void *); // todo + void ProcessOneShotScriptObject(uint8 sound); // test + void ProcessPed(CPhysical *ped); // test + void ProcessPedHeadphones(cPedParams *params); // test + void ProcessPedOneShots(cPedParams *params); // test, remove goto + void ProcessPhysical(int32 id); /// ok + void ProcessPlane(void *); // todo // void ProcessPlayersVehicleEngine(void *, void *); void ProcessPoliceCellBeatingScriptObject(uint8 sound); // todo void ProcessPornCinema(uint8 sound); /// ok @@ -506,7 +509,7 @@ public: // void ProcessReverb(); // bool ProcessReverseGear(void *); void ProcessSawMillScriptObject(uint8 sound); /// ok - void ProcessScriptObject(int32 id); // todo + void ProcessScriptObject(int32 id); // test void ProcessShopScriptObject(uint8 sound); /// ok void ProcessSpecial(); /// ok // bool ProcessTrainNoise(void *); @@ -523,19 +526,10 @@ public: void ProcessWeather(int32 id); // todo // bool ProcessWetRoadNoise(void *); void ProcessWorkShopScriptObject(uint8 sound); /// ok - - - void PlayOneShot(int, unsigned short, float); - void SetEffectsFadeVol(unsigned char); - void SetMusicFadeVol(unsigned char); - int8 SetCurrent3DProvider(unsigned char); - void ReportCrime(eCrimeType, CVector const &); - void PlaySuspectLastSeen(float, float, float); - void ReportCollision(CEntity *, CEntity *, unsigned char, unsigned char, float, float); - void ResetTimers(unsigned int); - void PreloadMissionAudio(char *); + + void SetupPedComments(cPedParams *params, uint32 sound); // todo hook }; -static_assert(sizeof(cAudioManager) == 0x4B14, "cAudioManager: error"); +static_assert(sizeof(cAudioManager) == 19220, "cAudioManager: error"); extern cAudioManager &AudioManager; diff --git a/src/audio/DMAudio.h b/src/audio/DMAudio.h index 318b9947..0932e581 100644 --- a/src/audio/DMAudio.h +++ b/src/audio/DMAudio.h @@ -1,4 +1,7 @@ #pragma once + +#include "Wanted.h" + enum eSound : int16 { SOUND_CAR_DOOR_CLOSE_BONNET = 0, -- cgit v1.2.3 From 458fc63f0196dc92362b44d5cf7ebf67bbc903e1 Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Fri, 2 Aug 2019 17:43:40 +0200 Subject: Cleanup --- src/audio/AudioManager.cpp | 1737 +++++++++++++++++++++++++++++++------------- src/audio/AudioManager.h | 95 +-- src/audio/DMAudio.cpp | 2 + 3 files changed, 1279 insertions(+), 555 deletions(-) (limited to 'src/audio') diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index 76bfb793..e08efbc6 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -4,23 +4,30 @@ #include "AudioManager.h" #include "Automobile.h" +#include "Boat.h" +#include "Bridge.h" #include "Camera.h" #include "DMAudio.h" #include "Explosion.h" #include "Garages.h" +#include "Heli.h" #include "ModelIndices.h" #include "MusicManager.h" +#include "Pad.h" #include "Ped.h" #include "Physical.h" #include "Plane.h" #include "PlayerPed.h" #include "Pools.h" -#include "sampman.h" +#include "Replay.h" #include "Stats.h" #include "SurfaceTable.h" +#include "Transmission.h" #include "Vehicle.h" -#include "Plane.h" +#include "Weather.h" #include "World.h" +#include "ZoneCull.h" +#include "sampman.h" uint32 *audioLogicTimers = (uint32 *)0x6508A0; @@ -254,70 +261,7 @@ cAudioManager::AddReleasingSounds() EAXJMP(0x57B8D0); } #else -void -cAudioManager::AddReleasingSounds() -{ - bool isFirstSampleQueue; - int32 calculatedIndex; - tActiveSample *sample; - uint8 field_76; - uint8 field_88; - int sampleQueue; - bool toProcess[44]; - isFirstSampleQueue = m_bActiveSampleQueue == 0; - - cAudioManager *s = (this + 2484 * isFirstSampleQueue); // wtf - - for(uint32 i = 0; i < m_bSampleRequestQueuesStatus[isFirstSampleQueue]; i++) { - calculatedIndex = i + 27 * isFirstSampleQueue; - sample = &s->m_asSamples[m_abSampleQueueIndexTable[calculatedIndex]]; - if(!s->m_asSamples[m_abSampleQueueIndexTable[calculatedIndex]].m_bLoopEnded) { - toProcess[i] = 0; - sampleQueue = m_bActiveSampleQueue; - for(uint8 j = 0; j < m_bSampleRequestQueuesStatus[m_bActiveSampleQueue]; - j++) { - if(sample->m_nEntityIndex == - m_asSamples[27 * sampleQueue + - m_abSampleQueueIndexTable[27 * sampleQueue + j]] - .m_nEntityIndex && - sample->field_4 == - m_asSamples[27 * sampleQueue + - m_abSampleQueueIndexTable[27 * sampleQueue + j]] - .field_4) { - toProcess[i] = 1; - break; - } - } - if(!toProcess[i]) { - if(sample->field_4 <= 255u || !sample->m_bLoopsRemaining) { - field_76 = sample->field_76; - if(!field_76) continue; - if(!sample->m_nLoopCount) { - uint8 &vol = sample->m_bVolume; - if(sample->field_88 == -1) { - sample->field_88 = vol / field_76; - if(sample->field_88 <= 0) - sample->field_88 = 1; - } - field_88 = sample->field_88; - if(vol <= field_88) { - sample->field_76 = 0; - continue; - } - vol -= field_88; - } - --sample->field_76; - if(field_2) { - if(sample->field_16 < 20u) ++sample->field_16; - } - sample->field_56 = 0; - } - memcpy(&m_sQueueSample, sample, 92); - AddSampleToRequestedQueue(); - } - } - } -} + #endif void @@ -453,9 +397,9 @@ cAudioManager::ComputeDopplerEffectedFrequency(uint32 oldFreq, float position1, float speedOfSource = (dist / field_19195) * speedMultiplier; if(speedOfSound > fabsf(speedOfSource)) { if(speedOfSource < 0.0f) { - speedOfSource = Max(speedOfSource, -1.5f); + speedOfSource = max(speedOfSource, -1.5f); } else { - speedOfSource = Min(speedOfSource, 1.5f); + speedOfSource = min(speedOfSource, 1.5f); } newFreq = (oldFreq * speedOfSound) / (speedOfSource + speedOfSound); } @@ -3407,6 +3351,13 @@ cAudioManager::GetGenericFemaleTalkSfx(int16 sound) return sfx; } +WRAPPER +void +cAudioManager::PlayOneShot(int32 index, int16 sound, float vol) +{ + EAXJMP(0x57A500); +} + #if 1 WRAPPER @@ -3417,317 +3368,7 @@ cAudioManager::ProcessActiveQueues() } #else -void -cAudioManager::ProcessActiveQueues() -{ - int v3; // ecx - cAudioManager *v4; // edx - tActiveSample *v5; // ebx - cAudioManager *v6; // edi - tActiveSample *v7; // esi - char v8; // al - unsigned __int8 v9; // dl - double v10; // st7 - double v11; // st6 - float a4; // ST08_4 - float a3; // ST04_4 - int activeSampleFreq; // ecx - int freq; // edi - int newFreq; // ecx - int v17; // eax - char v18; // al - unsigned __int8 v19; // al - float v20; // ST0C_4 - int v21; // edx - unsigned __int8 v22; // bl - cAudioManager *v23; // ebp - int v24; // ecx - cAudioManager *v25; // edx - tActiveSample *v26; // ebx - cAudioManager *v27; // ebp - unsigned int v28; // edi - unsigned int v29; // eax - unsigned __int8 v30; // cl - double v31; // st4 - double v32; // st7 - double v33; // st6 - double v34; // st5 - float v35; // ST0C_4 - float v36; // ST08_4 - float v37; // ST04_4 - float v38; // ST0C_4 - int v39; // edx - int v40; // [esp+Ch] [ebp-58h] - int v41; // [esp+Ch] [ebp-58h] - unsigned int v42; // [esp+10h] [ebp-54h] - int v43; // [esp+10h] [ebp-54h] - char v44; // [esp+14h] [ebp-50h] - unsigned __int8 v45; // [esp+14h] [ebp-50h] - unsigned __int8 l; // [esp+24h] [ebp-40h] - unsigned __int8 j; // [esp+28h] [ebp-3Ch] - unsigned __int8 k; // [esp+34h] [ebp-30h] - unsigned __int8 i; // [esp+38h] [ebp-2Ch] - CVector a2; // [esp+48h] [ebp-1Ch] - - for(uint32 i = 0; i < m_bActiveSamples; i++) { - m_asSamples[m_bActiveSampleQueue][i].m_bIsProcessed = 0; - m_asActiveSamples[i].m_bIsProcessed = 0; - } - - for(i = 0;; ++i) { - v21 = m_bActiveSampleQueue; - if(i >= m_bSampleRequestQueuesStatus[v21]) break; - v3 = i + 27 * v21; - v4 = (this + 2484 * v21); - v5 = &v4->m_asSamples[m_abSampleQueueIndexTable[v3]]; - if(v4->m_asSamples[m_abSampleQueueIndexTable[v3]].m_nSampleIndex != NO_SAMPLE) { - v6 = this; - for(j = 0;; ++j) { - if(j >= m_bActiveSamples) goto LABEL_58; - v7 = m_asActiveSamples; - if(v5->m_nEntityIndex == m_asActiveSamples[0].m_nEntityIndex && - v5->field_4 == m_asActiveSamples[0].field_4 && - v5->m_nSampleIndex == m_asActiveSamples[0].m_nSampleIndex) { - break; - } - LABEL_56: - v6 = (v6 + 92); - } - if(v5->m_nLoopCount) { - if(m_FrameCounter & 1) { - if(!(j & 1)) { - v8 = 0; - goto LABEL_17; - } - LABEL_16: - v8 = 1; - } else { - if(!(j & 1)) goto LABEL_16; - v8 = 0; - } - LABEL_17: - if(v8 && !SampleManager.GetChannelUsedFlag(j)) { - v5->m_bLoopEnded = 1; - m_asActiveSamples[0].m_bLoopEnded = 1; - m_asActiveSamples[0].m_nSampleIndex = NO_SAMPLE; - v7->m_nEntityIndex = -5; - goto LABEL_56; - } - } - v5->m_bIsProcessed = 1; - m_asActiveSamples[0].m_bIsProcessed = 1; - v5->field_88 = -1; - if(!v5->field_56) { - if(v5->m_bIsDistant) { - if(field_4) { - v9 = v5->m_bEmittingVolume; - if(v9 >= 63u) - v42 = 63; - else - v42 = v9; - v43 = 2 * v42; - } else { - v43 = v5->m_bEmittingVolume; - } - SampleManager.SetChannelFrequency(j, v5->m_nFrequency); - SampleManager.SetChannelEmittingVolume(j, v43); - } else { - v10 = m_asActiveSamples[0].m_fDistance; - v11 = v5->m_fDistance; - m_asActiveSamples[0].m_fDistance = v5->m_fDistance; - a4 = v11; - a3 = v10; - v5->m_nFrequency = ComputeDopplerEffectedFrequency( - v5->m_nFrequency, a3, a4, v5->field_48); - activeSampleFreq = m_asActiveSamples[0].m_nFrequency; - freq = v5->m_nFrequency; - if(freq != activeSampleFreq) { - if(freq <= activeSampleFreq) { - if(activeSampleFreq - 6000 > freq) - freq = activeSampleFreq - 6000; - newFreq = freq; - } else if(activeSampleFreq + 6000 >= freq) { - newFreq = v5->m_nFrequency; - } else { - newFreq = activeSampleFreq + 6000; - } - v7->m_nFrequency = newFreq; - SampleManager.SetChannelFrequency(j, newFreq); - } - v40 = v7->m_bEmittingVolume; - v17 = v5->m_bEmittingVolume; - if(v17 != v40) { - if(v17 <= v40) { - if(v40 - 10 > v17) v17 = v40 - 10; - v41 = v17; - } else if(v40 + 10 >= v17) { - v41 = v5->m_bEmittingVolume; - } else { - v41 = v40 + 10; - } - if(field_4) { - if(v41 >= 63) - v18 = 63; - else - v18 = v41; - v19 = 2 * v18; - } else { - v19 = v41; - } - SampleManager.SetChannelEmittingVolume(j, v19); - v7->m_bEmittingVolume = v41; - } - TranslateEntity(&v5->m_vecPos, &a2); - SampleManager.SetChannel3DPosition(j, a2.x, a2.y, a2.z); - v20 = 0.25f * v5->m_fSoundIntensity; - SampleManager.SetChannel3DDistances( - j, v5->m_fSoundIntensity, v20); - } - SampleManager.SetChannelReverbFlag(j, v5->m_bReverbFlag); - continue; - } - v5->m_bIsProcessed = 0; - m_asActiveSamples[0].m_bIsProcessed = 0; - goto LABEL_56; - } - LABEL_58:; - } - v22 = 0; - v23 = this; - for(uint32 i = 0; v22 < m_bActiveSamples; i++) { - if(v23->m_asActiveSamples[0].m_nSampleIndex != NO_SAMPLE && - !v23->m_asActiveSamples[0].m_bIsProcessed) { - SampleManager.StopChannel(i); - v23->m_asActiveSamples[0].m_nSampleIndex = NO_SAMPLE; - v23->m_asActiveSamples[0].m_nEntityIndex = -5; - } - v23 = (v23 + 92); - } - for(k = 0; k < m_bSampleRequestQueuesStatus[m_bActiveSampleQueue]; ++k) { - v24 = k + 27 * v39; - v25 = (this + 2484 * v39); - v26 = &v25->m_asSamples[m_abSampleQueueIndexTable[v24]]; - if(!v25->m_asSamples[m_abSampleQueueIndexTable[v24]].m_bIsProcessed && - !v25->m_asSamples[m_abSampleQueueIndexTable[v24]].m_bLoopEnded && - m_asAudioEntities[v26->m_nEntityIndex].m_bIsUsed && - v25->m_asSamples[m_abSampleQueueIndexTable[v24]].m_nSampleIndex < NO_SAMPLE) { - if(v25->m_asSamples[m_abSampleQueueIndexTable[v24]].field_4 > 255u && - v25->m_asSamples[m_abSampleQueueIndexTable[v24]].m_nLoopCount && - v25->m_asSamples[m_abSampleQueueIndexTable[v24]].m_bLoopsRemaining) { - --v25->m_asSamples[m_abSampleQueueIndexTable[v24]] - .m_bLoopsRemaining; - v26->field_76 = 1; - } else { - v27 = this; - for(l = 0; l < m_bActiveSamples; ++l) { - if(!v27->m_asActiveSamples[0].m_bIsProcessed) { - if(!v26->m_nLoopCount) goto LABEL_80; - v28 = v26->m_nFrequency / field_19192; - v29 = v26->m_nLoopCount * - SampleManager.GetSampleLength( - v26->m_nSampleIndex); - if(v28) { - v26->field_76 = v29 / v28 + 1; - LABEL_80: - memcpy(v27->m_asActiveSamples, v26, 92); - if(!v27->m_asActiveSamples[0].m_bIsDistant) - TranslateEntity( - &v27->m_asActiveSamples[0] - .m_vecPos, - &a2); - if(field_4) { - if(v27->m_asActiveSamples[0] - .m_bEmittingVolume >= 63u) - v44 = 63; - else - v44 = - v27 - ->m_asActiveSamples - [0] - .m_bEmittingVolume; - v45 = 2 * v44; - } else { - v45 = v27->m_asActiveSamples[0] - .m_bEmittingVolume; - } - if(SampleManager.InitialiseChannel( - l, - v27->m_asActiveSamples[0] - .m_nSampleIndex, - v27->m_asActiveSamples[0] - .m_bBankIndex)) { - SampleManager.SetChannelFrequency( - l, v27->m_asActiveSamples[0] - .m_nFrequency); - cSampleManager - .SetChannelEmittingVolume(l, - v45); - SampleManager.SetChannelLoopPoints( - l, - v27->m_asActiveSamples[0] - .m_nLoopStart, - v27->m_asActiveSamples[0] - .m_nLoopEnd); - SampleManager.SetChannelLoopCount( - l, v27->m_asActiveSamples[0] - .m_nLoopCount); - SampleManager.SetChannelReverbFlag( - l, v27->m_asActiveSamples[0] - .m_bReverbFlag); - if(v27->m_asActiveSamples[0] - .m_bIsDistant) { - v30 = v27->m_asActiveSamples - [0] - .m_bOffset; - if(v30 == 63) { - v31 = 0.0f; - } else if(v30 >= 63u) { - v31 = (v30 - 63) * - 15.873f; - } else { - v31 = -((63 - v30) * - 15.873f); - } - v32 = v31; - v33 = 0.0f; - v34 = 0.0f; - v27->m_asActiveSamples[0] - .m_fSoundIntensity = - 100000.0f; - } else { - v32 = a2.x; - v33 = a2.y; - v34 = a2.z; - } - v35 = v34; - v36 = v33; - v37 = v32; - SampleManager.SetChannel3DPosition( - l, v37, v36, v35); - v38 = 0.25f * - v27->m_asActiveSamples[0] - .m_fSoundIntensity; - cSampleManager - .SetChannel3DDistances( - l, - v27->m_asActiveSamples[0] - .m_fSoundIntensity, - v38); - SampleManager.StartChannel(l); - } - v27->m_asActiveSamples[0].m_bIsProcessed = - 1; - v26->m_bIsProcessed = 1; - v26->field_88 = -1; - break; - } - } - v27 = (v27 + 92); - } - } - } - } -} + #endif bool @@ -3824,25 +3465,235 @@ cAudioManager::ProcessAirportScriptObject(uint8 sound) } } -WRAPPER bool cAudioManager::ProcessBoatEngine(cVehicleParams *params) { - EAXJMP(0x56DE80); + CBoat *boat; + float padRelativeAccerate; + float gasPedal; + int32 padAccelerate; + uint8 emittingVol; + float oneShotVol; + + static uint16 LastAccel = 0; + static uint8 LastVol = 0; + + if(params->m_fDistance < 2500.f) { + boat = (CBoat *)params->m_pVehicle; + if(params->m_nIndex == REEFER) { + CalculateDistance((bool *)params, params->m_fDistance); + m_sQueueSample.m_bVolume = + ComputeVolume(80u, 50.f, m_sQueueSample.m_fDistance); + if(m_sQueueSample.m_bVolume) { + m_sQueueSample.field_4 = 39; + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_MOTOR; + m_sQueueSample.m_nFrequency = 10386; + m_sQueueSample.m_nFrequency += + (m_sQueueSample.m_nEntityIndex << 16) % 1000; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_16 = 3; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_bEmittingVolume = 80; + m_sQueueSample.m_nLoopStart = + SampleManager.GetSampleLoopStartOffset( + m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset( + m_sQueueSample.m_nSampleIndex); + m_sQueueSample.field_48 = 2.0f; + m_sQueueSample.m_fSoundIntensity = 50.0f; + m_sQueueSample.field_56 = 0; + m_sQueueSample.field_76 = 7; + m_sQueueSample.m_bReverbFlag = 1; + m_sQueueSample.m_bRequireReflection = 0; + AddSampleToRequestedQueue(); + } + if(FindPlayerVehicle() == params->m_pVehicle) { + if(Pads[0].GetAccelerate() <= Pads[0].GetBrake()) + padAccelerate = Pads[0].GetBrake(); + else + padAccelerate = Pads[0].GetAccelerate(); + padRelativeAccerate = padAccelerate / 255; + emittingVol = (100.f * padRelativeAccerate) + 15; + m_sQueueSample.m_nFrequency = (3000.f * padRelativeAccerate) + 6000; + if(!boat->m_bIsAnchored) + m_sQueueSample.m_nFrequency = + 11 * m_sQueueSample.m_nFrequency / 10u; + } else { + gasPedal = Abs(boat->m_fGasPedal); + if(gasPedal > 0.0f) { + m_sQueueSample.m_nFrequency = 6000; + emittingVol = 15; + } else { + emittingVol = (100.f * gasPedal) + 15; + m_sQueueSample.m_nFrequency = (3000.f * gasPedal) + 6000; + if(!boat->m_bIsAnchored) + m_sQueueSample.m_nFrequency = + 11 * m_sQueueSample.m_nFrequency / 10u; + } + } + m_sQueueSample.m_bVolume = + ComputeVolume(emittingVol, 50.f, m_sQueueSample.m_fDistance); + if(!m_sQueueSample.m_bVolume) return 1; + m_sQueueSample.field_4 = 40; + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_BOAT_ENGINE; + m_sQueueSample.m_nFrequency += (m_sQueueSample.m_nEntityIndex << 16) % 1000; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_16 = 3; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_bEmittingVolume = emittingVol; + m_sQueueSample.m_nLoopStart = + SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = + SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.field_48 = 2.0f; + m_sQueueSample.m_fSoundIntensity = 50.0f; + m_sQueueSample.field_56 = 0; + m_sQueueSample.field_76 = 7; + m_sQueueSample.m_bReverbFlag = 1; + m_sQueueSample.m_bRequireReflection = 0; + } else { + if(FindPlayerVehicle() == params->m_pVehicle) { + if(Pads[0].GetAccelerate() <= Pads[0].GetBrake()) + padAccelerate = Pads[0].GetBrake(); + else + padAccelerate = Pads[0].GetAccelerate(); + if(padAccelerate <= 20) { + emittingVol = 45 - 45 * padAccelerate / 40; + m_sQueueSample.m_nFrequency = 100 * padAccelerate + 11025; + m_sQueueSample.field_4 = 39; + m_sQueueSample.m_nSampleIndex = + AUDIO_SAMPLE_BOAT_ENGINE_IDLE; + if(LastAccel > 20) { + oneShotVol = LastVol; + PlayOneShot(m_sQueueSample.m_nEntityIndex, SOUND_17, + oneShotVol); + } + } else { + emittingVol = 105 * padAccelerate / 255 + 15; + m_sQueueSample.m_nFrequency = + 4000 * padAccelerate / 255 + 8000; + if(!boat->m_bIsAnchored) + m_sQueueSample.m_nFrequency = + 11 * m_sQueueSample.m_nFrequency / 10u; + m_sQueueSample.field_4 = 40; + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_BOAT_ENGINE; + } + LastVol = emittingVol; + LastAccel = padAccelerate; + } else { + gasPedal = Abs(boat->m_fGasPedal); + if(gasPedal > 0.0f) { + m_sQueueSample.m_nFrequency = 11025; + emittingVol = 45; + m_sQueueSample.field_4 = 39; + m_sQueueSample.m_nSampleIndex = + AUDIO_SAMPLE_BOAT_ENGINE_IDLE; + } else { + emittingVol = (105.f * gasPedal) + 15; + m_sQueueSample.m_nFrequency = (4000.f * gasPedal) + 8000; + if(!boat->m_bIsAnchored) + m_sQueueSample.m_nFrequency = + 11 * m_sQueueSample.m_nFrequency / 10u; + m_sQueueSample.field_4 = 40; + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_BOAT_ENGINE; + } + } + CalculateDistance((bool *)params, params->m_fDistance); + m_sQueueSample.m_bVolume = + ComputeVolume(emittingVol, 50.f, m_sQueueSample.m_fDistance); + if(!m_sQueueSample.m_bVolume) return 1; + m_sQueueSample.m_nFrequency += (m_sQueueSample.m_nEntityIndex << 16) % 1000; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_16 = 3; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_bEmittingVolume = emittingVol; + m_sQueueSample.m_nLoopStart = + SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = + SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.field_48 = 2.0f; + m_sQueueSample.m_fSoundIntensity = 50.0f; + m_sQueueSample.field_56 = 0; + m_sQueueSample.field_76 = 7; + m_sQueueSample.m_bReverbFlag = 1; + m_sQueueSample.m_bRequireReflection = 0; + } + AddSampleToRequestedQueue(); + return 1; + } + return 0; } -WRAPPER bool cAudioManager::ProcessBoatMovingOverWater(cVehicleParams *params) { - EAXJMP(0x56E500); + float velocityChange; + int32 vol; + float multiplier; + + if(params->m_fDistance > 2500.f) return 0; + + velocityChange = Abs(params->m_fVelocityChange); + if(velocityChange <= 0.0005f && params->m_pVehicle->GetPosition().y) return 1; + + velocityChange = min(0.75f, velocityChange); + multiplier = (velocityChange - 0.0005f) * 1.3342f; + CalculateDistance((bool *)params, params->m_fDistance); + vol = (30.f * multiplier); + m_sQueueSample.m_bVolume = ComputeVolume(vol, 50.f, m_sQueueSample.m_fDistance); + if(m_sQueueSample.m_bVolume) { + m_sQueueSample.field_4 = 38; + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_LOOPING_WATER; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_16 = 3; + m_sQueueSample.m_nFrequency = (6050.f * multiplier) + 16000; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_bEmittingVolume = vol; + m_sQueueSample.m_nLoopStart = + SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = + SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.field_48 = 2.0f; + m_sQueueSample.m_fSoundIntensity = 50.0f; + m_sQueueSample.field_56 = 0; + m_sQueueSample.field_76 = 3; + m_sQueueSample.m_bReverbFlag = 1; + m_sQueueSample.m_bRequireReflection = 0; + AddSampleToRequestedQueue(); + } + + return 1; } -WRAPPER void cAudioManager::ProcessBridge() { - EAXJMP(0x5790D0); + float dist; + bool something = false; + + if(CBridge::pLiftRoad) { + m_sQueueSample.m_vecPos = CBridge::pLiftRoad->GetPosition(); + dist = GetDistanceSquared(&m_sQueueSample.m_vecPos); + if(dist < 202500.0f) { + CalculateDistance(&something, dist); + switch(CBridge::State) { + case STATE_BRIDGE_LOCKED: + case STATE_LIFT_PART_IS_UP: + case STATE_LIFT_PART_ABOUT_TO_MOVE_UP: ProcessBridgeWarning(); break; + case STATE_LIFT_PART_MOVING_DOWN: + case STATE_LIFT_PART_MOVING_UP: + ProcessBridgeWarning(); + ProcessBridgeMotor(); + break; + default: break; + } + ProcessBridgeOneShots(); + } + } } void @@ -3873,11 +3724,56 @@ cAudioManager::ProcessBridgeMotor() } } -WRAPPER void cAudioManager::ProcessBridgeOneShots() { - EAXJMP(0x579310); + float maxDist; + + if(CBridge::State != STATE_LIFT_PART_IS_UP || + CBridge::OldState != STATE_LIFT_PART_MOVING_UP) { + if(CBridge::State != STATE_LIFT_PART_IS_DOWN || + CBridge::OldState != STATE_LIFT_PART_MOVING_DOWN) { + if(CBridge::State != STATE_LIFT_PART_MOVING_UP || + CBridge::OldState != STATE_LIFT_PART_ABOUT_TO_MOVE_UP) { + if(CBridge::State != STATE_LIFT_PART_MOVING_DOWN || + CBridge::OldState != STATE_LIFT_PART_IS_UP) + return; + maxDist = 400.f; + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_COLLISION_METAL_27; + } else { + maxDist = 400.f; + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_COLLISION_METAL_27; + } + } else { + maxDist = 400.f; + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_COLLISION_METAL_27; + } + } else { + maxDist = 400.f; + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_COLLISION_METAL_27; + } + if(m_sQueueSample.m_fDistance < maxDist) { + m_sQueueSample.m_bVolume = + ComputeVolume(maxVolume, maxDist, m_sQueueSample.m_fDistance); + if(m_sQueueSample.m_bVolume) { + m_sQueueSample.field_4 = 2; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_16 = 1; + m_sQueueSample.m_nFrequency = + SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopCount = 1; + m_sQueueSample.m_bEmittingVolume = maxVolume; + m_sQueueSample.m_nLoopStart = 0; + m_sQueueSample.m_nLoopEnd = -1; + m_sQueueSample.field_48 = 2.0f; + m_sQueueSample.m_fSoundIntensity = maxDist; + m_sQueueSample.field_56 = 1; + m_sQueueSample.m_bReverbFlag = 0; + m_sQueueSample.m_bRequireReflection = 0; + AddSampleToRequestedQueue(); + } + } } void @@ -3910,11 +3806,40 @@ cAudioManager::ProcessBridgeWarning() } } -WRAPPER bool -cAudioManager::ProcessCarBombTick(void *) +cAudioManager::ProcessCarBombTick(cVehicleParams *params) { - EAXJMP(0x56CC20); + CAutomobile *automobile; + + if(params->m_fDistance >= 1600.f) return 0; + automobile = (CAutomobile *)params->m_pVehicle; + if(automobile->bEngineOn && automobile->m_bombType == CARBOMB_TIMEDACTIVE) { + CalculateDistance((bool *)params, params->m_fDistance); + m_sQueueSample.m_bVolume = ComputeVolume(60u, 40.f, m_sQueueSample.m_fDistance); + if(m_sQueueSample.m_bVolume) { + m_sQueueSample.field_4 = 35; + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_CAR_BOMB_TICK; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_16 = 0; + m_sQueueSample.m_nFrequency = + SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_CAR_BOMB_TICK); + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_bEmittingVolume = 60; + m_sQueueSample.m_nLoopStart = + SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = + SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.field_48 = 2.0; + m_sQueueSample.m_fSoundIntensity = 40.0; + m_sQueueSample.field_56 = 0; + m_sQueueSample.field_76 = 3; + m_sQueueSample.m_bReverbFlag = 1; + m_sQueueSample.m_bRequireReflection = 0; + AddSampleToRequestedQueue(); + } + } + return 1; } WRAPPER @@ -4038,35 +3963,84 @@ cAudioManager::ProcessDocksScriptObject(uint8 sound) } } -void -cAudioManager::ProcessEntity(int32 id) +bool +cAudioManager::ProcessEngineDamage(cVehicleParams *params) { - if(m_asAudioEntities[id].m_bStatus) { - m_sQueueSample.m_nEntityIndex = id; - switch(m_asAudioEntities[id].m_nType) { - case AUDIOTYPE_PHYSICAL: - if(!m_bUserPause) { - m_sQueueSample.m_bReverbFlag = 1; - ProcessPhysical(id); - } - break; - case AUDIOTYPE_EXPLOSION: - if(!m_bUserPause) { - m_sQueueSample.m_bReverbFlag = 1; - ProcessExplosions(id); - } - break; - case AUDIOTYPE_FIRE: - if(!m_bUserPause) { - m_sQueueSample.m_bReverbFlag = 1; - ProcessFires(id); - } - break; - case AUDIOTYPE_WEATHER: - if(!m_bUserPause) { - m_sQueueSample.m_bReverbFlag = 1; - ProcessWeather(id); - } + CAutomobile *veh; + uint8 engineStatus; + uint8 emittingVolume; + + if(params->m_fDistance >= 1600.f) return 0; + veh = (CAutomobile *)params->m_pVehicle; + if(veh->bEngineOn) { + engineStatus = veh->Damage.GetEngineStatus(); + if(engineStatus > 250u || engineStatus < 100u) return 1; + if(engineStatus < 225u) { + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_JUMBO_TAXI_SOUND; + emittingVolume = 6; + m_sQueueSample.field_16 = 7; + m_sQueueSample.m_nFrequency = 40000; + } else { + emittingVolume = 60; + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_FIRE_ENTITY; + m_sQueueSample.field_16 = 7; + m_sQueueSample.m_nFrequency = + SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_FIRE_ENTITY); + } + CalculateDistance((bool *)params, params->m_fDistance); + m_sQueueSample.m_bVolume = + ComputeVolume(emittingVolume, 40.f, m_sQueueSample.m_fDistance); + if(m_sQueueSample.m_bVolume) { + m_sQueueSample.field_4 = 28; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_bEmittingVolume = emittingVolume; + m_sQueueSample.m_nLoopStart = + SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = + SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.field_48 = 2.0; + m_sQueueSample.m_fSoundIntensity = 40.0; + m_sQueueSample.field_56 = 0; + m_sQueueSample.field_76 = 3; + m_sQueueSample.m_bReverbFlag = 1; + m_sQueueSample.m_bRequireReflection = 0; + AddSampleToRequestedQueue(); + } + } + return 1; +} + +void +cAudioManager::ProcessEntity(int32 id) +{ + if(m_asAudioEntities[id].m_bStatus) { + m_sQueueSample.m_nEntityIndex = id; + switch(m_asAudioEntities[id].m_nType) { + case AUDIOTYPE_PHYSICAL: + if(!m_bUserPause) { + m_sQueueSample.m_bReverbFlag = 1; + ProcessPhysical(id); + } + break; + case AUDIOTYPE_EXPLOSION: + if(!m_bUserPause) { + m_sQueueSample.m_bReverbFlag = 1; + ProcessExplosions(id); + } + break; + case AUDIOTYPE_FIRE: + if(!m_bUserPause) { + m_sQueueSample.m_bReverbFlag = 1; + ProcessFires(id); + } + break; + case AUDIOTYPE_WEATHER: + if(!m_bUserPause) { + m_sQueueSample.m_bReverbFlag = 1; + ProcessWeather(id); + } break; case AUDIOTYPE_CRANE: if(!m_bUserPause) { @@ -4406,6 +4380,70 @@ cAudioManager::ProcessGarages() EAXJMP(0x578C20); } +struct tHelicopterSampleData { + float m_fMaxDistance; + float m_fBaseDistance; + char m_bBaseVolume; + char gap_9[3]; +}; + +tHelicopterSampleData *gHeliSfxRanges = (tHelicopterSampleData *)0x604784; + +bool +cAudioManager::ProcessHelicopter(cVehicleParams *params) +{ + CHeli *heli; + float MaxDist; + float dist; + float baseDist; + int32 emittingVol; + + if(gHeliSfxRanges[0].m_fMaxDistance * gHeliSfxRanges[0].m_fMaxDistance <= + params->m_fDistance) + return 0; + + CalculateDistance((bool *)params, params->m_fDistance); + heli = (CHeli *)params->m_pVehicle; + for(uint32 i = 0; i < 3; i++) { + MaxDist = gHeliSfxRanges[i].m_fMaxDistance; + dist = m_sQueueSample.m_fDistance; + if(dist >= MaxDist) return 1; + baseDist = gHeliSfxRanges[i].m_fBaseDistance; + if(dist < baseDist) + emittingVol = (gHeliSfxRanges[i].m_bBaseVolume * + ((MaxDist - dist) / (MaxDist - baseDist))); + else + emittingVol = gHeliSfxRanges[i].m_bBaseVolume; + + m_sQueueSample.m_bVolume = ComputeVolume( + emittingVol, gHeliSfxRanges[i].m_fMaxDistance, m_sQueueSample.m_fDistance); + if(m_sQueueSample.m_bVolume) { + m_sQueueSample.field_4 = i + 65; + m_sQueueSample.m_nSampleIndex = i + AUDIO_SAMPLE_HELI_FAR; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_16 = 0; + m_sQueueSample.m_nFrequency = + 1200 * heli->m_nHeliId + + SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_bEmittingVolume = emittingVol; + m_sQueueSample.m_nLoopStart = + SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = + SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.field_48 = 6.0; + m_sQueueSample.m_fSoundIntensity = gHeliSfxRanges[i].m_fMaxDistance; + m_sQueueSample.field_56 = 0; + m_sQueueSample.field_76 = 3; + m_sQueueSample.m_bReverbFlag = 1; + m_sQueueSample.m_bRequireReflection = 0; + AddSampleToRequestedQueue(); + } + } + return 1; +} + void cAudioManager::ProcessHomeScriptObject(uint8 sound) { @@ -5342,6 +5380,71 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) } } +void +cAudioManager::ProcessModelCarEngine(cVehicleParams *params) +{ + cAudioManager *v2; + CAutomobile *automobile; + float allowedVelocity; + int32 emittingVol; + float velocityChange; + + v2 = this; + if(params->m_fDistance < 900.f) { + automobile = (CAutomobile *)params->m_pVehicle; + if(automobile->bEngineOn) { + if(automobile->m_nWheelsOnGround) { + velocityChange = Abs(params->m_fVelocityChange); + } else { + if(automobile->m_nDriveWheelsOnGround) + automobile->m_fGasPedalAudio = + automobile->m_fGasPedalAudio * 0.4f; + velocityChange = automobile->m_fGasPedalAudio * + params->m_pTransmission->fMaxVelocity; + } + if(velocityChange > 0.001f) { + allowedVelocity = 0.5f * params->m_pTransmission->fMaxVelocity; + if(velocityChange < allowedVelocity) + emittingVol = (90.f * velocityChange / allowedVelocity); + else + emittingVol = 90; + if(emittingVol) { + CalculateDistance((bool *)params, params->m_fDistance); + m_sQueueSample.m_bVolume = ComputeVolume( + emittingVol, 30.f, m_sQueueSample.m_fDistance); + if(m_sQueueSample.m_bVolume) { + m_sQueueSample.field_4 = 2; + m_sQueueSample.m_nSampleIndex = + AUDIO_SAMPLE_MODEL_VEHICLE_ACCELERATING; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_16 = 1; + m_sQueueSample.m_nFrequency = + (11025.f * velocityChange / + params->m_pTransmission->fMaxVelocity + + 11025.f); + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_bEmittingVolume = emittingVol; + m_sQueueSample.m_nLoopStart = + SampleManager.GetSampleLoopStartOffset( + m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = + SampleManager.GetSampleLoopEndOffset( + m_sQueueSample.m_nSampleIndex); + m_sQueueSample.field_48 = 3.0; + m_sQueueSample.m_fSoundIntensity = 30.0; + m_sQueueSample.field_56 = 0; + m_sQueueSample.field_76 = 3; + m_sQueueSample.m_bReverbFlag = 1; + m_sQueueSample.m_bRequireReflection = 0; + AddSampleToRequestedQueue(); + } + } + } + } + } +} + void cAudioManager::ProcessOneShotScriptObject(uint8 sound) { @@ -5395,7 +5498,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) m_anRandomTable[iSound % 5] % 3u + AUDIO_SAMPLE_BULLET_HIT_GROUND_1; m_sQueueSample.m_bBankIndex = 0; m_sQueueSample.m_nFrequency = - cSampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); + SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency >> 5); m_sQueueSample.field_16 = 9; m_sQueueSample.field_48 = 0.0f; @@ -5404,14 +5507,14 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) break; case SCRIPT_SOUND_110: case SCRIPT_SOUND_111: - if(cSampleManager.IsSampleBankLoaded(0) != 1) return; + if(SampleManager.IsSampleBankLoaded(0) != 1) return; maxDist = 6400.f; m_sQueueSample.m_fSoundIntensity = 80.0f; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_389; m_sQueueSample.m_bBankIndex = 0; emittingVolume = 127; m_sQueueSample.m_nFrequency = - cSampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_389); + SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_389); m_sQueueSample.field_16 = 0; m_sQueueSample.field_48 = 2.0f; m_sQueueSample.m_bIsDistant = 0; @@ -5423,7 +5526,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) m_sQueueSample.m_bBankIndex = 0; emittingVolume = 80; m_sQueueSample.m_nFrequency = - cSampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_PAYPHONE_RINGING); + SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_PAYPHONE_RINGING); m_sQueueSample.field_16 = 1; m_sQueueSample.field_48 = 2.0f; m_sQueueSample.m_bIsDistant = 0; @@ -5436,7 +5539,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) m_sQueueSample.m_bBankIndex = 0; emittingVolume = 70; m_sQueueSample.m_nFrequency = - cSampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_GLASS_GENERIC_BREAK); + SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_GLASS_GENERIC_BREAK); m_sQueueSample.field_16 = 3; m_sQueueSample.field_48 = 0.0f; m_sQueueSample.m_bIsDistant = 0; @@ -5448,7 +5551,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) m_sQueueSample.m_bBankIndex = 0; emittingVolume = 60; m_sQueueSample.m_nFrequency = - cSampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_GLASS_GENERIC_BREAK); + SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_GLASS_GENERIC_BREAK); m_sQueueSample.field_16 = 3; m_sQueueSample.field_48 = 0.0f; m_sQueueSample.m_bIsDistant = 0; @@ -5460,7 +5563,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) m_sQueueSample.m_bBankIndex = 0; emittingVolume = 70; m_sQueueSample.m_nFrequency = - cSampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_GLASS_WINDSHIELD_CRACK); + SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_GLASS_WINDSHIELD_CRACK); m_sQueueSample.field_16 = 3; m_sQueueSample.field_48 = 0.0f; m_sQueueSample.m_bIsDistant = 0; @@ -5509,7 +5612,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) m_anRandomTable[3] % 5u + AUDIO_SAMPLE_COLLISION_METAL; m_sQueueSample.m_bBankIndex = 0; m_sQueueSample.m_nFrequency = - cSampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); + SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency >> 4); m_sQueueSample.field_16 = 3; m_sQueueSample.field_48 = 0.0f; @@ -5523,7 +5626,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_COLLISION_RUBBER; m_sQueueSample.m_bBankIndex = 0; m_sQueueSample.m_nFrequency = - cSampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); + SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency >> 4); m_sQueueSample.field_16 = 3; m_sQueueSample.field_48 = 0.0f; @@ -5670,14 +5773,14 @@ cAudioManager::ProcessPedHeadphones(cPedParams *params) m_sQueueSample.m_bBankIndex = 0; m_sQueueSample.m_bIsDistant = 0; m_sQueueSample.field_16 = 5; - m_sQueueSample.m_nFrequency = cSampleManager.GetSampleBaseFrequency( + m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency( AUDIO_SAMPLE_PED_HEADPHONES); m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_bEmittingVolume = emittingVol; m_sQueueSample.m_nLoopStart = - cSampleManager.GetSampleLoopStartOffset( + SampleManager.GetSampleLoopStartOffset( m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = cSampleManager.GetSampleLoopEndOffset( + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset( m_sQueueSample.m_nSampleIndex); m_sQueueSample.field_48 = 4.0f; m_sQueueSample.m_fSoundIntensity = 7.0f; @@ -5704,14 +5807,12 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) int16 sound; char noReflection; CWeapon *weapon; - uint16 i; float maxDist; static uint8 iSound = 21; - i = 0; weapon = nil; - while(i < m_asAudioEntities[m_sQueueSample.m_nEntityIndex].field_24) { + for(uint32 i = 0; i < m_asAudioEntities[m_sQueueSample.m_nEntityIndex].field_24; i++) { noReflection = 0; processed = 0; m_sQueueSample.m_bRequireReflection = 0; @@ -5778,7 +5879,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) m_asAudioEntities[0] .m_awAudioEvent[i + 20 * m_sQueueSample.m_nEntityIndex] - 28; - m_sQueueSample.m_nFrequency = cSampleManager.GetSampleBaseFrequency( + m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency( m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 17u); @@ -5809,7 +5910,6 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) m_sQueueSample.m_bIsDistant = 0; m_sQueueSample.field_56 = 1; m_sQueueSample.m_bRequireReflection = 1; - goto LABEL_84; } break; case SOUND_FALL_LAND: @@ -5829,7 +5929,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) } m_sQueueSample.m_bBankIndex = 0; m_sQueueSample.field_4 = 1; - m_sQueueSample.m_nFrequency = cSampleManager.GetSampleBaseFrequency( + m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency( m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 17u); @@ -5843,55 +5943,232 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) m_sQueueSample.m_bIsDistant = 0; m_sQueueSample.field_56 = 1; m_sQueueSample.m_bRequireReflection = 1; - goto LABEL_84; + break; } break; - case SOUND_21: + case SOUND_FIGHT_PUNCH_33: m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PED_HIT_1; m_sQueueSample.m_nFrequency = 18000; - goto LABEL_81; - case SOUND_22: + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.field_4 = iSound; + processed = 1; + ++iSound; + m_sQueueSample.field_16 = 3; + m_sQueueSample.field_48 = 0.0f; + m_sQueueSample.m_fSoundIntensity = 30.0f; + maxDist = 900.f; + m_sQueueSample.m_nLoopCount = 1; + m_sQueueSample.m_nLoopStart = 0; + emittingVol = m_anRandomTable[3] % 26 + 100; + m_sQueueSample.m_nLoopEnd = -1; + m_sQueueSample.m_bEmittingVolume = emittingVol; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_56 = 1; + m_sQueueSample.m_bRequireReflection = 1; + break; + case SOUND_FIGHT_KICK_34: m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PED_HIT_1; m_sQueueSample.m_nFrequency = 16500; - goto LABEL_81; - case SOUND_23: + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.field_4 = iSound; + processed = 1; + ++iSound; + m_sQueueSample.field_16 = 3; + m_sQueueSample.field_48 = 0.0f; + m_sQueueSample.m_fSoundIntensity = 30.0f; + maxDist = 900.f; + m_sQueueSample.m_nLoopCount = 1; + m_sQueueSample.m_nLoopStart = 0; + emittingVol = m_anRandomTable[3] % 26 + 100; + m_sQueueSample.m_nLoopEnd = -1; + m_sQueueSample.m_bEmittingVolume = emittingVol; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_56 = 1; + m_sQueueSample.m_bRequireReflection = 1; + break; + case SOUND_FIGHT_HEADBUTT_35: m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PED_HIT_1; - goto LABEL_80; - case SOUND_24: + m_sQueueSample.m_nFrequency = 20000; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.field_4 = iSound; + processed = 1; + ++iSound; + m_sQueueSample.field_16 = 3; + m_sQueueSample.field_48 = 0.0f; + m_sQueueSample.m_fSoundIntensity = 30.0f; + maxDist = 900.f; + m_sQueueSample.m_nLoopCount = 1; + m_sQueueSample.m_nLoopStart = 0; + emittingVol = m_anRandomTable[3] % 26 + 100; + m_sQueueSample.m_nLoopEnd = -1; + m_sQueueSample.m_bEmittingVolume = emittingVol; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_56 = 1; + m_sQueueSample.m_bRequireReflection = 1; + break; + case SOUND_FIGHT_PUNCH_36: m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PED_HIT_2; m_sQueueSample.m_nFrequency = 18000; - goto LABEL_81; - case SOUND_25: + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.field_4 = iSound; + processed = 1; + ++iSound; + m_sQueueSample.field_16 = 3; + m_sQueueSample.field_48 = 0.0f; + m_sQueueSample.m_fSoundIntensity = 30.0f; + maxDist = 900.f; + m_sQueueSample.m_nLoopCount = 1; + m_sQueueSample.m_nLoopStart = 0; + emittingVol = m_anRandomTable[3] % 26 + 100; + m_sQueueSample.m_nLoopEnd = -1; + m_sQueueSample.m_bEmittingVolume = emittingVol; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_56 = 1; + m_sQueueSample.m_bRequireReflection = 1; + break; + case SOUND_FIGHT_PUNCH_37: m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PED_HIT_2; m_sQueueSample.m_nFrequency = 16500; - goto LABEL_81; - case SOUND_26: + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.field_4 = iSound; + processed = 1; + ++iSound; + m_sQueueSample.field_16 = 3; + m_sQueueSample.field_48 = 0.0f; + m_sQueueSample.m_fSoundIntensity = 30.0f; + maxDist = 900.f; + m_sQueueSample.m_nLoopCount = 1; + m_sQueueSample.m_nLoopStart = 0; + emittingVol = m_anRandomTable[3] % 26 + 100; + m_sQueueSample.m_nLoopEnd = -1; + m_sQueueSample.m_bEmittingVolume = emittingVol; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_56 = 1; + m_sQueueSample.m_bRequireReflection = 1; + break; + case SOUND_FIGHT_CLOSE_PUNCH_38: m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PED_HIT_2; - goto LABEL_80; - case SOUND_WEAPON_PUNCH_ATTACK: + m_sQueueSample.m_nFrequency = 20000; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.field_4 = iSound; + processed = 1; + ++iSound; + m_sQueueSample.field_16 = 3; + m_sQueueSample.field_48 = 0.0f; + m_sQueueSample.m_fSoundIntensity = 30.0f; + maxDist = 900.f; + m_sQueueSample.m_nLoopCount = 1; + m_sQueueSample.m_nLoopStart = 0; + emittingVol = m_anRandomTable[3] % 26 + 100; + m_sQueueSample.m_nLoopEnd = -1; + m_sQueueSample.m_bEmittingVolume = emittingVol; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_56 = 1; + m_sQueueSample.m_bRequireReflection = 1; + break; + case SOUND_FIGHT_PUNCH_39: m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PED_HIT_3; m_sQueueSample.m_nFrequency = 18000; - goto LABEL_81; - case SOUND_28: + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.field_4 = iSound; + processed = 1; + ++iSound; + m_sQueueSample.field_16 = 3; + m_sQueueSample.field_48 = 0.0f; + m_sQueueSample.m_fSoundIntensity = 30.0f; + maxDist = 900.f; + m_sQueueSample.m_nLoopCount = 1; + m_sQueueSample.m_nLoopStart = 0; + emittingVol = m_anRandomTable[3] % 26 + 100; + m_sQueueSample.m_nLoopEnd = -1; + m_sQueueSample.m_bEmittingVolume = emittingVol; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_56 = 1; + m_sQueueSample.m_bRequireReflection = 1; + break; + case SOUND_FIGHT_PUNCH_OR_KICK_BELOW_40: m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PED_HIT_3; m_sQueueSample.m_nFrequency = 16500; - goto LABEL_81; - case SOUND_29: + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.field_4 = iSound; + processed = 1; + ++iSound; + m_sQueueSample.field_16 = 3; + m_sQueueSample.field_48 = 0.0f; + m_sQueueSample.m_fSoundIntensity = 30.0f; + maxDist = 900.f; + m_sQueueSample.m_nLoopCount = 1; + m_sQueueSample.m_nLoopStart = 0; + emittingVol = m_anRandomTable[3] % 26 + 100; + m_sQueueSample.m_nLoopEnd = -1; + m_sQueueSample.m_bEmittingVolume = emittingVol; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_56 = 1; + m_sQueueSample.m_bRequireReflection = 1; + break; + case SOUND_FIGHT_PUNCH_41: m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PED_HIT_3; - goto LABEL_80; - case SOUND_2A: + m_sQueueSample.m_nFrequency = 20000; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.field_4 = iSound; + processed = 1; + ++iSound; + m_sQueueSample.field_16 = 3; + m_sQueueSample.field_48 = 0.0f; + m_sQueueSample.m_fSoundIntensity = 30.0f; + maxDist = 900.f; + m_sQueueSample.m_nLoopCount = 1; + m_sQueueSample.m_nLoopStart = 0; + emittingVol = m_anRandomTable[3] % 26 + 100; + m_sQueueSample.m_nLoopEnd = -1; + m_sQueueSample.m_bEmittingVolume = emittingVol; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_56 = 1; + m_sQueueSample.m_bRequireReflection = 1; + break; + case SOUND_FIGHT_PUNCH_FROM_BEHIND_42: m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PED_HIT_4; m_sQueueSample.m_nFrequency = 18000; - goto LABEL_81; - case SOUND_2B: + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.field_4 = iSound; + processed = 1; + ++iSound; + m_sQueueSample.field_16 = 3; + m_sQueueSample.field_48 = 0.0f; + m_sQueueSample.m_fSoundIntensity = 30.0f; + maxDist = 900.f; + m_sQueueSample.m_nLoopCount = 1; + m_sQueueSample.m_nLoopStart = 0; + emittingVol = m_anRandomTable[3] % 26 + 100; + m_sQueueSample.m_nLoopEnd = -1; + m_sQueueSample.m_bEmittingVolume = emittingVol; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_56 = 1; + m_sQueueSample.m_bRequireReflection = 1; + break; + case SOUND_FIGHT_KNEE_OR_KICK_43: m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PED_HIT_4; m_sQueueSample.m_nFrequency = 16500; - goto LABEL_81; - case SOUND_2C: + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.field_4 = iSound; + processed = 1; + ++iSound; + m_sQueueSample.field_16 = 3; + m_sQueueSample.field_48 = 0.0f; + m_sQueueSample.m_fSoundIntensity = 30.0f; + maxDist = 900.f; + m_sQueueSample.m_nLoopCount = 1; + m_sQueueSample.m_nLoopStart = 0; + emittingVol = m_anRandomTable[3] % 26 + 100; + m_sQueueSample.m_nLoopEnd = -1; + m_sQueueSample.m_bEmittingVolume = emittingVol; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_56 = 1; + m_sQueueSample.m_bRequireReflection = 1; + break; + case SOUND_FIGHT_KICK_44: m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PED_HIT_4; - LABEL_80: m_sQueueSample.m_nFrequency = 20000; - LABEL_81: m_sQueueSample.m_bBankIndex = 0; m_sQueueSample.field_4 = iSound; processed = 1; @@ -5908,7 +6185,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) m_sQueueSample.m_bIsDistant = 0; m_sQueueSample.field_56 = 1; m_sQueueSample.m_bRequireReflection = 1; - goto LABEL_84; + break; case SOUND_WEAPON_BAT_ATTACK: m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PED_HIT_BY_BAT; m_sQueueSample.m_bBankIndex = 0; @@ -5930,7 +6207,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) m_sQueueSample.m_bRequireReflection = 1; else noReflection = 1; - goto LABEL_84; + break; case SOUND_WEAPON_SHOT_FIRED: weapon = &ped->m_weapons[ped->m_currentWeapon]; switch(weapon->m_eWeaponType) { @@ -5939,7 +6216,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) m_sQueueSample.m_bBankIndex = 0; m_sQueueSample.field_4 = iSound++; processed = 1; - m_sQueueSample.m_nFrequency = cSampleManager.GetSampleBaseFrequency( + m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency( AUDIO_SAMPLE_WEAPON_PISTOL_SHOT); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency >> 5); @@ -5958,13 +6235,13 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) m_sQueueSample.m_bRequireReflection = 1; else noReflection = 1; - goto LABEL_84; + break; case WEAPONTYPE_UZI: m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_WEAPON_UZI_SHOT; m_sQueueSample.m_bBankIndex = 0; m_sQueueSample.field_4 = iSound++; processed = 1; - m_sQueueSample.m_nFrequency = cSampleManager.GetSampleBaseFrequency( + m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency( AUDIO_SAMPLE_WEAPON_UZI_SHOT); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency >> 5); @@ -5979,13 +6256,13 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) m_sQueueSample.m_bEmittingVolume = emittingVol; m_sQueueSample.m_bIsDistant = 0; m_sQueueSample.field_56 = 1; - goto LABEL_84; + break; case WEAPONTYPE_SHOTGUN: m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_WEAPON_SHOTGUN_SHOT; m_sQueueSample.m_bBankIndex = 0; m_sQueueSample.field_4 = iSound++; processed = 1; - m_sQueueSample.m_nFrequency = cSampleManager.GetSampleBaseFrequency( + m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency( AUDIO_SAMPLE_WEAPON_SHOTGUN_SHOT); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency >> 5); @@ -6004,13 +6281,13 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) m_sQueueSample.m_bRequireReflection = 1; else noReflection = 1; - goto LABEL_84; + break; case WEAPONTYPE_AK47: m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_WEAPON_CHAINGUN_SHOT; m_sQueueSample.m_bBankIndex = 0; m_sQueueSample.field_4 = iSound++; processed = 1; - m_sQueueSample.m_nFrequency = cSampleManager.GetSampleBaseFrequency( + m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency( AUDIO_SAMPLE_WEAPON_CHAINGUN_SHOT); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency >> 5); @@ -6025,13 +6302,13 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) m_sQueueSample.m_bEmittingVolume = emittingVol; m_sQueueSample.m_bIsDistant = 0; m_sQueueSample.field_56 = 1; - goto LABEL_84; + break; case WEAPONTYPE_M16: m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_WEAPON_M16_SHOT; m_sQueueSample.m_bBankIndex = 0; m_sQueueSample.field_4 = iSound++; processed = 1; - m_sQueueSample.m_nFrequency = cSampleManager.GetSampleBaseFrequency( + m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency( AUDIO_SAMPLE_WEAPON_M16_SHOT); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency >> 5); @@ -6046,13 +6323,13 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) m_sQueueSample.m_bEmittingVolume = emittingVol; m_sQueueSample.m_bIsDistant = 0; m_sQueueSample.field_56 = 1; - goto LABEL_84; + break; case WEAPONTYPE_SNIPERRIFLE: m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_WEAPON_SNIPER_SHOT; m_sQueueSample.m_bBankIndex = 0; m_sQueueSample.field_4 = iSound++; processed = 1; - m_sQueueSample.m_nFrequency = cSampleManager.GetSampleBaseFrequency( + m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency( AUDIO_SAMPLE_WEAPON_SNIPER_SHOT); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency >> 5); @@ -6071,13 +6348,13 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) m_sQueueSample.m_bRequireReflection = 1; else noReflection = 1; - goto LABEL_84; + break; case WEAPONTYPE_ROCKETLAUNCHER: m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_WEAPON_ROCKET_SHOT; m_sQueueSample.m_bBankIndex = 0; m_sQueueSample.field_4 = iSound++; processed = 1; - m_sQueueSample.m_nFrequency = cSampleManager.GetSampleBaseFrequency( + m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency( AUDIO_SAMPLE_WEAPON_ROCKET_SHOT); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency >> 5); @@ -6096,7 +6373,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) m_sQueueSample.m_bRequireReflection = 1; else noReflection = 1; - goto LABEL_84; + break; case WEAPONTYPE_FLAMETHROWER: m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_WEAPON_FLAMETHROWER_SHOT; @@ -6105,7 +6382,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) emittingVol = 90; m_sQueueSample.m_nFrequency = (10 * m_sQueueSample.m_nEntityIndex & 2047) + - cSampleManager.GetSampleBaseFrequency( + SampleManager.GetSampleBaseFrequency( AUDIO_SAMPLE_WEAPON_FLAMETHROWER_SHOT); m_sQueueSample.field_16 = 3; m_sQueueSample.field_48 = 4.0f; @@ -6113,9 +6390,9 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) maxDist = 3600.f; m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nLoopStart = - cSampleManager.GetSampleLoopStartOffset( + SampleManager.GetSampleLoopStartOffset( m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = cSampleManager.GetSampleLoopEndOffset( + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset( m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_bEmittingVolume = 90; m_sQueueSample.m_bIsDistant = 0; @@ -6125,8 +6402,8 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) m_sQueueSample.m_bRequireReflection = 1; else noReflection = 1; - goto LABEL_84; - default: goto LABEL_100; + break; + default: continue; } break; @@ -6139,57 +6416,133 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) m_sQueueSample.field_4 = iSound++; processed = 1; m_sQueueSample.m_nFrequency = - cSampleManager.GetSampleBaseFrequency( + SampleManager.GetSampleBaseFrequency( AUDIO_SAMPLE_WEAPON_PISTOL_RELOAD) + RandomDisplacement(300u); - goto LABEL_63; + m_sQueueSample.m_nFrequency += RandomDisplacement(300u); + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.field_16 = 5; + m_sQueueSample.field_48 = 0.0f; + m_sQueueSample.m_fSoundIntensity = 30.0f; + maxDist = 900.f; + m_sQueueSample.m_nLoopCount = 1; + m_sQueueSample.m_nLoopStart = 0; + m_sQueueSample.m_nLoopEnd = -1; + m_sQueueSample.m_bEmittingVolume = 75; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_56 = 1; + m_sQueueSample.m_bRequireReflection = 1; + break; case WEAPONTYPE_UZI: m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_WEAPON_UZI_RELOAD; emittingVol = 75; m_sQueueSample.field_4 = iSound++; processed = 1; m_sQueueSample.m_nFrequency = 39243; - goto LABEL_63; + m_sQueueSample.m_nFrequency += RandomDisplacement(300u); + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.field_16 = 5; + m_sQueueSample.field_48 = 0.0f; + m_sQueueSample.m_fSoundIntensity = 30.0f; + maxDist = 900.f; + m_sQueueSample.m_nLoopCount = 1; + m_sQueueSample.m_nLoopStart = 0; + m_sQueueSample.m_nLoopEnd = -1; + m_sQueueSample.m_bEmittingVolume = 75; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_56 = 1; + m_sQueueSample.m_bRequireReflection = 1; + break; case WEAPONTYPE_SHOTGUN: m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_WEAPON_CHAINGUN_RELOAD; emittingVol = 75; m_sQueueSample.field_4 = iSound++; processed = 1; m_sQueueSample.m_nFrequency = 30290; - goto LABEL_63; + m_sQueueSample.m_nFrequency += RandomDisplacement(300u); + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.field_16 = 5; + m_sQueueSample.field_48 = 0.0f; + m_sQueueSample.m_fSoundIntensity = 30.0f; + maxDist = 900.f; + m_sQueueSample.m_nLoopCount = 1; + m_sQueueSample.m_nLoopStart = 0; + m_sQueueSample.m_nLoopEnd = -1; + m_sQueueSample.m_bEmittingVolume = 75; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_56 = 1; + m_sQueueSample.m_bRequireReflection = 1; + break; case WEAPONTYPE_AK47: m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_WEAPON_CHAINGUN_RELOAD; emittingVol = 75; m_sQueueSample.field_4 = iSound++; processed = 1; - m_sQueueSample.m_nFrequency = cSampleManager.GetSampleBaseFrequency( + m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency( AUDIO_SAMPLE_WEAPON_CHAINGUN_RELOAD); - goto LABEL_62; + m_sQueueSample.m_nFrequency += RandomDisplacement(300u); + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.field_16 = 5; + m_sQueueSample.field_48 = 0.0f; + m_sQueueSample.m_fSoundIntensity = 30.0f; + maxDist = 900.f; + m_sQueueSample.m_nLoopCount = 1; + m_sQueueSample.m_nLoopStart = 0; + m_sQueueSample.m_nLoopEnd = -1; + m_sQueueSample.m_bEmittingVolume = 75; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_56 = 1; + m_sQueueSample.m_bRequireReflection = 1; + break; case WEAPONTYPE_M16: m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_WEAPON_UZI_RELOAD; emittingVol = 75; m_sQueueSample.field_4 = iSound++; processed = 1; - m_sQueueSample.m_nFrequency = cSampleManager.GetSampleBaseFrequency( + m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency( AUDIO_SAMPLE_WEAPON_UZI_RELOAD); - goto LABEL_62; + m_sQueueSample.m_nFrequency += RandomDisplacement(300u); + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.field_16 = 5; + m_sQueueSample.field_48 = 0.0f; + m_sQueueSample.m_fSoundIntensity = 30.0f; + maxDist = 900.f; + m_sQueueSample.m_nLoopCount = 1; + m_sQueueSample.m_nLoopStart = 0; + m_sQueueSample.m_nLoopEnd = -1; + m_sQueueSample.m_bEmittingVolume = 75; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_56 = 1; + m_sQueueSample.m_bRequireReflection = 1; + break; case WEAPONTYPE_SNIPERRIFLE: m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_WEAPON_SNIPER_RELOAD; emittingVol = 75; m_sQueueSample.field_4 = iSound++; processed = 1; - m_sQueueSample.m_nFrequency = cSampleManager.GetSampleBaseFrequency( + m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency( AUDIO_SAMPLE_WEAPON_SNIPER_RELOAD); - goto LABEL_62; + m_sQueueSample.m_nFrequency += RandomDisplacement(300u); + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.field_16 = 5; + m_sQueueSample.field_48 = 0.0f; + m_sQueueSample.m_fSoundIntensity = 30.0f; + maxDist = 900.f; + m_sQueueSample.m_nLoopCount = 1; + m_sQueueSample.m_nLoopStart = 0; + m_sQueueSample.m_nLoopEnd = -1; + m_sQueueSample.m_bEmittingVolume = 75; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_56 = 1; + m_sQueueSample.m_bRequireReflection = 1; + break; case WEAPONTYPE_ROCKETLAUNCHER: m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_WEAPON_ROCKET_RELOAD; emittingVol = 75; m_sQueueSample.field_4 = iSound++; processed = 1; - m_sQueueSample.m_nFrequency = cSampleManager.GetSampleBaseFrequency( + m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency( AUDIO_SAMPLE_WEAPON_ROCKET_RELOAD); - LABEL_62: - LABEL_63: m_sQueueSample.m_nFrequency += RandomDisplacement(300u); m_sQueueSample.m_bBankIndex = 0; m_sQueueSample.field_16 = 5; @@ -6203,10 +6556,9 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) m_sQueueSample.m_bIsDistant = 0; m_sQueueSample.field_56 = 1; m_sQueueSample.m_bRequireReflection = 1; - goto LABEL_84; - default: goto LABEL_100; + break; + default: continue; } - break; case SOUND_WEAPON_AK47_BULLET_ECHO: case SOUND_WEAPON_UZI_BULLET_ECHO: @@ -6216,7 +6568,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) m_sQueueSample.field_4 = iSound++; processed = 1; m_sQueueSample.m_nFrequency = - cSampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_75); + SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_75); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency >> 4); m_sQueueSample.field_16 = 3; @@ -6234,12 +6586,12 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) m_sQueueSample.m_bRequireReflection = 1; else noReflection = 1; - goto LABEL_84; + break; case SOUND_WEAPON_FLAMETHROWER_FIRE: m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_WEAPON_FLAMETHROWER_FIRE; m_sQueueSample.m_bBankIndex = 0; m_sQueueSample.field_4 = iSound++; - m_sQueueSample.m_nFrequency = cSampleManager.GetSampleBaseFrequency( + m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency( AUDIO_SAMPLE_WEAPON_FLAMETHROWER_FIRE); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency >> 4); @@ -6254,14 +6606,14 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) m_sQueueSample.m_bEmittingVolume = 70; m_sQueueSample.m_bIsDistant = 0; m_sQueueSample.field_56 = 1; - goto LABEL_84; + break; case SOUND_WEAPON_HIT_PED: m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_BULLET_HIT_PED; m_sQueueSample.m_bBankIndex = 0; m_sQueueSample.field_4 = iSound++; processed = 1; m_sQueueSample.m_nFrequency = - cSampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_BULLET_HIT_PED); + SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_BULLET_HIT_PED); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency >> 3); m_sQueueSample.field_16 = 7; @@ -6275,7 +6627,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) m_sQueueSample.m_bEmittingVolume = emittingVol; m_sQueueSample.m_bIsDistant = 0; m_sQueueSample.field_56 = 1; - goto LABEL_84; + break; case SOUND_SPLASH: m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_COLLISION_WATER; m_sQueueSample.m_bBankIndex = 0; @@ -6294,7 +6646,11 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) m_sQueueSample.m_bIsDistant = 0; m_sQueueSample.field_56 = 1; m_sQueueSample.m_bRequireReflection = 1; - LABEL_84: + break; + default: + SetupPedComments(params, sound); + continue; + if(processed && iSound > 60u) iSound = 21; if(params->m_fDistance < maxDist) { CalculateDistance((bool *)params, params->m_fDistance); @@ -6331,11 +6687,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) } } } - break; - default: SetupPedComments(params, sound); break; } - LABEL_100: - ++i; } } @@ -6356,11 +6708,318 @@ cAudioManager::ProcessPhysical(int32 id) } } -WRAPPER void -cAudioManager::ProcessPlane(void *ptr) +cAudioManager::ProcessPlane(cVehicleParams *params) { - EAXJMP(0x56E860); + switch(params->m_nIndex) { + case AIRTRAIN: ProcessJumbo(params); break; + case DEADDODO: ProcessCesna(params); break; + default: debug("Plane Model Id is %d\n, ", params->m_pVehicle->m_modelIndex); break; + } +} + +struct tVehicleSampleData { + eAudioSamples m_nAccelerationSampleIndex; + char m_bEngineSoundType; + char gap_5[3]; + eAudioSamples m_nHornSample; + int m_nHornFrequency; + char m_nSirenOrAlarmSample; + int m_nSirenOrAlarmFrequency; + char m_bDoorType; + char gap_25[3]; +}; + +int32 *CSWTCH_554 = (int32 *)0x606A50; +tVehicleSampleData *vehicleSampleData = (tVehicleSampleData *)0x606204; + +void +cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile *automobile) +{ + cTransmission *transmission; + float velocityChange; + float relativeVelocityChange; + float accelerationMultipler; + uint8 wheelInUseCounter; + uint8 i; + float time; + uint32 freq4; + int baseFreq; + uint8 vol; + unsigned int freq5; + int gearNr; + int freq; + unsigned int freq3; + unsigned int freq2; + + int freqModifier; + int soundOffset; + uint8 engineSoundType; + int32 accelerateState; + bool channelUsed; + char lostTraction; + bool processedAccelSampleStopped; + uint8 currentGear; + float gasPedalAudio; + CVector pos; + + static uint16 LastAccel = 0; + static uint16 LastBrake = 0; + static uint8 CurrentPretendGear = 1; + static bool bLostTractionLastFrame = 0; + static bool bHandbrakeOnLastFrame = 0; + static uint32 nCruising = 0; + static uint8 bAccelSampleStopped = 1; + + lostTraction = 0; + processedAccelSampleStopped = 0; + if(bPlayerJustEnteredCar) { + bAccelSampleStopped = 1; + bPlayerJustEnteredCar = 0; + nCruising = 0; + LastAccel = 0; + bLostTractionLastFrame = 0; + LastBrake = 0; + bHandbrakeOnLastFrame = 0; + CurrentPretendGear = 1; + } + if(CReplay::IsPlayingBack()) { + accelerateState = 255.f * max(0.0f, min(1.0f, automobile->m_fGasPedal)); + } else { + accelerateState = Pads->GetAccelerate(); + } + channelUsed = SampleManager.GetChannelUsedFlag(m_bActiveSamples); + transmission = params->m_pTransmission; + velocityChange = params->m_fVelocityChange; + relativeVelocityChange = 2.0f * velocityChange / transmission->fMaxVelocity; + + accelerationMultipler = 0.0f; + + if(relativeVelocityChange > 1.0f) accelerationMultipler = relativeVelocityChange; + + gasPedalAudio = accelerationMultipler; + currentGear = params->m_pVehicle->m_nCurrentGear; + if(transmission->nDriveType == '4') { + wheelInUseCounter = 0; + i = 0; + do { + if(automobile->m_aWheelState[i]) ++wheelInUseCounter; + ++i; + } while(i < 4u); + if(wheelInUseCounter > 2u) lostTraction = 1; + } else if(transmission->nDriveType == 'F') { + if((automobile->m_aWheelState[0] || automobile->m_aWheelState[2]) && + (automobile->m_aWheelState[1] || automobile->m_aWheelState[3])) { + lostTraction = 1; + } + } else if(transmission->nDriveType == 'R' && + (automobile->m_aWheelState[1] || automobile->m_aWheelState[3])) { + lostTraction = 1; + } + if(0.0f != velocityChange) { // ok + time = params->m_pVehicle->m_vecMoveSpeed.z / velocityChange; + if(time <= 0.0f) { + freqModifier = max(-0.2f, time) * -15000.f; + } else { + freqModifier = -(min(0.2f, time) * 15000.f); + } + if(params->m_fVelocityChange < -0.001f) freqModifier = -freqModifier; // ok + } else { + freqModifier = 0; + } + engineSoundType = vehicleSampleData[params->m_nIndex].m_bEngineSoundType; + soundOffset = 3 * (engineSoundType - 1); + if(accelerateState <= 0) { + if(params->m_fVelocityChange < -0.001f) { + if(channelUsed) { + SampleManager.StopChannel(m_bActiveSamples); + bAccelSampleStopped = 1; + } + if(!automobile->m_nWheelsOnGround || automobile->bIsHandbrakeOn || + lostTraction) { + gasPedalAudio = automobile->m_fGasPedalAudio; + } else { + gasPedalAudio = min( + 1.0f, params->m_fVelocityChange / + params->m_pTransmission->fMaxReverseVelocity); // ok + } + gasPedalAudio = max(0.0f, gasPedalAudio); // ok + automobile->m_fGasPedalAudio = gasPedalAudio; + } else if(LastAccel > 0) { + if(channelUsed) { + SampleManager.StopChannel(m_bActiveSamples); + bAccelSampleStopped = 1; + } + nCruising = 0; + if(!automobile->m_nWheelsOnGround || automobile->bIsHandbrakeOn || + lostTraction || + params->m_fVelocityChange >= 0.01f && + automobile->m_fGasPedalAudio > 0.2f) { + automobile->m_fGasPedalAudio = automobile->m_fGasPedalAudio * 0.6f; + gasPedalAudio = automobile->m_fGasPedalAudio; + } + if(gasPedalAudio > 0.05) { // ok + freq3 = (5000.f * (gasPedalAudio - 0.05f) * 20.f / 19) + 19000; + if(engineSoundType == 6) freq3 >>= 1; + AddPlayerCarSample( + (25.f * (gasPedalAudio - 0.05f) * 20.f / 19) + 40, freq3, + (soundOffset + AUDIO_SAMPLE_VEHICLE_ENGINE_STOPPING_GENERIC), + engineSoundType, 63u, 0); + } + } + freq2 = (10000.f * gasPedalAudio) + 22050; + if(engineSoundType == 6) freq2 >>= 1; + AddPlayerCarSample(110 - (40.f * gasPedalAudio), freq2, + (engineSoundType + AUDIO_SAMPLE_VEHICLE_ENGINE_IDLE_NONE), 0, + 52u, 1); + + CurrentPretendGear = max(1, currentGear); + LastAccel = accelerateState; + + bHandbrakeOnLastFrame = automobile->bIsHandbrakeOn; + bLostTractionLastFrame = lostTraction; + return; + } + if(nCruising) { + if(accelerateState < 150 || !automobile->m_nWheelsOnGround || + automobile->bIsHandbrakeOn || lostTraction || + currentGear < 2u && + velocityChange - automobile->m_fVelocityChangeForAudio >= 0.01f) { + if(!automobile->m_nWheelsOnGround || automobile->bIsHandbrakeOn || + lostTraction) { + if(!automobile->m_nWheelsOnGround && + automobile->m_nDriveWheelsOnGround || + (automobile->bIsHandbrakeOn && !bHandbrakeOnLastFrame || + lostTraction && !bLostTractionLastFrame) && + automobile->m_nWheelsOnGround) { + automobile->m_fGasPedalAudio = + automobile->m_fGasPedalAudio * 0.6f; + } + freqModifier = 0; + baseFreq = (15000.f * automobile->m_fGasPedalAudio) + 14000; + vol = (25.0f * automobile->m_fGasPedalAudio) + 60; + } else { + baseFreq = (8000.f * accelerationMultipler) + 16000; + vol = (25.0f * accelerationMultipler) + 60; + automobile->m_fGasPedalAudio = accelerationMultipler; + } + freq5 = freqModifier + baseFreq; + if(engineSoundType == 6) freq5 >>= 1; + if(channelUsed) { + SampleManager.StopChannel(m_bActiveSamples); + bAccelSampleStopped = 1; + } + AddPlayerCarSample(vol, freq5, + (engineSoundType + AUDIO_SAMPLE_PAYPHONE_RINGING), 0, 2u, + 1); + LastAccel = accelerateState; + + bHandbrakeOnLastFrame = automobile->bIsHandbrakeOn; + bLostTractionLastFrame = lostTraction; + return; + } + TranslateEntity(&m_sQueueSample.m_vecPos, &pos); + if(bAccelSampleStopped) { + if(CurrentPretendGear != 1 || currentGear != 2) { + gearNr = currentGear - 1; + if(gearNr < 1) gearNr = 1; + CurrentPretendGear = gearNr; + } + processedAccelSampleStopped = 1; + bAccelSampleStopped = 0; + } + if(channelUsed) { + SampleManager.SetChannelEmittingVolume(m_bActiveSamples, 85u); + SampleManager.SetChannel3DPosition(m_bActiveSamples, pos.x, pos.y, pos.z); + SampleManager.SetChannel3DDistances(m_bActiveSamples, 50.f, 12.5f); + if(engineSoundType == 6) + freq = (CSWTCH_554[CurrentPretendGear] + freqModifier + 22050) >> 1; + else + freq = CSWTCH_554[CurrentPretendGear] + freqModifier + 22050; + SampleManager.SetChannelFrequency(m_bActiveSamples, freq); + if(!channelUsed) { + SampleManager.SetChannelReverbFlag( + m_bActiveSamples, m_bDynamicAcousticModelingStatus != 0); + SampleManager.StartChannel(m_bActiveSamples); + } + LastAccel = accelerateState; + + bHandbrakeOnLastFrame = automobile->bIsHandbrakeOn; + bLostTractionLastFrame = lostTraction; + return; + } + if(processedAccelSampleStopped) { + if(!SampleManager.InitialiseChannel(m_bActiveSamples, soundOffset + 345, 0)) + return; + SampleManager.SetChannelLoopCount(m_bActiveSamples, 1); + SampleManager.SetChannelLoopPoints(m_bActiveSamples, 0, -1); + SampleManager.SetChannelEmittingVolume(m_bActiveSamples, 85u); + SampleManager.SetChannel3DPosition(m_bActiveSamples, pos.x, pos.y, pos.z); + SampleManager.SetChannel3DDistances(m_bActiveSamples, 50.f, 12.5f); + if(engineSoundType == 6) + freq = (CSWTCH_554[CurrentPretendGear] + freqModifier + 22050) >> 1; + else + freq = CSWTCH_554[CurrentPretendGear] + freqModifier + 22050; + SampleManager.SetChannelFrequency(m_bActiveSamples, freq); + if(!channelUsed) { + SampleManager.SetChannelReverbFlag( + m_bActiveSamples, m_bDynamicAcousticModelingStatus != 0); + SampleManager.StartChannel(m_bActiveSamples); + } + LastAccel = accelerateState; + + bHandbrakeOnLastFrame = automobile->bIsHandbrakeOn; + bLostTractionLastFrame = lostTraction; + return; + } + if(CurrentPretendGear < params->m_pTransmission->nNumberOfGears - 1) { + ++CurrentPretendGear; + if(!SampleManager.InitialiseChannel(m_bActiveSamples, soundOffset + 345, 0)) + return; + SampleManager.SetChannelLoopCount(m_bActiveSamples, 1); + SampleManager.SetChannelLoopPoints(m_bActiveSamples, 0, -1); + SampleManager.SetChannelEmittingVolume(m_bActiveSamples, 85u); + SampleManager.SetChannel3DPosition(m_bActiveSamples, pos.x, pos.y, pos.z); + SampleManager.SetChannel3DDistances(m_bActiveSamples, 50.f, 12.5f); + if(engineSoundType == 6) + freq = (CSWTCH_554[CurrentPretendGear] + freqModifier + 22050) >> 1; + else + freq = CSWTCH_554[CurrentPretendGear] + freqModifier + 22050; + SampleManager.SetChannelFrequency(m_bActiveSamples, freq); + if(!channelUsed) { + SampleManager.SetChannelReverbFlag( + m_bActiveSamples, m_bDynamicAcousticModelingStatus != 0); + SampleManager.StartChannel(m_bActiveSamples); + } + LastAccel = accelerateState; + + bHandbrakeOnLastFrame = automobile->bIsHandbrakeOn; + bLostTractionLastFrame = lostTraction; + return; + } + nCruising = 1; + } + bAccelSampleStopped = 1; + if(accelerateState < 150 || !automobile->m_nWheelsOnGround || automobile->bIsHandbrakeOn || + lostTraction || currentGear < params->m_pTransmission->nNumberOfGears - 1) { + nCruising = 0; + } else { + if(accelerateState >= 220 && + 0.001f + params->m_fVelocityChange < automobile->m_fVelocityChangeForAudio) { + if(nCruising < 800) ++nCruising; + } else if(nCruising > 3) { + --nCruising; + } + freq4 = 27 * nCruising + freqModifier + 22050; + if(engineSoundType == 6) freq4 >>= 1; + AddPlayerCarSample(85u, freq4, + (soundOffset + AUDIO_SAMPLE_VEHICLE_ENGINE_CHANGE_GEAR_GENERIC), + engineSoundType, 64u, 1); + } + LastAccel = accelerateState; + + bHandbrakeOnLastFrame = automobile->bIsHandbrakeOn; + bLostTractionLastFrame = lostTraction; } WRAPPER @@ -6490,6 +7149,47 @@ cAudioManager::ProcessProjectiles() EAXJMP(0x578A80); } +void +cAudioManager::ProcessRainOnVehicle(cVehicleParams *params) +{ + float emittingVol; + CVehicle *veh; + + if(params->m_fDistance < 484.f && CWeather::Rain > 0.01f && + (!CCullZones::CamNoRain() || !CCullZones::PlayerNoRain())) { + ++params->m_pVehicle->m_bRainAudioCounter; + veh = params->m_pVehicle; + if(veh->m_bRainAudioCounter >= 2u) { + veh->m_bRainAudioCounter = 0; + CalculateDistance((bool *)params, params->m_fDistance); + emittingVol = 30.f * CWeather::Rain; + m_sQueueSample.m_bVolume = + ComputeVolume(emittingVol, 22.f, m_sQueueSample.m_fDistance); + if(m_sQueueSample.m_bVolume) { + m_sQueueSample.field_4 = veh->m_bRainSamplesCounter++; + veh = params->m_pVehicle; + if(veh->m_bRainSamplesCounter > 4u) veh->m_bRainSamplesCounter = 68; + m_sQueueSample.m_nSampleIndex = + (m_anRandomTable[1] & 3) + AUDIO_SAMPLE_RAIN_ON_VEHICLE_1; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_16 = 9; + m_sQueueSample.m_nFrequency = m_anRandomTable[1] % 4000u + 28000; + m_sQueueSample.m_nLoopCount = 1; + m_sQueueSample.m_bEmittingVolume = (uint8)emittingVol; + m_sQueueSample.m_nLoopStart = 0; + m_sQueueSample.m_nLoopEnd = -1; + m_sQueueSample.field_48 = 0.0; + m_sQueueSample.m_fSoundIntensity = 22.0; + m_sQueueSample.field_56 = 1; + m_sQueueSample.m_bReverbFlag = 0; + m_sQueueSample.m_bRequireReflection = 0; + AddSampleToRequestedQueue(); + } + } + } +} + void cAudioManager::ProcessSawMillScriptObject(uint8 sound) { @@ -7089,14 +7789,21 @@ InjectHook(0x575510, &cAudioManager::GetGenericFemaleTalkSfx, PATCH_JUMP); // InjectHook(0x57BA60, &cAudioManager::ProcessActiveQueues, PATCH_JUMP); InjectHook(0x56C940, &cAudioManager::ProcessAirBrakes, PATCH_JUMP); InjectHook(0x577B30, &cAudioManager::ProcessAirportScriptObject, PATCH_JUMP); +InjectHook(0x56DE80, &cAudioManager::ProcessBoatEngine, PATCH_JUMP); +InjectHook(0x56E500, &cAudioManager::ProcessBoatMovingOverWater, PATCH_JUMP); +InjectHook(0x5790D0, &cAudioManager::ProcessBridge, PATCH_JUMP); InjectHook(0x579250, &cAudioManager::ProcessBridgeMotor, PATCH_JUMP); +InjectHook(0x579310, &cAudioManager::ProcessBridgeOneShots, PATCH_JUMP); InjectHook(0x579170, &cAudioManager::ProcessBridgeWarning, PATCH_JUMP); +InjectHook(0x56CC20, &cAudioManager::ProcessCarBombTick, PATCH_JUMP); InjectHook(0x577CA0, &cAudioManager::ProcessCinemaScriptObject, PATCH_JUMP); InjectHook(0x577E50, &cAudioManager::ProcessDocksScriptObject, PATCH_JUMP); +InjectHook(0x56CAF0, &cAudioManager::ProcessEngineDamage, PATCH_JUMP); InjectHook(0x569870, &cAudioManager::ProcessEntity, PATCH_JUMP); InjectHook(0x575AC0, &cAudioManager::ProcessExplosions, PATCH_JUMP); InjectHook(0x578FD0, &cAudioManager::ProcessFireHydrant, PATCH_JUMP); InjectHook(0x5785E0, &cAudioManager::ProcessFrontEnd, PATCH_JUMP); +InjectHook(0x56E6A0, &cAudioManager::ProcessHelicopter, PATCH_JUMP); InjectHook(0x577FE0, &cAudioManager::ProcessHomeScriptObject, PATCH_JUMP); InjectHook(0x56E8F0, &cAudioManager::ProcessJumbo, PATCH_JUMP); InjectHook(0x56EA40, &cAudioManager::ProcessJumboAccel, PATCH_JUMP); @@ -7107,12 +7814,16 @@ InjectHook(0x56EC00, &cAudioManager::ProcessJumboTakeOff, PATCH_JUMP); InjectHook(0x56EA10, &cAudioManager::ProcessJumboTaxi, PATCH_JUMP); InjectHook(0x5777E0, &cAudioManager::ProcessLaunderetteScriptObject, PATCH_JUMP); InjectHook(0x576770, &cAudioManager::ProcessLoopingScriptObject, PATCH_JUMP); +InjectHook(0x56A050, &cAudioManager::ProcessModelCarEngine, PATCH_JUMP); InjectHook(0x5760C0, &cAudioManager::ProcessOneShotScriptObject, PATCH_JUMP); InjectHook(0x56F450, &cAudioManager::ProcessPed, PATCH_JUMP); InjectHook(0x56F4D0, &cAudioManager::ProcessPedHeadphones, PATCH_JUMP); InjectHook(0x56F650, &cAudioManager::ProcessPedOneShots, PATCH_JUMP); InjectHook(0x5699C0, &cAudioManager::ProcessPhysical, PATCH_JUMP); +InjectHook(0x56E860, &cAudioManager::ProcessPlane, PATCH_JUMP); +InjectHook(0x56B0D0, &cAudioManager::ProcessPlayersVehicleEngine, PATCH_JUMP); InjectHook(0x577280, &cAudioManager::ProcessPornCinema, PATCH_JUMP); +InjectHook(0x569CC0, &cAudioManager::ProcessRainOnVehicle, PATCH_JUMP); InjectHook(0x577630, &cAudioManager::ProcessSawMillScriptObject, PATCH_JUMP); InjectHook(0x576070, &cAudioManager::ProcessScriptObject, PATCH_JUMP); InjectHook(0x577970, &cAudioManager::ProcessShopScriptObject, PATCH_JUMP); diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index 5b74cc16..12e823b7 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -72,6 +72,7 @@ enum eAudioType : int32 { }; class CPhysical; +class CAutomobile; class tAudioEntity { @@ -112,7 +113,7 @@ public: uint8 activeBank; uint8 gap_1163[1]; - void Add(tPedComment *com); // test + void Add(tPedComment *com); /// ok }; static_assert(sizeof(cPedComments) == 1164, "cPedComments: error"); @@ -191,8 +192,7 @@ public: static_assert(sizeof(cAudioScriptObject) == 20, "cAudioScriptObject: error"); -enum -{ +enum { /* REFLECTION_YMAX = 0, top REFLECTION_YMIN = 1, bottom @@ -209,6 +209,7 @@ enum MAX_REFLECTIONS, }; +<<<<<<< HEAD enum AudioEntityHandle { AEHANDLE_NONE = -5, @@ -222,6 +223,8 @@ enum AudioEntityHandle #define AEHANDLE_IS_OK(h) ((h)>=0) +======= +>>>>>>> Cleanup class cAudioManager { public: @@ -270,10 +273,15 @@ public: uint8 m_bPreviousUserPause; uint8 field_19195; uint32 m_FrameCounter; - + inline uint32 GetFrameCounter(void) { return m_FrameCounter; } float GetReflectionsDistance(int32 idx) { return m_afReflectionsDistances[idx]; } +<<<<<<< HEAD int32 GetRandomNumber(int32 idx) { return m_anRandomTable[idx]; } +======= + int32 GetRandomTabe(int32 idx) { return m_anRandomTable[idx]; } + +>>>>>>> Cleanup // void AddDetailsToRequestedOrderList(uint8 sample); /// ok @@ -283,7 +291,7 @@ public: void AddReleasingSounds(); // todo (difficult) void AddSampleToRequestedQueue(); /// ok void AgeCrimes(); // todo - int8 GetCurrent3DProviderIndex(); /// ok + int8 GetCurrent3DProviderIndex(); /// ok void CalculateDistance(bool *ptr, float dist); /// ok bool CheckForAnAudioFileOnCD(); /// ok @@ -461,55 +469,58 @@ public: uint32 GetGenericMaleTalkSfx(int16 sound); uint32 GetGenericFemaleTalkSfx(int16 sound); + void PlayOneShot(int32 index, int16 sound, float vol); // todo + void ProcessActiveQueues(); // todo bool ProcessAirBrakes(cVehicleParams *params); /// ok void ProcessAirportScriptObject(uint8 sound); /// ok - bool ProcessBoatEngine(cVehicleParams *params); // todo requires CBoat - bool ProcessBoatMovingOverWater(cVehicleParams *params); // todo requires CBoat - void ProcessBridge(); // todo requires CBridge + bool ProcessBoatEngine(cVehicleParams *params); /// ok + bool ProcessBoatMovingOverWater(cVehicleParams *params); /// ok + void ProcessBridge(); /// ok void ProcessBridgeMotor(); /// ok - void ProcessBridgeOneShots(); // todo requires CBridge + void ProcessBridgeOneShots(); /// ok void ProcessBridgeWarning(); /// ok - bool ProcessCarBombTick(void *); // todo requires CVehicle + bool ProcessCarBombTick(cVehicleParams *params); /// ok void ProcessCesna(void *); // todo requires CPlane void ProcessCinemaScriptObject(uint8 sound); /// ok void ProcessCrane(); // todo requires CCrane void ProcessDocksScriptObject(uint8 sound); /// ok - // bool ProcessEngineDamage(void *); //todo requires CVehicle - void ProcessEntity(int32 sound); /// ok - void ProcessExplosions(int32 explosion); // test - void ProcessFireHydrant(); /// ok - void ProcessFires(int32 entity); // todo requires gFireManager - void ProcessFrontEnd(); /// ok - void ProcessGarages(); // todo requires CGarages::aGarages - // bool ProcessHelicopter(void *); // todo requires CVehicle - void ProcessHomeScriptObject(uint8 sound); /// ok - void ProcessJumbo(cVehicleParams *); /// ok - void ProcessJumboAccel(CPlane *plane); /// ok - void ProcessJumboDecel(CPlane *plane); /// ok - void ProcessJumboFlying(); /// ok - void ProcessJumboLanding(CPlane *plane); /// ok - void ProcessJumboTakeOff(CPlane *plane); /// ok - void ProcessJumboTaxi(); /// ok - void ProcessLaunderetteScriptObject(uint8 sound); /// ok - void ProcessLoopingScriptObject(uint8 sound); /// ok + bool ProcessEngineDamage(cVehicleParams *params); /// ok + void ProcessEntity(int32 sound); /// ok + void ProcessExplosions(int32 explosion); /// ok + void ProcessFireHydrant(); /// ok + void ProcessFires(int32 entity); // todo requires gFireManager + void ProcessFrontEnd(); /// ok + void ProcessGarages(); // todo requires CGarages::aGarages + bool ProcessHelicopter(cVehicleParams *params); /// ok + void ProcessHomeScriptObject(uint8 sound); /// ok + void ProcessJumbo(cVehicleParams *); /// ok + void ProcessJumboAccel(CPlane *plane); /// ok + void ProcessJumboDecel(CPlane *plane); /// ok + void ProcessJumboFlying(); /// ok + void ProcessJumboLanding(CPlane *plane); /// ok + void ProcessJumboTakeOff(CPlane *plane); /// ok + void ProcessJumboTaxi(); /// ok + void ProcessLaunderetteScriptObject(uint8 sound); /// ok + void ProcessLoopingScriptObject(uint8 sound); /// ok // void ProcessMissionAudio(); - // void ProcessModelVehicle(void *); - void ProcessOneShotScriptObject(uint8 sound); // test - void ProcessPed(CPhysical *ped); // test - void ProcessPedHeadphones(cPedParams *params); // test - void ProcessPedOneShots(cPedParams *params); // test, remove goto - void ProcessPhysical(int32 id); /// ok - void ProcessPlane(void *); // todo - // void ProcessPlayersVehicleEngine(void *, void *); - void ProcessPoliceCellBeatingScriptObject(uint8 sound); // todo - void ProcessPornCinema(uint8 sound); /// ok - void ProcessProjectiles(); // todo - // void ProcessRainOnVehicle(void *); + void ProcessModelCarEngine(cVehicleParams *params); /// (check float comparisons) + void ProcessOneShotScriptObject(uint8 sound); /// ok + void ProcessPed(CPhysical *ped); /// ok + void ProcessPedHeadphones(cPedParams *params); /// ok + void ProcessPedOneShots(cPedParams *params); /// ok + void ProcessPhysical(int32 id); /// ok + void ProcessPlane(cVehicleParams *params); /// ok + void ProcessPlayersVehicleEngine(cVehicleParams *params, + CAutomobile *automobile); /// ok (check float comparisons) + void ProcessPoliceCellBeatingScriptObject(uint8 sound); // todo + void ProcessPornCinema(uint8 sound); /// ok + void ProcessProjectiles(); // todo requires CProjectileInfo + void ProcessRainOnVehicle(cVehicleParams *params); /// ok // void ProcessReverb(); // bool ProcessReverseGear(void *); void ProcessSawMillScriptObject(uint8 sound); /// ok - void ProcessScriptObject(int32 id); // test + void ProcessScriptObject(int32 id); /// ok void ProcessShopScriptObject(uint8 sound); /// ok void ProcessSpecial(); /// ok // bool ProcessTrainNoise(void *); @@ -527,7 +538,7 @@ public: // bool ProcessWetRoadNoise(void *); void ProcessWorkShopScriptObject(uint8 sound); /// ok - void SetupPedComments(cPedParams *params, uint32 sound); // todo hook + void SetupPedComments(cPedParams *params, uint32 sound); /// ok }; static_assert(sizeof(cAudioManager) == 19220, "cAudioManager: error"); diff --git a/src/audio/DMAudio.cpp b/src/audio/DMAudio.cpp index 6fb6d1e5..076c1178 100644 --- a/src/audio/DMAudio.cpp +++ b/src/audio/DMAudio.cpp @@ -7,6 +7,8 @@ cDMAudio &DMAudio = *(cDMAudio*)0x95CDBE; +#define AEHANDLE_IS_FAILED(h) ((h)<0) +#define AEHANDLE_IS_OK(h) ((h)>=0) void cDMAudio::Initialise(void) -- cgit v1.2.3 From 2fabbc3b4cab40220986f402569af64673cb4cd9 Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Fri, 16 Aug 2019 20:17:15 +0200 Subject: More more more audio --- src/audio/AudioManager.cpp | 1715 +++++++++++++++++++++++++++++++------------- src/audio/AudioManager.h | 208 +++--- src/audio/sampman.cpp | 35 +- 3 files changed, 1330 insertions(+), 628 deletions(-) (limited to 'src/audio') diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index e08efbc6..e1860698 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -22,6 +22,7 @@ #include "Replay.h" #include "Stats.h" #include "SurfaceTable.h" +#include "Train.h" #include "Transmission.h" #include "Vehicle.h" #include "Weather.h" @@ -29,6 +30,11 @@ #include "ZoneCull.h" #include "sampman.h" +cAudioManager &AudioManager = *(cAudioManager *)0x880FC0; + +constexpr int totalAudioEntitiesSlots = 200; +constexpr int maxVolume = 127; + uint32 *audioLogicTimers = (uint32 *)0x6508A0; // TODO: where is this used? Is this the right file? @@ -111,26 +117,117 @@ cPedComments::Add(tPedComment *com) uint8 index; if(nrOfCommentsInBank[activeBank] >= 20u) { - index = field_1120[activeBank][19]; + index = indexMap[activeBank][19]; if(m_asPedComments[activeBank][index].m_bVolume > com->m_bVolume) return; } else { index = nrOfCommentsInBank[activeBank]++; } - m_asPedComments[activeBank][index] = *com; + + m_asPedComments[activeBank][index].m_nSampleIndex = com->m_nSampleIndex; + m_asPedComments[activeBank][index].m_entityIndex = com->m_entityIndex; + m_asPedComments[activeBank][index].m_vecPos = com->m_vecPos; + m_asPedComments[activeBank][index].m_fDistance = com->m_fDistance; + m_asPedComments[activeBank][index].m_bVolume = com->m_bVolume; uint32 i = 0; if(index != 0) { for(i = 0; i < index; i++) { - if(m_asPedComments[activeBank][field_1120[activeBank][i]].m_bVolume < + if(m_asPedComments[activeBank][indexMap[activeBank][i]].m_bVolume < m_asPedComments[activeBank][index].m_bVolume) { - memmove(&field_1120[activeBank][i + 1], &field_1120[activeBank][i], - 19 - i); break; } } + + if(i < index) + memmove(&indexMap[activeBank][i + 1], &indexMap[activeBank][i], 19 - i); } - field_1120[activeBank][i] = index; + indexMap[activeBank][i] = index; +} + +void +cPedComments::Process() +{ + int sampleIndex; + uint8 actualUsedBank; + tPedComment *comment; + + if(!AudioManager.m_bUserPause) { + if(nrOfCommentsInBank[activeBank]) { + sampleIndex = + m_asPedComments[activeBank][indexMap[activeBank][0]].m_nSampleIndex; + if(!SampleManager.IsPedCommentLoaded(sampleIndex)) + SampleManager.LoadPedComment(sampleIndex); + + AudioManager.m_sQueueSample.m_nEntityIndex = + m_asPedComments[activeBank][indexMap[activeBank][0]].m_entityIndex; + AudioManager.m_sQueueSample.m_counter = 0; + AudioManager.m_sQueueSample.m_nSampleIndex = sampleIndex; + AudioManager.m_sQueueSample.m_bBankIndex = 1; + AudioManager.m_sQueueSample.field_16 = 3; + AudioManager.m_sQueueSample.m_bVolume = + m_asPedComments[activeBank][indexMap[activeBank][0]].m_bVolume; + AudioManager.m_sQueueSample.m_fDistance = + m_asPedComments[activeBank][indexMap[activeBank][0]].m_fDistance; + AudioManager.m_sQueueSample.m_nLoopCount = 1; + AudioManager.m_sQueueSample.m_nLoopStart = 0; + AudioManager.m_sQueueSample.m_nLoopEnd = -1; + AudioManager.m_sQueueSample.m_bEmittingVolume = maxVolume; + AudioManager.m_sQueueSample.field_48 = 3.0f; + switch(sampleIndex) { + case AUDIO_SAMPLE_POLICE_HELI_FOUND_PLAYER_1: + case AUDIO_SAMPLE_POLICE_HELI_FOUND_PLAYER_2: + case AUDIO_SAMPLE_POLICE_HELI_FOUND_PLAYER_3: + AudioManager.m_sQueueSample.m_fSoundIntensity = 400.0f; + break; + default: AudioManager.m_sQueueSample.m_fSoundIntensity = 50.0f; break; + } + AudioManager.m_sQueueSample.field_56 = 1; + AudioManager.m_sQueueSample.m_vecPos = + m_asPedComments[activeBank][indexMap[activeBank][0]].m_vecPos; + + if((sampleIndex - AUDIO_SAMPLE_AMMUNATION_WELCOME_1) > 1 && + sampleIndex != AUDIO_SAMPLE_AMMUNATION_WELCOME_3) { + AudioManager.m_sQueueSample.m_bReverbFlag = 1; + AudioManager.m_sQueueSample.m_bRequireReflection = 1; + } else { + AudioManager.m_sQueueSample.m_bReverbFlag = 0; + AudioManager.m_sQueueSample.m_bRequireReflection = 0; + } + + AudioManager.m_sQueueSample.m_bIsDistant = 0; + AudioManager.m_sQueueSample.m_nFrequency = + SampleManager.GetSampleBaseFrequency( + AudioManager.m_sQueueSample.m_nSampleIndex) + + AudioManager.RandomDisplacement(750u); + if(CTimer::GetIsSlowMotionActive()) + AudioManager.m_sQueueSample.m_nFrequency = + AudioManager.m_sQueueSample.m_nFrequency >> 1; + m_asPedComments[activeBank][indexMap[activeBank][0]].field_25 = -1; + AudioManager.AddSampleToRequestedQueue(); + } + + // Switch bank + if(activeBank) { + actualUsedBank = 1; + activeBank = 0; + } else { + actualUsedBank = 0; + activeBank = 1; + } + comment = m_asPedComments[actualUsedBank]; + for(uint32 i = 0; i < nrOfCommentsInBank[actualUsedBank]; i++) { + if(m_asPedComments[actualUsedBank][indexMap[actualUsedBank][i]].field_25 > + 0) { + --m_asPedComments[actualUsedBank][indexMap[actualUsedBank][i]] + .field_25; + Add(&comment[indexMap[actualUsedBank][i]]); + } + } + + for(uint32 i = 0; i < 20; i++) { indexMap[actualUsedBank][i] = 20; } + nrOfCommentsInBank[actualUsedBank] = 0; + } } void * @@ -154,11 +251,6 @@ cAudioScriptObject::operator delete(void *p, int handle) CPools::GetAudioScriptObjectPool()->Delete((cAudioScriptObject *)p); } -cAudioManager &AudioManager = *(cAudioManager *)0x880FC0; - -constexpr int totalAudioEntitiesSlots = 200; -constexpr int maxVolume = 127; - char &g_nMissionAudioPlayingStatus = *(char *)0x60ED88; void @@ -184,11 +276,11 @@ cAudioManager::AddDetailsToRequestedOrderList(uint8 sample) void cAudioManager::AddPlayerCarSample(uint8 emittingVolume, int32 freq, uint32 sample, uint8 unk1, - uint8 unk2, bool notLooping) + uint8 counter, bool notLooping) { m_sQueueSample.m_bVolume = ComputeVolume(emittingVolume, 50.f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.field_4 = unk2; + m_sQueueSample.m_counter = counter; m_sQueueSample.m_nSampleIndex = sample; m_sQueueSample.m_bBankIndex = 0; m_sQueueSample.m_bIsDistant = 0; @@ -234,7 +326,7 @@ cAudioManager::AddReflectionsToRequestedQueue() ComputeVolume(emittingVolume, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume > emittingVolume >> 4) { - m_sQueueSample.field_4 += ((i + 1) << 8); + m_sQueueSample.m_counter += ((i + 1) << 8); if(m_sQueueSample.m_nLoopCount) { noise = RandomDisplacement( m_sQueueSample.m_nFrequency >> 5); @@ -244,9 +336,7 @@ cAudioManager::AddReflectionsToRequestedQueue() m_sQueueSample.m_nFrequency -= noise; } m_sQueueSample.field_16 += 20; - m_sQueueSample.m_vecPos.x = m_avecReflectionsPos[i].x; - m_sQueueSample.m_vecPos.y = m_avecReflectionsPos[i].y; - m_sQueueSample.m_vecPos.z = m_avecReflectionsPos[i].z; + m_sQueueSample.m_vecPos = m_avecReflectionsPos[i]; AddSampleToRequestedQueue(); } } @@ -268,7 +358,6 @@ void cAudioManager::AddSampleToRequestedQueue() { int32 calculatedVolume; - tActiveSample *sample; uint8 sampleIndex; bool bReflections; @@ -300,33 +389,7 @@ cAudioManager::AddSampleToRequestedQueue() if(!m_bDynamicAcousticModelingStatus) m_sQueueSample.m_bReverbFlag = 0; - sample = &m_asSamples[m_bActiveSampleQueue][sampleIndex]; - sample->m_nEntityIndex = m_sQueueSample.m_nEntityIndex; - sample->field_4 = m_sQueueSample.field_4; - sample->m_nSampleIndex = m_sQueueSample.m_nSampleIndex; - sample->m_bBankIndex = m_sQueueSample.m_bBankIndex; - sample->m_bIsDistant = m_sQueueSample.m_bIsDistant; - sample->field_16 = m_sQueueSample.field_16; - sample->m_nFrequency = m_sQueueSample.m_nFrequency; - sample->m_bVolume = m_sQueueSample.m_bVolume; - sample->m_fDistance = m_sQueueSample.m_fDistance; - sample->m_nLoopCount = m_sQueueSample.m_nLoopCount; - sample->m_nLoopStart = m_sQueueSample.m_nLoopStart; - sample->m_nLoopEnd = m_sQueueSample.m_nLoopEnd; - sample->m_bEmittingVolume = m_sQueueSample.m_bEmittingVolume; - sample->field_48 = m_sQueueSample.field_48; - sample->m_fSoundIntensity = m_sQueueSample.m_fSoundIntensity; - sample->field_56 = m_sQueueSample.field_56; - sample->m_vecPos = m_sQueueSample.m_vecPos; - sample->m_bReverbFlag = m_sQueueSample.m_bReverbFlag; - sample->m_bLoopsRemaining = m_sQueueSample.m_bLoopsRemaining; - sample->m_bRequireReflection = m_sQueueSample.m_bRequireReflection; - sample->m_bOffset = m_sQueueSample.m_bOffset; - sample->field_76 = m_sQueueSample.field_76; - sample->m_bIsProcessed = m_sQueueSample.m_bIsProcessed; - sample->m_bLoopEnded = m_sQueueSample.m_bLoopEnded; - sample->calculatedVolume = m_sQueueSample.calculatedVolume; - sample->field_88 = m_sQueueSample.field_88; + m_asSamples[m_bActiveSampleQueue][sampleIndex] = m_sQueueSample; AddDetailsToRequestedOrderList(sampleIndex); if(bReflections) AddReflectionsToRequestedQueue(); @@ -340,14 +403,6 @@ cAudioManager::AgeCrimes() EAXJMP(0x580AF0); } -int8 -cAudioManager::GetCurrent3DProviderIndex() -{ - if(m_bIsInitialised) return SampleManager.GetCurrent3DProviderIndex(); - - return -1; -} - void cAudioManager::CalculateDistance(bool *ptr, float dist) { @@ -358,7 +413,7 @@ cAudioManager::CalculateDistance(bool *ptr, float dist) } bool -cAudioManager::CheckForAnAudioFileOnCD() +cAudioManager::CheckForAnAudioFileOnCD() const { return SampleManager.CheckForAnAudioFileOnCD(); } @@ -388,18 +443,18 @@ cAudioManager::ClearRequestedQueue() int32 cAudioManager::ComputeDopplerEffectedFrequency(uint32 oldFreq, float position1, float position2, - float speedMultiplier) + float speedMultiplier) const { uint32 newFreq = oldFreq; if(!TheCamera.Get_Just_Switched_Status() && speedMultiplier != 0.0f) { float dist = position2 - position1; if(dist != 0.0f) { float speedOfSource = (dist / field_19195) * speedMultiplier; - if(speedOfSound > fabsf(speedOfSource)) { + if(speedOfSound > Abs(speedOfSource)) { if(speedOfSource < 0.0f) { - speedOfSource = max(speedOfSource, -1.5f); + speedOfSource = Max(speedOfSource, -1.5f); } else { - speedOfSource = min(speedOfSource, 1.5f); + speedOfSource = Min(speedOfSource, 1.5f); } newFreq = (oldFreq * speedOfSound) / (speedOfSource + speedOfSound); } @@ -416,7 +471,7 @@ cAudioManager::ComputePan(float, CVector *) } uint32 -cAudioManager::ComputeVolume(int emittingVolume, float soundIntensity, float distance) +cAudioManager::ComputeVolume(int emittingVolume, float soundIntensity, float distance) const { float newSoundIntensity; if(soundIntensity <= 0.0f) return 0; @@ -445,7 +500,7 @@ cAudioManager::CreateEntity(int32 type, void *entity) m_asAudioEntities[i].m_awAudioEvent[1] = SOUND_TOTAL_PED_SOUNDS; m_asAudioEntities[i].m_awAudioEvent[2] = SOUND_TOTAL_PED_SOUNDS; m_asAudioEntities[i].m_awAudioEvent[3] = SOUND_TOTAL_PED_SOUNDS; - m_asAudioEntities[i].field_24 = 0; + m_asAudioEntities[i].m_Loops = 0; m_anAudioEntityIndices[m_nAudioEntitiesTotal++] = i; return i; } @@ -467,7 +522,7 @@ cAudioManager::DestroyAllGameCreatedEntities() case AUDIOTYPE_WEATHER: case AUDIOTYPE_CRANE: case AUDIOTYPE_GARAGE: - case AUDIOTYPE_FIREHYDRANT: cAudioManager::DestroyEntity(i); break; + case AUDIOTYPE_FIREHYDRANT: DestroyEntity(i); break; case AUDIOTYPE_SCRIPTOBJECT: entity = (cAudioScriptObject *)m_asAudioEntities[i].m_pEntity; @@ -506,7 +561,7 @@ void cAudioManager::DoPoliceRadioCrackle() { m_sQueueSample.m_nEntityIndex = m_nPoliceChannelEntity; - m_sQueueSample.field_4 = 0; + m_sQueueSample.m_counter = 0; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_CRACKLE; m_sQueueSample.m_bBankIndex = 0; m_sQueueSample.m_bIsDistant = 1; @@ -532,15 +587,8 @@ cAudioManager::GenerateIntegerRandomNumberTable() for(int32 i = 0; i < 5; i++) { m_anRandomTable[i] = rand(); } } -float -cAudioManager::GetDistanceSquared(CVector *v) -{ - const CVector &c = TheCamera.GetPosition(); - return sq(v->x - c.x) + sq(v->y - c.y) + sq((v->z - c.z) * 0.2f); -} - void -cAudioManager::TranslateEntity(CVector *v1, CVector *v2) +cAudioManager::TranslateEntity(CVector *v1, CVector *v2) const { const RwMatrix &cM = TheCamera.GetMatrix().m_matrix; const CVector &cV = TheCamera.GetPosition(); @@ -555,24 +603,27 @@ cAudioManager::TranslateEntity(CVector *v1, CVector *v2) } void -cAudioManager::Initialise() +cAudioManager::ResetAudioLogicTimers(int32 timer) { - if(!m_bIsInitialised) { - PreInitialiseGameSpecificSetup(); - m_bIsInitialised = SampleManager.Initialise(); - if(m_bIsInitialised) { - m_bActiveSamples = SampleManager.GetMaximumSupportedChannels(); - if(m_bActiveSamples <= 1u) { - Terminate(); - } else { - --m_bActiveSamples; - PostInitialiseGameSpecificSetup(); - InitialisePoliceRadioZones(); - InitialisePoliceRadio(); - MusicManager.Initialise(); + audioLogicTimers[0] = timer; + audioLogicTimers[8] = timer; + audioLogicTimers[1] = timer; + audioLogicTimers[7] = timer; + audioLogicTimers[2] = timer; + audioLogicTimers[6] = timer; + audioLogicTimers[3] = timer; + audioLogicTimers[5] = timer; + audioLogicTimers[4] = timer; + for(int32 i = 0; i < m_nAudioEntitiesTotal; i++) { + if(m_asAudioEntities[m_anAudioEntityIndices[i]].m_nType == AUDIOTYPE_PHYSICAL) { + CPed *ped = (CPed *)m_asAudioEntities[m_anAudioEntityIndices[i]].m_pEntity; + if(ped->IsPed()) { + ped->m_lastSoundStart = timer; + ped->m_soundStart = timer + m_anRandomTable[0] % 3000u; } } } +<<<<<<< HEAD } void @@ -623,6 +674,10 @@ void cAudioManager::ResetAudioLogicTimers(int32 timer) { EAXJMP(0x569650); +======= + ClearMissionAudio(); + SampleManager.StopChannel(28); +>>>>>>> More more more audio } void @@ -651,29 +706,15 @@ cAudioManager::Terminate() } } -char -cAudioManager::GetMissionScriptPoliceAudioPlayingStatus() -{ - return g_nMissionAudioPlayingStatus; -} - -bool -cAudioManager::GetMissionAudioLoadingStatus() -{ - if(m_bIsInitialised) return m_sMissionAudio.m_bLoadingStatus; - - return true; -} - uint8 -cAudioManager::GetNum3DProvidersAvailable() +cAudioManager::GetNum3DProvidersAvailable() const { if(m_bIsInitialised) return SampleManager.GetNum3DProvidersAvailable(); return 0; } bool -cAudioManager::IsMP3RadioChannelAvailable() +cAudioManager::IsMP3RadioChannelAvailable() const { if(m_bIsInitialised) return SampleManager.IsMP3RadioChannelAvailable(); @@ -681,7 +722,7 @@ cAudioManager::IsMP3RadioChannelAvailable() } uint8 -cAudioManager::GetCDAudioDriveLetter() +cAudioManager::GetCDAudioDriveLetter() const { if(m_bIsInitialised) return SampleManager.GetCDAudioDriveLetter(); @@ -689,31 +730,31 @@ cAudioManager::GetCDAudioDriveLetter() } void -cAudioManager::SetEffectsMasterVolume(uint8 volume) +cAudioManager::SetEffectsMasterVolume(uint8 volume) const { SampleManager.SetEffectsMasterVolume(volume); } void -cAudioManager::SetMusicMasterVolume(uint8 volume) +cAudioManager::SetMusicMasterVolume(uint8 volume) const { SampleManager.SetMusicMasterVolume(volume); } void -cAudioManager::SetEffectsFadeVolume(uint8 volume) +cAudioManager::SetEffectsFadeVolume(uint8 volume) const { SampleManager.SetEffectsFadeVolume(volume); } void -cAudioManager::SetMusicFadeVolume(uint8 volume) +cAudioManager::SetMusicFadeVolume(uint8 volume) const { SampleManager.SetMusicFadeVolume(volume); } void -cAudioManager::SetSpeakerConfig(int32 conf) +cAudioManager::SetSpeakerConfig(int32 conf) const { SampleManager.SetSpeakerConfig(conf); } @@ -724,7 +765,7 @@ bool cAudioManager::SetupJumboEngineSound(uint8, int32) { EAXJMP(0x56F140); } int32 *BankStartOffset = (int32 *)0x6FAB70; //[2] void -cAudioManager::PreInitialiseGameSpecificSetup() +cAudioManager::PreInitialiseGameSpecificSetup() const { BankStartOffset[0] = AUDIO_SAMPLE_VEHICLE_HORN_0; BankStartOffset[1] = AUDIO_SAMPLE_POLICE_COP_1_ARREST_1; @@ -733,7 +774,7 @@ cAudioManager::PreInitialiseGameSpecificSetup() int32 &g_nMissionAudioSfx = *(int32 *)0x60ED84; void -cAudioManager::SetMissionScriptPoliceAudio(int32 sfx) +cAudioManager::SetMissionScriptPoliceAudio(int32 sfx) const { if(m_bIsInitialised) { if(g_nMissionAudioPlayingStatus != 1) { @@ -744,7 +785,7 @@ cAudioManager::SetMissionScriptPoliceAudio(int32 sfx) } bool -cAudioManager::UsesSiren(int32 model) +cAudioManager::UsesSiren(int32 model) const { switch(model) { case FIRETRUK: @@ -758,7 +799,7 @@ cAudioManager::UsesSiren(int32 model) } bool -cAudioManager::UsesSirenSwitching(int32 model) +cAudioManager::UsesSirenSwitching(int32 model) const { switch(model) { case AMBULAN: @@ -769,28 +810,8 @@ cAudioManager::UsesSirenSwitching(int32 model) } } -bool -cAudioManager::MissionScriptAudioUsesPoliceChannel(int32 soundMission) -{ - switch(soundMission) { - case STREAMED_SOUND_MISSION_J6_D: - case STREAMED_SOUND_MISSION_T4_A: - case STREAMED_SOUND_MISSION_S1_H: - case STREAMED_SOUND_MISSION_S3_B: - case STREAMED_SOUND_MISSION_EL3_A: - case STREAMED_SOUND_MISSION_A3_A: - case STREAMED_SOUND_MISSION_A5_A: - case STREAMED_SOUND_MISSION_K1_A: - case STREAMED_SOUND_MISSION_R1_A: - case STREAMED_SOUND_MISSION_R5_A: - case STREAMED_SOUND_MISSION_LO2_A: - case STREAMED_SOUND_MISSION_LO6_A: return true; - default: return false; - } -} - char * -cAudioManager::Get3DProviderName(uint8 id) +cAudioManager::Get3DProviderName(uint8 id) const { if(!m_bIsInitialised) return 0; if(id >= SampleManager.GetNum3DProvidersAvailable()) return 0; @@ -802,13 +823,13 @@ cAudioManager::SetupJumboFlySound(uint8 emittingVol) { int32 vol; - if(m_sQueueSample.m_fDistance >= 440.0) return 0; + if(m_sQueueSample.m_fDistance >= 440.0f) return 0; vol = ComputeVolume(emittingVol, 440.0f, m_sQueueSample.m_fDistance); m_sQueueSample.m_bVolume = vol; if(m_sQueueSample.m_bVolume) { m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_JUMBO_FLY_SOUND; - m_sQueueSample.field_4 = 0; + m_sQueueSample.m_counter = 0; m_sQueueSample.m_bBankIndex = 0; m_sQueueSample.m_bIsDistant = 0; m_sQueueSample.field_16 = 1; @@ -838,7 +859,7 @@ cAudioManager::SetupJumboRumbleSound(uint8 emittingVol) m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, 240.f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.field_4 = 5; + m_sQueueSample.m_counter = 5; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_JUMBO_RUMBLE_SOUND; m_sQueueSample.m_bBankIndex = 0; m_sQueueSample.m_bIsDistant = 1; @@ -859,10 +880,10 @@ cAudioManager::SetupJumboRumbleSound(uint8 emittingVol) m_sQueueSample.m_bReverbFlag = 1; m_sQueueSample.m_bRequireReflection = 0; AddSampleToRequestedQueue(); - m_sQueueSample.field_4 = 6; + m_sQueueSample.m_counter = 6; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_JUMBO_RUMBLE_SOUND; m_sQueueSample.m_nFrequency += 200; - m_sQueueSample.m_bOffset = 127; + m_sQueueSample.m_bOffset = maxVolume; AddSampleToRequestedQueue(); } return 1; @@ -884,7 +905,7 @@ cAudioManager::SetupJumboTaxiSound(uint8 vol) m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, 180.f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.field_4 = 1; + m_sQueueSample.m_counter = 1; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_JUMBO_TAXI_SOUND; m_sQueueSample.m_bBankIndex = 0; m_sQueueSample.m_bIsDistant = 0; @@ -915,7 +936,7 @@ cAudioManager::SetupJumboWhineSound(uint8 emittingVol, int32 freq) m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, 170.f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.field_4 = 2; + m_sQueueSample.m_counter = 2; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_JUMBO_WHINE_SOUND; m_sQueueSample.m_bBankIndex = 0; m_sQueueSample.m_bIsDistant = 0; @@ -938,15 +959,6 @@ cAudioManager::SetupJumboWhineSound(uint8 emittingVol, int32 freq) return 1; } -void -cAudioManager::PlayLoadedMissionAudio() -{ - if(m_bIsInitialised && m_sMissionAudio.m_nSampleIndex != NO_SAMPLE && - m_sMissionAudio.m_bLoadingStatus == 1 && !m_sMissionAudio.m_bPlayStatus) { - m_sMissionAudio.m_bIsPlayed = true; - } -} - void cAudioManager::SetMissionAudioLocation(float x, float y, float z) { @@ -967,54 +979,15 @@ cAudioManager::ResetPoliceRadio() } } -void -cAudioManager::InterrogateAudioEntities() -{ - for(int32 i = 0; i < m_nAudioEntitiesTotal; i++) { - ProcessEntity(m_anAudioEntityIndices[i]); - m_asAudioEntities[m_anAudioEntityIndices[i]].field_24 = 0; - } -} - bool -cAudioManager::UsesReverseWarning(int32 model) +cAudioManager::UsesReverseWarning(int32 model) const { return model == LINERUN || model == FIRETRUK || model == TRASH || model == BUS || - model == COACH; // fix -} - -bool -cAudioManager::HasAirBrakes(int32 model) -{ - return model == LINERUN || model == FIRETRUK || model == TRASH || model == BUS || - model == COACH; // fix + model == COACH; } int32 -cAudioManager::GetJumboTaxiFreq() -{ - return (60.833f * m_sQueueSample.m_fDistance) + 22050; -} - -bool -cAudioManager::IsMissionAudioSampleFinished() -{ - if(m_bIsInitialised) return m_sMissionAudio.m_bPlayStatus == 2; - - static int32 cPretendFrame = 1; - - return (cPretendFrame++ & 63) == 0; -} - -WRAPPER -void -cAudioManager::InitialisePoliceRadio() -{ - EAXJMP(0x57EEC0); -} - -int32 -cAudioManager::RandomDisplacement(uint32 seed) +cAudioManager::RandomDisplacement(uint32 seed) const { int32 value; @@ -1032,13 +1005,13 @@ cAudioManager::RandomDisplacement(uint32 seed) } void -cAudioManager::ReleaseDigitalHandle() +cAudioManager::ReleaseDigitalHandle() const { if(m_bIsInitialised) { SampleManager.ReleaseDigitalHandle(); } } void -cAudioManager::ReacquireDigitalHandle() +cAudioManager::ReacquireDigitalHandle() const { if(m_bIsInitialised) { SampleManager.ReacquireDigitalHandle(); } } @@ -1064,60 +1037,7 @@ cAudioManager::SetEntityStatus(int32 id, bool status) } void -cAudioManager::PreTerminateGameSpecificShutdown() -{ - if(m_nBridgeEntity >= 0) { - DestroyEntity(m_nBridgeEntity); - m_nBridgeEntity = -5; - } - if(m_nPoliceChannelEntity >= 0) { - DestroyEntity(m_nPoliceChannelEntity); - m_nPoliceChannelEntity = -5; - } - if(m_nWaterCannonEntity >= 0) { - DestroyEntity(m_nWaterCannonEntity); - m_nWaterCannonEntity = -5; - } - if(m_nFireAudioEntity >= 0) { - DestroyEntity(m_nFireAudioEntity); - m_nFireAudioEntity = -5; - } - if(m_nCollisionEntity >= 0) { - DestroyEntity(m_nCollisionEntity); - m_nCollisionEntity = -5; - } - if(m_nFrontEndEntity >= 0) { - DestroyEntity(m_nFrontEndEntity); - m_nFrontEndEntity = -5; - } - if(m_nProjectileEntity >= 0) { - DestroyEntity(m_nProjectileEntity); - m_nProjectileEntity = -5; - } -} - -void -cAudioManager::PostTerminateGameSpecificShutdown() -{ - ; -} - -bool &bPlayerJustEnteredCar = *(bool *)0x6508C4; - -void -cAudioManager::PlayerJustGotInCar() -{ - if(m_bIsInitialised) { bPlayerJustEnteredCar = true; } -} - -void -cAudioManager::PlayerJustLeftCar(void) -{ - // UNUSED: This is a perfectly empty function. -} - -void -cAudioManager::GetPhrase(uint32 *phrase, uint32 *prevPhrase, uint32 sample, uint32 maxOffset) +cAudioManager::GetPhrase(uint32 *phrase, uint32 *prevPhrase, uint32 sample, uint32 maxOffset) const { *phrase = sample + m_anRandomTable[m_sQueueSample.m_nEntityIndex & 3] % maxOffset; @@ -1130,7 +1050,7 @@ cAudioManager::GetPhrase(uint32 *phrase, uint32 *prevPhrase, uint32 sample, uint uint8 &jumboVolOffset = *(uint8 *)0x6508ED; void -cAudioManager::DoJumboVolOffset() +cAudioManager::DoJumboVolOffset() const { if(!(m_FrameCounter % (m_anRandomTable[0] % 6u + 3))) jumboVolOffset = m_anRandomTable[1] % 60u; @@ -1258,9 +1178,7 @@ cAudioManager::GetCopTalkSfx(int16 sound) if(sound == SOUND_PED_ARREST_COP) { GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_POLICE_COP_1_ARREST_1, 6u); } else { - if(sound != SOUND_PED_PURSUIT_COP) { - return cAudioManager::GetGenericMaleTalkSfx(sound); - } + if(sound != SOUND_PED_PURSUIT_COP) { return GetGenericMaleTalkSfx(sound); } pedState = FindPlayerPed()->m_nPedState; if(pedState == PED_ARRESTED || pedState == PED_DEAD || pedState == PED_DIE) @@ -1281,9 +1199,7 @@ cAudioManager::GetSwatTalkSfx(int16 sound) if(sound == SOUND_PED_ARREST_SWAT) { GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_POLICE_SWAT_1_PURSUIT_ARREST_1, 6u); } else { - if(sound != SOUND_PED_PURSUIT_SWAT) { - return cAudioManager::GetGenericMaleTalkSfx(sound); - } + if(sound != SOUND_PED_PURSUIT_SWAT) { return GetGenericMaleTalkSfx(sound); } pedState = FindPlayerPed()->m_nPedState; if(pedState == PED_ARRESTED || pedState == PED_DEAD || pedState == PED_DIE) @@ -1304,9 +1220,7 @@ cAudioManager::GetFBITalkSfx(int16 sound) if(sound == SOUND_PED_ARREST_FBI) { GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_POLICE_FBI_1_PURSUIT_ARREST_1, 6u); } else { - if(sound != SOUND_PED_PURSUIT_FBI) { - return cAudioManager::GetGenericMaleTalkSfx(sound); - } + if(sound != SOUND_PED_PURSUIT_FBI) { return GetGenericMaleTalkSfx(sound); } pedState = FindPlayerPed()->m_nPedState; if(pedState == PED_ARRESTED || pedState == PED_DEAD || pedState == PED_DIE) @@ -1324,7 +1238,7 @@ cAudioManager::GetArmyTalkSfx(int16 sound) PedState pedState; static uint32 lastSfx = NO_SAMPLE; - if(sound != SOUND_PED_PURSUIT_ARMY) { return cAudioManager::GetGenericMaleTalkSfx(sound); } + if(sound != SOUND_PED_PURSUIT_ARMY) { return GetGenericMaleTalkSfx(sound); } pedState = FindPlayerPed()->m_nPedState; if(pedState == PED_ARRESTED || pedState == PED_DEAD || pedState == PED_DIE) @@ -1356,7 +1270,7 @@ cAudioManager::GetMedicTalkSfx(int16 sound) case SOUND_PED_FLEE_RUN: GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_MEDIC_1_FLEE_RUN_1, 6u); break; - default: return cAudioManager::GetGenericMaleTalkSfx(sound); + default: return GetGenericMaleTalkSfx(sound); } return 37 * (m_sQueueSample.m_nEntityIndex & 1) + sfx; } @@ -1364,7 +1278,7 @@ cAudioManager::GetMedicTalkSfx(int16 sound) uint32 cAudioManager::GetFiremanTalkSfx(int16 sound) { - return cAudioManager::GetGenericMaleTalkSfx(sound); + return GetGenericMaleTalkSfx(sound); } uint32 @@ -1398,7 +1312,7 @@ cAudioManager::GetNormalMaleTalkSfx(int16 sound) case SOUND_PED_CHAT: GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_NORMAL_MALE_CHAT_1, 25u); break; - default: return cAudioManager::GetGenericMaleTalkSfx(sound); + default: return GetGenericMaleTalkSfx(sound); } return sfx; } @@ -1412,8 +1326,7 @@ cAudioManager::GetTaxiDriverTalkSfx(int16 sound) if(sound == SOUND_PED_CAR_JACKED) { GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_TAXI_DRIVER_1_CAR_JACKED_1, 7u); } else { - if(sound != SOUND_PED_CAR_COLLISION) - return cAudioManager::GetGenericMaleTalkSfx(sound); + if(sound != SOUND_PED_CAR_COLLISION) return GetGenericMaleTalkSfx(sound); GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_TAXI_DRIVER_1_CAR_COLLISION_1, 6u); } return 13 * (m_sQueueSample.m_nEntityIndex & 1) + sfx; @@ -1441,7 +1354,7 @@ cAudioManager::GetPimpTalkSfx(int16 sound) GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_PIMP_CHAT_EVENT_1, 2u); break; case SOUND_PED_CHAT: GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_PIMP_CHAT_1, 17u); break; - default: return cAudioManager::GetGenericMaleTalkSfx(sound); + default: return GetGenericMaleTalkSfx(sound); } return sfx; } @@ -1472,7 +1385,7 @@ cAudioManager::GetMafiaTalkSfx(int16 sound) GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_MAFIA_1_CHAT_SEXY_1, 3u); break; case SOUND_PED_CHAT: GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_MAFIA_1_CHAT_1, 7u); break; - default: return cAudioManager::GetGenericMaleTalkSfx(sound); + default: return GetGenericMaleTalkSfx(sound); } return 30 * (m_sQueueSample.m_nEntityIndex % 3) + sfx; } @@ -1506,7 +1419,7 @@ cAudioManager::GetTriadTalkSfx(int16 sound) GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_TRIAD_1_CHAT_SEXY_1, 3u); break; case SOUND_PED_CHAT: GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_TRIAD_1_CHAT_1, 8u); break; - default: return cAudioManager::GetGenericMaleTalkSfx(sound); + default: return GetGenericMaleTalkSfx(sound); } return sfx; } @@ -1523,7 +1436,7 @@ cAudioManager::GetDiabloTalkSfx(int16 sound) break; case SOUND_PED_HANDS_COWER: sound = SOUND_PED_FLEE_SPRINT; - return cAudioManager::GetGenericMaleTalkSfx(sound); + return GetGenericMaleTalkSfx(sound); break; case SOUND_PED_CAR_JACKING: GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_DIABLO_1_CAR_JACKING_1, 2u); @@ -1544,7 +1457,7 @@ cAudioManager::GetDiabloTalkSfx(int16 sound) GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_DIABLO_1_CHAT_SEXY_1, 4u); break; case SOUND_PED_CHAT: GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_DIABLO_1_CHAT_1, 5u); break; - default: return cAudioManager::GetGenericMaleTalkSfx(sound); + default: return GetGenericMaleTalkSfx(sound); } return 30 * (m_sQueueSample.m_nEntityIndex & 1) + sfx; } @@ -1572,7 +1485,7 @@ cAudioManager::GetYakuzaTalkSfx(int16 sound) GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_YAKUZA_1_CAR_COLLISION_1, 6u); break; case SOUND_PED_CHAT: GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_YAKUZA_1_CHAT_1, 5u); break; - default: return cAudioManager::GetGenericMaleTalkSfx(sound); + default: return GetGenericMaleTalkSfx(sound); } return 24 * (m_sQueueSample.m_nEntityIndex & 1) + sfx; } @@ -1602,7 +1515,7 @@ cAudioManager::GetYardieTalkSfx(int16 sound) GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_YARDIE_1_CHAT_SEXY_1, 2u); break; case SOUND_PED_CHAT: GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_YARDIE_1_CHAT_1, 8u); break; - default: return cAudioManager::GetGenericMaleTalkSfx(sound); + default: return GetGenericMaleTalkSfx(sound); } return 31 * (m_sQueueSample.m_nEntityIndex & 1) + sfx; } @@ -1633,7 +1546,7 @@ cAudioManager::GetColumbianTalkSfx(int16 sound) GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_COLUMB_1_CHAT_SEXY_1, 2u); break; case SOUND_PED_CHAT: GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_COLUMB_1_CHAT_1, 5u); break; - default: return cAudioManager::GetGenericMaleTalkSfx(sound); + default: return GetGenericMaleTalkSfx(sound); } return 27 * (m_sQueueSample.m_nEntityIndex & 1) + sfx; } @@ -1668,7 +1581,7 @@ cAudioManager::GetHoodTalkSfx(int16 sound) break; case SOUND_PED_CHAT: GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_HOODS_1_CHAT_1, 6u); break; - default: return cAudioManager::GetGenericMaleTalkSfx(sound); break; + default: return GetGenericMaleTalkSfx(sound); break; } return 35 * (m_sQueueSample.m_nEntityIndex & 1) + sfx; } @@ -1696,7 +1609,7 @@ cAudioManager::GetBlackCriminalTalkSfx(int16 sound) case SOUND_PED_CAR_COLLISION: GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_BLACK_CRIMINAL_1_CAR_COLLISION_1, 5u); break; - default: return cAudioManager::GetGenericMaleTalkSfx(sound); break; + default: return GetGenericMaleTalkSfx(sound); break; } return sfx; } @@ -1724,7 +1637,7 @@ cAudioManager::GetWhiteCriminalTalkSfx(int16 sound) case SOUND_PED_CAR_COLLISION: GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_WHITE_CRIMINAL_1_CAR_COLLISION_1, 4u); break; - default: return cAudioManager::GetGenericMaleTalkSfx(sound); break; + default: return GetGenericMaleTalkSfx(sound); break; } return sfx; } @@ -1737,8 +1650,7 @@ cAudioManager::GetMaleNo2TalkSfx(int16 sound) switch(sound) { case SOUND_PED_CAR_JACKED: - cAudioManager::GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_MALE_NO_2_CAR_JACKED_1, - 3u); + GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_MALE_NO_2_CAR_JACKED_1, 3u); break; case SOUND_PED_ROBBED: GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_MALE_NO_2_ROBBED_1, 4u); @@ -1750,8 +1662,7 @@ cAudioManager::GetMaleNo2TalkSfx(int16 sound) GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_MALE_NO_2_EVADE_1, 4u); break; case SOUND_PED_CAR_COLLISION: - cAudioManager::GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_MALE_NO_2_CAR_COLLISION_1, - 7u); + GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_MALE_NO_2_CAR_COLLISION_1, 7u); break; case SOUND_PED_CHAT_SEXY: GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_MALE_NO_2_CHAT_SEXY_1, 5u); @@ -1759,7 +1670,7 @@ cAudioManager::GetMaleNo2TalkSfx(int16 sound) case SOUND_PED_CHAT: GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_MALE_NO_2_CHAT_1, 7u); break; - default: return cAudioManager::GetGenericMaleTalkSfx(sound); + default: return GetGenericMaleTalkSfx(sound); } return sfx; } @@ -2122,9 +2033,8 @@ cAudioManager::GetBlackProjectFemaleOldTalkSfx(int16 sound) 6u); break; case SOUND_PED_CAR_COLLISION: - cAudioManager::GetPhrase( - &sfx, &lastSfx, AUDIO_SAMPLE_PED_BLACK_PROJECT_FEMALE_OLD_1_CAR_COLLISION_1, - 7u); + GetPhrase(&sfx, &lastSfx, + AUDIO_SAMPLE_PED_BLACK_PROJECT_FEMALE_OLD_1_CAR_COLLISION_1, 7u); break; case SOUND_PED_CHAT_EVENT: GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_BLACK_PROJECT_FEMALE_OLD_1_CHAT_EVENT_1, @@ -2146,9 +2056,8 @@ cAudioManager::GetBlackProjectFemaleYoungTalkSfx(int16 sound) switch(sound) { case SOUND_PED_HANDS_COWER: - cAudioManager::GetPhrase( - &sfx, &lastSfx, AUDIO_SAMPLE_PED_BLACK_PROJECT_FEMALE_YOUNG_1_HANDS_COWER_1, - 4u); + GetPhrase(&sfx, &lastSfx, + AUDIO_SAMPLE_PED_BLACK_PROJECT_FEMALE_YOUNG_1_HANDS_COWER_1, 4u); break; case SOUND_PED_CAR_JACKED: sfx = AUDIO_SAMPLE_PED_BLACK_PROJECT_FEMALE_YOUNG_1_CAR_JACKED_1; @@ -2162,9 +2071,8 @@ cAudioManager::GetBlackProjectFemaleYoungTalkSfx(int16 sound) 5u); break; case SOUND_PED_CAR_COLLISION: - cAudioManager::GetPhrase( - &sfx, &lastSfx, AUDIO_SAMPLE_PED_BLACK_PROJECT_FEMALE_YOUNG_1_CAR_COLLISION_1, - 6u); + GetPhrase(&sfx, &lastSfx, + AUDIO_SAMPLE_PED_BLACK_PROJECT_FEMALE_YOUNG_1_CAR_COLLISION_1, 6u); break; case SOUND_PED_CHAT_EVENT: GetPhrase(&sfx, &lastSfx, @@ -3173,17 +3081,15 @@ cAudioManager::GetEightTalkSfx(int16 sound) switch(sound) { case SOUND_PED_HANDS_UP: - cAudioManager::GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_EIGHT_HANDS_UP_1, 2u); + GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_EIGHT_HANDS_UP_1, 2u); break; case SOUND_PED_ROBBED: - cAudioManager::GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_EIGHT_ROBBED_1, 2u); + GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_EIGHT_ROBBED_1, 2u); break; case SOUND_PED_ATTACK: - cAudioManager::GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_EIGHT_ATTACK_1, 6u); - break; - case SOUND_PED_EVADE: - cAudioManager::GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_EIGHT_EVADE_1, 7u); + GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_EIGHT_ATTACK_1, 6u); break; + case SOUND_PED_EVADE: GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_EIGHT_EVADE_1, 7u); break; default: return GetGenericMaleTalkSfx(sound); } return sfx; @@ -3333,29 +3239,302 @@ cAudioManager::GetGenericFemaleTalkSfx(int16 sound) switch(sound) { case SOUND_PED_DEATH: - cAudioManager::GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_FEMALE_DEATH_1, 10u); + GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_FEMALE_DEATH_1, 10u); break; case SOUND_PED_BULLET_HIT: case SOUND_PED_DEFEND: - cAudioManager::GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_INJURED_PED_FEMALE_OUCH_1, - 11u); + GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_INJURED_PED_FEMALE_OUCH_1, 11u); break; case SOUND_PED_BURNING: - cAudioManager::GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_FEMALE_BURNING_1, 9u); + GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_FEMALE_BURNING_1, 9u); break; case SOUND_PED_FLEE_SPRINT: - cAudioManager::GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_FEMALE_FLEE_SPRINT_1, 8u); + GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_FEMALE_FLEE_SPRINT_1, 8u); break; default: return NO_SAMPLE; } - return sfx; -} - -WRAPPER -void -cAudioManager::PlayOneShot(int32 index, int16 sound, float vol) -{ - EAXJMP(0x57A500); + return sfx; +} + +int8 +cAudioManager::GetCurrent3DProviderIndex() const +{ + if(m_bIsInitialised) return SampleManager.GetCurrent3DProviderIndex(); + + return -1; +} + +float +cAudioManager::GetCollisionLoopingRatio(uint32 a, uint32 b, float c) const +{ + return GetCollisionRatio(c, 0.0f, 0.02f, 0.02f); +} + +float +cAudioManager::GetCollisionOneShotRatio(uint32 a, float b) const +{ + float result; + + switch(a) { + case 0u: + case 1u: + case 5u: + case 26u: + case 31u: result = GetCollisionRatio(b, 10.0, 60.0, 50.0); break; + case 2u: + case 3u: + case 4u: + case 30u: result = GetCollisionRatio(b, 0.0, 2.0, 2.0); break; + case 6u: result = GetCollisionRatio(b, 6.0, 50.0, 44.0); break; + case 7u: + case 16u: result = GetCollisionRatio(b, 0.1, 10.0, 9.9); break; + case 8u: + case 11u: result = GetCollisionRatio(b, 30.0, 130.0, 100.0); break; + case 9u: result = GetCollisionRatio(b, 20.0, 100.0, 80.0); break; + case 10u: result = GetCollisionRatio(b, 0.0, 4.0, 4.0); break; + case 12u: + case 13u: + case 32u: result = GetCollisionRatio(b, 1.0, 10.0, 9.0); break; + case 14u: result = GetCollisionRatio(b, 1.0, 15.0, 14.0); break; + case 15u: result = GetCollisionRatio(b, 8.0, 50.0, 42.0); break; + case 17u: result = GetCollisionRatio(b, 0.0, 20.0, 20.0); break; + case 18u: + case 19u: + case 23u: + case 29u: result = GetCollisionRatio(b, 0.0, 10.0, 10.0); break; + case 20u: result = GetCollisionRatio(b, 1.0, 4.0, 3.0); break; + case 21u: result = GetCollisionRatio(b, 0.1, 5.0, 4.9); break; + case 22u: result = GetCollisionRatio(b, 0.1, 40.0, 39.9); break; + case 24u: result = GetCollisionRatio(b, 0.1, 4.0, 3.9); break; + case 25u: result = GetCollisionRatio(b, 0.0, 0.5, 0.5); break; + case 27u: result = GetCollisionRatio(b, 4.0, 40.0, 36.0); break; + case 28u: result = GetCollisionRatio(b, 0.0, 5.0, 5.0); break; + default: result = 0.0; break; + } + return result; +} + +float +cAudioManager::GetCollisionRatio(float a, float b, float c, float d) const +{ + float e; + e = a; + if(a <= b) return 0.0f; + if(c <= a) e = c; + return (e - b) / d; +} + +float +cAudioManager::GetDistanceSquared(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); +} + +int32 +cAudioManager::GetJumboTaxiFreq() const +{ + return (60.833f * m_sQueueSample.m_fDistance) + 22050; +} + +bool +cAudioManager::GetMissionAudioLoadingStatus() const +{ + if(m_bIsInitialised) return m_sMissionAudio.m_bLoadingStatus; + + return true; +} + +char +cAudioManager::GetMissionScriptPoliceAudioPlayingStatus() const +{ + return g_nMissionAudioPlayingStatus; +} + +bool +cAudioManager::HasAirBrakes(int32 model) const +{ + return model == LINERUN || model == FIRETRUK || model == TRASH || model == BUS || + model == COACH; +} + +void +cAudioManager::Initialise() +{ + if(!m_bIsInitialised) { + PreInitialiseGameSpecificSetup(); + m_bIsInitialised = SampleManager.Initialise(); + if(m_bIsInitialised) { + m_bActiveSamples = SampleManager.GetMaximumSupportedChannels(); + if(m_bActiveSamples <= 1u) { + Terminate(); + } else { + --m_bActiveSamples; + PostInitialiseGameSpecificSetup(); + InitialisePoliceRadioZones(); + InitialisePoliceRadio(); + MusicManager.Initialise(); + } + } + } +} + +WRAPPER +void +cAudioManager::InitialisePoliceRadio() +{ + EAXJMP(0x57EEC0); +} + +WRAPPER +void +cAudioManager::InitialisePoliceRadioZones() +{ + EAXJMP(0x57EAC0); +} + +void +cAudioManager::InterrogateAudioEntities() +{ + for(int32 i = 0; i < m_nAudioEntitiesTotal; i++) { + ProcessEntity(m_anAudioEntityIndices[i]); + m_asAudioEntities[m_anAudioEntityIndices[i]].m_Loops = 0; + } +} + +bool +cAudioManager::IsMissionAudioSampleFinished() +{ + if(m_bIsInitialised) return m_sMissionAudio.m_bPlayStatus == 2; + + static int32 cPretendFrame = 1; + + return (cPretendFrame++ & 63) == 0; +} + +bool +cAudioManager::MissionScriptAudioUsesPoliceChannel(int32 soundMission) const +{ + switch(soundMission) { + case STREAMED_SOUND_MISSION_J6_D: + case STREAMED_SOUND_MISSION_T4_A: + case STREAMED_SOUND_MISSION_S1_H: + case STREAMED_SOUND_MISSION_S3_B: + case STREAMED_SOUND_MISSION_EL3_A: + case STREAMED_SOUND_MISSION_A3_A: + case STREAMED_SOUND_MISSION_A5_A: + case STREAMED_SOUND_MISSION_K1_A: + case STREAMED_SOUND_MISSION_R1_A: + case STREAMED_SOUND_MISSION_R5_A: + case STREAMED_SOUND_MISSION_LO2_A: + case STREAMED_SOUND_MISSION_LO6_A: return true; + default: return false; + } +} + +void +cAudioManager::PlayLoadedMissionAudio() +{ + if(m_bIsInitialised && m_sMissionAudio.m_nSampleIndex != NO_SAMPLE && + m_sMissionAudio.m_bLoadingStatus == 1 && !m_sMissionAudio.m_bPlayStatus) { + m_sMissionAudio.m_bIsPlayed = true; + } +} + +WRAPPER +void +cAudioManager::PlayOneShot(int32 index, int16 sound, float vol) +{ + EAXJMP(0x57A500); +} + +bool &bPlayerJustEnteredCar = *(bool *)0x6508C4; + +void +cAudioManager::PlayerJustGotInCar() const +{ + if(m_bIsInitialised) { bPlayerJustEnteredCar = true; } +} + +void +cAudioManager::PlayerJustLeftCar(void) const +{ + // UNUSED: This is a perfectly empty function. +} + +void +cAudioManager::PostInitialiseGameSpecificSetup() +{ + m_nFireAudioEntity = + CreateEntity(AUDIOTYPE_FIRE, + (CPhysical *)0x8F31D0); // last is addr of firemanager @todo change + if(m_nFireAudioEntity >= 0) SetEntityStatus(m_nFireAudioEntity, 1); + + m_nCollisionEntity = CreateEntity(AUDIOTYPE_COLLISION, (CPhysical *)1); + if(m_nCollisionEntity >= 0) SetEntityStatus(m_nCollisionEntity, 1); + + m_nFrontEndEntity = CreateEntity(AUDIOTYPE_FRONTEND, (CPhysical *)1); + if(m_nFrontEndEntity >= 0) SetEntityStatus(m_nFrontEndEntity, 1); + + m_nProjectileEntity = CreateEntity(AUDIOTYPE_PROJECTILE, (CPhysical *)1); + if(m_nProjectileEntity >= 0) SetEntityStatus(m_nProjectileEntity, 1); + + m_nWaterCannonEntity = CreateEntity(AUDIOTYPE_WATER_CANNON, (CPhysical *)1); + if(m_nWaterCannonEntity >= 0) SetEntityStatus(m_nWaterCannonEntity, 1); + + m_nPoliceChannelEntity = CreateEntity(AUDIOTYPE_D, (CPhysical *)1); + if(m_nPoliceChannelEntity >= 0) SetEntityStatus(m_nPoliceChannelEntity, 1); + + m_nBridgeEntity = CreateEntity(AUDIOTYPE_BRIDGE, (CPhysical *)1); + if(m_nBridgeEntity >= 0) SetEntityStatus(m_nBridgeEntity, 1); + + m_sMissionAudio.m_nSampleIndex = NO_SAMPLE; + m_sMissionAudio.m_bLoadingStatus = 0; + m_sMissionAudio.m_bPlayStatus = 0; + m_sMissionAudio.field_22 = 0; + m_sMissionAudio.m_bIsPlayed = 0; + m_sMissionAudio.field_12 = 1; + m_sMissionAudio.field_24 = 0; + ResetAudioLogicTimers((int32)CTimer::GetTimeInMilliseconds); +} + +void +cAudioManager::PostTerminateGameSpecificShutdown() +{ + ; +} + +void +cAudioManager::PreTerminateGameSpecificShutdown() +{ + if(m_nBridgeEntity >= 0) { + DestroyEntity(m_nBridgeEntity); + m_nBridgeEntity = -5; + } + if(m_nPoliceChannelEntity >= 0) { + DestroyEntity(m_nPoliceChannelEntity); + m_nPoliceChannelEntity = -5; + } + if(m_nWaterCannonEntity >= 0) { + DestroyEntity(m_nWaterCannonEntity); + m_nWaterCannonEntity = -5; + } + if(m_nFireAudioEntity >= 0) { + DestroyEntity(m_nFireAudioEntity); + m_nFireAudioEntity = -5; + } + if(m_nCollisionEntity >= 0) { + DestroyEntity(m_nCollisionEntity); + m_nCollisionEntity = -5; + } + if(m_nFrontEndEntity >= 0) { + DestroyEntity(m_nFrontEndEntity); + m_nFrontEndEntity = -5; + } + if(m_nProjectileEntity >= 0) { + DestroyEntity(m_nProjectileEntity); + m_nProjectileEntity = -5; + } } #if 1 @@ -3390,7 +3569,7 @@ cAudioManager::ProcessAirBrakes(cVehicleParams *params) rand = m_anRandomTable[0] % 10u + 70; m_sQueueSample.m_bVolume = ComputeVolume(rand, 30.0f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.field_4 = 13; + m_sQueueSample.m_counter = 13; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_VEHICLE_AIR_BRAKES; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_VEHICLE_AIR_BRAKES); @@ -3447,7 +3626,7 @@ cAudioManager::ProcessAirportScriptObject(uint8 sound) m_sQueueSample.m_bBankIndex = 0; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency( m_sQueueSample.m_nSampleIndex); - m_sQueueSample.field_4 = counter++; + m_sQueueSample.m_counter = counter++; m_sQueueSample.m_bIsDistant = 0; m_sQueueSample.m_nLoopCount = 1; m_sQueueSample.field_56 = 1; @@ -3485,7 +3664,7 @@ cAudioManager::ProcessBoatEngine(cVehicleParams *params) m_sQueueSample.m_bVolume = ComputeVolume(80u, 50.f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.field_4 = 39; + m_sQueueSample.m_counter = 39; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_MOTOR; m_sQueueSample.m_nFrequency = 10386; m_sQueueSample.m_nFrequency += @@ -3535,7 +3714,7 @@ cAudioManager::ProcessBoatEngine(cVehicleParams *params) m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, 50.f, m_sQueueSample.m_fDistance); if(!m_sQueueSample.m_bVolume) return 1; - m_sQueueSample.field_4 = 40; + m_sQueueSample.m_counter = 40; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_BOAT_ENGINE; m_sQueueSample.m_nFrequency += (m_sQueueSample.m_nEntityIndex << 16) % 1000; m_sQueueSample.m_bBankIndex = 0; @@ -3562,7 +3741,7 @@ cAudioManager::ProcessBoatEngine(cVehicleParams *params) if(padAccelerate <= 20) { emittingVol = 45 - 45 * padAccelerate / 40; m_sQueueSample.m_nFrequency = 100 * padAccelerate + 11025; - m_sQueueSample.field_4 = 39; + m_sQueueSample.m_counter = 39; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_BOAT_ENGINE_IDLE; if(LastAccel > 20) { @@ -3577,7 +3756,7 @@ cAudioManager::ProcessBoatEngine(cVehicleParams *params) if(!boat->m_bIsAnchored) m_sQueueSample.m_nFrequency = 11 * m_sQueueSample.m_nFrequency / 10u; - m_sQueueSample.field_4 = 40; + m_sQueueSample.m_counter = 40; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_BOAT_ENGINE; } LastVol = emittingVol; @@ -3587,7 +3766,7 @@ cAudioManager::ProcessBoatEngine(cVehicleParams *params) if(gasPedal > 0.0f) { m_sQueueSample.m_nFrequency = 11025; emittingVol = 45; - m_sQueueSample.field_4 = 39; + m_sQueueSample.m_counter = 39; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_BOAT_ENGINE_IDLE; } else { @@ -3596,7 +3775,7 @@ cAudioManager::ProcessBoatEngine(cVehicleParams *params) if(!boat->m_bIsAnchored) m_sQueueSample.m_nFrequency = 11 * m_sQueueSample.m_nFrequency / 10u; - m_sQueueSample.field_4 = 40; + m_sQueueSample.m_counter = 40; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_BOAT_ENGINE; } } @@ -3639,13 +3818,13 @@ cAudioManager::ProcessBoatMovingOverWater(cVehicleParams *params) velocityChange = Abs(params->m_fVelocityChange); if(velocityChange <= 0.0005f && params->m_pVehicle->GetPosition().y) return 1; - velocityChange = min(0.75f, velocityChange); + velocityChange = Min(0.75f, velocityChange); multiplier = (velocityChange - 0.0005f) * 1.3342f; CalculateDistance((bool *)params, params->m_fDistance); vol = (30.f * multiplier); m_sQueueSample.m_bVolume = ComputeVolume(vol, 50.f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.field_4 = 38; + m_sQueueSample.m_counter = 38; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_LOOPING_WATER; m_sQueueSample.m_bBankIndex = 0; m_sQueueSample.m_bIsDistant = 0; @@ -3700,16 +3879,17 @@ void cAudioManager::ProcessBridgeMotor() { if(m_sQueueSample.m_fDistance < 400.f) { - m_sQueueSample.m_bVolume = ComputeVolume(127, 400.f, m_sQueueSample.m_fDistance); + m_sQueueSample.m_bVolume = + ComputeVolume(maxVolume, 400.f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.field_4 = 1; + m_sQueueSample.m_counter = 1; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_MOTOR; m_sQueueSample.m_bBankIndex = 0; m_sQueueSample.m_bIsDistant = 0; m_sQueueSample.field_16 = 1; m_sQueueSample.m_nFrequency = 5500; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_bEmittingVolume = 127; + m_sQueueSample.m_bEmittingVolume = maxVolume; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = @@ -3756,7 +3936,7 @@ cAudioManager::ProcessBridgeOneShots() m_sQueueSample.m_bVolume = ComputeVolume(maxVolume, maxDist, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.field_4 = 2; + m_sQueueSample.m_counter = 2; m_sQueueSample.m_bBankIndex = 0; m_sQueueSample.m_bIsDistant = 0; m_sQueueSample.field_16 = 1; @@ -3782,7 +3962,7 @@ cAudioManager::ProcessBridgeWarning() if(CStats::CommercialPassed && m_sQueueSample.m_fDistance < 450.f) { m_sQueueSample.m_bVolume = ComputeVolume(100u, 450.f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.field_4 = 0; + m_sQueueSample.m_counter = 0; m_sQueueSample.m_nSampleIndex = 457; m_sQueueSample.m_bBankIndex = 0; m_sQueueSample.m_bIsDistant = 0; @@ -3817,7 +3997,7 @@ cAudioManager::ProcessCarBombTick(cVehicleParams *params) CalculateDistance((bool *)params, params->m_fDistance); m_sQueueSample.m_bVolume = ComputeVolume(60u, 40.f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.field_4 = 35; + m_sQueueSample.m_counter = 35; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_CAR_BOMB_TICK; m_sQueueSample.m_bBankIndex = 0; m_sQueueSample.m_bIsDistant = 0; @@ -3830,8 +4010,8 @@ cAudioManager::ProcessCarBombTick(cVehicleParams *params) SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.field_48 = 2.0; - m_sQueueSample.m_fSoundIntensity = 40.0; + m_sQueueSample.field_48 = 2.0f; + m_sQueueSample.m_fSoundIntensity = 40.0f; m_sQueueSample.field_56 = 0; m_sQueueSample.field_76 = 3; m_sQueueSample.m_bReverbFlag = 1; @@ -3884,7 +4064,7 @@ cAudioManager::ProcessCinemaScriptObject(uint8 sound) m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency >> 2); - m_sQueueSample.field_4 = counter++; + m_sQueueSample.m_counter = counter++; m_sQueueSample.m_bIsDistant = 0; m_sQueueSample.m_nLoopCount = 1; m_sQueueSample.field_56 = 1; @@ -3945,7 +4125,7 @@ cAudioManager::ProcessDocksScriptObject(uint8 sound) SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_DOCKS); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency >> 3); - m_sQueueSample.field_4 = counter++; + m_sQueueSample.m_counter = counter++; m_sQueueSample.m_bIsDistant = 0; m_sQueueSample.m_nLoopCount = 1; m_sQueueSample.field_56 = 1; @@ -3991,7 +4171,7 @@ cAudioManager::ProcessEngineDamage(cVehicleParams *params) m_sQueueSample.m_bVolume = ComputeVolume(emittingVolume, 40.f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.field_4 = 28; + m_sQueueSample.m_counter = 28; m_sQueueSample.m_bBankIndex = 0; m_sQueueSample.m_bIsDistant = 0; m_sQueueSample.m_nLoopCount = 0; @@ -4000,8 +4180,8 @@ cAudioManager::ProcessEngineDamage(cVehicleParams *params) SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.field_48 = 2.0; - m_sQueueSample.m_fSoundIntensity = 40.0; + m_sQueueSample.field_48 = 2.0f; + m_sQueueSample.m_fSoundIntensity = 40.0f; m_sQueueSample.field_56 = 0; m_sQueueSample.field_76 = 3; m_sQueueSample.m_bReverbFlag = 1; @@ -4146,9 +4326,7 @@ cAudioManager::ProcessExplosions(int32 explosion) break; } pos = CExplosion::GetExplosionPosition(i); - m_sQueueSample.m_vecPos.x = pos->x; - m_sQueueSample.m_vecPos.y = pos->y; - m_sQueueSample.m_vecPos.z = pos->z; + m_sQueueSample.m_vecPos = *pos; distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos); if(distSquared < maxDist) { m_sQueueSample.m_fDistance = Sqrt(distSquared); @@ -4156,7 +4334,7 @@ cAudioManager::ProcessExplosions(int32 explosion) ComputeVolume(maxVolume, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.field_4 = i; + m_sQueueSample.m_counter = i; m_sQueueSample.field_48 = 2.0f; m_sQueueSample.m_bIsDistant = 0; m_sQueueSample.m_nLoopCount = 1; @@ -4187,7 +4365,7 @@ cAudioManager::ProcessFireHydrant() CalculateDistance(&something, distSquared); m_sQueueSample.m_bVolume = ComputeVolume(40u, 35.f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.field_4 = 0; + m_sQueueSample.m_counter = 0; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_JUMBO_TAXI_SOUND; m_sQueueSample.m_bBankIndex = 0; m_sQueueSample.m_bIsDistant = 0; @@ -4225,7 +4403,7 @@ cAudioManager::ProcessFrontEnd() static uint32 counter = 0; - for(uint32 i = 0; i < m_asAudioEntities[m_sQueueSample.m_nEntityIndex].field_24; i++) { + for(uint32 i = 0; i < m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_Loops; i++) { processed = 0; switch( m_asAudioEntities[0].m_awAudioEvent[i + 20 * m_sQueueSample.m_nEntityIndex]) { @@ -4348,7 +4526,7 @@ cAudioManager::ProcessFrontEnd() SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); } m_sQueueSample.m_bVolume = 110; - m_sQueueSample.field_4 = counter++; + m_sQueueSample.m_counter = counter++; m_sQueueSample.m_nLoopCount = 1; m_sQueueSample.field_56 = 1; m_sQueueSample.m_bBankIndex = 0; @@ -4366,8 +4544,8 @@ cAudioManager::ProcessFrontEnd() AddSampleToRequestedQueue(); if(processed) { ++m_sQueueSample.m_nSampleIndex; - m_sQueueSample.field_4 = counter++; - m_sQueueSample.m_bOffset = 127 - m_sQueueSample.m_bOffset; + m_sQueueSample.m_counter = counter++; + m_sQueueSample.m_bOffset = maxVolume - m_sQueueSample.m_bOffset; AddSampleToRequestedQueue(); } } @@ -4418,7 +4596,7 @@ cAudioManager::ProcessHelicopter(cVehicleParams *params) m_sQueueSample.m_bVolume = ComputeVolume( emittingVol, gHeliSfxRanges[i].m_fMaxDistance, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.field_4 = i + 65; + m_sQueueSample.m_counter = i + 65; m_sQueueSample.m_nSampleIndex = i + AUDIO_SAMPLE_HELI_FAR; m_sQueueSample.m_bBankIndex = 0; m_sQueueSample.m_bIsDistant = 0; @@ -4432,7 +4610,7 @@ cAudioManager::ProcessHelicopter(cVehicleParams *params) SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.field_48 = 6.0; + m_sQueueSample.field_48 = 6.0f; m_sQueueSample.m_fSoundIntensity = gHeliSfxRanges[i].m_fMaxDistance; m_sQueueSample.field_56 = 0; m_sQueueSample.field_76 = 3; @@ -4481,7 +4659,7 @@ cAudioManager::ProcessHomeScriptObject(uint8 sound) m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency >> 4); - m_sQueueSample.field_4 = counter++; + m_sQueueSample.m_counter = counter++; m_sQueueSample.m_bIsDistant = 0; m_sQueueSample.m_nLoopCount = 1; m_sQueueSample.field_56 = 1; @@ -4546,7 +4724,7 @@ cAudioManager::ProcessJumboAccel(CPlane *plane) if(SetupJumboFlySound(20u)) { modificator = (plane->m_fSpeed - 0.10334f) * 1.676f; if(modificator > 1.0f) modificator = 1.0f; - if(cAudioManager::SetupJumboRumbleSound(maxVolume * modificator) && + if(SetupJumboRumbleSound(maxVolume * modificator) && SetupJumboTaxiSound((1.0f - modificator) * 75.f)) { if(modificator < 0.2f) { whineSoundFreq = modificator * 5.f * 14600.0f + 29500; @@ -4579,7 +4757,7 @@ cAudioManager::ProcessJumboDecel(CPlane *plane) void cAudioManager::ProcessJumboFlying() { - if(SetupJumboFlySound(127u)) SetupJumboEngineSound(63u, 22050); + if(SetupJumboFlySound(maxVolume)) SetupJumboEngineSound(63u, 22050); } void @@ -4598,12 +4776,12 @@ cAudioManager::ProcessJumboLanding(CPlane *plane) void cAudioManager::ProcessJumboTakeOff(CPlane *plane) { - double modificator = (PlanePathPosition[plane->m_nPlaneId] - TakeOffPoint) * 0.0033333f; + float modificator = (PlanePathPosition[plane->m_nPlaneId] - TakeOffPoint) * 0.0033333f; - if(cAudioManager::SetupJumboFlySound((107.f * modificator) + 20) && - cAudioManager::SetupJumboRumbleSound(maxVolume * (1.f - modificator))) { - if(cAudioManager::SetupJumboEngineSound(127u, 22050)) - cAudioManager::SetupJumboWhineSound(18.f * (1.f - modificator), 44100); + if(SetupJumboFlySound((107.f * modificator) + 20) && + SetupJumboRumbleSound(maxVolume * (1.f - modificator))) { + if(SetupJumboEngineSound(maxVolume, 22050)) + SetupJumboWhineSound(18.f * (1.f - modificator), 44100); } } @@ -4639,7 +4817,7 @@ cAudioManager::ProcessLaunderetteScriptObject(uint8 sound) m_sQueueSample.m_bBankIndex = 0; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_LAUNDERETTE_1); - m_sQueueSample.field_4 = 0; + m_sQueueSample.m_counter = 0; m_sQueueSample.m_bIsDistant = 0; m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.field_56 = 0; @@ -4661,7 +4839,7 @@ cAudioManager::ProcessLaunderetteScriptObject(uint8 sound) m_sQueueSample.m_bBankIndex = 0; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_LAUNDERETTE_2); - m_sQueueSample.field_4 = 1; + m_sQueueSample.m_counter = 1; m_sQueueSample.m_bIsDistant = 0; m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.field_56 = 0; @@ -4692,7 +4870,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) m_sQueueSample.m_fSoundIntensity = 30.0f; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PARTY_1; m_sQueueSample.m_bBankIndex = 0; - emittingVolume = 127; + emittingVolume = maxVolume; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_PARTY_1); m_sQueueSample.field_16 = 3; @@ -4704,7 +4882,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) m_sQueueSample.m_fSoundIntensity = 80.0f; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PARTY_1; m_sQueueSample.m_bBankIndex = 0; - emittingVolume = 127; + emittingVolume = maxVolume; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_PARTY_1); m_sQueueSample.field_16 = 3; @@ -4716,7 +4894,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) m_sQueueSample.m_fSoundIntensity = 30.0f; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PARTY_2; m_sQueueSample.m_bBankIndex = 0; - emittingVolume = 127; + emittingVolume = maxVolume; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_PARTY_2); m_sQueueSample.field_16 = 3; @@ -4728,7 +4906,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) m_sQueueSample.m_fSoundIntensity = 80.0f; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PARTY_2; m_sQueueSample.m_bBankIndex = 0; - emittingVolume = 127; + emittingVolume = maxVolume; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_PARTY_2); m_sQueueSample.field_16 = 3; @@ -4740,7 +4918,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) m_sQueueSample.m_fSoundIntensity = 30.0f; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PARTY_3; m_sQueueSample.m_bBankIndex = 0; - emittingVolume = 127; + emittingVolume = maxVolume; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_PARTY_3); m_sQueueSample.field_16 = 3; @@ -4752,7 +4930,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) m_sQueueSample.m_fSoundIntensity = 80.0f; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PARTY_3; m_sQueueSample.m_bBankIndex = 0; - emittingVolume = 127; + emittingVolume = maxVolume; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_PARTY_3); m_sQueueSample.field_16 = 3; @@ -4764,7 +4942,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) m_sQueueSample.m_fSoundIntensity = 30.0f; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PARTY_4; m_sQueueSample.m_bBankIndex = 0; - emittingVolume = 127; + emittingVolume = maxVolume; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_PARTY_4); m_sQueueSample.field_16 = 3; @@ -4776,7 +4954,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) m_sQueueSample.m_fSoundIntensity = 80.0f; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PARTY_4; m_sQueueSample.m_bBankIndex = 0; - emittingVolume = 127; + emittingVolume = maxVolume; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_PARTY_4); m_sQueueSample.field_16 = 3; @@ -4788,7 +4966,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) m_sQueueSample.m_fSoundIntensity = 30.0f; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PARTY_5; m_sQueueSample.m_bBankIndex = 0; - emittingVolume = 127; + emittingVolume = maxVolume; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_PARTY_5); m_sQueueSample.field_16 = 3; @@ -4800,7 +4978,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) m_sQueueSample.m_fSoundIntensity = 80.0f; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PARTY_5; m_sQueueSample.m_bBankIndex = 0; - emittingVolume = 127; + emittingVolume = maxVolume; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_PARTY_5); m_sQueueSample.field_16 = 3; @@ -4812,7 +4990,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) m_sQueueSample.m_fSoundIntensity = 30.0f; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PARTY_6; m_sQueueSample.m_bBankIndex = 0; - emittingVolume = 127; + emittingVolume = maxVolume; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_PARTY_6); m_sQueueSample.field_16 = 3; @@ -4824,7 +5002,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) m_sQueueSample.m_fSoundIntensity = 80.0f; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PARTY_6; m_sQueueSample.m_bBankIndex = 0; - emittingVolume = 127; + emittingVolume = maxVolume; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_PARTY_6); m_sQueueSample.field_16 = 3; @@ -4836,7 +5014,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) m_sQueueSample.m_fSoundIntensity = 30.0f; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PARTY_7; m_sQueueSample.m_bBankIndex = 0; - emittingVolume = 127; + emittingVolume = maxVolume; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_PARTY_7); m_sQueueSample.field_16 = 3; @@ -4848,7 +5026,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) m_sQueueSample.m_fSoundIntensity = 80.0f; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PARTY_7; m_sQueueSample.m_bBankIndex = 0; - emittingVolume = 127; + emittingVolume = maxVolume; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_PARTY_7); m_sQueueSample.field_16 = 3; @@ -4860,7 +5038,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) m_sQueueSample.m_fSoundIntensity = 30.0f; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PARTY_8; m_sQueueSample.m_bBankIndex = 0; - emittingVolume = 127; + emittingVolume = maxVolume; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_PARTY_8); m_sQueueSample.field_16 = 3; @@ -4872,7 +5050,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) m_sQueueSample.m_fSoundIntensity = 80.0f; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PARTY_8; m_sQueueSample.m_bBankIndex = 0; - emittingVolume = 127; + emittingVolume = maxVolume; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_PARTY_8); m_sQueueSample.field_16 = 3; @@ -4884,7 +5062,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) m_sQueueSample.m_fSoundIntensity = 30.0f; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PARTY_9; m_sQueueSample.m_bBankIndex = 0; - emittingVolume = 127; + emittingVolume = maxVolume; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_PARTY_9); m_sQueueSample.field_16 = 3; @@ -4896,7 +5074,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) m_sQueueSample.m_fSoundIntensity = 80.0f; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PARTY_9; m_sQueueSample.m_bBankIndex = 0; - emittingVolume = 127; + emittingVolume = maxVolume; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_PARTY_9); m_sQueueSample.field_16 = 3; @@ -4908,7 +5086,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) m_sQueueSample.m_fSoundIntensity = 30.0f; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PARTY_10; m_sQueueSample.m_bBankIndex = 0; - emittingVolume = 127; + emittingVolume = maxVolume; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_PARTY_10); m_sQueueSample.field_16 = 3; @@ -4920,7 +5098,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) m_sQueueSample.m_fSoundIntensity = 80.0f; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PARTY_10; m_sQueueSample.m_bBankIndex = 0; - emittingVolume = 127; + emittingVolume = maxVolume; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_PARTY_10); m_sQueueSample.field_16 = 3; @@ -4932,7 +5110,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) m_sQueueSample.m_fSoundIntensity = 30.0f; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PARTY_11; m_sQueueSample.m_bBankIndex = 0; - emittingVolume = 127; + emittingVolume = maxVolume; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_PARTY_11); m_sQueueSample.field_16 = 3; @@ -4944,7 +5122,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) m_sQueueSample.m_fSoundIntensity = 80.0f; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PARTY_11; m_sQueueSample.m_bBankIndex = 0; - emittingVolume = 127; + emittingVolume = maxVolume; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_PARTY_11); m_sQueueSample.field_16 = 3; @@ -4956,7 +5134,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) m_sQueueSample.m_fSoundIntensity = 30.0f; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PARTY_12; m_sQueueSample.m_bBankIndex = 0; - emittingVolume = 127; + emittingVolume = maxVolume; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_PARTY_12); m_sQueueSample.field_16 = 3; @@ -4968,7 +5146,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) m_sQueueSample.m_fSoundIntensity = 80.0f; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PARTY_12; m_sQueueSample.m_bBankIndex = 0; - emittingVolume = 127; + emittingVolume = maxVolume; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_PARTY_12); m_sQueueSample.field_16 = 3; @@ -4980,7 +5158,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) m_sQueueSample.m_fSoundIntensity = 30.0f; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PARTY_13; m_sQueueSample.m_bBankIndex = 0; - emittingVolume = 127; + emittingVolume = maxVolume; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_PARTY_13); m_sQueueSample.field_16 = 3; @@ -4992,7 +5170,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) m_sQueueSample.m_fSoundIntensity = 80.0f; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PARTY_13; m_sQueueSample.m_bBankIndex = 0; - emittingVolume = 127; + emittingVolume = maxVolume; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_PARTY_13); m_sQueueSample.field_16 = 3; @@ -5004,7 +5182,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) m_sQueueSample.m_fSoundIntensity = 30.0f; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_STRIP_CLUB_1; m_sQueueSample.m_bBankIndex = 0; - emittingVolume = 127; + emittingVolume = maxVolume; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_STRIP_CLUB_1); m_sQueueSample.field_16 = 3; @@ -5016,7 +5194,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) m_sQueueSample.m_fSoundIntensity = 80.0f; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_STRIP_CLUB_1; m_sQueueSample.m_bBankIndex = 0; - emittingVolume = 127; + emittingVolume = maxVolume; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_STRIP_CLUB_1); m_sQueueSample.field_16 = 3; @@ -5028,7 +5206,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) m_sQueueSample.m_fSoundIntensity = 30.0f; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_STRIP_CLUB_2; m_sQueueSample.m_bBankIndex = 0; - emittingVolume = 127; + emittingVolume = maxVolume; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_STRIP_CLUB_2); m_sQueueSample.field_16 = 3; @@ -5040,7 +5218,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) m_sQueueSample.m_fSoundIntensity = 80.0f; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_STRIP_CLUB_2; m_sQueueSample.m_bBankIndex = 0; - emittingVolume = 127; + emittingVolume = maxVolume; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_STRIP_CLUB_2); m_sQueueSample.field_16 = 3; @@ -5048,11 +5226,9 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) m_sQueueSample.field_48 = 2.0f; break; case SCRIPT_SOUND_WORK_SHOP_LOOP_S: - case SCRIPT_SOUND_WORK_SHOP_LOOP_L: - cAudioManager::ProcessWorkShopScriptObject(sound); - return; + case SCRIPT_SOUND_WORK_SHOP_LOOP_L: ProcessWorkShopScriptObject(sound); return; case SCRIPT_SOUND_SAWMILL_LOOP_S: - case SCRIPT_SOUND_SAWMILL_LOOP_L: cAudioManager::ProcessSawMillScriptObject(sound); return; + case SCRIPT_SOUND_SAWMILL_LOOP_L: ProcessSawMillScriptObject(sound); return; case SCRIPT_SOUND_38: maxDist = 900.f; m_sQueueSample.m_fSoundIntensity = 30.0f; @@ -5182,15 +5358,15 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_CINEMA_LOOP_S: case SCRIPT_SOUND_CINEMA_LOOP_L: ProcessCinemaScriptObject(sound); return; case SCRIPT_SOUND_DOCKS_LOOP_S: - case SCRIPT_SOUND_DOCKS_LOOP_L: cAudioManager::ProcessDocksScriptObject(sound); return; + case SCRIPT_SOUND_DOCKS_LOOP_L: ProcessDocksScriptObject(sound); return; case SCRIPT_SOUND_HOME_LOOP_S: - case SCRIPT_SOUND_HOME_LOOP_L: cAudioManager::ProcessHomeScriptObject(sound); return; + case SCRIPT_SOUND_HOME_LOOP_L: ProcessHomeScriptObject(sound); return; case SCRIPT_SOUND_FRANKIE_PIANO: maxDist = 900.f; m_sQueueSample.m_fSoundIntensity = 30.0f; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_FRANKIE_PIANO; m_sQueueSample.m_bBankIndex = 0; - emittingVolume = 127; + emittingVolume = maxVolume; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_FRANKIE_PIANO); m_sQueueSample.field_16 = 3; @@ -5202,7 +5378,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) m_sQueueSample.m_fSoundIntensity = 80.0f; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PARTY_1; m_sQueueSample.m_bBankIndex = 0; - emittingVolume = 127; + emittingVolume = maxVolume; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_PARTY_1); m_sQueueSample.field_16 = 3; @@ -5246,7 +5422,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) m_sQueueSample.m_fSoundIntensity = 30.0f; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_POLICE_BALL; m_sQueueSample.m_bBankIndex = 0; - emittingVolume = 127; + emittingVolume = maxVolume; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_POLICE_BALL); m_sQueueSample.field_16 = 2; @@ -5258,7 +5434,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) m_sQueueSample.m_fSoundIntensity = 80.0f; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_POLICE_BALL; m_sQueueSample.m_bBankIndex = 0; - emittingVolume = 127; + emittingVolume = maxVolume; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_POLICE_BALL); m_sQueueSample.field_16 = 2; @@ -5270,7 +5446,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) m_sQueueSample.m_fSoundIntensity = 30.0f; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_RAVE_INDUSTRIAL; m_sQueueSample.m_bBankIndex = 0; - emittingVolume = 127; + emittingVolume = maxVolume; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_RAVE_INDUSTRIAL); m_sQueueSample.field_16 = 3; @@ -5282,7 +5458,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) m_sQueueSample.m_fSoundIntensity = 80.0f; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_RAVE_INDUSTRIAL; m_sQueueSample.m_bBankIndex = 0; - emittingVolume = 127; + emittingVolume = maxVolume; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_RAVE_INDUSTRIAL); m_sQueueSample.field_16 = 3; @@ -5291,7 +5467,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) break; case SCRIPT_SOUND_POLICE_CELL_BEATING_LOOP_S: case SCRIPT_SOUND_POLICE_CELL_BEATING_LOOP_L: - cAudioManager::ProcessPoliceCellBeatingScriptObject(sound); + ProcessPoliceCellBeatingScriptObject(sound); return; case SCRIPT_SOUND_RAVE_1_LOOP_S: case SCRIPT_SOUND_RAVE_2_LOOP_S: @@ -5299,7 +5475,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) m_sQueueSample.m_fSoundIntensity = 30.0f; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_RAVE_1; m_sQueueSample.m_bBankIndex = 0; - emittingVolume = 127; + emittingVolume = maxVolume; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.field_16 = 3; @@ -5312,7 +5488,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) m_sQueueSample.m_fSoundIntensity = 80.0f; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_RAVE_1; m_sQueueSample.m_bBankIndex = 0; - emittingVolume = 127; + emittingVolume = maxVolume; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.field_16 = 3; @@ -5324,7 +5500,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) m_sQueueSample.m_fSoundIntensity = 30.0f; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_RAVE_2; m_sQueueSample.m_bBankIndex = 0; - emittingVolume = 127; + emittingVolume = maxVolume; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_RAVE_2); m_sQueueSample.field_16 = 3; @@ -5336,7 +5512,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) m_sQueueSample.m_fSoundIntensity = 80.0f; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_RAVE_2; m_sQueueSample.m_bBankIndex = 0; - emittingVolume = 127; + emittingVolume = maxVolume; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_RAVE_2); m_sQueueSample.field_16 = 3; @@ -5364,7 +5540,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) m_sQueueSample.m_bVolume = ComputeVolume( emittingVolume, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.field_4 = 0; + m_sQueueSample.m_counter = 0; m_sQueueSample.m_bIsDistant = 0; m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.field_56 = 0; @@ -5380,6 +5556,155 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) } } +bool &g_bMissionAudioLoadFailed = *(bool *)0x95CD8E; + +void +cAudioManager::ProcessMissionAudio() +{ + float dist; + uint8 emittingVol; + uint8 pan; + float distSquared; + CVector vec; + + static uint8 nCheckPlayingDelay = 0; + static uint8 nFramesUntilFailedLoad = 0; + static uint8 nFramesForPretendPlaying = 0; + + if(this->m_bIsInitialised) { + if(m_sMissionAudio.m_nSampleIndex != 3033) { + switch(this->m_sMissionAudio.m_bLoadingStatus) { + case 0: + SampleManager.PreloadStreamedFile(m_sMissionAudio.m_nSampleIndex, + 1u); + m_sMissionAudio.m_bLoadingStatus = 1; + nFramesUntilFailedLoad = 0; + return; + case 1: + if(!this->m_sMissionAudio.m_bIsPlayed) return; + if(g_bMissionAudioLoadFailed) { + if(this->m_bTimerJustReset) { + ClearMissionAudio(); + SampleManager.StopStreamedFile(1u); + nFramesForPretendPlaying = 0; + nCheckPlayingDelay = 0; + nFramesUntilFailedLoad = 0; + } else if(!m_bUserPause) { + if(++nFramesForPretendPlaying < 120u) { + this->m_sMissionAudio.m_bPlayStatus = 1; + } else { + this->m_sMissionAudio.m_bPlayStatus = 2; + this->m_sMissionAudio.m_nSampleIndex = 3033; + } + } + } else { + if(m_sMissionAudio.m_bPlayStatus) { + if(m_sMissionAudio.m_bPlayStatus != 1) return; + if(this->m_bTimerJustReset) { + ClearMissionAudio(); + SampleManager.StopStreamedFile(1u); + return; + } + if(MissionScriptAudioUsesPoliceChannel( + m_sMissionAudio.m_nSampleIndex)) { + if(!m_bUserPause) { + if(nCheckPlayingDelay) { + --nCheckPlayingDelay; + } else if( + GetMissionScriptPoliceAudioPlayingStatus() == + 2 || + --m_sMissionAudio.field_24) { + m_sMissionAudio + .m_bPlayStatus = 2; + m_sMissionAudio + .m_nSampleIndex = 3033; + SampleManager + .StopStreamedFile(1u); + m_sMissionAudio.field_24 = + 0; + } + } + } else if(m_sMissionAudio.field_22) { + if(SampleManager.IsStreamPlaying(1u) || + m_bUserPause || m_bPreviousUserPause) { + if(m_bUserPause) + SampleManager.PauseStream( + 1, 1u); + else + SampleManager.PauseStream( + 0, 1u); + } else { + m_sMissionAudio.m_bPlayStatus = 2; + m_sMissionAudio.m_nSampleIndex = + 3033; + SampleManager.StopStreamedFile(1u); + m_sMissionAudio.field_24 = 0; + } + } else { + if(m_bUserPause) return; + if(nCheckPlayingDelay--) { + if(!SampleManager.IsStreamPlaying( + 1u)) + return; + nCheckPlayingDelay = 0; + } + m_sMissionAudio.field_22 = 1; + } + } else { + if(MissionScriptAudioUsesPoliceChannel( + m_sMissionAudio.m_nSampleIndex)) { + SetMissionScriptPoliceAudio( + m_sMissionAudio.m_nSampleIndex); + } else { + if(m_bUserPause) + SampleManager.PauseStream(1, 1u); + if(m_sMissionAudio.field_12) { + SampleManager + .SetStreamedVolumeAndPan( + 80u, 63u, 1, 1u); + } else { + distSquared = GetDistanceSquared( + &m_sMissionAudio.m_vecPos); + if(distSquared >= 2500.f) { + emittingVol = 0; + pan = 63; + } else { + dist = Sqrt(distSquared); + emittingVol = ComputeVolume( + 80u, 50.0f, dist); + TranslateEntity( + &m_sMissionAudio + .m_vecPos, + &vec); + pan = + ComputePan(50.f, &vec); + } + SampleManager + .SetStreamedVolumeAndPan( + emittingVol, pan, 1, 1u); + } + SampleManager.StartPreloadedStreamedFile( + 1u); + } + m_sMissionAudio.m_bPlayStatus = 1; + nCheckPlayingDelay = 30; + } + } + break; + case 2: + if(++nFramesUntilFailedLoad >= 90u) { + nFramesForPretendPlaying = 0; + g_bMissionAudioLoadFailed = 1; + nFramesUntilFailedLoad = 0; + this->m_sMissionAudio.m_bLoadingStatus = 1; + } + return; + default: return; + } + } + } +} + void cAudioManager::ProcessModelCarEngine(cVehicleParams *params) { @@ -5413,7 +5738,7 @@ cAudioManager::ProcessModelCarEngine(cVehicleParams *params) m_sQueueSample.m_bVolume = ComputeVolume( emittingVol, 30.f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.field_4 = 2; + m_sQueueSample.m_counter = 2; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_MODEL_VEHICLE_ACCELERATING; m_sQueueSample.m_bBankIndex = 0; @@ -5431,8 +5756,8 @@ cAudioManager::ProcessModelCarEngine(cVehicleParams *params) m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset( m_sQueueSample.m_nSampleIndex); - m_sQueueSample.field_48 = 3.0; - m_sQueueSample.m_fSoundIntensity = 30.0; + m_sQueueSample.field_48 = 3.0f; + m_sQueueSample.m_fSoundIntensity = 30.0f; m_sQueueSample.field_56 = 0; m_sQueueSample.field_76 = 3; m_sQueueSample.m_bReverbFlag = 1; @@ -5464,14 +5789,14 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) male.m_pPed = nil; male.m_bDistanceCalculated = 0; male.m_fDistance = GetDistanceSquared(&m_sQueueSample.m_vecPos); - cAudioManager::SetupPedComments(&male, SOUND_INJURED_PED_MALE_OUCH); + 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 = 0; female.m_fDistance = GetDistanceSquared(&m_sQueueSample.m_vecPos); - cAudioManager::SetupPedComments(&female, SOUND_INJURED_PED_FEMALE); + SetupPedComments(&female, SOUND_INJURED_PED_FEMALE); return; case SCRIPT_SOUND_GATE_START_CLUNK: case SCRIPT_SOUND_GATE_STOP_CLUNK: @@ -5512,7 +5837,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) m_sQueueSample.m_fSoundIntensity = 80.0f; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_389; m_sQueueSample.m_bBankIndex = 0; - emittingVolume = 127; + emittingVolume = maxVolume; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_389); m_sQueueSample.field_16 = 0; @@ -5663,7 +5988,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) emittingVolume, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.field_4 = iSound++; + m_sQueueSample.m_counter = iSound++; m_sQueueSample.m_nLoopCount = 1; m_sQueueSample.field_56 = 1; m_sQueueSample.m_bEmittingVolume = emittingVolume; @@ -5708,7 +6033,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) m_sQueueSample.m_bVolume = ComputeVolume( emittingVolume, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.field_4 = iSound++; + m_sQueueSample.m_counter = iSound++; m_sQueueSample.m_nLoopCount = 1; m_sQueueSample.field_56 = 1; m_sQueueSample.m_bEmittingVolume = emittingVolume; @@ -5768,7 +6093,7 @@ cAudioManager::ProcessPedHeadphones(cPedParams *params) m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, 7.f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.field_4 = 64; + m_sQueueSample.m_counter = 64; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PED_HEADPHONES; m_sQueueSample.m_bBankIndex = 0; m_sQueueSample.m_bIsDistant = 0; @@ -5795,6 +6120,14 @@ cAudioManager::ProcessPedHeadphones(cPedParams *params) } } +#if 1 +WRAPPER +void +cAudioManager::ProcessPedOneShots(cPedParams *params) +{ + EAXJMP(0x56F650); +} +#else void cAudioManager::ProcessPedOneShots(cPedParams *params) { @@ -5812,11 +6145,11 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) static uint8 iSound = 21; weapon = nil; - for(uint32 i = 0; i < m_asAudioEntities[m_sQueueSample.m_nEntityIndex].field_24; i++) { + for(uint32 i = 0; i < m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_Loops; i++) { noReflection = 0; processed = 0; m_sQueueSample.m_bRequireReflection = 0; - sound = m_asAudioEntities[0].m_awAudioEvent[i + 20 * m_sQueueSample.m_nEntityIndex]; + sound = m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_awAudioEvent[i]; switch(sound) { case SOUND_STEP_START: case SOUND_STEP_END: @@ -5875,9 +6208,9 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) } m_sQueueSample.m_nSampleIndex = sampleIndex; m_sQueueSample.m_bBankIndex = 0; - m_sQueueSample.field_4 = - m_asAudioEntities[0] - .m_awAudioEvent[i + 20 * m_sQueueSample.m_nEntityIndex] - + m_sQueueSample.m_counter = + m_asAudioEntities[m_sQueueSample.m_nEntityIndex] + .m_awAudioEvent[i] - 28; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency( m_sQueueSample.m_nSampleIndex); @@ -5928,7 +6261,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) AUDIO_SAMPLE_PED_FALL_COLLAPSE; } m_sQueueSample.m_bBankIndex = 0; - m_sQueueSample.field_4 = 1; + m_sQueueSample.m_counter = 1; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency( m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nFrequency += @@ -5950,7 +6283,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PED_HIT_1; m_sQueueSample.m_nFrequency = 18000; m_sQueueSample.m_bBankIndex = 0; - m_sQueueSample.field_4 = iSound; + m_sQueueSample.m_counter = iSound; processed = 1; ++iSound; m_sQueueSample.field_16 = 3; @@ -5970,7 +6303,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PED_HIT_1; m_sQueueSample.m_nFrequency = 16500; m_sQueueSample.m_bBankIndex = 0; - m_sQueueSample.field_4 = iSound; + m_sQueueSample.m_counter = iSound; processed = 1; ++iSound; m_sQueueSample.field_16 = 3; @@ -5990,7 +6323,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PED_HIT_1; m_sQueueSample.m_nFrequency = 20000; m_sQueueSample.m_bBankIndex = 0; - m_sQueueSample.field_4 = iSound; + m_sQueueSample.m_counter = iSound; processed = 1; ++iSound; m_sQueueSample.field_16 = 3; @@ -6010,7 +6343,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PED_HIT_2; m_sQueueSample.m_nFrequency = 18000; m_sQueueSample.m_bBankIndex = 0; - m_sQueueSample.field_4 = iSound; + m_sQueueSample.m_counter = iSound; processed = 1; ++iSound; m_sQueueSample.field_16 = 3; @@ -6030,7 +6363,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PED_HIT_2; m_sQueueSample.m_nFrequency = 16500; m_sQueueSample.m_bBankIndex = 0; - m_sQueueSample.field_4 = iSound; + m_sQueueSample.m_counter = iSound; processed = 1; ++iSound; m_sQueueSample.field_16 = 3; @@ -6050,7 +6383,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PED_HIT_2; m_sQueueSample.m_nFrequency = 20000; m_sQueueSample.m_bBankIndex = 0; - m_sQueueSample.field_4 = iSound; + m_sQueueSample.m_counter = iSound; processed = 1; ++iSound; m_sQueueSample.field_16 = 3; @@ -6070,7 +6403,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PED_HIT_3; m_sQueueSample.m_nFrequency = 18000; m_sQueueSample.m_bBankIndex = 0; - m_sQueueSample.field_4 = iSound; + m_sQueueSample.m_counter = iSound; processed = 1; ++iSound; m_sQueueSample.field_16 = 3; @@ -6090,7 +6423,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PED_HIT_3; m_sQueueSample.m_nFrequency = 16500; m_sQueueSample.m_bBankIndex = 0; - m_sQueueSample.field_4 = iSound; + m_sQueueSample.m_counter = iSound; processed = 1; ++iSound; m_sQueueSample.field_16 = 3; @@ -6110,7 +6443,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PED_HIT_3; m_sQueueSample.m_nFrequency = 20000; m_sQueueSample.m_bBankIndex = 0; - m_sQueueSample.field_4 = iSound; + m_sQueueSample.m_counter = iSound; processed = 1; ++iSound; m_sQueueSample.field_16 = 3; @@ -6130,7 +6463,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PED_HIT_4; m_sQueueSample.m_nFrequency = 18000; m_sQueueSample.m_bBankIndex = 0; - m_sQueueSample.field_4 = iSound; + m_sQueueSample.m_counter = iSound; processed = 1; ++iSound; m_sQueueSample.field_16 = 3; @@ -6150,7 +6483,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PED_HIT_4; m_sQueueSample.m_nFrequency = 16500; m_sQueueSample.m_bBankIndex = 0; - m_sQueueSample.field_4 = iSound; + m_sQueueSample.m_counter = iSound; processed = 1; ++iSound; m_sQueueSample.field_16 = 3; @@ -6170,7 +6503,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PED_HIT_4; m_sQueueSample.m_nFrequency = 20000; m_sQueueSample.m_bBankIndex = 0; - m_sQueueSample.field_4 = iSound; + m_sQueueSample.m_counter = iSound; processed = 1; ++iSound; m_sQueueSample.field_16 = 3; @@ -6189,7 +6522,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) case SOUND_WEAPON_BAT_ATTACK: m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_PED_HIT_BY_BAT; m_sQueueSample.m_bBankIndex = 0; - m_sQueueSample.field_4 = iSound++; + m_sQueueSample.m_counter = iSound++; processed = 1; m_sQueueSample.m_nFrequency = RandomDisplacement(2000u) + 22000; m_sQueueSample.field_16 = 3; @@ -6214,7 +6547,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) case WEAPONTYPE_COLT45: m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_WEAPON_PISTOL_SHOT; m_sQueueSample.m_bBankIndex = 0; - m_sQueueSample.field_4 = iSound++; + m_sQueueSample.m_counter = iSound++; processed = 1; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency( AUDIO_SAMPLE_WEAPON_PISTOL_SHOT); @@ -6239,7 +6572,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) case WEAPONTYPE_UZI: m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_WEAPON_UZI_SHOT; m_sQueueSample.m_bBankIndex = 0; - m_sQueueSample.field_4 = iSound++; + m_sQueueSample.m_counter = iSound++; processed = 1; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency( AUDIO_SAMPLE_WEAPON_UZI_SHOT); @@ -6260,7 +6593,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) case WEAPONTYPE_SHOTGUN: m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_WEAPON_SHOTGUN_SHOT; m_sQueueSample.m_bBankIndex = 0; - m_sQueueSample.field_4 = iSound++; + m_sQueueSample.m_counter = iSound++; processed = 1; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency( AUDIO_SAMPLE_WEAPON_SHOTGUN_SHOT); @@ -6285,7 +6618,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) case WEAPONTYPE_AK47: m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_WEAPON_CHAINGUN_SHOT; m_sQueueSample.m_bBankIndex = 0; - m_sQueueSample.field_4 = iSound++; + m_sQueueSample.m_counter = iSound++; processed = 1; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency( AUDIO_SAMPLE_WEAPON_CHAINGUN_SHOT); @@ -6306,7 +6639,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) case WEAPONTYPE_M16: m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_WEAPON_M16_SHOT; m_sQueueSample.m_bBankIndex = 0; - m_sQueueSample.field_4 = iSound++; + m_sQueueSample.m_counter = iSound++; processed = 1; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency( AUDIO_SAMPLE_WEAPON_M16_SHOT); @@ -6327,7 +6660,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) case WEAPONTYPE_SNIPERRIFLE: m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_WEAPON_SNIPER_SHOT; m_sQueueSample.m_bBankIndex = 0; - m_sQueueSample.field_4 = iSound++; + m_sQueueSample.m_counter = iSound++; processed = 1; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency( AUDIO_SAMPLE_WEAPON_SNIPER_SHOT); @@ -6352,7 +6685,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) case WEAPONTYPE_ROCKETLAUNCHER: m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_WEAPON_ROCKET_SHOT; m_sQueueSample.m_bBankIndex = 0; - m_sQueueSample.field_4 = iSound++; + m_sQueueSample.m_counter = iSound++; processed = 1; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency( AUDIO_SAMPLE_WEAPON_ROCKET_SHOT); @@ -6378,7 +6711,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_WEAPON_FLAMETHROWER_SHOT; m_sQueueSample.m_bBankIndex = 0; - m_sQueueSample.field_4 = 9; + m_sQueueSample.m_counter = 9; emittingVol = 90; m_sQueueSample.m_nFrequency = (10 * m_sQueueSample.m_nEntityIndex & 2047) + @@ -6413,7 +6746,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) case WEAPONTYPE_COLT45: m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_WEAPON_PISTOL_RELOAD; emittingVol = 75; - m_sQueueSample.field_4 = iSound++; + m_sQueueSample.m_counter = iSound++; processed = 1; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency( @@ -6436,7 +6769,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) case WEAPONTYPE_UZI: m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_WEAPON_UZI_RELOAD; emittingVol = 75; - m_sQueueSample.field_4 = iSound++; + m_sQueueSample.m_counter = iSound++; processed = 1; m_sQueueSample.m_nFrequency = 39243; m_sQueueSample.m_nFrequency += RandomDisplacement(300u); @@ -6456,7 +6789,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) case WEAPONTYPE_SHOTGUN: m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_WEAPON_CHAINGUN_RELOAD; emittingVol = 75; - m_sQueueSample.field_4 = iSound++; + m_sQueueSample.m_counter = iSound++; processed = 1; m_sQueueSample.m_nFrequency = 30290; m_sQueueSample.m_nFrequency += RandomDisplacement(300u); @@ -6476,7 +6809,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) case WEAPONTYPE_AK47: m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_WEAPON_CHAINGUN_RELOAD; emittingVol = 75; - m_sQueueSample.field_4 = iSound++; + m_sQueueSample.m_counter = iSound++; processed = 1; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency( AUDIO_SAMPLE_WEAPON_CHAINGUN_RELOAD); @@ -6497,7 +6830,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) case WEAPONTYPE_M16: m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_WEAPON_UZI_RELOAD; emittingVol = 75; - m_sQueueSample.field_4 = iSound++; + m_sQueueSample.m_counter = iSound++; processed = 1; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency( AUDIO_SAMPLE_WEAPON_UZI_RELOAD); @@ -6518,7 +6851,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) case WEAPONTYPE_SNIPERRIFLE: m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_WEAPON_SNIPER_RELOAD; emittingVol = 75; - m_sQueueSample.field_4 = iSound++; + m_sQueueSample.m_counter = iSound++; processed = 1; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency( AUDIO_SAMPLE_WEAPON_SNIPER_RELOAD); @@ -6539,7 +6872,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) case WEAPONTYPE_ROCKETLAUNCHER: m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_WEAPON_ROCKET_RELOAD; emittingVol = 75; - m_sQueueSample.field_4 = iSound++; + m_sQueueSample.m_counter = iSound++; processed = 1; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency( AUDIO_SAMPLE_WEAPON_ROCKET_RELOAD); @@ -6565,7 +6898,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) case SOUND_WEAPON_M16_BULLET_ECHO: m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_75; m_sQueueSample.m_bBankIndex = 0; - m_sQueueSample.field_4 = iSound++; + m_sQueueSample.m_counter = iSound++; processed = 1; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_75); @@ -6590,7 +6923,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) case SOUND_WEAPON_FLAMETHROWER_FIRE: m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_WEAPON_FLAMETHROWER_FIRE; m_sQueueSample.m_bBankIndex = 0; - m_sQueueSample.field_4 = iSound++; + m_sQueueSample.m_counter = iSound++; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency( AUDIO_SAMPLE_WEAPON_FLAMETHROWER_FIRE); m_sQueueSample.m_nFrequency += @@ -6610,7 +6943,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) case SOUND_WEAPON_HIT_PED: m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_BULLET_HIT_PED; m_sQueueSample.m_bBankIndex = 0; - m_sQueueSample.field_4 = iSound++; + m_sQueueSample.m_counter = iSound++; processed = 1; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_BULLET_HIT_PED); @@ -6631,7 +6964,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) case SOUND_SPLASH: m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_COLLISION_WATER; m_sQueueSample.m_bBankIndex = 0; - m_sQueueSample.field_4 = iSound++; + m_sQueueSample.m_counter = iSound++; processed = 1; m_sQueueSample.m_nFrequency = RandomDisplacement(1400u) + 20000; m_sQueueSample.field_16 = 1; @@ -6672,16 +7005,14 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) if(noReflection) { m_sQueueSample.m_bOffset = 127; ++m_sQueueSample.m_nSampleIndex; - if(m_asAudioEntities[0].m_awAudioEvent - [i + - 20 * m_sQueueSample.m_nEntityIndex] != - 47 || + if(m_asAudioEntities[m_sQueueSample.m_nEntityIndex] + .m_awAudioEvent[i] != 47 || weapon->m_eWeaponType != WEAPONTYPE_FLAMETHROWER) { - m_sQueueSample.field_4 = iSound++; + m_sQueueSample.m_counter = iSound++; if(iSound > 60u) iSound = 21; } else { - ++m_sQueueSample.field_4; + ++m_sQueueSample.m_counter; } AddSampleToRequestedQueue(); } @@ -6690,6 +7021,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) } } } +#endif void cAudioManager::ProcessPhysical(int32 id) @@ -6723,7 +7055,7 @@ struct tVehicleSampleData { char m_bEngineSoundType; char gap_5[3]; eAudioSamples m_nHornSample; - int m_nHornFrequency; + int32 m_nHornFrequency; char m_nSirenOrAlarmSample; int m_nSirenOrAlarmFrequency; char m_bDoorType; @@ -6733,6 +7065,15 @@ struct tVehicleSampleData { int32 *CSWTCH_554 = (int32 *)0x606A50; tVehicleSampleData *vehicleSampleData = (tVehicleSampleData *)0x606204; +#if 0 +WRAPPER +void +cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile *automobile) +{ + EAXJMP(0x56B0D0); +} +#else + void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile *automobile) { @@ -6743,14 +7084,10 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile * uint8 wheelInUseCounter; uint8 i; float time; - uint32 freq4; int baseFreq; uint8 vol; - unsigned int freq5; int gearNr; - int freq; - unsigned int freq3; - unsigned int freq2; + int32 freq; int freqModifier; int soundOffset; @@ -6763,13 +7100,13 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile * float gasPedalAudio; CVector pos; - static uint16 LastAccel = 0; - static uint16 LastBrake = 0; + static int16 LastAccel = 0; + static int16 LastBrake = 0; static uint8 CurrentPretendGear = 1; static bool bLostTractionLastFrame = 0; static bool bHandbrakeOnLastFrame = 0; - static uint32 nCruising = 0; - static uint8 bAccelSampleStopped = 1; + static int32 nCruising = 0; + static bool bAccelSampleStopped = 1; lostTraction = 0; processedAccelSampleStopped = 0; @@ -6784,7 +7121,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile * CurrentPretendGear = 1; } if(CReplay::IsPlayingBack()) { - accelerateState = 255.f * max(0.0f, min(1.0f, automobile->m_fGasPedal)); + accelerateState = 255.f * Max(0.0f, Min(1.0f, automobile->m_fGasPedal)); } else { accelerateState = Pads->GetAccelerate(); } @@ -6816,14 +7153,14 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile * (automobile->m_aWheelState[1] || automobile->m_aWheelState[3])) { lostTraction = 1; } - if(0.0f != velocityChange) { // ok + if(0.0f != velocityChange) { time = params->m_pVehicle->m_vecMoveSpeed.z / velocityChange; if(time <= 0.0f) { - freqModifier = max(-0.2f, time) * -15000.f; + freqModifier = Max(-0.2f, time) * -15000.f; } else { - freqModifier = -(min(0.2f, time) * 15000.f); + freqModifier = -(Min(0.2f, time) * 15000.f); } - if(params->m_fVelocityChange < -0.001f) freqModifier = -freqModifier; // ok + if(params->m_fVelocityChange < -0.001f) freqModifier = -freqModifier; } else { freqModifier = 0; } @@ -6839,11 +7176,11 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile * lostTraction) { gasPedalAudio = automobile->m_fGasPedalAudio; } else { - gasPedalAudio = min( - 1.0f, params->m_fVelocityChange / - params->m_pTransmission->fMaxReverseVelocity); // ok + gasPedalAudio = + Min(1.0f, params->m_fVelocityChange / + params->m_pTransmission->fMaxReverseVelocity); } - gasPedalAudio = max(0.0f, gasPedalAudio); // ok + gasPedalAudio = Max(0.0f, gasPedalAudio); automobile->m_fGasPedalAudio = gasPedalAudio; } else if(LastAccel > 0) { if(channelUsed) { @@ -6858,29 +7195,29 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile * automobile->m_fGasPedalAudio = automobile->m_fGasPedalAudio * 0.6f; gasPedalAudio = automobile->m_fGasPedalAudio; } - if(gasPedalAudio > 0.05) { // ok - freq3 = (5000.f * (gasPedalAudio - 0.05f) * 20.f / 19) + 19000; - if(engineSoundType == 6) freq3 >>= 1; + if(gasPedalAudio > 0.05f) { + freq = (5000.f * (gasPedalAudio - 0.05f) * 20.f / 19) + 19000; + if(engineSoundType == 6) freq >>= 1; AddPlayerCarSample( - (25.f * (gasPedalAudio - 0.05f) * 20.f / 19) + 40, freq3, + (25.f * (gasPedalAudio - 0.05f) * 20.f / 19) + 40, freq, (soundOffset + AUDIO_SAMPLE_VEHICLE_ENGINE_STOPPING_GENERIC), engineSoundType, 63u, 0); } } - freq2 = (10000.f * gasPedalAudio) + 22050; - if(engineSoundType == 6) freq2 >>= 1; - AddPlayerCarSample(110 - (40.f * gasPedalAudio), freq2, + freq = (10000.f * gasPedalAudio) + 22050; + if(engineSoundType == 6) freq >>= 1; + AddPlayerCarSample(110 - (40.f * gasPedalAudio), freq, (engineSoundType + AUDIO_SAMPLE_VEHICLE_ENGINE_IDLE_NONE), 0, 52u, 1); - CurrentPretendGear = max(1, currentGear); + CurrentPretendGear = Max(1, currentGear); LastAccel = accelerateState; bHandbrakeOnLastFrame = automobile->bIsHandbrakeOn; bLostTractionLastFrame = lostTraction; return; } - if(nCruising) { + if(!nCruising) { if(accelerateState < 150 || !automobile->m_nWheelsOnGround || automobile->bIsHandbrakeOn || lostTraction || currentGear < 2u && @@ -6903,15 +7240,14 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile * vol = (25.0f * accelerationMultipler) + 60; automobile->m_fGasPedalAudio = accelerationMultipler; } - freq5 = freqModifier + baseFreq; - if(engineSoundType == 6) freq5 >>= 1; + freq = freqModifier + baseFreq; + if(engineSoundType == 6) freq >>= 1; if(channelUsed) { SampleManager.StopChannel(m_bActiveSamples); bAccelSampleStopped = 1; } - AddPlayerCarSample(vol, freq5, - (engineSoundType + AUDIO_SAMPLE_PAYPHONE_RINGING), 0, 2u, - 1); + AddPlayerCarSample( + vol, freq, (engineSoundType + AUDIO_SAMPLE_PAYPHONE_RINGING), 0, 2u, 1); LastAccel = accelerateState; bHandbrakeOnLastFrame = automobile->bIsHandbrakeOn; @@ -6981,10 +7317,10 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile * SampleManager.SetChannelEmittingVolume(m_bActiveSamples, 85u); SampleManager.SetChannel3DPosition(m_bActiveSamples, pos.x, pos.y, pos.z); SampleManager.SetChannel3DDistances(m_bActiveSamples, 50.f, 12.5f); - if(engineSoundType == 6) - freq = (CSWTCH_554[CurrentPretendGear] + freqModifier + 22050) >> 1; - else - freq = CSWTCH_554[CurrentPretendGear] + freqModifier + 22050; + freq = CSWTCH_554[CurrentPretendGear] + freqModifier + 22050; + + if(engineSoundType == 6) freq >>= 1; + SampleManager.SetChannelFrequency(m_bActiveSamples, freq); if(!channelUsed) { SampleManager.SetChannelReverbFlag( @@ -7010,9 +7346,9 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile * } else if(nCruising > 3) { --nCruising; } - freq4 = 27 * nCruising + freqModifier + 22050; - if(engineSoundType == 6) freq4 >>= 1; - AddPlayerCarSample(85u, freq4, + freq = 27 * nCruising + freqModifier + 22050; + if(engineSoundType == 6) freq >>= 1; + AddPlayerCarSample(85u, freq, (soundOffset + AUDIO_SAMPLE_VEHICLE_ENGINE_CHANGE_GEAR_GENERIC), engineSoundType, 64u, 1); } @@ -7021,6 +7357,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile * bHandbrakeOnLastFrame = automobile->bIsHandbrakeOn; bLostTractionLastFrame = lostTraction; } +#endif WRAPPER void @@ -7096,7 +7433,7 @@ cAudioManager::ProcessPornCinema(uint8 sound) if(m_sQueueSample.m_bVolume) { m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency( m_sQueueSample.m_nSampleIndex); - m_sQueueSample.field_4 = 0; + m_sQueueSample.m_counter = 0; m_sQueueSample.m_bIsDistant = 0; m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.field_56 = 0; @@ -7125,7 +7462,7 @@ cAudioManager::ProcessPornCinema(uint8 sound) m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency >> 4); - m_sQueueSample.field_4 = rand + 1; + m_sQueueSample.m_counter = rand + 1; m_sQueueSample.m_bIsDistant = 0; m_sQueueSample.m_nLoopCount = 1; m_sQueueSample.field_56 = 1; @@ -7166,7 +7503,7 @@ cAudioManager::ProcessRainOnVehicle(cVehicleParams *params) m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, 22.f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.field_4 = veh->m_bRainSamplesCounter++; + m_sQueueSample.m_counter = veh->m_bRainSamplesCounter++; veh = params->m_pVehicle; if(veh->m_bRainSamplesCounter > 4u) veh->m_bRainSamplesCounter = 68; m_sQueueSample.m_nSampleIndex = @@ -7179,8 +7516,8 @@ cAudioManager::ProcessRainOnVehicle(cVehicleParams *params) m_sQueueSample.m_bEmittingVolume = (uint8)emittingVol; m_sQueueSample.m_nLoopStart = 0; m_sQueueSample.m_nLoopEnd = -1; - m_sQueueSample.field_48 = 0.0; - m_sQueueSample.m_fSoundIntensity = 22.0; + m_sQueueSample.field_48 = 0.0f; + m_sQueueSample.m_fSoundIntensity = 22.0f; m_sQueueSample.field_56 = 1; m_sQueueSample.m_bReverbFlag = 0; m_sQueueSample.m_bRequireReflection = 0; @@ -7190,6 +7527,73 @@ cAudioManager::ProcessRainOnVehicle(cVehicleParams *params) } } +void +cAudioManager::ProcessReverb() const +{ + if(SampleManager.UpdateReverb() && m_bDynamicAcousticModelingStatus) { + for(uint32 i = 0; i < 28; i++) { + if(m_asActiveSamples[i].m_bReverbFlag) + SampleManager.SetChannelReverbFlag(i, 1); + } + } +} + +bool +cAudioManager::ProcessReverseGear(cVehicleParams *params) +{ + CVehicle *veh; + CAutomobile *automobile; + int32 emittingVol; + float modificator; + + if(params->m_fDistance >= 900.f) return 0; + veh = params->m_pVehicle; + if(veh->bEngineOn && (veh->m_fGasPedal < 0.0f || !veh->m_nCurrentGear)) { + CalculateDistance((bool *)params, params->m_fDistance); + automobile = (CAutomobile *)params->m_pVehicle; + if(automobile->m_nWheelsOnGround) { + modificator = params->m_fVelocityChange / + params->m_pTransmission->fMaxReverseVelocity; + } else { + if(automobile->m_nDriveWheelsOnGround) + automobile->m_fGasPedalAudio = automobile->m_fGasPedalAudio * 0.4f; + modificator = automobile->m_fGasPedalAudio; + } + modificator = Abs(modificator); + emittingVol = (24.f * modificator); + m_sQueueSample.m_bVolume = + ComputeVolume(emittingVol, 30.f, m_sQueueSample.m_fDistance); + if(m_sQueueSample.m_bVolume) { + if(params->m_pVehicle->m_fGasPedal >= 0.0f) { + m_sQueueSample.m_counter = 62; + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_REVERSE_GEAR_CONSTANT; + } else { + m_sQueueSample.m_counter = 61; + m_sQueueSample.m_nSampleIndex = + AUDIO_SAMPLE_REVERSE_GEAR_ACCELERATING; + } + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_16 = 3; + m_sQueueSample.m_nFrequency = (6000.f * modificator) + 7000; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_bEmittingVolume = emittingVol; + m_sQueueSample.m_nLoopStart = + SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = + SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.field_48 = 3.0f; + m_sQueueSample.m_fSoundIntensity = 30.0f; + m_sQueueSample.field_56 = 0; + m_sQueueSample.field_76 = 5; + m_sQueueSample.m_bReverbFlag = 1; + m_sQueueSample.m_bRequireReflection = 0; + AddSampleToRequestedQueue(); + } + } + return 1; +} + void cAudioManager::ProcessSawMillScriptObject(uint8 sound) { @@ -7215,7 +7619,7 @@ cAudioManager::ProcessSawMillScriptObject(uint8 sound) m_sQueueSample.m_bBankIndex = 0; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_SAWMILL_1); - m_sQueueSample.field_4 = 0; + m_sQueueSample.m_counter = 0; m_sQueueSample.m_bIsDistant = 0; m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.field_56 = 0; @@ -7239,7 +7643,7 @@ cAudioManager::ProcessSawMillScriptObject(uint8 sound) m_sQueueSample.m_bBankIndex = 0; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency( m_sQueueSample.m_nSampleIndex); - m_sQueueSample.field_4 = 1; + m_sQueueSample.m_counter = 1; m_sQueueSample.m_bIsDistant = 0; m_sQueueSample.m_nLoopCount = 1; m_sQueueSample.field_56 = 1; @@ -7261,10 +7665,8 @@ cAudioManager::ProcessScriptObject(int32 id) { cAudioScriptObject *entity = (cAudioScriptObject *)m_asAudioEntities[id].m_pEntity; if(entity) { - m_sQueueSample.m_vecPos.x = entity->m_vecPos.x; - m_sQueueSample.m_vecPos.y = entity->m_vecPos.y; - m_sQueueSample.m_vecPos.z = entity->m_vecPos.z; - if(m_asAudioEntities[id].field_24 == 1) + m_sQueueSample.m_vecPos = entity->m_vecPos; + if(m_asAudioEntities[id].m_Loops == 1) ProcessOneShotScriptObject(m_asAudioEntities[id].m_awAudioEvent[0]); else ProcessLoopingScriptObject(entity->m_wSound); @@ -7297,7 +7699,7 @@ cAudioManager::ProcessShopScriptObject(uint8 sound) m_sQueueSample.m_bBankIndex = 0; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_SHOP_1); - m_sQueueSample.field_4 = 0; + m_sQueueSample.m_counter = 0; m_sQueueSample.m_bIsDistant = 0; m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.field_56 = 0; @@ -7322,7 +7724,7 @@ cAudioManager::ProcessShopScriptObject(uint8 sound) m_sQueueSample.m_bBankIndex = 0; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency( m_sQueueSample.m_nSampleIndex); - m_sQueueSample.field_4 = rand + 1; + m_sQueueSample.m_counter = rand + 1; m_sQueueSample.m_bIsDistant = 0; m_sQueueSample.m_nLoopCount = 1; m_sQueueSample.field_56 = 1; @@ -7364,6 +7766,79 @@ cAudioManager::ProcessSpecial() } } +bool +cAudioManager::ProcessTrainNoise(cVehicleParams *params) +{ + CTrain *train; + int32 emittingVol; + float speedMultipler; + + if(params->m_fDistance >= 90000.f) return 0; + + if(params->m_fVelocityChange <= 0.0f) { + CalculateDistance((bool *)params, params->m_fDistance); + train = (CTrain *)params->m_pVehicle; + speedMultipler = Min(1.0f, train->m_fSpeed * 250.f / 51.f); + emittingVol = (75.f * speedMultipler); + if(train->m_fWagonPosition == 0.0f) { + m_sQueueSample.m_bVolume = + ComputeVolume(emittingVol, 300.f, m_sQueueSample.m_fDistance); + if(m_sQueueSample.m_bVolume) { + m_sQueueSample.m_counter = 32; + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_TRAIN_FAR; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_16 = 2; + m_sQueueSample.m_nFrequency = + SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_TRAIN_FAR); + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_bEmittingVolume = emittingVol; + m_sQueueSample.m_nLoopStart = + SampleManager.GetSampleLoopStartOffset( + m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset( + m_sQueueSample.m_nSampleIndex); + m_sQueueSample.field_48 = 3.0f; + m_sQueueSample.m_fSoundIntensity = 300.0f; + m_sQueueSample.field_56 = 0; + m_sQueueSample.field_76 = 3; + m_sQueueSample.m_bReverbFlag = 1; + m_sQueueSample.m_bRequireReflection = 0; + AddSampleToRequestedQueue(); + } + } + if(params->m_fDistance < 4900.f) { + m_sQueueSample.m_bVolume = + ComputeVolume(emittingVol, 70.f, m_sQueueSample.m_fDistance); + if(m_sQueueSample.m_bVolume) { + m_sQueueSample.m_counter = 33; + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_TRAIN_CLOSE; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_16 = 5; + m_sQueueSample.m_nFrequency = + SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_TRAIN_CLOSE) + + 100 * m_sQueueSample.m_nEntityIndex % 987; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_bEmittingVolume = emittingVol; + m_sQueueSample.m_nLoopStart = + SampleManager.GetSampleLoopStartOffset( + m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset( + m_sQueueSample.m_nSampleIndex); + m_sQueueSample.field_48 = 6.0f; + m_sQueueSample.m_fSoundIntensity = 70.0f; + m_sQueueSample.field_56 = 0; + m_sQueueSample.field_76 = 3; + m_sQueueSample.m_bReverbFlag = 1; + m_sQueueSample.m_bRequireReflection = 0; + AddSampleToRequestedQueue(); + } + } + } + return 1; +} + #if 1 WRAPPER void @@ -7371,6 +7846,7 @@ cAudioManager::ProcessVehicle(CVehicle *) { EAXJMP(0x569A00); } + #else void cAudioManager::ProcessVehicle(CVehicle *) @@ -7379,6 +7855,159 @@ cAudioManager::ProcessVehicle(CVehicle *) } #endif +bool +cAudioManager::ProcessVehicleDoors(cVehicleParams *params) +{ + CAutomobile *automobile; + int8 doorState; + int32 emittingVol; + float velocity; + + if(params->m_fDistance >= 1600.f) return 0; + + automobile = (CAutomobile *)params->m_pVehicle; + CalculateDistance((bool *)params, params->m_fDistance); + for(int32 i = 0; i < 6; i++) { + if(automobile->Damage.GetDoorStatus(i) == 2) { + doorState = automobile->Doors[i].m_nDoorState; + if(doorState == 1 || doorState == 2) { + velocity = Min(0.3f, Abs(automobile->Doors[i].m_fAngVel)); + if(velocity > 0.0035f) { + emittingVol = (100.f * velocity * 10.f / 3.f); + m_sQueueSample.m_bVolume = ComputeVolume( + emittingVol, 40.f, m_sQueueSample.m_fDistance); + if(m_sQueueSample.m_bVolume) { + m_sQueueSample.m_counter = i + 6; + m_sQueueSample.m_nSampleIndex = + m_anRandomTable[1] % 6u + + AUDIO_SAMPLE_CAR_DOOR_MOVEMENT_1; + m_sQueueSample.m_nFrequency = + SampleManager.GetSampleBaseFrequency( + m_sQueueSample.m_nSampleIndex) + + RandomDisplacement(1000u); + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_16 = 10; + m_sQueueSample.m_nLoopCount = 1; + m_sQueueSample.m_bEmittingVolume = emittingVol; + m_sQueueSample.m_nLoopStart = 0; + m_sQueueSample.m_nLoopEnd = -1; + m_sQueueSample.field_48 = 1.0f; + m_sQueueSample.m_fSoundIntensity = 40.0f; + m_sQueueSample.field_56 = 1; + m_sQueueSample.m_bReverbFlag = 1; + m_sQueueSample.m_bRequireReflection = 1; + AddSampleToRequestedQueue(); + } + } + } + } + } + return 1; +} + +bool +cAudioManager::ProcessVehicleReverseWarning(cVehicleParams *params) +{ + CVehicle *veh = params->m_pVehicle; + + if(params->m_fDistance >= 2500.f) return 0; + + if(veh->bEngineOn && veh->m_fGasPedal < 0.0f) { + CalculateDistance((bool *)params, params->m_fDistance); + m_sQueueSample.m_bVolume = ComputeVolume(60u, 50.f, m_sQueueSample.m_fDistance); + if(m_sQueueSample.m_bVolume) { + m_sQueueSample.m_counter = 12; + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_VEHICLE_REVERSE_WARNING; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_16 = 2; + m_sQueueSample.m_nFrequency = + (100 * m_sQueueSample.m_nEntityIndex & 0x3FF) + + SampleManager.GetSampleBaseFrequency( + AUDIO_SAMPLE_VEHICLE_REVERSE_WARNING); + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_bEmittingVolume = 60; + m_sQueueSample.m_nLoopStart = + SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = + SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.field_48 = 3.0f; + m_sQueueSample.m_fSoundIntensity = 50.0f; + m_sQueueSample.field_56 = 0; + m_sQueueSample.field_76 = 3; + m_sQueueSample.m_bReverbFlag = 1; + m_sQueueSample.m_bRequireReflection = 0; + AddSampleToRequestedQueue(); + } + } + return 1; +} + +bool +cAudioManager::ProcessVehicleRoadNoise(cVehicleParams *params) +{ + int32 emittingVol; + uint32 freq; + float modificator; + int sampleFreq; + float velocity; + + if(params->m_fDistance >= 9025.f) return 0; + if(params->m_pTransmission) { + if(params->m_pVehicle->m_vecMoveSpeed.z) { + velocity = Abs(params->m_fVelocityChange); + if(velocity > 0.0f) { + CalculateDistance((bool *)params, params->m_fDistance); + emittingVol = + 30.f * + Min(1.f, + velocity / (0.5f * params->m_pTransmission->fMaxVelocity)); + m_sQueueSample.m_bVolume = + ComputeVolume(emittingVol, 95.f, m_sQueueSample.m_fDistance); + if(m_sQueueSample.m_bVolume) { + m_sQueueSample.m_counter = 0; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_16 = 3; + if(params->m_pVehicle->m_nSurfaceTouched == + SURFACE_PUDDLE) { + m_sQueueSample.m_nSampleIndex = + AUDIO_SAMPLE_LOOPING_WATER; + freq = 6050 * emittingVol / 30 + 16000; + } else { + m_sQueueSample.m_nSampleIndex = + AUDIO_SAMPLE_VEHICLE_ROAD_NOISE; + modificator = + m_sQueueSample.m_fDistance * 1.f / 95.f * 0.5f; + sampleFreq = SampleManager.GetSampleBaseFrequency( + AUDIO_SAMPLE_VEHICLE_ROAD_NOISE); + freq = (sampleFreq * modificator) + + ((3 * sampleFreq) >> 2); + } + m_sQueueSample.m_nFrequency = freq; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_bEmittingVolume = emittingVol; + m_sQueueSample.m_nLoopStart = + SampleManager.GetSampleLoopStartOffset( + m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = + SampleManager.GetSampleLoopEndOffset( + m_sQueueSample.m_nSampleIndex); + m_sQueueSample.field_48 = 6.0f; + m_sQueueSample.m_fSoundIntensity = 95.0f; + m_sQueueSample.field_56 = 0; + m_sQueueSample.field_76 = 4; + m_sQueueSample.m_bReverbFlag = 1; + m_sQueueSample.m_bRequireReflection = 0; + AddSampleToRequestedQueue(); + } + } + } + } + return 1; +} + WRAPPER void cAudioManager::ProcessWaterCannon(int32) { EAXJMP(0x575F30); } @@ -7389,6 +8018,60 @@ cAudioManager::ProcessWeather(int32 id) EAXJMP(0x578370); } +bool +cAudioManager::ProcessWetRoadNoise(cVehicleParams *params) +{ + float relativeVelocity; + int32 emittingVol; + float modificator; + int freq; + float velChange; + + if(params->m_fDistance >= 900.f) return 0; + if(params->m_pTransmission) { + if(params->m_pVehicle->m_vecMoveSpeed.z) { + velChange = Abs(params->m_fVelocityChange); + if(velChange > 0.f) { + CalculateDistance((bool *)params, params->m_fDistance); + relativeVelocity = + Min(1.0f, + velChange / (0.5f * params->m_pTransmission->fMaxVelocity)); + emittingVol = 23.0f * relativeVelocity * CWeather::WetRoads; + m_sQueueSample.m_bVolume = + ComputeVolume(emittingVol, 30.f, m_sQueueSample.m_fDistance); + if(m_sQueueSample.m_bVolume) { + m_sQueueSample.m_counter = 1; + m_sQueueSample.m_nSampleIndex = + AUDIO_SAMPLE_VEHICLE_ROAD_NOISE; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_16 = 3; + modificator = m_sQueueSample.m_fDistance * 1.f / 3.f * 0.5f; + freq = SampleManager.GetSampleBaseFrequency( + AUDIO_SAMPLE_VEHICLE_ROAD_NOISE); + m_sQueueSample.m_nFrequency = freq + freq * modificator; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_bEmittingVolume = emittingVol; + m_sQueueSample.m_nLoopStart = + SampleManager.GetSampleLoopStartOffset( + m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = + SampleManager.GetSampleLoopEndOffset( + m_sQueueSample.m_nSampleIndex); + m_sQueueSample.field_48 = 6.0f; + m_sQueueSample.m_fSoundIntensity = 30.0f; + m_sQueueSample.field_56 = 0; + m_sQueueSample.field_76 = 4; + m_sQueueSample.m_bReverbFlag = 1; + m_sQueueSample.m_bRequireReflection = 0; + AddSampleToRequestedQueue(); + } + } + } + } + return 1; +} + void cAudioManager::ProcessWorkShopScriptObject(uint8 sound) { @@ -7413,7 +8096,7 @@ cAudioManager::ProcessWorkShopScriptObject(uint8 sound) m_sQueueSample.m_bBankIndex = 0; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_WORK_SHOP); - m_sQueueSample.field_4 = 0; + m_sQueueSample.m_counter = 0; m_sQueueSample.m_bIsDistant = 0; m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.field_56 = 0; @@ -7481,10 +8164,8 @@ cAudioManager::SetupPedComments(cPedParams *params, uint32 sound) emittingVol, soundIntensity, m_sQueueSample.m_fDistance); pedComment.field_25 = 10; if(m_sQueueSample.m_bVolume) { - pedComment.field_4 = m_sQueueSample.m_nEntityIndex; - pedComment.m_vecPos.x = m_sQueueSample.m_vecPos.x; - pedComment.m_vecPos.y = m_sQueueSample.m_vecPos.y; - pedComment.m_vecPos.z = m_sQueueSample.m_vecPos.z; + pedComment.m_entityIndex = m_sQueueSample.m_nEntityIndex; + pedComment.m_vecPos = m_sQueueSample.m_vecPos; pedComment.m_fDistance = m_sQueueSample.m_fDistance; pedComment.m_bVolume = m_sQueueSample.m_bVolume; m_sPedComments.Add(&pedComment); @@ -7548,10 +8229,8 @@ cAudioManager::SetupPedComments(cPedParams *params, uint32 sound) emittingVol, soundIntensity, m_sQueueSample.m_fDistance); pedComment.field_25 = 10; if(m_sQueueSample.m_bVolume) { - pedComment.field_4 = m_sQueueSample.m_nEntityIndex; - pedComment.m_vecPos.x = m_sQueueSample.m_vecPos.x; - pedComment.m_vecPos.y = m_sQueueSample.m_vecPos.y; - pedComment.m_vecPos.z = m_sQueueSample.m_vecPos.z; + pedComment.m_entityIndex = m_sQueueSample.m_nEntityIndex; + pedComment.m_vecPos = m_sQueueSample.m_vecPos; pedComment.m_fDistance = m_sQueueSample.m_fDistance; pedComment.m_bVolume = m_sQueueSample.m_bVolume; m_sPedComments.Add(&pedComment); @@ -7614,6 +8293,7 @@ WRAPPER void cAudioManager::PreloadMissionAudio(char *) STARTPATCHES InjectHook(0x5755C0, &cPedComments::Add, PATCH_JUMP); +InjectHook(0x575730, &cPedComments::Process, PATCH_JUMP); InjectHook(0x57B210, &cAudioManager::AddDetailsToRequestedOrderList, PATCH_JUMP); InjectHook(0x56AD30, &cAudioManager::AddPlayerCarSample, PATCH_JUMP); @@ -7642,7 +8322,7 @@ InjectHook(0x57AC60, &cAudioManager::TranslateEntity, PATCH_JUMP); InjectHook(0x57A0E0, &cAudioManager::Initialise, PATCH_JUMP); InjectHook(0x569420, &cAudioManager::PostInitialiseGameSpecificSetup, PATCH_JUMP); // InjectHook(0x57EAC0, &cAudioManager::InitialisePoliceRadioZones, PATCH_JUMP); -// InjectHook(0x569650, &cAudioManager::ResetAudioLogicTimers, PATCH_JUMP); +InjectHook(0x569650, &cAudioManager::ResetAudioLogicTimers, PATCH_JUMP); InjectHook(0x57A150, &cAudioManager::Terminate, PATCH_JUMP); InjectHook(0x57F050, &cAudioManager::GetMissionScriptPoliceAudioPlayingStatus, PATCH_JUMP); @@ -7814,20 +8494,27 @@ InjectHook(0x56EC00, &cAudioManager::ProcessJumboTakeOff, PATCH_JUMP); InjectHook(0x56EA10, &cAudioManager::ProcessJumboTaxi, PATCH_JUMP); InjectHook(0x5777E0, &cAudioManager::ProcessLaunderetteScriptObject, PATCH_JUMP); InjectHook(0x576770, &cAudioManager::ProcessLoopingScriptObject, PATCH_JUMP); +InjectHook(0x5796E0, &cAudioManager::ProcessMissionAudio, PATCH_JUMP); InjectHook(0x56A050, &cAudioManager::ProcessModelCarEngine, PATCH_JUMP); InjectHook(0x5760C0, &cAudioManager::ProcessOneShotScriptObject, PATCH_JUMP); InjectHook(0x56F450, &cAudioManager::ProcessPed, PATCH_JUMP); InjectHook(0x56F4D0, &cAudioManager::ProcessPedHeadphones, PATCH_JUMP); -InjectHook(0x56F650, &cAudioManager::ProcessPedOneShots, PATCH_JUMP); +// InjectHook(0x56F650, &cAudioManager::ProcessPedOneShots, PATCH_JUMP); InjectHook(0x5699C0, &cAudioManager::ProcessPhysical, PATCH_JUMP); InjectHook(0x56E860, &cAudioManager::ProcessPlane, PATCH_JUMP); InjectHook(0x56B0D0, &cAudioManager::ProcessPlayersVehicleEngine, PATCH_JUMP); InjectHook(0x577280, &cAudioManager::ProcessPornCinema, PATCH_JUMP); InjectHook(0x569CC0, &cAudioManager::ProcessRainOnVehicle, PATCH_JUMP); +InjectHook(0x569700, &cAudioManager::ProcessReverb, PATCH_JUMP); +InjectHook(0x569E50, &cAudioManager::ProcessReverseGear, PATCH_JUMP); InjectHook(0x577630, &cAudioManager::ProcessSawMillScriptObject, PATCH_JUMP); InjectHook(0x576070, &cAudioManager::ProcessScriptObject, PATCH_JUMP); InjectHook(0x577970, &cAudioManager::ProcessShopScriptObject, PATCH_JUMP); InjectHook(0x5697D0, &cAudioManager::ProcessSpecial, PATCH_JUMP); +InjectHook(0x56DBF0, &cAudioManager::ProcessTrainNoise, PATCH_JUMP); +InjectHook(0x56C770, &cAudioManager::ProcessVehicleDoors, PATCH_JUMP); +InjectHook(0x56C640, &cAudioManager::ProcessVehicleReverseWarning, PATCH_JUMP); +InjectHook(0x56A230, &cAudioManager::ProcessVehicleRoadNoise, PATCH_JUMP); InjectHook(0x577530, &cAudioManager::ProcessWorkShopScriptObject, PATCH_JUMP); InjectHook(0x570690, &cAudioManager::SetupPedComments, PATCH_JUMP); ENDPATCHES diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index 12e823b7..5ad14050 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include "AudioSamples.h" #include "DMAudio.h" @@ -8,7 +8,7 @@ class tActiveSample { public: int32 m_nEntityIndex; - int32 field_4; + int32 m_counter; int32 m_nSampleIndex; uint8 m_bBankIndex; uint8 m_bIsDistant; @@ -49,6 +49,8 @@ public: uint8 field_89; uint8 field_90; uint8 field_91; + + // no methods }; static_assert(sizeof(tActiveSample) == 92, "tActiveSample: error"); @@ -84,8 +86,10 @@ public: int16 m_awAudioEvent[4]; uint8 gap_18[2]; float m_afVolume[4]; - uint8 field_24; // is looping + uint8 m_Loops; uint8 field_25[3]; + + // no methods }; static_assert(sizeof(tAudioEntity) == 40, "tAudioEntity: error"); @@ -93,13 +97,15 @@ static_assert(sizeof(tAudioEntity) == 40, "tAudioEntity: error"); class tPedComment { public: - int m_nSampleIndex; - int field_4; + int32 m_nSampleIndex; + int32 m_entityIndex; CVector m_vecPos; float m_fDistance; uint8 m_bVolume; - uint8 field_25; + int8 field_25; // allocated time? uint8 gap_26[2]; + + // no methods }; static_assert(sizeof(tPedComment) == 28, "tPedComment: error"); @@ -108,12 +114,14 @@ class cPedComments { public: tPedComment m_asPedComments[2][20]; - uint8 field_1120[2][20]; + uint8 indexMap[2][20]; uint8 nrOfCommentsInBank[2]; uint8 activeBank; uint8 gap_1163[1]; + // reversed all methods void Add(tPedComment *com); /// ok + void Process(); /// ok }; static_assert(sizeof(cPedComments) == 1164, "cPedComments: error"); @@ -134,6 +142,8 @@ public: CVector m_vecPosition; float m_fDistance; int32 m_nBaseVolume; + + // no methods }; static_assert(sizeof(cAudioCollision) == 40, "cAudioCollision: error"); @@ -176,6 +186,7 @@ class CPlane; class CVehicle; class CPed; class cPedParams; +class cTransmission; class cAudioScriptObject { public: @@ -271,9 +282,10 @@ public: uint8 field_19192; uint8 m_bUserPause; uint8 m_bPreviousUserPause; - uint8 field_19195; + uint8 field_19195; // time? uint32 m_FrameCounter; +<<<<<<< HEAD inline uint32 GetFrameCounter(void) { return m_FrameCounter; } float GetReflectionsDistance(int32 idx) { return m_afReflectionsDistances[idx]; } <<<<<<< HEAD @@ -283,25 +295,36 @@ public: >>>>>>> Cleanup // +======= + // getters + uint32 GetFrameCounter() const { return m_FrameCounter; } + float GetReflectionsDistance(int32 idx) const { return m_afReflectionsDistances[idx]; } + int32 GetRandomTabe(int32 idx) const { return m_anRandomTable[idx]; } +>>>>>>> More more more audio + // "Should" be in alphabetic order, except "getXTalkSfx" void AddDetailsToRequestedOrderList(uint8 sample); /// ok void AddPlayerCarSample(uint8 emittingVolume, int32 freq, uint32 sample, uint8 unk1, - uint8 unk2, bool notLooping); /// ok - void AddReflectionsToRequestedQueue(); /// ok (check value) - void AddReleasingSounds(); // todo (difficult) - void AddSampleToRequestedQueue(); /// ok - void AgeCrimes(); // todo - int8 GetCurrent3DProviderIndex(); /// ok + uint8 counter, bool notLooping); /// ok + void AddReflectionsToRequestedQueue(); /// ok (check value) + void AddReleasingSounds(); // todo (difficult) + void AddSampleToRequestedQueue(); /// ok + void AgeCrimes(); // todo void CalculateDistance(bool *ptr, float dist); /// ok - bool CheckForAnAudioFileOnCD(); /// ok + bool CheckForAnAudioFileOnCD() const; /// ok void ClearMissionAudio(); /// ok void ClearRequestedQueue(); /// ok int32 ComputeDopplerEffectedFrequency(uint32 oldFreq, float position1, float position2, - float speedMultiplier); /// ok + float speedMultiplier) const; /// ok int32 ComputePan(float, CVector *); // todo +<<<<<<< HEAD uint32 ComputeVolume(int emittingVolume, float soundIntensity, float distance); /// ok int32 CreateEntity(int32 type, void *entity); /// ok +======= + uint32 ComputeVolume(int emittingVolume, float soundIntensity, float distance) const; /// ok + int32 CreateEntity(int32 type, CPhysical *entity); /// ok +>>>>>>> More more more audio void DestroyAllGameCreatedEntities(); /// ok void DestroyEntity(int32 id); /// ok @@ -309,89 +332,60 @@ public: void GenerateIntegerRandomNumberTable(); /// ok - float GetDistanceSquared(CVector *v); /// ok - - void TranslateEntity(CVector *v1, CVector *v2); /// ok + void TranslateEntity(CVector *v1, CVector *v2) const ; /// ok - // done - - void Initialise(); - void PostInitialiseGameSpecificSetup(); - void InitialisePoliceRadioZones(); // todo - void ResetAudioLogicTimers(int32 timer); // todo + void ResetAudioLogicTimers(int32 timer); /// ok void Terminate(); + uint8 GetNum3DProvidersAvailable() const; + bool IsMP3RadioChannelAvailable() const; + uint8 GetCDAudioDriveLetter() const; - char GetMissionScriptPoliceAudioPlayingStatus(); - bool GetMissionAudioLoadingStatus(); - - uint8 GetNum3DProvidersAvailable(); - bool IsMP3RadioChannelAvailable(); - uint8 GetCDAudioDriveLetter(); + void SetEffectsMasterVolume(uint8 volume) const; + void SetMusicMasterVolume(uint8 volume) const; + void SetEffectsFadeVolume(uint8 volume) const; + void SetMusicFadeVolume(uint8 volume) const; - void SetEffectsMasterVolume(uint8 volume); - void SetMusicMasterVolume(uint8 volume); - void SetEffectsFadeVolume(uint8 volume); - void SetMusicFadeVolume(uint8 volume); - - void SetSpeakerConfig(int32 conf); + void SetSpeakerConfig(int32 conf) const; bool SetupJumboEngineSound(uint8, int32); // todo - void PreInitialiseGameSpecificSetup(); - void SetMissionScriptPoliceAudio(int32 sfx); - - bool UsesSiren(int32 model); - bool UsesSirenSwitching(int32 model); + void PreInitialiseGameSpecificSetup() const; + void SetMissionScriptPoliceAudio(int32 sfx) const; - bool MissionScriptAudioUsesPoliceChannel(int32 soundMission); + bool UsesSiren(int32 model) const; + bool UsesSirenSwitching(int32 model) const; - char *Get3DProviderName(uint8 id); + char *Get3DProviderName(uint8 id) const; bool SetupJumboFlySound(uint8 emittingVol); /// ok bool SetupJumboRumbleSound(uint8 emittingVol); /// ok bool SetupJumboTaxiSound(uint8 vol); /// ok bool SetupJumboWhineSound(uint8 emittingVol, int32 freq); /// ok - void PlayLoadedMissionAudio(); - void SetMissionAudioLocation(float x, float y, float z); void ResetPoliceRadio(); - void InterrogateAudioEntities(); - - bool UsesReverseWarning(int32 model); - bool HasAirBrakes(int32 model); - - int32 GetJumboTaxiFreq(); + bool UsesReverseWarning(int32 model) const; - bool IsMissionAudioSampleFinished(); + int32 RandomDisplacement(uint32 seed) const; - void InitialisePoliceRadio(); // todo - - int32 RandomDisplacement(uint32 seed); - - void ReleaseDigitalHandle(); - void ReacquireDigitalHandle(); + void ReleaseDigitalHandle() const; + void ReacquireDigitalHandle() const; void SetDynamicAcousticModelingStatus(bool status); bool IsAudioInitialised() const; void SetEntityStatus(int32 id, bool status); - void PreTerminateGameSpecificShutdown(); - void PostTerminateGameSpecificShutdown(); - - void PlayerJustGotInCar(); - void PlayerJustLeftCar(); - void Service(); - void GetPhrase(uint32 *phrase, uint32 *prevPhrase, uint32 sample, uint32 maxOffset); + void GetPhrase(uint32 *phrase, uint32 *prevPhrase, uint32 sample, uint32 maxOffset) const; - void DoJumboVolOffset(); + void DoJumboVolOffset() const; int32 GetPedCommentSfx(CPed *ped, int32 sound); + // order from GetPedCommentSfx uint32 GetPlayerTalkSfx(int16 sound); uint32 GetCopTalkSfx(int16 sound); uint32 GetSwatTalkSfx(int16 sound); @@ -469,8 +463,38 @@ public: uint32 GetGenericMaleTalkSfx(int16 sound); uint32 GetGenericFemaleTalkSfx(int16 sound); + int8 GetCurrent3DProviderIndex() const; /// ok + float GetCollisionLoopingRatio(uint32 a, uint32 b, float c) const; // todo hook + float GetCollisionOneShotRatio(uint32 a, float b) const; // todo hook + float GetCollisionRatio(float a, float b, float c, float d) const; // todo hook + float GetDistanceSquared(CVector *v) const; /// ok + int32 GetJumboTaxiFreq() const; /// ok + bool GetMissionAudioLoadingStatus() const; /// ok + char GetMissionScriptPoliceAudioPlayingStatus() const; /// ok + float GetVehicleDriveWheelSkidValue(uint8 a1, CAutomobile *a2, cTransmission *a3, + float a4); // todo + int32 GetVehicleNonDriveWheelSkidValue(float a1, int a2, int a3, int a4, float a5); // todo + + bool HasAirBrakes(int32 model) const; /// ok + + void Initialise(); /// ok + void InitialisePoliceRadio(); // todo + void InitialisePoliceRadioZones(); // todo + void InterrogateAudioEntities(); /// ok + bool IsMissionAudioSampleFinished(); /// ok + + bool MissionScriptAudioUsesPoliceChannel(int32 soundMission) const; /// ok + + void PlayLoadedMissionAudio(); /// ok void PlayOneShot(int32 index, int16 sound, float vol); // todo - + uint32 PlaySuspectLastSeen(float x, float y, float z); // todo + void PlayerJustGotInCar() const; /// ok + void PlayerJustLeftCar() const; /// ok + void PostInitialiseGameSpecificSetup(); /// ok + void PostTerminateGameSpecificShutdown(); /// ok + void PreTerminateGameSpecificShutdown(); /// ok + void PreloadMissionAudio(char *); // todo + /// processX - main logic of adding new sounds void ProcessActiveQueues(); // todo bool ProcessAirBrakes(cVehicleParams *params); /// ok void ProcessAirportScriptObject(uint8 sound); /// ok @@ -503,40 +527,40 @@ public: void ProcessJumboTaxi(); /// ok void ProcessLaunderetteScriptObject(uint8 sound); /// ok void ProcessLoopingScriptObject(uint8 sound); /// ok - // void ProcessMissionAudio(); - void ProcessModelCarEngine(cVehicleParams *params); /// (check float comparisons) - void ProcessOneShotScriptObject(uint8 sound); /// ok - void ProcessPed(CPhysical *ped); /// ok - void ProcessPedHeadphones(cPedParams *params); /// ok - void ProcessPedOneShots(cPedParams *params); /// ok - void ProcessPhysical(int32 id); /// ok - void ProcessPlane(cVehicleParams *params); /// ok + void ProcessMissionAudio(); /// ok + void ProcessModelCarEngine(cVehicleParams *params); /// ok (check float comparisons) + void ProcessOneShotScriptObject(uint8 sound); /// ok + void ProcessPed(CPhysical *ped); /// ok + void ProcessPedHeadphones(cPedParams *params); /// ok + void ProcessPedOneShots(cPedParams *params); // todo later (weird) + void ProcessPhysical(int32 id); /// ok + void ProcessPlane(cVehicleParams *params); /// ok void ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile *automobile); /// ok (check float comparisons) void ProcessPoliceCellBeatingScriptObject(uint8 sound); // todo void ProcessPornCinema(uint8 sound); /// ok void ProcessProjectiles(); // todo requires CProjectileInfo void ProcessRainOnVehicle(cVehicleParams *params); /// ok - // void ProcessReverb(); - // bool ProcessReverseGear(void *); - void ProcessSawMillScriptObject(uint8 sound); /// ok - void ProcessScriptObject(int32 id); /// ok - void ProcessShopScriptObject(uint8 sound); /// ok - void ProcessSpecial(); /// ok - // bool ProcessTrainNoise(void *); - void ProcessVehicle(CVehicle *); // todo - // bool ProcessVehicleDoors(void *); + void ProcessReverb() const; /// ok + bool ProcessReverseGear(cVehicleParams *a2); /// ok + void ProcessSawMillScriptObject(uint8 sound); /// ok + void ProcessScriptObject(int32 id); /// ok + void ProcessShopScriptObject(uint8 sound); /// ok + void ProcessSpecial(); /// ok + bool ProcessTrainNoise(cVehicleParams *params); /// ok + void ProcessVehicle(CVehicle *); // todo + bool ProcessVehicleDoors(cVehicleParams *params); /// ok // bool ProcessVehicleEngine(void *); - // void ProcessVehicleHorn(void *); + // void ProcessVehicleHorn(cVehicleParams *params); // void ProcessVehicleOneShots(void *); - // bool ProcessVehicleReverseWarning(void *); - // bool ProcessVehicleRoadNoise(void *); + bool ProcessVehicleReverseWarning(cVehicleParams *params); /// ok + bool ProcessVehicleRoadNoise(cVehicleParams *params); /// ok // void ProcessVehicleSirenOrAlarm(void *); // void ProcessVehicleSkidding(void *); - void ProcessWaterCannon(int32); // todo - void ProcessWeather(int32 id); // todo - // bool ProcessWetRoadNoise(void *); - void ProcessWorkShopScriptObject(uint8 sound); /// ok + void ProcessWaterCannon(int32); // todo + void ProcessWeather(int32 id); // todo + bool ProcessWetRoadNoise(cVehicleParams *params); // todo hook + void ProcessWorkShopScriptObject(uint8 sound); /// ok void SetupPedComments(cPedParams *params, uint32 sound); /// ok }; diff --git a/src/audio/sampman.cpp b/src/audio/sampman.cpp index de222493..58da6f64 100644 --- a/src/audio/sampman.cpp +++ b/src/audio/sampman.cpp @@ -158,14 +158,14 @@ release_existing() if ( opened_samples[i] ) { AIL_release_3D_sample_handle(opened_samples[i]); - opened_samples[i] = NULL; + opened_samples[i] = 0; } } if ( opened_provider ) { AIL_close_3D_provider(opened_provider); - opened_provider = NULL; + opened_provider = 0; } _fPrevEaxRatioDestination = 0.0f; @@ -879,7 +879,7 @@ cSampleManager::Initialise(void) _maxSamples = 0; - opened_provider = NULL; + opened_provider = 0; DIG = NULL; for ( int32 i = 0; i < MAXCHANNELS; i++ ) @@ -2020,10 +2020,9 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) { uint32 i = 0; - if ( !_bIsMp3Active ) goto FIND_MP3TRACK; - do { + if(_bIsMp3Active){ if ( ++_CurMP3Index >= nNumMP3s ) _CurMP3Index = 0; @@ -2059,21 +2058,15 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) AIL_pause_stream(mp3Stream[nStream], 0); return true; } - - goto NEXT_MP3TRACK; - -FIND_MP3TRACK: - if ( nPos > nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] ) - position = 0; - - tMP3Entry *e; - if ( !_GetMP3PosFromStreamPos(&position, &e) ) - { - if ( e == NULL ) - { - nFile = 0; - goto PLAY_STREAMEDTRACK; - } + } + if(nPos > nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER]) position = 0; + + tMP3Entry *e; + if(!_GetMP3PosFromStreamPos(&position, &e)) { + if(e == NULL) { + nFile = 0; + goto PLAY_STREAMEDTRACK; + } } if ( e->pLinkPath != NULL ) @@ -2097,14 +2090,12 @@ FIND_MP3TRACK: return true; } -NEXT_MP3TRACK: _bIsMp3Active = false; } while ( ++i < nNumMP3s ); position = 0; nFile = 0; - goto PLAY_STREAMEDTRACK; } PLAY_STREAMEDTRACK: -- cgit v1.2.3 From 01ac2929cd723b579454788ffbe9579d1863d240 Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Tue, 27 Aug 2019 20:50:59 +0200 Subject: Cleanup --- src/audio/AudioManager.cpp | 1931 ++++++++++++++++++------------------- src/audio/AudioManager.h | 206 ++-- src/audio/AudioManager.h.autosave | 549 +++++++++++ src/audio/DMAudio.cpp | 12 +- 4 files changed, 1583 insertions(+), 1115 deletions(-) create mode 100644 src/audio/AudioManager.h.autosave (limited to 'src/audio') diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index e1860698..1e4b9c3b 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -31,12 +31,18 @@ #include "sampman.h" cAudioManager &AudioManager = *(cAudioManager *)0x880FC0; +uint32 *audioLogicTimers = (uint32 *)0x6508A0; +uint8 &jumboVolOffset = *(uint8 *)0x6508ED; +uint8 &gJumboVolOffsetPercentage = *(uint8 *)0x6508ED; +char &g_nMissionAudioPlayingStatus = *(char *)0x60ED88; +int32 *BankStartOffset = (int32 *)0x6FAB70; //[2] +int32 &g_nMissionAudioSfx = *(int32 *)0x60ED84; +bool &bPlayerJustEnteredCar = *(bool *)0x6508C4; +bool &g_bMissionAudioLoadFailed = *(bool *)0x95CD8E; constexpr int totalAudioEntitiesSlots = 200; constexpr int maxVolume = 127; -uint32 *audioLogicTimers = (uint32 *)0x6508A0; - // TODO: where is this used? Is this the right file? enum eVehicleModel { LANDSTAL, @@ -251,8 +257,6 @@ cAudioScriptObject::operator delete(void *p, int handle) CPools::GetAudioScriptObjectPool()->Delete((cAudioScriptObject *)p); } -char &g_nMissionAudioPlayingStatus = *(char *)0x60ED88; - void cAudioManager::AddDetailsToRequestedOrderList(uint8 sample) { @@ -311,8 +315,7 @@ cAudioManager::AddReflectionsToRequestedQueue() { float reflectionDistance; int32 noise; - uint8 emittingVolume = emittingVolume = - (m_sQueueSample.m_bVolume >> 1) + (m_sQueueSample.m_bVolume >> 3); + uint8 emittingVolume = (m_sQueueSample.m_bVolume >> 1) + (m_sQueueSample.m_bVolume >> 3); for(uint32 i = 0; i < 5u; i++) { reflectionDistance = m_afReflectionsDistances[i]; @@ -452,9 +455,9 @@ cAudioManager::ComputeDopplerEffectedFrequency(uint32 oldFreq, float position1, float speedOfSource = (dist / field_19195) * speedMultiplier; if(speedOfSound > Abs(speedOfSource)) { if(speedOfSource < 0.0f) { - speedOfSource = Max(speedOfSource, -1.5f); + speedOfSource = max(speedOfSource, -1.5f); } else { - speedOfSource = Min(speedOfSource, 1.5f); + speedOfSource = min(speedOfSource, 1.5f); } newFreq = (oldFreq * speedOfSound) / (speedOfSource + speedOfSound); } @@ -485,7 +488,7 @@ cAudioManager::ComputeVolume(int emittingVolume, float soundIntensity, float dis } int32 -cAudioManager::CreateEntity(int32 type, void *entity) +cAudioManager::CreateEntity(int32 type, CPhysical *entity) { if(!m_bIsInitialised) return -4; if(!entity) return -2; @@ -495,7 +498,7 @@ cAudioManager::CreateEntity(int32 type, void *entity) m_asAudioEntities[i].m_bIsUsed = true; m_asAudioEntities[i].m_bStatus = 0; m_asAudioEntities[i].m_nType = (eAudioType)type; - m_asAudioEntities[i].m_pEntity = entity; + m_asAudioEntities[i].m_pEntity = (void*)entity; m_asAudioEntities[i].m_awAudioEvent[0] = SOUND_TOTAL_PED_SOUNDS; m_asAudioEntities[i].m_awAudioEvent[1] = SOUND_TOTAL_PED_SOUNDS; m_asAudioEntities[i].m_awAudioEvent[2] = SOUND_TOTAL_PED_SOUNDS; @@ -557,6 +560,13 @@ cAudioManager::DestroyEntity(int32 id) } } +void +cAudioManager::DoJumboVolOffset() const +{ + if(!(m_FrameCounter % (m_anRandomTable[0] % 6u + 3))) + jumboVolOffset = m_anRandomTable[1] % 60u; +} + void cAudioManager::DoPoliceRadioCrackle() { @@ -581,711 +591,144 @@ cAudioManager::DoPoliceRadioCrackle() AddSampleToRequestedQueue(); } -void -cAudioManager::GenerateIntegerRandomNumberTable() +uint32 +cAudioManager::GetPlayerTalkSfx(int16 sound) { - for(int32 i = 0; i < 5; i++) { m_anRandomTable[i] = rand(); } -} + uint32 sfx; + static uint32 lastSfx = NO_SAMPLE; -void -cAudioManager::TranslateEntity(CVector *v1, CVector *v2) const -{ - const RwMatrix &cM = TheCamera.GetMatrix().m_matrix; - const CVector &cV = TheCamera.GetPosition(); + switch(sound) { + case SOUND_PED_DAMAGE: + GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_DAMAGE_REACTION_1, 11u); + break; - float a = v1->z - cV.z; - float b = v1->y - cV.y; - float c = v1->x - cV.x; + case SOUND_PED_HIT: GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_HIT_REACTION_1, 10u); break; - v2->x = cM.right.y * b + cM.right.x * c + cM.right.z * a; - v2->y = cM.up.y * b + cM.up.x * c + cM.up.z * a; - v2->z = cM.at.y * b + cM.at.x * c + cM.at.z * a; -} + case SOUND_PED_LAND: GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_FALL_REACTION_1, 6u); break; -void -cAudioManager::ResetAudioLogicTimers(int32 timer) -{ - audioLogicTimers[0] = timer; - audioLogicTimers[8] = timer; - audioLogicTimers[1] = timer; - audioLogicTimers[7] = timer; - audioLogicTimers[2] = timer; - audioLogicTimers[6] = timer; - audioLogicTimers[3] = timer; - audioLogicTimers[5] = timer; - audioLogicTimers[4] = timer; - for(int32 i = 0; i < m_nAudioEntitiesTotal; i++) { - if(m_asAudioEntities[m_anAudioEntityIndices[i]].m_nType == AUDIOTYPE_PHYSICAL) { - CPed *ped = (CPed *)m_asAudioEntities[m_anAudioEntityIndices[i]].m_pEntity; - if(ped->IsPed()) { - ped->m_lastSoundStart = timer; - ped->m_soundStart = timer + m_anRandomTable[0] % 3000u; - } - } + default: sfx = NO_SAMPLE; break; } -<<<<<<< HEAD + return sfx; } -void -cAudioManager::PostInitialiseGameSpecificSetup() +uint32 +cAudioManager::GetCopTalkSfx(int16 sound) { - m_nFireAudioEntity = - CreateEntity(AUDIOTYPE_FIRE, - (CPhysical *)0x8F31D0); // last is addr of firemanager @todo change - if(m_nFireAudioEntity >= 0) SetEntityStatus(m_nFireAudioEntity, 1); - - m_nCollisionEntity = CreateEntity(AUDIOTYPE_COLLISION, (CPhysical *)1); - if(m_nCollisionEntity >= 0) SetEntityStatus(m_nCollisionEntity, 1); - - m_nFrontEndEntity = CreateEntity(AUDIOTYPE_FRONTEND, (CPhysical *)1); - if(m_nFrontEndEntity >= 0) SetEntityStatus(m_nFrontEndEntity, 1); - - m_nProjectileEntity = CreateEntity(AUDIOTYPE_PROJECTILE, (CPhysical *)1); - if(m_nProjectileEntity >= 0) SetEntityStatus(m_nProjectileEntity, 1); - - m_nWaterCannonEntity = CreateEntity(AUDIOTYPE_WATERCANNON, (CPhysical *)1); - if(m_nWaterCannonEntity >= 0) SetEntityStatus(m_nWaterCannonEntity, 1); - - m_nPoliceChannelEntity = CreateEntity(AUDIOTYPE_POLICERADIO, (CPhysical *)1); - if(m_nPoliceChannelEntity >= 0) SetEntityStatus(m_nPoliceChannelEntity, 1); + uint32 sfx; + PedState pedState; + static uint32 lastSfx = NO_SAMPLE; - m_nBridgeEntity = CreateEntity(AUDIOTYPE_BRIDGE, (CPhysical *)1); - if(m_nBridgeEntity >= 0) SetEntityStatus(m_nBridgeEntity, 1); + if(sound == SOUND_PED_ARREST_COP) { + GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_POLICE_COP_1_ARREST_1, 6u); + } else { + if(sound != SOUND_PED_PURSUIT_COP) { return GetGenericMaleTalkSfx(sound); } - m_sMissionAudio.m_nSampleIndex = NO_SAMPLE; - m_sMissionAudio.m_bLoadingStatus = 0; - m_sMissionAudio.m_bPlayStatus = 0; - m_sMissionAudio.field_22 = 0; - m_sMissionAudio.m_bIsPlayed = 0; - m_sMissionAudio.field_12 = 1; - m_sMissionAudio.field_24 = 0; - ResetAudioLogicTimers((int32)CTimer::GetTimeInMilliseconds); -} + pedState = FindPlayerPed()->m_nPedState; + if(pedState == PED_ARRESTED || pedState == PED_DEAD || pedState == PED_DIE) + return NO_SAMPLE; + GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_POLICE_COP_1_PURSUIT_1, 7u); + } -WRAPPER -void -cAudioManager::InitialisePoliceRadioZones() -{ - EAXJMP(0x57EAC0); + return 13 * (m_sQueueSample.m_nEntityIndex % 5) + sfx; } -WRAPPER -void -cAudioManager::ResetAudioLogicTimers(int32 timer) +uint32 +cAudioManager::GetSwatTalkSfx(int16 sound) { - EAXJMP(0x569650); -======= - ClearMissionAudio(); - SampleManager.StopChannel(28); ->>>>>>> More more more audio -} + uint32 sfx; + PedState pedState; + static uint32 lastSfx = NO_SAMPLE; -void -cAudioManager::Terminate() -{ - if(m_bIsInitialised) { - MusicManager.Terminate(); + if(sound == SOUND_PED_ARREST_SWAT) { + GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_POLICE_SWAT_1_PURSUIT_ARREST_1, 6u); + } else { + if(sound != SOUND_PED_PURSUIT_SWAT) { return GetGenericMaleTalkSfx(sound); } - for(uint32 i = 0; i < totalAudioEntitiesSlots; i++) { - m_asAudioEntities[i].m_bIsUsed = 0; - m_anAudioEntityIndices[i] = 200; - } + pedState = FindPlayerPed()->m_nPedState; + if(pedState == PED_ARRESTED || pedState == PED_DEAD || pedState == PED_DIE) + return NO_SAMPLE; + GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_POLICE_SWAT_1_PURSUIT_ARREST_1, 6u); + } - m_nAudioEntitiesTotal = 0; - m_nScriptObjectEntityTotal = 0; - PreTerminateGameSpecificShutdown(); + return 6 * (m_sQueueSample.m_nEntityIndex % 3) + sfx; +} - for(uint32 i = 0; i < 2; i++) { - if(SampleManager.IsSampleBankLoaded(i)) SampleManager.UnloadSampleBank(i); - } +uint32 +cAudioManager::GetFBITalkSfx(int16 sound) +{ + uint32 sfx; + PedState pedState; + static uint32 lastSfx = NO_SAMPLE; - SampleManager.Terminate(); + if(sound == SOUND_PED_ARREST_FBI) { + GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_POLICE_FBI_1_PURSUIT_ARREST_1, 6u); + } else { + if(sound != SOUND_PED_PURSUIT_FBI) { return GetGenericMaleTalkSfx(sound); } - m_bIsInitialised = 0; - PostTerminateGameSpecificShutdown(); + pedState = FindPlayerPed()->m_nPedState; + if(pedState == PED_ARRESTED || pedState == PED_DEAD || pedState == PED_DIE) + return NO_SAMPLE; + GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_POLICE_FBI_1_PURSUIT_ARREST_1, 6u); } -} -uint8 -cAudioManager::GetNum3DProvidersAvailable() const -{ - if(m_bIsInitialised) return SampleManager.GetNum3DProvidersAvailable(); - return 0; + return 6 * (m_sQueueSample.m_nEntityIndex % 3) + sfx; } -bool -cAudioManager::IsMP3RadioChannelAvailable() const +uint32 +cAudioManager::GetArmyTalkSfx(int16 sound) { - if(m_bIsInitialised) return SampleManager.IsMP3RadioChannelAvailable(); - - return 0; -} + uint32 sfx; + PedState pedState; + static uint32 lastSfx = NO_SAMPLE; -uint8 -cAudioManager::GetCDAudioDriveLetter() const -{ - if(m_bIsInitialised) return SampleManager.GetCDAudioDriveLetter(); + if(sound != SOUND_PED_PURSUIT_ARMY) { return GetGenericMaleTalkSfx(sound); } - return 0; -} + pedState = FindPlayerPed()->m_nPedState; + if(pedState == PED_ARRESTED || pedState == PED_DEAD || pedState == PED_DIE) + return NO_SAMPLE; + GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_POLICE_ARMY_1_PURSUIT_1, 15u); -void -cAudioManager::SetEffectsMasterVolume(uint8 volume) const -{ - SampleManager.SetEffectsMasterVolume(volume); + return 15 * (m_sQueueSample.m_nEntityIndex % 1) + sfx; } -void -cAudioManager::SetMusicMasterVolume(uint8 volume) const +uint32 +cAudioManager::GetMedicTalkSfx(int16 sound) { - SampleManager.SetMusicMasterVolume(volume); -} + uint32 sfx; + static uint32 lastSfx = NO_SAMPLE; -void -cAudioManager::SetEffectsFadeVolume(uint8 volume) const -{ - SampleManager.SetEffectsFadeVolume(volume); + switch(sound) { + case SOUND_PED_HANDS_COWER: + GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_MEDIC_1_HANDS_COWER_1, 5u); + break; + case SOUND_PED_CAR_JACKED: + GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_MEDIC_1_CAR_JACKED_1, 5u); + break; + case SOUND_PED_HEALING: + GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_MEDIC_1_HEALING_1, 12u); + break; + case SOUND_PED_LEAVE_VEHICLE: + GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_MEDIC_1_LEAVE_VEHICLE_1, 9u); + break; + case SOUND_PED_FLEE_RUN: + GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_MEDIC_1_FLEE_RUN_1, 6u); + break; + default: return GetGenericMaleTalkSfx(sound); + } + return 37 * (m_sQueueSample.m_nEntityIndex & 1) + sfx; } -void -cAudioManager::SetMusicFadeVolume(uint8 volume) const +uint32 +cAudioManager::GetFiremanTalkSfx(int16 sound) { - SampleManager.SetMusicFadeVolume(volume); + return GetGenericMaleTalkSfx(sound); } -void -cAudioManager::SetSpeakerConfig(int32 conf) const +uint32 +cAudioManager::GetNormalMaleTalkSfx(int16 sound) { - SampleManager.SetSpeakerConfig(conf); -} - -WRAPPER -bool cAudioManager::SetupJumboEngineSound(uint8, int32) { EAXJMP(0x56F140); } - -int32 *BankStartOffset = (int32 *)0x6FAB70; //[2] - -void -cAudioManager::PreInitialiseGameSpecificSetup() const -{ - BankStartOffset[0] = AUDIO_SAMPLE_VEHICLE_HORN_0; - BankStartOffset[1] = AUDIO_SAMPLE_POLICE_COP_1_ARREST_1; -} - -int32 &g_nMissionAudioSfx = *(int32 *)0x60ED84; - -void -cAudioManager::SetMissionScriptPoliceAudio(int32 sfx) const -{ - if(m_bIsInitialised) { - if(g_nMissionAudioPlayingStatus != 1) { - g_nMissionAudioPlayingStatus = 0; - g_nMissionAudioSfx = sfx; - } - } -} - -bool -cAudioManager::UsesSiren(int32 model) const -{ - switch(model) { - case FIRETRUK: - case AMBULAN: - case FBICAR: - case POLICE: - case ENFORCER: - case PREDATOR: return true; - default: return false; - } -} - -bool -cAudioManager::UsesSirenSwitching(int32 model) const -{ - switch(model) { - case AMBULAN: - case POLICE: - case ENFORCER: - case PREDATOR: return true; - default: return false; - } -} - -char * -cAudioManager::Get3DProviderName(uint8 id) const -{ - if(!m_bIsInitialised) return 0; - if(id >= SampleManager.GetNum3DProvidersAvailable()) return 0; - return SampleManager.Get3DProviderName(id); -} - -bool -cAudioManager::SetupJumboFlySound(uint8 emittingVol) -{ - int32 vol; - - if(m_sQueueSample.m_fDistance >= 440.0f) return 0; - - vol = ComputeVolume(emittingVol, 440.0f, m_sQueueSample.m_fDistance); - m_sQueueSample.m_bVolume = vol; - if(m_sQueueSample.m_bVolume) { - m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_JUMBO_FLY_SOUND; - m_sQueueSample.m_counter = 0; - m_sQueueSample.m_bBankIndex = 0; - m_sQueueSample.m_bIsDistant = 0; - m_sQueueSample.field_16 = 1; - m_sQueueSample.m_bEmittingVolume = emittingVol; - m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nFrequency = - SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_JUMBO_FLY_SOUND); - m_sQueueSample.m_nLoopStart = - SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_fSoundIntensity = 440.0f; - m_sQueueSample.field_56 = 0; - m_sQueueSample.field_48 = 4.0f; - m_sQueueSample.m_bReverbFlag = 1; - m_sQueueSample.field_76 = 5; - m_sQueueSample.m_nLoopEnd = - SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - AddSampleToRequestedQueue(); - } - return 1; -} - -bool -cAudioManager::SetupJumboRumbleSound(uint8 emittingVol) -{ - if(m_sQueueSample.m_fDistance >= 240.f) return 0; - - m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, 240.f, m_sQueueSample.m_fDistance); - - if(m_sQueueSample.m_bVolume) { - m_sQueueSample.m_counter = 5; - m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_JUMBO_RUMBLE_SOUND; - m_sQueueSample.m_bBankIndex = 0; - m_sQueueSample.m_bIsDistant = 1; - m_sQueueSample.field_16 = 1; - m_sQueueSample.m_nFrequency = - SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_JUMBO_RUMBLE_SOUND); - m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_bEmittingVolume = emittingVol; - m_sQueueSample.m_nLoopStart = - SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = - SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.field_48 = 4.0f; - m_sQueueSample.m_fSoundIntensity = 240.0f; - m_sQueueSample.field_56 = 0; - m_sQueueSample.field_76 = 12; - m_sQueueSample.m_bOffset = 0; - m_sQueueSample.m_bReverbFlag = 1; - m_sQueueSample.m_bRequireReflection = 0; - AddSampleToRequestedQueue(); - m_sQueueSample.m_counter = 6; - m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_JUMBO_RUMBLE_SOUND; - m_sQueueSample.m_nFrequency += 200; - m_sQueueSample.m_bOffset = maxVolume; - AddSampleToRequestedQueue(); - } - return 1; -} - -uint8 &gJumboVolOffsetPercentage = *(uint8 *)0x6508ED; - -bool -cAudioManager::SetupJumboTaxiSound(uint8 vol) -{ - uint8 emittingVol; - - if(m_sQueueSample.m_fDistance >= 180.f) return 0; - - emittingVol = (vol >> 1) + ((vol >> 1) * m_sQueueSample.m_fDistance * 0.0055556f); - - if(m_sQueueSample.m_fDistance * 0.0055556f < 0.7f) - emittingVol -= emittingVol * gJumboVolOffsetPercentage / 100; - m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, 180.f, m_sQueueSample.m_fDistance); - - if(m_sQueueSample.m_bVolume) { - m_sQueueSample.m_counter = 1; - m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_JUMBO_TAXI_SOUND; - m_sQueueSample.m_bBankIndex = 0; - m_sQueueSample.m_bIsDistant = 0; - m_sQueueSample.field_16 = 1; - m_sQueueSample.m_nFrequency = GetJumboTaxiFreq(); - m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_bEmittingVolume = emittingVol; - m_sQueueSample.m_nLoopStart = - SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = - SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.field_48 = 4.0f; - m_sQueueSample.m_fSoundIntensity = 180.0f; - m_sQueueSample.field_56 = 0; - m_sQueueSample.field_76 = 4; - m_sQueueSample.m_bReverbFlag = 1; - m_sQueueSample.m_bRequireReflection = 0; - AddSampleToRequestedQueue(); - } - return 1; -} - -bool -cAudioManager::SetupJumboWhineSound(uint8 emittingVol, int32 freq) -{ - if(m_sQueueSample.m_fDistance >= 170.f) return 0; - - m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, 170.f, m_sQueueSample.m_fDistance); - - if(m_sQueueSample.m_bVolume) { - m_sQueueSample.m_counter = 2; - m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_JUMBO_WHINE_SOUND; - m_sQueueSample.m_bBankIndex = 0; - m_sQueueSample.m_bIsDistant = 0; - m_sQueueSample.field_16 = 1; - m_sQueueSample.m_nFrequency = freq; - m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_bEmittingVolume = emittingVol; - m_sQueueSample.m_nLoopStart = - SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = - SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.field_48 = 4.0f; - m_sQueueSample.m_fSoundIntensity = 170.0f; - m_sQueueSample.field_56 = 0; - m_sQueueSample.field_76 = 4; - m_sQueueSample.m_bReverbFlag = 1; - m_sQueueSample.m_bRequireReflection = 0; - AddSampleToRequestedQueue(); - } - return 1; -} - -void -cAudioManager::SetMissionAudioLocation(float x, float y, float z) -{ - if(m_bIsInitialised) { - m_sMissionAudio.field_12 = 0; - m_sMissionAudio.m_vecPos.x = x; - m_sMissionAudio.m_vecPos.y = y; - m_sMissionAudio.m_vecPos.z = z; - } -} - -void -cAudioManager::ResetPoliceRadio() -{ - if(m_bIsInitialised) { - if(SampleManager.GetChannelUsedFlag(28)) SampleManager.StopChannel(28); - InitialisePoliceRadio(); - } -} - -bool -cAudioManager::UsesReverseWarning(int32 model) const -{ - return model == LINERUN || model == FIRETRUK || model == TRASH || model == BUS || - model == COACH; -} - -int32 -cAudioManager::RandomDisplacement(uint32 seed) const -{ - int32 value; - - static bool bIsEven = true; - static uint32 base = 0; - - if(!seed) return 0; - - value = m_anRandomTable[(base + seed) % 5] % seed; - base += value; - - if(value % 2) { bIsEven = !bIsEven; } - if(!bIsEven) value = -value; - return value; -} - -void -cAudioManager::ReleaseDigitalHandle() const -{ - if(m_bIsInitialised) { SampleManager.ReleaseDigitalHandle(); } -} - -void -cAudioManager::ReacquireDigitalHandle() const -{ - if(m_bIsInitialised) { SampleManager.ReacquireDigitalHandle(); } -} - -void -cAudioManager::SetDynamicAcousticModelingStatus(bool status) -{ - m_bDynamicAcousticModelingStatus = status; -} - -bool -cAudioManager::IsAudioInitialised() const -{ - return m_bIsInitialised; -} - -void -cAudioManager::SetEntityStatus(int32 id, bool status) -{ - if(m_bIsInitialised && id >= 0 && id < totalAudioEntitiesSlots) { - if(m_asAudioEntities[id].m_bIsUsed) { m_asAudioEntities[id].m_bStatus = status; } - } -} - -void -cAudioManager::GetPhrase(uint32 *phrase, uint32 *prevPhrase, uint32 sample, uint32 maxOffset) const -{ - *phrase = sample + m_anRandomTable[m_sQueueSample.m_nEntityIndex & 3] % maxOffset; - - // check if the same sfx like last time, if yes, then try use next one, - // if exceeded range, then choose first available sample - if(*phrase == *prevPhrase && ++*phrase >= sample + maxOffset) *phrase = sample; - *prevPhrase = *phrase; -} - -uint8 &jumboVolOffset = *(uint8 *)0x6508ED; - -void -cAudioManager::DoJumboVolOffset() const -{ - if(!(m_FrameCounter % (m_anRandomTable[0] % 6u + 3))) - jumboVolOffset = m_anRandomTable[1] % 60u; -} - -int32 -cAudioManager::GetPedCommentSfx(CPed *ped, int32 sound) -{ - if(ped->IsPlayer()) return GetPlayerTalkSfx(sound); - - switch(ped->m_modelIndex) { - case MI_COP: return GetCopTalkSfx(sound); - case MI_SWAT: return GetSwatTalkSfx(sound); - case MI_FBI: return GetFBITalkSfx(sound); - case MI_ARMY: return GetArmyTalkSfx(sound); - case MI_MEDIC: return GetMedicTalkSfx(sound); - case MI_FIREMAN: return GetFiremanTalkSfx(sound); - case MI_MALE01: return GetNormalMaleTalkSfx(sound); - case MI_TAXI_D: return GetTaxiDriverTalkSfx(sound); - case MI_PIMP: return GetPimpTalkSfx(sound); - case MI_GANG01: - case MI_GANG02: return GetMafiaTalkSfx(sound); - case MI_GANG03: - case MI_GANG04: return GetTriadTalkSfx(sound); - case MI_GANG05: - case MI_GANG06: return GetDiabloTalkSfx(sound); - case MI_GANG07: - case MI_GANG08: return GetYakuzaTalkSfx(sound); - case MI_GANG09: - case MI_GANG10: return GetYardieTalkSfx(sound); - case MI_GANG11: - case MI_GANG12: return GetColumbianTalkSfx(sound); - case MI_GANG13: - case MI_GANG14: return GetHoodTalkSfx(sound); - case MI_CRIMINAL01: return GetBlackCriminalTalkSfx(sound); - case MI_CRIMINAL02: return GetWhiteCriminalTalkSfx(sound); - case MI_SPECIAL01: - case MI_SPECIAL02: - case MI_SPECIAL03: - case MI_SPECIAL04: return GetSpecialCharacterTalkSfx(ped->m_modelIndex, sound); - case MI_MALE02: return GetMaleNo2TalkSfx(sound); - case MI_MALE03: - case MI_P_MAN1: - case MI_P_MAN2: return GetBlackProjectMaleTalkSfx(sound, ped->m_modelIndex); - case MI_FATMALE01: return GetWhiteFatMaleTalkSfx(sound); - case MI_FATMALE02: return GetBlackFatMaleTalkSfx(sound); - case MI_FEMALE01: return GetBlackCasualFemaleTalkSfx(sound); - case MI_FEMALE02: - case MI_CAS_WOM: return GetWhiteCasualFemaleTalkSfx(sound); - case MI_FEMALE03: return GetFemaleNo3TalkSfx(sound); - case MI_FATFEMALE01: return GetBlackFatFemaleTalkSfx(sound); - case MI_FATFEMALE02: return GetWhiteFatFemaleTalkSfx(sound); - case MI_PROSTITUTE: return GetBlackFemaleProstituteTalkSfx(sound); - case MI_PROSTITUTE2: return GetWhiteFemaleProstituteTalkSfx(sound); - case MI_P_WOM1: return GetBlackProjectFemaleOldTalkSfx(sound); - case MI_P_WOM2: return GetBlackProjectFemaleYoungTalkSfx(sound); - case MI_CT_MAN1: return GetChinatownMaleOldTalkSfx(sound); - case MI_CT_MAN2: return GetChinatownMaleYoungTalkSfx(sound); - case MI_CT_WOM1: return GetChinatownFemaleOldTalkSfx(sound); - case MI_CT_WOM2: return GetChinatownFemaleYoungTalkSfx(sound); - case MI_LI_MAN1: - case MI_LI_MAN2: return GetLittleItalyMaleTalkSfx(sound); - case MI_LI_WOM1: return GetLittleItalyFemaleOldTalkSfx(sound); - case MI_LI_WOM2: return GetLittleItalyFemaleYoungTalkSfx(sound); - case MI_DOCKER1: return GetWhiteDockerMaleTalkSfx(sound); - case MI_DOCKER2: return GetBlackDockerMaleTalkSfx(sound); - case MI_SCUM_MAN: return GetScumMaleTalkSfx(sound); - case MI_SCUM_WOM: return GetScumFemaleTalkSfx(sound); - case MI_WORKER1: return GetWhiteWorkerMaleTalkSfx(sound); - case MI_WORKER2: return GetBlackWorkerMaleTalkSfx(sound); - case MI_B_MAN1: - case MI_B_MAN3: return GetBusinessMaleYoungTalkSfx(sound, ped->m_modelIndex); - case MI_B_MAN2: return GetBusinessMaleOldTalkSfx(sound); - case MI_B_WOM1: - case MI_B_WOM2: return GetWhiteBusinessFemaleTalkSfx(sound, ped->m_modelIndex); - case MI_B_WOM3: return GetBlackBusinessFemaleTalkSfx(sound); - case MI_MOD_MAN: return GetSupermodelMaleTalkSfx(sound); - case MI_MOD_WOM: return GetSupermodelFemaleTalkSfx(sound); - case MI_ST_MAN: return GetStewardMaleTalkSfx(sound); - case MI_ST_WOM: return GetStewardFemaleTalkSfx(sound); - case MI_FAN_MAN1: - case MI_FAN_MAN2: return GetFanMaleTalkSfx(sound, ped->m_modelIndex); - case MI_FAN_WOM: return GetFanFemaleTalkSfx(sound); - case MI_HOS_MAN: return GetHospitalMaleTalkSfx(sound); - case MI_HOS_WOM: return GetHospitalFemaleTalkSfx(sound); - case MI_CONST1: return GetWhiteConstructionWorkerTalkSfx(sound); - case MI_CONST2: return GetBlackConstructionWorkerTalkSfx(sound); - case MI_SHOPPER1: - case MI_SHOPPER2: - case MI_SHOPPER3: return GetShopperFemaleTalkSfx(sound, ped->m_modelIndex); - case MI_STUD_MAN: return GetStudentMaleTalkSfx(sound); - case MI_STUD_WOM: return GetStudentFemaleTalkSfx(sound); - case MI_CAS_MAN: return GetCasualMaleOldTalkSfx(sound); - default: return GetGenericMaleTalkSfx(sound); - } -} - -uint32 -cAudioManager::GetPlayerTalkSfx(int16 sound) -{ - uint32 sfx; - static uint32 lastSfx = NO_SAMPLE; - - switch(sound) { - case SOUND_PED_DAMAGE: - GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_DAMAGE_REACTION_1, 11u); - break; - - case SOUND_PED_HIT: GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_HIT_REACTION_1, 10u); break; - - case SOUND_PED_LAND: GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_FALL_REACTION_1, 6u); break; - - default: sfx = NO_SAMPLE; break; - } - return sfx; -} - -uint32 -cAudioManager::GetCopTalkSfx(int16 sound) -{ - uint32 sfx; - PedState pedState; - static uint32 lastSfx = NO_SAMPLE; - - if(sound == SOUND_PED_ARREST_COP) { - GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_POLICE_COP_1_ARREST_1, 6u); - } else { - if(sound != SOUND_PED_PURSUIT_COP) { return GetGenericMaleTalkSfx(sound); } - - pedState = FindPlayerPed()->m_nPedState; - if(pedState == PED_ARRESTED || pedState == PED_DEAD || pedState == PED_DIE) - return NO_SAMPLE; - GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_POLICE_COP_1_PURSUIT_1, 7u); - } - - return 13 * (m_sQueueSample.m_nEntityIndex % 5) + sfx; -} - -uint32 -cAudioManager::GetSwatTalkSfx(int16 sound) -{ - uint32 sfx; - PedState pedState; - static uint32 lastSfx = NO_SAMPLE; - - if(sound == SOUND_PED_ARREST_SWAT) { - GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_POLICE_SWAT_1_PURSUIT_ARREST_1, 6u); - } else { - if(sound != SOUND_PED_PURSUIT_SWAT) { return GetGenericMaleTalkSfx(sound); } - - pedState = FindPlayerPed()->m_nPedState; - if(pedState == PED_ARRESTED || pedState == PED_DEAD || pedState == PED_DIE) - return NO_SAMPLE; - GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_POLICE_SWAT_1_PURSUIT_ARREST_1, 6u); - } - - return 6 * (m_sQueueSample.m_nEntityIndex % 3) + sfx; -} - -uint32 -cAudioManager::GetFBITalkSfx(int16 sound) -{ - uint32 sfx; - PedState pedState; - static uint32 lastSfx = NO_SAMPLE; - - if(sound == SOUND_PED_ARREST_FBI) { - GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_POLICE_FBI_1_PURSUIT_ARREST_1, 6u); - } else { - if(sound != SOUND_PED_PURSUIT_FBI) { return GetGenericMaleTalkSfx(sound); } - - pedState = FindPlayerPed()->m_nPedState; - if(pedState == PED_ARRESTED || pedState == PED_DEAD || pedState == PED_DIE) - return NO_SAMPLE; - GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_POLICE_FBI_1_PURSUIT_ARREST_1, 6u); - } - - return 6 * (m_sQueueSample.m_nEntityIndex % 3) + sfx; -} - -uint32 -cAudioManager::GetArmyTalkSfx(int16 sound) -{ - uint32 sfx; - PedState pedState; - static uint32 lastSfx = NO_SAMPLE; - - if(sound != SOUND_PED_PURSUIT_ARMY) { return GetGenericMaleTalkSfx(sound); } - - pedState = FindPlayerPed()->m_nPedState; - if(pedState == PED_ARRESTED || pedState == PED_DEAD || pedState == PED_DIE) - return NO_SAMPLE; - GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_POLICE_ARMY_1_PURSUIT_1, 15u); - - return 15 * (m_sQueueSample.m_nEntityIndex % 1) + sfx; -} - -uint32 -cAudioManager::GetMedicTalkSfx(int16 sound) -{ - uint32 sfx; - static uint32 lastSfx = NO_SAMPLE; - - switch(sound) { - case SOUND_PED_HANDS_COWER: - GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_MEDIC_1_HANDS_COWER_1, 5u); - break; - case SOUND_PED_CAR_JACKED: - GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_MEDIC_1_CAR_JACKED_1, 5u); - break; - case SOUND_PED_HEALING: - GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_MEDIC_1_HEALING_1, 12u); - break; - case SOUND_PED_LEAVE_VEHICLE: - GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_MEDIC_1_LEAVE_VEHICLE_1, 9u); - break; - case SOUND_PED_FLEE_RUN: - GetPhrase(&sfx, &lastSfx, AUDIO_SAMPLE_PED_MEDIC_1_FLEE_RUN_1, 6u); - break; - default: return GetGenericMaleTalkSfx(sound); - } - return 37 * (m_sQueueSample.m_nEntityIndex & 1) + sfx; -} - -uint32 -cAudioManager::GetFiremanTalkSfx(int16 sound) -{ - return GetGenericMaleTalkSfx(sound); -} - -uint32 -cAudioManager::GetNormalMaleTalkSfx(int16 sound) -{ - uint32 sfx; - static uint32 lastSfx = NO_SAMPLE; + uint32 sfx; + static uint32 lastSfx = NO_SAMPLE; switch(sound) { case SOUND_PED_HANDS_COWER: @@ -3256,6 +2699,28 @@ cAudioManager::GetGenericFemaleTalkSfx(int16 sound) return sfx; } +void +cAudioManager::GenerateIntegerRandomNumberTable() +{ + for(int32 i = 0; i < 5; i++) { m_anRandomTable[i] = rand(); } +} + +char * +cAudioManager::Get3DProviderName(uint8 id) const +{ + if(!m_bIsInitialised) return 0; + if(id >= SampleManager.GetNum3DProvidersAvailable()) return 0; + return SampleManager.Get3DProviderName(id); +} + +uint8 +cAudioManager::GetCDAudioDriveLetter() const +{ + if(m_bIsInitialised) return SampleManager.GetCDAudioDriveLetter(); + + return 0; +} + int8 cAudioManager::GetCurrent3DProviderIndex() const { @@ -3351,6 +2816,117 @@ cAudioManager::GetMissionScriptPoliceAudioPlayingStatus() const return g_nMissionAudioPlayingStatus; } +uint8 +cAudioManager::GetNum3DProvidersAvailable() const +{ + if(m_bIsInitialised) return SampleManager.GetNum3DProvidersAvailable(); + return 0; +} + + +int32 +cAudioManager::GetPedCommentSfx(CPed *ped, int32 sound) +{ + if(ped->IsPlayer()) return GetPlayerTalkSfx(sound); + + switch(ped->m_modelIndex) { + case MI_COP: return GetCopTalkSfx(sound); + case MI_SWAT: return GetSwatTalkSfx(sound); + case MI_FBI: return GetFBITalkSfx(sound); + case MI_ARMY: return GetArmyTalkSfx(sound); + case MI_MEDIC: return GetMedicTalkSfx(sound); + case MI_FIREMAN: return GetFiremanTalkSfx(sound); + case MI_MALE01: return GetNormalMaleTalkSfx(sound); + case MI_TAXI_D: return GetTaxiDriverTalkSfx(sound); + case MI_PIMP: return GetPimpTalkSfx(sound); + case MI_GANG01: + case MI_GANG02: return GetMafiaTalkSfx(sound); + case MI_GANG03: + case MI_GANG04: return GetTriadTalkSfx(sound); + case MI_GANG05: + case MI_GANG06: return GetDiabloTalkSfx(sound); + case MI_GANG07: + case MI_GANG08: return GetYakuzaTalkSfx(sound); + case MI_GANG09: + case MI_GANG10: return GetYardieTalkSfx(sound); + case MI_GANG11: + case MI_GANG12: return GetColumbianTalkSfx(sound); + case MI_GANG13: + case MI_GANG14: return GetHoodTalkSfx(sound); + case MI_CRIMINAL01: return GetBlackCriminalTalkSfx(sound); + case MI_CRIMINAL02: return GetWhiteCriminalTalkSfx(sound); + case MI_SPECIAL01: + case MI_SPECIAL02: + case MI_SPECIAL03: + case MI_SPECIAL04: return GetSpecialCharacterTalkSfx(ped->m_modelIndex, sound); + case MI_MALE02: return GetMaleNo2TalkSfx(sound); + case MI_MALE03: + case MI_P_MAN1: + case MI_P_MAN2: return GetBlackProjectMaleTalkSfx(sound, ped->m_modelIndex); + case MI_FATMALE01: return GetWhiteFatMaleTalkSfx(sound); + case MI_FATMALE02: return GetBlackFatMaleTalkSfx(sound); + case MI_FEMALE01: return GetBlackCasualFemaleTalkSfx(sound); + case MI_FEMALE02: + case MI_CAS_WOM: return GetWhiteCasualFemaleTalkSfx(sound); + case MI_FEMALE03: return GetFemaleNo3TalkSfx(sound); + case MI_FATFEMALE01: return GetBlackFatFemaleTalkSfx(sound); + case MI_FATFEMALE02: return GetWhiteFatFemaleTalkSfx(sound); + case MI_PROSTITUTE: return GetBlackFemaleProstituteTalkSfx(sound); + case MI_PROSTITUTE2: return GetWhiteFemaleProstituteTalkSfx(sound); + case MI_P_WOM1: return GetBlackProjectFemaleOldTalkSfx(sound); + case MI_P_WOM2: return GetBlackProjectFemaleYoungTalkSfx(sound); + case MI_CT_MAN1: return GetChinatownMaleOldTalkSfx(sound); + case MI_CT_MAN2: return GetChinatownMaleYoungTalkSfx(sound); + case MI_CT_WOM1: return GetChinatownFemaleOldTalkSfx(sound); + case MI_CT_WOM2: return GetChinatownFemaleYoungTalkSfx(sound); + case MI_LI_MAN1: + case MI_LI_MAN2: return GetLittleItalyMaleTalkSfx(sound); + case MI_LI_WOM1: return GetLittleItalyFemaleOldTalkSfx(sound); + case MI_LI_WOM2: return GetLittleItalyFemaleYoungTalkSfx(sound); + case MI_DOCKER1: return GetWhiteDockerMaleTalkSfx(sound); + case MI_DOCKER2: return GetBlackDockerMaleTalkSfx(sound); + case MI_SCUM_MAN: return GetScumMaleTalkSfx(sound); + case MI_SCUM_WOM: return GetScumFemaleTalkSfx(sound); + case MI_WORKER1: return GetWhiteWorkerMaleTalkSfx(sound); + case MI_WORKER2: return GetBlackWorkerMaleTalkSfx(sound); + case MI_B_MAN1: + case MI_B_MAN3: return GetBusinessMaleYoungTalkSfx(sound, ped->m_modelIndex); + case MI_B_MAN2: return GetBusinessMaleOldTalkSfx(sound); + case MI_B_WOM1: + case MI_B_WOM2: return GetWhiteBusinessFemaleTalkSfx(sound, ped->m_modelIndex); + case MI_B_WOM3: return GetBlackBusinessFemaleTalkSfx(sound); + case MI_MOD_MAN: return GetSupermodelMaleTalkSfx(sound); + case MI_MOD_WOM: return GetSupermodelFemaleTalkSfx(sound); + case MI_ST_MAN: return GetStewardMaleTalkSfx(sound); + case MI_ST_WOM: return GetStewardFemaleTalkSfx(sound); + case MI_FAN_MAN1: + case MI_FAN_MAN2: return GetFanMaleTalkSfx(sound, ped->m_modelIndex); + case MI_FAN_WOM: return GetFanFemaleTalkSfx(sound); + case MI_HOS_MAN: return GetHospitalMaleTalkSfx(sound); + case MI_HOS_WOM: return GetHospitalFemaleTalkSfx(sound); + case MI_CONST1: return GetWhiteConstructionWorkerTalkSfx(sound); + case MI_CONST2: return GetBlackConstructionWorkerTalkSfx(sound); + case MI_SHOPPER1: + case MI_SHOPPER2: + case MI_SHOPPER3: return GetShopperFemaleTalkSfx(sound, ped->m_modelIndex); + case MI_STUD_MAN: return GetStudentMaleTalkSfx(sound); + case MI_STUD_WOM: return GetStudentFemaleTalkSfx(sound); + case MI_CAS_MAN: return GetCasualMaleOldTalkSfx(sound); + default: return GetGenericMaleTalkSfx(sound); + } +} + +void +cAudioManager::GetPhrase(uint32 *phrase, uint32 *prevPhrase, uint32 sample, uint32 maxOffset) const +{ + *phrase = sample + m_anRandomTable[m_sQueueSample.m_nEntityIndex & 3] % maxOffset; + + // check if the same sfx like last time, if yes, then try use next one, + // if exceeded range, then choose first available sample + if(*phrase == *prevPhrase && ++*phrase >= sample + maxOffset) *phrase = sample; + *prevPhrase = *phrase; +} + bool cAudioManager::HasAirBrakes(int32 model) const { @@ -3402,6 +2978,12 @@ cAudioManager::InterrogateAudioEntities() } } +bool +cAudioManager::IsAudioInitialised() const +{ + return m_bIsInitialised; +} + bool cAudioManager::IsMissionAudioSampleFinished() { @@ -3412,6 +2994,14 @@ cAudioManager::IsMissionAudioSampleFinished() return (cPretendFrame++ & 63) == 0; } +bool +cAudioManager::IsMP3RadioChannelAvailable() const +{ + if(m_bIsInitialised) return SampleManager.IsMP3RadioChannelAvailable(); + + return 0; +} + bool cAudioManager::MissionScriptAudioUsesPoliceChannel(int32 soundMission) const { @@ -3448,8 +3038,6 @@ cAudioManager::PlayOneShot(int32 index, int16 sound, float vol) EAXJMP(0x57A500); } -bool &bPlayerJustEnteredCar = *(bool *)0x6508C4; - void cAudioManager::PlayerJustGotInCar() const { @@ -3479,10 +3067,10 @@ cAudioManager::PostInitialiseGameSpecificSetup() m_nProjectileEntity = CreateEntity(AUDIOTYPE_PROJECTILE, (CPhysical *)1); if(m_nProjectileEntity >= 0) SetEntityStatus(m_nProjectileEntity, 1); - m_nWaterCannonEntity = CreateEntity(AUDIOTYPE_WATER_CANNON, (CPhysical *)1); + m_nWaterCannonEntity = CreateEntity(AUDIOTYPE_WATERCANNON, (CPhysical *)1); if(m_nWaterCannonEntity >= 0) SetEntityStatus(m_nWaterCannonEntity, 1); - m_nPoliceChannelEntity = CreateEntity(AUDIOTYPE_D, (CPhysical *)1); + m_nPoliceChannelEntity = CreateEntity(AUDIOTYPE_POLICERADIO, (CPhysical *)1); if(m_nPoliceChannelEntity >= 0) SetEntityStatus(m_nPoliceChannelEntity, 1); m_nBridgeEntity = CreateEntity(AUDIOTYPE_BRIDGE, (CPhysical *)1); @@ -3504,6 +3092,14 @@ cAudioManager::PostTerminateGameSpecificShutdown() ; } + +void +cAudioManager::PreInitialiseGameSpecificSetup() const +{ + BankStartOffset[0] = AUDIO_SAMPLE_VEHICLE_HORN_0; + BankStartOffset[1] = AUDIO_SAMPLE_POLICE_COP_1_ARREST_1; +} + void cAudioManager::PreTerminateGameSpecificShutdown() { @@ -3818,7 +3414,7 @@ cAudioManager::ProcessBoatMovingOverWater(cVehicleParams *params) velocityChange = Abs(params->m_fVelocityChange); if(velocityChange <= 0.0005f && params->m_pVehicle->GetPosition().y) return 1; - velocityChange = Min(0.75f, velocityChange); + velocityChange = min(0.75f, velocityChange); multiplier = (velocityChange - 0.0005f) * 1.3342f; CalculateDistance((bool *)params, params->m_fDistance); vol = (30.f * multiplier); @@ -5556,8 +5152,6 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) } } -bool &g_bMissionAudioLoadFailed = *(bool *)0x95CD8E; - void cAudioManager::ProcessMissionAudio() { @@ -5571,9 +5165,9 @@ cAudioManager::ProcessMissionAudio() static uint8 nFramesUntilFailedLoad = 0; static uint8 nFramesForPretendPlaying = 0; - if(this->m_bIsInitialised) { + if(m_bIsInitialised) { if(m_sMissionAudio.m_nSampleIndex != 3033) { - switch(this->m_sMissionAudio.m_bLoadingStatus) { + switch(m_sMissionAudio.m_bLoadingStatus) { case 0: SampleManager.PreloadStreamedFile(m_sMissionAudio.m_nSampleIndex, 1u); @@ -5581,9 +5175,9 @@ cAudioManager::ProcessMissionAudio() nFramesUntilFailedLoad = 0; return; case 1: - if(!this->m_sMissionAudio.m_bIsPlayed) return; + if(!m_sMissionAudio.m_bIsPlayed) return; if(g_bMissionAudioLoadFailed) { - if(this->m_bTimerJustReset) { + if(m_bTimerJustReset) { ClearMissionAudio(); SampleManager.StopStreamedFile(1u); nFramesForPretendPlaying = 0; @@ -5591,16 +5185,16 @@ cAudioManager::ProcessMissionAudio() nFramesUntilFailedLoad = 0; } else if(!m_bUserPause) { if(++nFramesForPretendPlaying < 120u) { - this->m_sMissionAudio.m_bPlayStatus = 1; + m_sMissionAudio.m_bPlayStatus = 1; } else { - this->m_sMissionAudio.m_bPlayStatus = 2; - this->m_sMissionAudio.m_nSampleIndex = 3033; + m_sMissionAudio.m_bPlayStatus = 2; + m_sMissionAudio.m_nSampleIndex = 3033; } } } else { if(m_sMissionAudio.m_bPlayStatus) { if(m_sMissionAudio.m_bPlayStatus != 1) return; - if(this->m_bTimerJustReset) { + if(m_bTimerJustReset) { ClearMissionAudio(); SampleManager.StopStreamedFile(1u); return; @@ -5696,7 +5290,7 @@ cAudioManager::ProcessMissionAudio() nFramesForPretendPlaying = 0; g_bMissionAudioLoadFailed = 1; nFramesUntilFailedLoad = 0; - this->m_sMissionAudio.m_bLoadingStatus = 1; + m_sMissionAudio.m_bLoadingStatus = 1; } return; default: return; @@ -6072,7 +5666,7 @@ cAudioManager::ProcessPedHeadphones(cPedParams *params) if(params->m_fDistance < 49.f) { ped = params->m_pPed; - if(!(ped->m_ped_flagA20) || ped->m_bodyPartBleeding != 2) { + if(!ped->bIsAimingGun || ped->m_bodyPartBleeding != 2) { CalculateDistance((bool *)params, params->m_fDistance); if(ped->bInVehicle && ped->m_nPedState == PED_DRIVING) { emittingVol = 10; @@ -7121,7 +6715,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile * CurrentPretendGear = 1; } if(CReplay::IsPlayingBack()) { - accelerateState = 255.f * Max(0.0f, Min(1.0f, automobile->m_fGasPedal)); + accelerateState = 255.f * max(0.0f, min(1.0f, automobile->m_fGasPedal)); } else { accelerateState = Pads->GetAccelerate(); } @@ -7156,9 +6750,9 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile * if(0.0f != velocityChange) { time = params->m_pVehicle->m_vecMoveSpeed.z / velocityChange; if(time <= 0.0f) { - freqModifier = Max(-0.2f, time) * -15000.f; + freqModifier = max(-0.2f, time) * -15000.f; } else { - freqModifier = -(Min(0.2f, time) * 15000.f); + freqModifier = -(min(0.2f, time) * 15000.f); } if(params->m_fVelocityChange < -0.001f) freqModifier = -freqModifier; } else { @@ -7177,10 +6771,10 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile * gasPedalAudio = automobile->m_fGasPedalAudio; } else { gasPedalAudio = - Min(1.0f, params->m_fVelocityChange / + min(1.0f, params->m_fVelocityChange / params->m_pTransmission->fMaxReverseVelocity); } - gasPedalAudio = Max(0.0f, gasPedalAudio); + gasPedalAudio = max(0.0f, gasPedalAudio); automobile->m_fGasPedalAudio = gasPedalAudio; } else if(LastAccel > 0) { if(channelUsed) { @@ -7210,7 +6804,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile * (engineSoundType + AUDIO_SAMPLE_VEHICLE_ENGINE_IDLE_NONE), 0, 52u, 1); - CurrentPretendGear = Max(1, currentGear); + CurrentPretendGear = max(1, currentGear); LastAccel = accelerateState; bHandbrakeOnLastFrame = automobile->bIsHandbrakeOn; @@ -7665,11 +7259,11 @@ cAudioManager::ProcessScriptObject(int32 id) { cAudioScriptObject *entity = (cAudioScriptObject *)m_asAudioEntities[id].m_pEntity; if(entity) { - m_sQueueSample.m_vecPos = entity->m_vecPos; + m_sQueueSample.m_vecPos = entity->Posn; if(m_asAudioEntities[id].m_Loops == 1) ProcessOneShotScriptObject(m_asAudioEntities[id].m_awAudioEvent[0]); else - ProcessLoopingScriptObject(entity->m_wSound); + ProcessLoopingScriptObject(entity->AudioId); } } @@ -7778,7 +7372,7 @@ cAudioManager::ProcessTrainNoise(cVehicleParams *params) if(params->m_fVelocityChange <= 0.0f) { CalculateDistance((bool *)params, params->m_fDistance); train = (CTrain *)params->m_pVehicle; - speedMultipler = Min(1.0f, train->m_fSpeed * 250.f / 51.f); + speedMultipler = min(1.0f, train->m_fSpeed * 250.f / 51.f); emittingVol = (75.f * speedMultipler); if(train->m_fWagonPosition == 0.0f) { m_sQueueSample.m_bVolume = @@ -7871,7 +7465,7 @@ cAudioManager::ProcessVehicleDoors(cVehicleParams *params) if(automobile->Damage.GetDoorStatus(i) == 2) { doorState = automobile->Doors[i].m_nDoorState; if(doorState == 1 || doorState == 2) { - velocity = Min(0.3f, Abs(automobile->Doors[i].m_fAngVel)); + velocity = min(0.3f, Abs(automobile->Doors[i].m_fAngVel)); if(velocity > 0.0035f) { emittingVol = (100.f * velocity * 10.f / 3.f); m_sQueueSample.m_bVolume = ComputeVolume( @@ -7941,51 +7535,167 @@ cAudioManager::ProcessVehicleReverseWarning(cVehicleParams *params) AddSampleToRequestedQueue(); } } - return 1; + return 1; +} + +bool +cAudioManager::ProcessVehicleRoadNoise(cVehicleParams *params) +{ + int32 emittingVol; + uint32 freq; + float modificator; + int sampleFreq; + float velocity; + + if(params->m_fDistance >= 9025.f) return 0; + if(params->m_pTransmission) { + if(params->m_pVehicle->m_vecMoveSpeed.z) { + velocity = Abs(params->m_fVelocityChange); + if(velocity > 0.0f) { + CalculateDistance((bool *)params, params->m_fDistance); + emittingVol = + 30.f * + min(1.f, + velocity / (0.5f * params->m_pTransmission->fMaxVelocity)); + m_sQueueSample.m_bVolume = + ComputeVolume(emittingVol, 95.f, m_sQueueSample.m_fDistance); + if(m_sQueueSample.m_bVolume) { + m_sQueueSample.m_counter = 0; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_16 = 3; + if(params->m_pVehicle->m_nSurfaceTouched == + SURFACE_PUDDLE) { + m_sQueueSample.m_nSampleIndex = + AUDIO_SAMPLE_LOOPING_WATER; + freq = 6050 * emittingVol / 30 + 16000; + } else { + m_sQueueSample.m_nSampleIndex = + AUDIO_SAMPLE_VEHICLE_ROAD_NOISE; + modificator = + m_sQueueSample.m_fDistance * 1.f / 95.f * 0.5f; + sampleFreq = SampleManager.GetSampleBaseFrequency( + AUDIO_SAMPLE_VEHICLE_ROAD_NOISE); + freq = (sampleFreq * modificator) + + ((3 * sampleFreq) >> 2); + } + m_sQueueSample.m_nFrequency = freq; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_bEmittingVolume = emittingVol; + m_sQueueSample.m_nLoopStart = + SampleManager.GetSampleLoopStartOffset( + m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = + SampleManager.GetSampleLoopEndOffset( + m_sQueueSample.m_nSampleIndex); + m_sQueueSample.field_48 = 6.0f; + m_sQueueSample.m_fSoundIntensity = 95.0f; + m_sQueueSample.field_56 = 0; + m_sQueueSample.field_76 = 4; + m_sQueueSample.m_bReverbFlag = 1; + m_sQueueSample.m_bRequireReflection = 0; + AddSampleToRequestedQueue(); + } + } + } + } + return 1; +} + +WRAPPER +void cAudioManager::ProcessWaterCannon(int32) { EAXJMP(0x575F30); } + +void +cAudioManager::ProcessWeather(int32 id) +{ + uint8 vol; + static uint8 counter = 0; + + if(m_asAudioEntities[id].m_Loops && + m_asAudioEntities[id].m_awAudioEvent[0] == SOUND_LIGHTNING) { + if(m_asAudioEntities[id].m_afVolume[0] >= 10.f) { + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_EXPLOSION_CAR; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.m_nFrequency = RandomDisplacement(500u) + 4000; + vol = (m_asAudioEntities[id].m_afVolume[0] - 10.f) + 40; + } else { + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_WEAPON_GRENADE_EXPLOSION; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.m_nFrequency = RandomDisplacement(500u) + 4000; + vol = (m_asAudioEntities[id].m_afVolume[0]) + 35; + } + m_sQueueSample.m_bVolume = vol; + if(TheCamera.SoundDistUp < 20.f) m_sQueueSample.m_bVolume >>= 1; + if(counter == 4) counter = 0; + m_sQueueSample.m_counter = counter++; + m_sQueueSample.field_16 = 0; + m_sQueueSample.m_bOffset = (m_anRandomTable[2] & 15) + 55; + m_sQueueSample.m_bIsDistant = 1; + m_sQueueSample.m_nLoopCount = 1; + m_sQueueSample.field_56 = 1; + m_sQueueSample.m_bEmittingVolume = m_sQueueSample.m_bVolume; + m_sQueueSample.m_nLoopStart = 0; + m_sQueueSample.m_nLoopEnd = -1; + m_sQueueSample.m_bReverbFlag = 0; + m_sQueueSample.m_bRequireReflection = 0; + cAudioManager::AddSampleToRequestedQueue(); + } + if(CWeather::Rain > 0.0f && (!CCullZones::CamNoRain() || !CCullZones::PlayerNoRain())) { + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_COLLISION_LOOPING_GRASS; + m_sQueueSample.m_nFrequency = + SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_COLLISION_LOOPING_GRASS); + m_sQueueSample.m_bVolume = (uint8)(25.f * CWeather::Rain); + m_sQueueSample.m_counter = 4; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.field_16 = 0; + m_sQueueSample.m_bOffset = 63; + m_sQueueSample.m_bIsDistant = 1; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.field_56 = 0; + m_sQueueSample.field_76 = 30; + m_sQueueSample.m_bReverbFlag = 0; + m_sQueueSample.m_bEmittingVolume = m_sQueueSample.m_bVolume; + m_sQueueSample.m_nLoopStart = + SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = + SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_bRequireReflection = 0; + cAudioManager::AddSampleToRequestedQueue(); + } } bool -cAudioManager::ProcessVehicleRoadNoise(cVehicleParams *params) +cAudioManager::ProcessWetRoadNoise(cVehicleParams *params) { + float relativeVelocity; int32 emittingVol; - uint32 freq; float modificator; - int sampleFreq; - float velocity; + int freq; + float velChange; - if(params->m_fDistance >= 9025.f) return 0; + if(params->m_fDistance >= 900.f) return 0; if(params->m_pTransmission) { if(params->m_pVehicle->m_vecMoveSpeed.z) { - velocity = Abs(params->m_fVelocityChange); - if(velocity > 0.0f) { + velChange = Abs(params->m_fVelocityChange); + if(velChange > 0.f) { CalculateDistance((bool *)params, params->m_fDistance); - emittingVol = - 30.f * - Min(1.f, - velocity / (0.5f * params->m_pTransmission->fMaxVelocity)); + relativeVelocity = + min(1.0f, + velChange / (0.5f * params->m_pTransmission->fMaxVelocity)); + emittingVol = 23.0f * relativeVelocity * CWeather::WetRoads; m_sQueueSample.m_bVolume = - ComputeVolume(emittingVol, 95.f, m_sQueueSample.m_fDistance); + ComputeVolume(emittingVol, 30.f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.m_counter = 0; + m_sQueueSample.m_counter = 1; + m_sQueueSample.m_nSampleIndex = + AUDIO_SAMPLE_VEHICLE_ROAD_NOISE; m_sQueueSample.m_bBankIndex = 0; m_sQueueSample.m_bIsDistant = 0; m_sQueueSample.field_16 = 3; - if(params->m_pVehicle->m_nSurfaceTouched == - SURFACE_PUDDLE) { - m_sQueueSample.m_nSampleIndex = - AUDIO_SAMPLE_LOOPING_WATER; - freq = 6050 * emittingVol / 30 + 16000; - } else { - m_sQueueSample.m_nSampleIndex = - AUDIO_SAMPLE_VEHICLE_ROAD_NOISE; - modificator = - m_sQueueSample.m_fDistance * 1.f / 95.f * 0.5f; - sampleFreq = SampleManager.GetSampleBaseFrequency( - AUDIO_SAMPLE_VEHICLE_ROAD_NOISE); - freq = (sampleFreq * modificator) + - ((3 * sampleFreq) >> 2); - } - m_sQueueSample.m_nFrequency = freq; + modificator = m_sQueueSample.m_fDistance * 1.f / 3.f * 0.5f; + freq = SampleManager.GetSampleBaseFrequency( + AUDIO_SAMPLE_VEHICLE_ROAD_NOISE); + m_sQueueSample.m_nFrequency = freq + freq * modificator; m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_bEmittingVolume = emittingVol; m_sQueueSample.m_nLoopStart = @@ -7995,7 +7705,7 @@ cAudioManager::ProcessVehicleRoadNoise(cVehicleParams *params) SampleManager.GetSampleLoopEndOffset( m_sQueueSample.m_nSampleIndex); m_sQueueSample.field_48 = 6.0f; - m_sQueueSample.m_fSoundIntensity = 95.0f; + m_sQueueSample.m_fSoundIntensity = 30.0f; m_sQueueSample.field_56 = 0; m_sQueueSample.field_76 = 4; m_sQueueSample.m_bReverbFlag = 1; @@ -8008,110 +7718,326 @@ cAudioManager::ProcessVehicleRoadNoise(cVehicleParams *params) return 1; } -WRAPPER -void cAudioManager::ProcessWaterCannon(int32) { EAXJMP(0x575F30); } - -WRAPPER -void -cAudioManager::ProcessWeather(int32 id) +void +cAudioManager::ProcessWorkShopScriptObject(uint8 sound) +{ + float distSquared; + float maxDist; + + switch(sound) { + case SCRIPT_SOUND_WORK_SHOP_LOOP_S: + case SCRIPT_SOUND_WORK_SHOP_LOOP_L: + maxDist = 400.f; + m_sQueueSample.m_fSoundIntensity = 20.0f; + break; + default: break; + } + distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos); + if(distSquared < maxDist) { + m_sQueueSample.m_fDistance = sqrt(distSquared); + m_sQueueSample.m_bVolume = ComputeVolume(30u, m_sQueueSample.m_fSoundIntensity, + m_sQueueSample.m_fDistance); + if(m_sQueueSample.m_bVolume) { + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_WORK_SHOP; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.m_nFrequency = + SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_WORK_SHOP); + m_sQueueSample.m_counter = 0; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.field_56 = 0; + m_sQueueSample.field_16 = 5; + m_sQueueSample.field_48 = 2.0f; + m_sQueueSample.m_bEmittingVolume = 30; + m_sQueueSample.m_nLoopStart = + SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = + SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_bReverbFlag = 1; + m_sQueueSample.m_bRequireReflection = 0; + AddSampleToRequestedQueue(); + } + } +} + +int32 +cAudioManager::RandomDisplacement(uint32 seed) const +{ + int32 value; + + static bool bIsEven = true; + static uint32 base = 0; + + if(!seed) return 0; + + value = m_anRandomTable[(base + seed) % 5] % seed; + base += value; + + if(value % 2) { bIsEven = !bIsEven; } + if(!bIsEven) value = -value; + return value; +} + +void +cAudioManager::ReacquireDigitalHandle() const +{ + if(m_bIsInitialised) { SampleManager.ReacquireDigitalHandle(); } +} + +void +cAudioManager::ReleaseDigitalHandle() const +{ + if(m_bIsInitialised) { SampleManager.ReleaseDigitalHandle(); } +} + +void +cAudioManager::ResetAudioLogicTimers(int32 timer) +{ + audioLogicTimers[0] = timer; + audioLogicTimers[8] = timer; + audioLogicTimers[1] = timer; + audioLogicTimers[7] = timer; + audioLogicTimers[2] = timer; + audioLogicTimers[6] = timer; + audioLogicTimers[3] = timer; + audioLogicTimers[5] = timer; + audioLogicTimers[4] = timer; + for(int32 i = 0; i < m_nAudioEntitiesTotal; i++) { + if(m_asAudioEntities[m_anAudioEntityIndices[i]].m_nType == AUDIOTYPE_PHYSICAL) { + CPed *ped = (CPed *)m_asAudioEntities[m_anAudioEntityIndices[i]].m_pEntity; + if(ped->IsPed()) { + ped->m_lastSoundStart = timer; + ped->m_soundStart = timer + m_anRandomTable[0] % 3000u; + } + } + } + ClearMissionAudio(); + SampleManager.StopChannel(28); +} + +void +cAudioManager::ResetPoliceRadio() +{ + if(m_bIsInitialised) { + if(SampleManager.GetChannelUsedFlag(28)) SampleManager.StopChannel(28); + InitialisePoliceRadio(); + } +} + +WRAPPER void +cAudioManager::Service() +{ + EAXJMP(0x57A2A0); +} + + +void +cAudioManager::SetDynamicAcousticModelingStatus(bool status) +{ + m_bDynamicAcousticModelingStatus = status; +} + +void +cAudioManager::SetEffectsFadeVolume(uint8 volume) const +{ + SampleManager.SetEffectsFadeVolume(volume); +} + +void +cAudioManager::SetEffectsMasterVolume(uint8 volume) const +{ + SampleManager.SetEffectsMasterVolume(volume); +} + +void +cAudioManager::SetEntityStatus(int32 id, bool status) +{ + if(m_bIsInitialised && id >= 0 && id < totalAudioEntitiesSlots) { + if(m_asAudioEntities[id].m_bIsUsed) { m_asAudioEntities[id].m_bStatus = status; } + } +} + +void +cAudioManager::SetMissionAudioLocation(float x, float y, float z) +{ + if(m_bIsInitialised) { + m_sMissionAudio.field_12 = 0; + m_sMissionAudio.m_vecPos.x = x; + m_sMissionAudio.m_vecPos.y = y; + m_sMissionAudio.m_vecPos.z = z; + } +} + +void +cAudioManager::SetMissionScriptPoliceAudio(int32 sfx) const +{ + if(m_bIsInitialised) { + if(g_nMissionAudioPlayingStatus != 1) { + g_nMissionAudioPlayingStatus = 0; + g_nMissionAudioSfx = sfx; + } + } +} + +void +cAudioManager::SetMusicFadeVolume(uint8 volume) const +{ + SampleManager.SetMusicFadeVolume(volume); +} + +void +cAudioManager::SetMusicMasterVolume(uint8 volume) const +{ + SampleManager.SetMusicMasterVolume(volume); +} + + +void +cAudioManager::SetSpeakerConfig(int32 conf) const +{ + SampleManager.SetSpeakerConfig(conf); +} + +WRAPPER +bool cAudioManager::SetupJumboEngineSound(uint8, int32) { EAXJMP(0x56F140); } + +bool +cAudioManager::SetupJumboFlySound(uint8 emittingVol) +{ + int32 vol; + + if(m_sQueueSample.m_fDistance >= 440.0f) return 0; + + vol = ComputeVolume(emittingVol, 440.0f, m_sQueueSample.m_fDistance); + m_sQueueSample.m_bVolume = vol; + if(m_sQueueSample.m_bVolume) { + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_JUMBO_FLY_SOUND; + m_sQueueSample.m_counter = 0; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_16 = 1; + m_sQueueSample.m_bEmittingVolume = emittingVol; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nFrequency = + SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_JUMBO_FLY_SOUND); + m_sQueueSample.m_nLoopStart = + SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_fSoundIntensity = 440.0f; + m_sQueueSample.field_56 = 0; + m_sQueueSample.field_48 = 4.0f; + m_sQueueSample.m_bReverbFlag = 1; + m_sQueueSample.field_76 = 5; + m_sQueueSample.m_nLoopEnd = + SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + AddSampleToRequestedQueue(); + } + return 1; +} + +bool +cAudioManager::SetupJumboRumbleSound(uint8 emittingVol) { - EAXJMP(0x578370); + if(m_sQueueSample.m_fDistance >= 240.f) return 0; + + m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, 240.f, m_sQueueSample.m_fDistance); + + if(m_sQueueSample.m_bVolume) { + m_sQueueSample.m_counter = 5; + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_JUMBO_RUMBLE_SOUND; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.m_bIsDistant = 1; + m_sQueueSample.field_16 = 1; + m_sQueueSample.m_nFrequency = + SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_JUMBO_RUMBLE_SOUND); + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_bEmittingVolume = emittingVol; + m_sQueueSample.m_nLoopStart = + SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = + SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.field_48 = 4.0f; + m_sQueueSample.m_fSoundIntensity = 240.0f; + m_sQueueSample.field_56 = 0; + m_sQueueSample.field_76 = 12; + m_sQueueSample.m_bOffset = 0; + m_sQueueSample.m_bReverbFlag = 1; + m_sQueueSample.m_bRequireReflection = 0; + AddSampleToRequestedQueue(); + m_sQueueSample.m_counter = 6; + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_JUMBO_RUMBLE_SOUND; + m_sQueueSample.m_nFrequency += 200; + m_sQueueSample.m_bOffset = maxVolume; + AddSampleToRequestedQueue(); + } + return 1; } bool -cAudioManager::ProcessWetRoadNoise(cVehicleParams *params) +cAudioManager::SetupJumboTaxiSound(uint8 vol) { - float relativeVelocity; - int32 emittingVol; - float modificator; - int freq; - float velChange; + uint8 emittingVol; - if(params->m_fDistance >= 900.f) return 0; - if(params->m_pTransmission) { - if(params->m_pVehicle->m_vecMoveSpeed.z) { - velChange = Abs(params->m_fVelocityChange); - if(velChange > 0.f) { - CalculateDistance((bool *)params, params->m_fDistance); - relativeVelocity = - Min(1.0f, - velChange / (0.5f * params->m_pTransmission->fMaxVelocity)); - emittingVol = 23.0f * relativeVelocity * CWeather::WetRoads; - m_sQueueSample.m_bVolume = - ComputeVolume(emittingVol, 30.f, m_sQueueSample.m_fDistance); - if(m_sQueueSample.m_bVolume) { - m_sQueueSample.m_counter = 1; - m_sQueueSample.m_nSampleIndex = - AUDIO_SAMPLE_VEHICLE_ROAD_NOISE; - m_sQueueSample.m_bBankIndex = 0; - m_sQueueSample.m_bIsDistant = 0; - m_sQueueSample.field_16 = 3; - modificator = m_sQueueSample.m_fDistance * 1.f / 3.f * 0.5f; - freq = SampleManager.GetSampleBaseFrequency( - AUDIO_SAMPLE_VEHICLE_ROAD_NOISE); - m_sQueueSample.m_nFrequency = freq + freq * modificator; - m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_bEmittingVolume = emittingVol; - m_sQueueSample.m_nLoopStart = - SampleManager.GetSampleLoopStartOffset( - m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = - SampleManager.GetSampleLoopEndOffset( - m_sQueueSample.m_nSampleIndex); - m_sQueueSample.field_48 = 6.0f; - m_sQueueSample.m_fSoundIntensity = 30.0f; - m_sQueueSample.field_56 = 0; - m_sQueueSample.field_76 = 4; - m_sQueueSample.m_bReverbFlag = 1; - m_sQueueSample.m_bRequireReflection = 0; - AddSampleToRequestedQueue(); - } - } - } + if(m_sQueueSample.m_fDistance >= 180.f) return 0; + + emittingVol = (vol >> 1) + ((vol >> 1) * m_sQueueSample.m_fDistance * 0.0055556f); + + if(m_sQueueSample.m_fDistance * 0.0055556f < 0.7f) + emittingVol -= emittingVol * gJumboVolOffsetPercentage / 100; + m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, 180.f, m_sQueueSample.m_fDistance); + + if(m_sQueueSample.m_bVolume) { + m_sQueueSample.m_counter = 1; + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_JUMBO_TAXI_SOUND; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_16 = 1; + m_sQueueSample.m_nFrequency = GetJumboTaxiFreq(); + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_bEmittingVolume = emittingVol; + m_sQueueSample.m_nLoopStart = + SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = + SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.field_48 = 4.0f; + m_sQueueSample.m_fSoundIntensity = 180.0f; + m_sQueueSample.field_56 = 0; + m_sQueueSample.field_76 = 4; + m_sQueueSample.m_bReverbFlag = 1; + m_sQueueSample.m_bRequireReflection = 0; + AddSampleToRequestedQueue(); } return 1; } -void -cAudioManager::ProcessWorkShopScriptObject(uint8 sound) +bool +cAudioManager::SetupJumboWhineSound(uint8 emittingVol, int32 freq) { - float distSquared; - float maxDist; + if(m_sQueueSample.m_fDistance >= 170.f) return 0; - switch(sound) { - case SCRIPT_SOUND_WORK_SHOP_LOOP_S: - case SCRIPT_SOUND_WORK_SHOP_LOOP_L: - maxDist = 400.f; - m_sQueueSample.m_fSoundIntensity = 20.0f; - break; - default: break; - } - distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos); - if(distSquared < maxDist) { - m_sQueueSample.m_fDistance = sqrt(distSquared); - m_sQueueSample.m_bVolume = ComputeVolume(30u, m_sQueueSample.m_fSoundIntensity, - m_sQueueSample.m_fDistance); - if(m_sQueueSample.m_bVolume) { - m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_WORK_SHOP; - m_sQueueSample.m_bBankIndex = 0; - m_sQueueSample.m_nFrequency = - SampleManager.GetSampleBaseFrequency(AUDIO_SAMPLE_WORK_SHOP); - m_sQueueSample.m_counter = 0; - m_sQueueSample.m_bIsDistant = 0; - m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.field_56 = 0; - m_sQueueSample.field_16 = 5; - m_sQueueSample.field_48 = 2.0f; - m_sQueueSample.m_bEmittingVolume = 30; - m_sQueueSample.m_nLoopStart = - SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = - SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_bReverbFlag = 1; - m_sQueueSample.m_bRequireReflection = 0; - AddSampleToRequestedQueue(); - } + m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, 170.f, m_sQueueSample.m_fDistance); + + if(m_sQueueSample.m_bVolume) { + m_sQueueSample.m_counter = 2; + m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_JUMBO_WHINE_SOUND; + m_sQueueSample.m_bBankIndex = 0; + m_sQueueSample.m_bIsDistant = 0; + m_sQueueSample.field_16 = 1; + m_sQueueSample.m_nFrequency = freq; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_bEmittingVolume = emittingVol; + m_sQueueSample.m_nLoopStart = + SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = + SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.field_48 = 4.0f; + m_sQueueSample.m_fSoundIntensity = 170.0f; + m_sQueueSample.field_56 = 0; + m_sQueueSample.field_76 = 4; + m_sQueueSample.m_bReverbFlag = 1; + m_sQueueSample.m_bRequireReflection = 0; + AddSampleToRequestedQueue(); } + return 1; } void @@ -8240,69 +8166,105 @@ cAudioManager::SetupPedComments(cPedParams *params, uint32 sound) } } -WRAPPER void -cAudioManager::Service() +void +cAudioManager::Terminate() { - EAXJMP(0x57A2A0); -} + if(m_bIsInitialised) { + MusicManager.Terminate(); -WRAPPER void cAudioManager::PlayOneShot(int, unsigned short, float) -{ - EAXJMP(0x57A500); -} + for(uint32 i = 0; i < totalAudioEntitiesSlots; i++) { + m_asAudioEntities[i].m_bIsUsed = 0; + m_anAudioEntityIndices[i] = 200; + } -WRAPPER void cAudioManager::SetEffectsFadeVol(unsigned char) -{ - EAXJMP(0x57A770); -} + m_nAudioEntitiesTotal = 0; + m_nScriptObjectEntityTotal = 0; + PreTerminateGameSpecificShutdown(); -WRAPPER void cAudioManager::SetMusicFadeVol(unsigned char) -{ - EAXJMP(0x57A790); -} + for(uint32 i = 0; i < 2; i++) { + if(SampleManager.IsSampleBankLoaded(i)) SampleManager.UnloadSampleBank(i); + } -WRAPPER int8 cAudioManager::SetCurrent3DProvider(unsigned char) -{ - EAXJMP(0x57A910); + SampleManager.Terminate(); + + m_bIsInitialised = 0; + PostTerminateGameSpecificShutdown(); + } } -WRAPPER void cAudioManager::ReportCrime(eCrimeType, CVector const &) +void +cAudioManager::TranslateEntity(CVector *v1, CVector *v2) const { - EAXJMP(0x5803D0); + const RwMatrix &cM = TheCamera.GetMatrix().m_matrix; + const CVector &cV = TheCamera.GetPosition(); + + float a = v1->z - cV.z; + float b = v1->y - cV.y; + float c = v1->x - cV.x; + + v2->x = cM.right.y * b + cM.right.x * c + cM.right.z * a; + v2->y = cM.up.y * b + cM.up.x * c + cM.up.z * a; + v2->z = cM.at.y * b + cM.at.x * c + cM.at.z * a; } -WRAPPER void cAudioManager::PlaySuspectLastSeen(float, float, float) +void +cAudioManager::UpdateGasPedalAudio(CAutomobile *automobile) { - EAXJMP(0x580500); + float newGasPedalAudio; + + float gasPedal = Abs(automobile->m_fGasPedal); + float gasPedalAudio = automobile->m_fGasPedalAudio; + + if(gasPedalAudio < gasPedal) { + newGasPedalAudio = gasPedalAudio + 0.09f; + if(gasPedal <= newGasPedalAudio) newGasPedalAudio = gasPedal; + } else { + newGasPedalAudio = gasPedalAudio - 0.07f; + if(gasPedal >= newGasPedalAudio) newGasPedalAudio = gasPedal; + } + automobile->m_fGasPedalAudio = newGasPedalAudio; } -WRAPPER void cAudioManager::ReportCollision(CEntity *, CEntity *, unsigned char, unsigned char, float, float) +bool +cAudioManager::UsesReverseWarning(int32 model) const { - EAXJMP(0x568410); + return model == LINERUN || model == FIRETRUK || model == TRASH || model == BUS || + model == COACH; } -WRAPPER void cAudioManager::ResetTimers(unsigned int) +bool +cAudioManager::UsesSiren(int32 model) const { - EAXJMP(0x57A7B0); + switch(model) { + case FIRETRUK: + case AMBULAN: + case FBICAR: + case POLICE: + case ENFORCER: + case PREDATOR: return true; + default: return false; + } } -WRAPPER void cAudioManager::PreloadMissionAudio(char *) +bool +cAudioManager::UsesSirenSwitching(int32 model) const { - EAXJMP(0x579550); + switch(model) { + case AMBULAN: + case POLICE: + case ENFORCER: + case PREDATOR: return true; + default: return false; + } } STARTPATCHES -InjectHook(0x5755C0, &cPedComments::Add, PATCH_JUMP); -InjectHook(0x575730, &cPedComments::Process, PATCH_JUMP); - InjectHook(0x57B210, &cAudioManager::AddDetailsToRequestedOrderList, PATCH_JUMP); InjectHook(0x56AD30, &cAudioManager::AddPlayerCarSample, PATCH_JUMP); InjectHook(0x57B300, &cAudioManager::AddReflectionsToRequestedQueue, PATCH_JUMP); // InjectHook(0x57B8D0, &cAudioManager::AddReleasingSounds, PATCH_JUMP); InjectHook(0x57B070, &cAudioManager::AddSampleToRequestedQueue, PATCH_JUMP); -InjectHook(0x57A8F0, &cAudioManager::GetCurrent3DProviderIndex, PATCH_JUMP); // InjectHook(0x580AF0, &cAudioManager::AgeCrimes, PATCH_JUMP); - InjectHook(0x5697A0, &cAudioManager::CalculateDistance, PATCH_JUMP); InjectHook(0x57AA10, &cAudioManager::CheckForAnAudioFileOnCD, PATCH_JUMP); InjectHook(0x5796A0, &cAudioManager::ClearMissionAudio, PATCH_JUMP); @@ -8310,162 +8272,111 @@ InjectHook(0x57C120, &cAudioManager::ClearRequestedQueue, PATCH_JUMP); InjectHook(0x57AE00, &cAudioManager::ComputeDopplerEffectedFrequency, PATCH_JUMP); InjectHook(0x57ABB0, &cAudioManager::ComputeVolume, PATCH_JUMP); InjectHook(0x57A310, &cAudioManager::CreateEntity, PATCH_JUMP); - InjectHook(0x57A830, &cAudioManager::DestroyAllGameCreatedEntities, PATCH_JUMP); InjectHook(0x57A400, &cAudioManager::DestroyEntity, PATCH_JUMP); InjectHook(0x57F060, &cAudioManager::DoPoliceRadioCrackle, PATCH_JUMP); - InjectHook(0x57C290, &cAudioManager::GenerateIntegerRandomNumberTable, PATCH_JUMP); -InjectHook(0x569750, &cAudioManager::GetDistanceSquared, PATCH_JUMP); -InjectHook(0x57AC60, &cAudioManager::TranslateEntity, PATCH_JUMP); - -InjectHook(0x57A0E0, &cAudioManager::Initialise, PATCH_JUMP); -InjectHook(0x569420, &cAudioManager::PostInitialiseGameSpecificSetup, PATCH_JUMP); -// InjectHook(0x57EAC0, &cAudioManager::InitialisePoliceRadioZones, PATCH_JUMP); -InjectHook(0x569650, &cAudioManager::ResetAudioLogicTimers, PATCH_JUMP); -InjectHook(0x57A150, &cAudioManager::Terminate, PATCH_JUMP); - -InjectHook(0x57F050, &cAudioManager::GetMissionScriptPoliceAudioPlayingStatus, PATCH_JUMP); -InjectHook(0x5795D0, &cAudioManager::GetMissionAudioLoadingStatus, PATCH_JUMP); - -InjectHook(0x57A8A0, &cAudioManager::GetNum3DProvidersAvailable, PATCH_JUMP); -InjectHook(0x57A9C0, &cAudioManager::IsMP3RadioChannelAvailable, PATCH_JUMP); -InjectHook(0x57AA30, &cAudioManager::GetCDAudioDriveLetter, PATCH_JUMP); - -InjectHook(0x57A730, &cAudioManager::SetEffectsMasterVolume, PATCH_JUMP); -InjectHook(0x57A750, &cAudioManager::SetMusicMasterVolume, PATCH_JUMP); -InjectHook(0x57A770, &cAudioManager::SetEffectsFadeVolume, PATCH_JUMP); -InjectHook(0x57A790, &cAudioManager::SetMusicFadeVolume, PATCH_JUMP); - -InjectHook(0x57A9A0, &cAudioManager::SetSpeakerConfig, PATCH_JUMP); - -InjectHook(0x569400, &cAudioManager::PreInitialiseGameSpecificSetup, PATCH_JUMP); - -InjectHook(0x57F020, &cAudioManager::SetMissionScriptPoliceAudio, PATCH_JUMP); - -InjectHook(0x56C3C0, &cAudioManager::UsesSiren, PATCH_JUMP); -InjectHook(0x56C3F0, &cAudioManager::UsesSirenSwitching, PATCH_JUMP); - -InjectHook(0x579520, &cAudioManager::MissionScriptAudioUsesPoliceChannel, PATCH_JUMP); - InjectHook(0x57A8C0, &cAudioManager::Get3DProviderName, PATCH_JUMP); -InjectHook(0x56F230, &cAudioManager::SetupJumboFlySound, PATCH_JUMP); -InjectHook(0x56F310, &cAudioManager::SetupJumboRumbleSound, PATCH_JUMP); -InjectHook(0x56EF20, &cAudioManager::SetupJumboTaxiSound, PATCH_JUMP); -InjectHook(0x56F070, &cAudioManager::SetupJumboWhineSound, PATCH_JUMP); - -InjectHook(0x579620, &cAudioManager::PlayLoadedMissionAudio, PATCH_JUMP); - -InjectHook(0x5795F0, &cAudioManager::SetMissionAudioLocation, PATCH_JUMP); - -InjectHook(0x57EFF0, &cAudioManager::ResetPoliceRadio, PATCH_JUMP); - -InjectHook(0x57B030, &cAudioManager::InterrogateAudioEntities, PATCH_JUMP); - -InjectHook(0x56C600, &cAudioManager::UsesReverseWarning, PATCH_JUMP); -InjectHook(0x56CAB0, &cAudioManager::HasAirBrakes, PATCH_JUMP); - -InjectHook(0x56F410, &cAudioManager::GetJumboTaxiFreq, PATCH_JUMP); - -InjectHook(0x579650, &cAudioManager::IsMissionAudioSampleFinished, PATCH_JUMP); -InjectHook(0x57AF90, &cAudioManager::RandomDisplacement, PATCH_JUMP); - -InjectHook(0x57A9E0, &cAudioManager::ReleaseDigitalHandle, PATCH_JUMP); -InjectHook(0x57A9F0, &cAudioManager::ReacquireDigitalHandle, PATCH_JUMP); -InjectHook(0x57AA00, &cAudioManager::SetDynamicAcousticModelingStatus, PATCH_JUMP); - -InjectHook(0x57AA50, &cAudioManager::IsAudioInitialised, PATCH_JUMP); - -InjectHook(0x57A4C0, &cAudioManager::SetEntityStatus, PATCH_JUMP); - -InjectHook(0x569570, &cAudioManager::PreTerminateGameSpecificShutdown, PATCH_JUMP); -InjectHook(0x569640, &cAudioManager::PostTerminateGameSpecificShutdown, PATCH_JUMP); - -InjectHook(0x56AD10, &cAudioManager::PlayerJustGotInCar, PATCH_JUMP); -InjectHook(0x56AD20, &cAudioManager::PlayerJustLeftCar, PATCH_JUMP); -InjectHook(0x570DB0, &cAudioManager::GetPhrase, PATCH_JUMP); - -// Get ped sfx stuff -InjectHook(0x570960, &cAudioManager::GetPedCommentSfx, PATCH_JUMP); - -InjectHook(0x570E00, &cAudioManager::GetPlayerTalkSfx, PATCH_JUMP); -InjectHook(0x570EA0, &cAudioManager::GetCopTalkSfx, PATCH_JUMP); -InjectHook(0x570F80, &cAudioManager::GetSwatTalkSfx, PATCH_JUMP); -InjectHook(0x571040, &cAudioManager::GetFBITalkSfx, PATCH_JUMP); InjectHook(0x571110, &cAudioManager::GetArmyTalkSfx, PATCH_JUMP); -InjectHook(0x5711C0, &cAudioManager::GetMedicTalkSfx, PATCH_JUMP); -InjectHook(0x5712B0, &cAudioManager::GetFiremanTalkSfx, PATCH_JUMP); -InjectHook(0x575340, &cAudioManager::GetNormalMaleTalkSfx, PATCH_JUMP); -InjectHook(0x575190, &cAudioManager::GetTaxiDriverTalkSfx, PATCH_JUMP); -InjectHook(0x575240, &cAudioManager::GetPimpTalkSfx, PATCH_JUMP); -InjectHook(0x571510, &cAudioManager::GetMafiaTalkSfx, PATCH_JUMP); -InjectHook(0x571650, &cAudioManager::GetTriadTalkSfx, PATCH_JUMP); -InjectHook(0x571770, &cAudioManager::GetDiabloTalkSfx, PATCH_JUMP); -InjectHook(0x5718D0, &cAudioManager::GetYakuzaTalkSfx, PATCH_JUMP); -InjectHook(0x5719E0, &cAudioManager::GetYardieTalkSfx, PATCH_JUMP); -InjectHook(0x571B00, &cAudioManager::GetColumbianTalkSfx, PATCH_JUMP); -InjectHook(0x571C30, &cAudioManager::GetHoodTalkSfx, PATCH_JUMP); -InjectHook(0x571D80, &cAudioManager::GetBlackCriminalTalkSfx, PATCH_JUMP); -InjectHook(0x571E60, &cAudioManager::GetWhiteCriminalTalkSfx, PATCH_JUMP); -InjectHook(0x571F40, &cAudioManager::GetMaleNo2TalkSfx, PATCH_JUMP); -InjectHook(0x572AF0, &cAudioManager::GetBlackProjectMaleTalkSfx, PATCH_JUMP); -InjectHook(0x5725D0, &cAudioManager::GetWhiteFatMaleTalkSfx, PATCH_JUMP); -InjectHook(0x5726C0, &cAudioManager::GetBlackFatMaleTalkSfx, PATCH_JUMP); +InjectHook(0x573AB0, &cAudioManager::GetBlackBusinessFemaleTalkSfx, PATCH_JUMP); InjectHook(0x572050, &cAudioManager::GetBlackCasualFemaleTalkSfx, PATCH_JUMP); -InjectHook(0x572170, &cAudioManager::GetWhiteCasualFemaleTalkSfx, PATCH_JUMP); -InjectHook(0x572280, &cAudioManager::GetFemaleNo3TalkSfx, PATCH_JUMP); +InjectHook(0x574380, &cAudioManager::GetBlackConstructionWorkerTalkSfx, PATCH_JUMP); +InjectHook(0x571D80, &cAudioManager::GetBlackCriminalTalkSfx, PATCH_JUMP); +InjectHook(0x5735E0, &cAudioManager::GetBlackDockerMaleTalkSfx, PATCH_JUMP); InjectHook(0x5724D0, &cAudioManager::GetBlackFatFemaleTalkSfx, PATCH_JUMP); -InjectHook(0x5727B0, &cAudioManager::GetWhiteFatFemaleTalkSfx, PATCH_JUMP); +InjectHook(0x5726C0, &cAudioManager::GetBlackFatMaleTalkSfx, PATCH_JUMP); InjectHook(0x5728B0, &cAudioManager::GetBlackFemaleProstituteTalkSfx, PATCH_JUMP); -InjectHook(0x5729D0, &cAudioManager::GetWhiteFemaleProstituteTalkSfx, PATCH_JUMP); InjectHook(0x572C20, &cAudioManager::GetBlackProjectFemaleOldTalkSfx, PATCH_JUMP); InjectHook(0x572D20, &cAudioManager::GetBlackProjectFemaleYoungTalkSfx, PATCH_JUMP); -InjectHook(0x572E10, &cAudioManager::GetChinatownMaleOldTalkSfx, PATCH_JUMP); -InjectHook(0x572F10, &cAudioManager::GetChinatownMaleYoungTalkSfx, PATCH_JUMP); -InjectHook(0x573010, &cAudioManager::GetChinatownFemaleOldTalkSfx, PATCH_JUMP); -InjectHook(0x5730F0, &cAudioManager::GetChinatownFemaleYoungTalkSfx, PATCH_JUMP); -InjectHook(0x5731E0, &cAudioManager::GetLittleItalyMaleTalkSfx, PATCH_JUMP); -InjectHook(0x573310, &cAudioManager::GetLittleItalyFemaleOldTalkSfx, PATCH_JUMP); -InjectHook(0x573400, &cAudioManager::GetLittleItalyFemaleYoungTalkSfx, PATCH_JUMP); -InjectHook(0x5734F0, &cAudioManager::GetWhiteDockerMaleTalkSfx, PATCH_JUMP); -InjectHook(0x5735E0, &cAudioManager::GetBlackDockerMaleTalkSfx, PATCH_JUMP); -InjectHook(0x5736D0, &cAudioManager::GetScumMaleTalkSfx, PATCH_JUMP); -InjectHook(0x5737E0, &cAudioManager::GetScumFemaleTalkSfx, PATCH_JUMP); -InjectHook(0x5738D0, &cAudioManager::GetWhiteWorkerMaleTalkSfx, PATCH_JUMP); +InjectHook(0x572AF0, &cAudioManager::GetBlackProjectMaleTalkSfx, PATCH_JUMP); InjectHook(0x5739C0, &cAudioManager::GetBlackWorkerMaleTalkSfx, PATCH_JUMP); -InjectHook(0x5713E0, &cAudioManager::GetBusinessMaleYoungTalkSfx, PATCH_JUMP); +InjectHook(0x574FF0, &cAudioManager::GetBomberTalkSfx, PATCH_JUMP); InjectHook(0x5712C0, &cAudioManager::GetBusinessMaleOldTalkSfx, PATCH_JUMP); -InjectHook(0x5723A0, &cAudioManager::GetWhiteBusinessFemaleTalkSfx, PATCH_JUMP); -InjectHook(0x573AB0, &cAudioManager::GetBlackBusinessFemaleTalkSfx, PATCH_JUMP); -InjectHook(0x573BD0, &cAudioManager::GetSupermodelMaleTalkSfx, PATCH_JUMP); -InjectHook(0x573CD0, &cAudioManager::GetSupermodelFemaleTalkSfx, PATCH_JUMP); -InjectHook(0x573DC0, &cAudioManager::GetStewardMaleTalkSfx, PATCH_JUMP); -InjectHook(0x573E90, &cAudioManager::GetStewardFemaleTalkSfx, PATCH_JUMP); -InjectHook(0x573F60, &cAudioManager::GetFanMaleTalkSfx, PATCH_JUMP); -InjectHook(0x574040, &cAudioManager::GetFanFemaleTalkSfx, PATCH_JUMP); -InjectHook(0x574120, &cAudioManager::GetHospitalMaleTalkSfx, PATCH_JUMP); -InjectHook(0x5741F0, &cAudioManager::GetHospitalFemaleTalkSfx, PATCH_JUMP); -InjectHook(0x574290, &cAudioManager::GetWhiteConstructionWorkerTalkSfx, PATCH_JUMP); -InjectHook(0x574380, &cAudioManager::GetBlackConstructionWorkerTalkSfx, PATCH_JUMP); -InjectHook(0x574480, &cAudioManager::GetShopperFemaleTalkSfx, PATCH_JUMP); -InjectHook(0x574590, &cAudioManager::GetStudentMaleTalkSfx, PATCH_JUMP); -InjectHook(0x574690, &cAudioManager::GetStudentFemaleTalkSfx, PATCH_JUMP); +InjectHook(0x5713E0, &cAudioManager::GetBusinessMaleYoungTalkSfx, PATCH_JUMP); InjectHook(0x572040, &cAudioManager::GetCasualMaleOldTalkSfx, PATCH_JUMP); - -InjectHook(0x574790, &cAudioManager::GetSpecialCharacterTalkSfx, PATCH_JUMP); +InjectHook(0x574FE0, &cAudioManager::GetCatatalinaTalkSfx, PATCH_JUMP); +InjectHook(0x57AA30, &cAudioManager::GetCDAudioDriveLetter, PATCH_JUMP); +InjectHook(0x573010, &cAudioManager::GetChinatownFemaleOldTalkSfx, PATCH_JUMP); +InjectHook(0x5730F0, &cAudioManager::GetChinatownFemaleYoungTalkSfx, PATCH_JUMP); +InjectHook(0x572E10, &cAudioManager::GetChinatownMaleOldTalkSfx, PATCH_JUMP); +InjectHook(0x572F10, &cAudioManager::GetChinatownMaleYoungTalkSfx, PATCH_JUMP); +InjectHook(0x575120, &cAudioManager::GetChunkyTalkSfx, PATCH_JUMP); +InjectHook(0x571B00, &cAudioManager::GetColumbianTalkSfx, PATCH_JUMP); +InjectHook(0x570EA0, &cAudioManager::GetCopTalkSfx, PATCH_JUMP); +InjectHook(0x57A8F0, &cAudioManager::GetCurrent3DProviderIndex, PATCH_JUMP); +InjectHook(0x569060, &cAudioManager::GetCollisionOneShotRatio, PATCH_JUMP); +InjectHook(0x5693B0, &cAudioManager::GetCollisionRatio, PATCH_JUMP); +InjectHook(0x571770, &cAudioManager::GetDiabloTalkSfx, PATCH_JUMP); +InjectHook(0x569750, &cAudioManager::GetDistanceSquared, PATCH_JUMP); InjectHook(0x574DA0, &cAudioManager::GetEightTalkSfx, PATCH_JUMP); +InjectHook(0x574040, &cAudioManager::GetFanFemaleTalkSfx, PATCH_JUMP); +InjectHook(0x573F60, &cAudioManager::GetFanMaleTalkSfx, PATCH_JUMP); +InjectHook(0x571040, &cAudioManager::GetFBITalkSfx, PATCH_JUMP); +InjectHook(0x572280, &cAudioManager::GetFemaleNo3TalkSfx, PATCH_JUMP); +InjectHook(0x5712B0, &cAudioManager::GetFiremanTalkSfx, PATCH_JUMP); InjectHook(0x574E50, &cAudioManager::GetFrankieTalkSfx, PATCH_JUMP); +InjectHook(0x575510, &cAudioManager::GetGenericFemaleTalkSfx, PATCH_JUMP); +InjectHook(0x575460, &cAudioManager::GetGenericMaleTalkSfx, PATCH_JUMP); +InjectHook(0x571C30, &cAudioManager::GetHoodTalkSfx, PATCH_JUMP); +InjectHook(0x5741F0, &cAudioManager::GetHospitalFemaleTalkSfx, PATCH_JUMP); +InjectHook(0x574120, &cAudioManager::GetHospitalMaleTalkSfx, PATCH_JUMP); +InjectHook(0x56F410, &cAudioManager::GetJumboTaxiFreq, PATCH_JUMP); +InjectHook(0x573310, &cAudioManager::GetLittleItalyFemaleOldTalkSfx, PATCH_JUMP); +InjectHook(0x573400, &cAudioManager::GetLittleItalyFemaleYoungTalkSfx, PATCH_JUMP); +InjectHook(0x5731E0, &cAudioManager::GetLittleItalyMaleTalkSfx, PATCH_JUMP); +InjectHook(0x571510, &cAudioManager::GetMafiaTalkSfx, PATCH_JUMP); +InjectHook(0x571F40, &cAudioManager::GetMaleNo2TalkSfx, PATCH_JUMP); +InjectHook(0x5711C0, &cAudioManager::GetMedicTalkSfx, PATCH_JUMP); +InjectHook(0x5795D0, &cAudioManager::GetMissionAudioLoadingStatus, PATCH_JUMP); +InjectHook(0x57F050, &cAudioManager::GetMissionScriptPoliceAudioPlayingStatus, PATCH_JUMP); InjectHook(0x574F00, &cAudioManager::GetMistyTalkSfx, PATCH_JUMP); +InjectHook(0x575340, &cAudioManager::GetNormalMaleTalkSfx, PATCH_JUMP); +InjectHook(0x57A8A0, &cAudioManager::GetNum3DProvidersAvailable, PATCH_JUMP); InjectHook(0x574FD0, &cAudioManager::GetOJGTalkSfx, PATCH_JUMP); -InjectHook(0x574FE0, &cAudioManager::GetCatatalinaTalkSfx, PATCH_JUMP); -InjectHook(0x574FF0, &cAudioManager::GetBomberTalkSfx, PATCH_JUMP); +InjectHook(0x570960, &cAudioManager::GetPedCommentSfx, PATCH_JUMP); +InjectHook(0x570DB0, &cAudioManager::GetPhrase, PATCH_JUMP); +InjectHook(0x575240, &cAudioManager::GetPimpTalkSfx, PATCH_JUMP); +InjectHook(0x570E00, &cAudioManager::GetPlayerTalkSfx, PATCH_JUMP); +InjectHook(0x5737E0, &cAudioManager::GetScumFemaleTalkSfx, PATCH_JUMP); +InjectHook(0x5736D0, &cAudioManager::GetScumMaleTalkSfx, PATCH_JUMP); InjectHook(0x575060, &cAudioManager::GetSecurityGuardTalkSfx, PATCH_JUMP); -InjectHook(0x575120, &cAudioManager::GetChunkyTalkSfx, PATCH_JUMP); - -InjectHook(0x575460, &cAudioManager::GetGenericMaleTalkSfx, PATCH_JUMP); -InjectHook(0x575510, &cAudioManager::GetGenericFemaleTalkSfx, PATCH_JUMP); - -// Process stuff +InjectHook(0x574480, &cAudioManager::GetShopperFemaleTalkSfx, PATCH_JUMP); +InjectHook(0x574790, &cAudioManager::GetSpecialCharacterTalkSfx, PATCH_JUMP); +InjectHook(0x573E90, &cAudioManager::GetStewardFemaleTalkSfx, PATCH_JUMP); +InjectHook(0x573DC0, &cAudioManager::GetStewardMaleTalkSfx, PATCH_JUMP); +InjectHook(0x574690, &cAudioManager::GetStudentFemaleTalkSfx, PATCH_JUMP); +InjectHook(0x574590, &cAudioManager::GetStudentMaleTalkSfx, PATCH_JUMP); +InjectHook(0x573CD0, &cAudioManager::GetSupermodelFemaleTalkSfx, PATCH_JUMP); +InjectHook(0x573BD0, &cAudioManager::GetSupermodelMaleTalkSfx, PATCH_JUMP); +InjectHook(0x570F80, &cAudioManager::GetSwatTalkSfx, PATCH_JUMP); +InjectHook(0x575190, &cAudioManager::GetTaxiDriverTalkSfx, PATCH_JUMP); +InjectHook(0x571650, &cAudioManager::GetTriadTalkSfx, PATCH_JUMP); +InjectHook(0x5723A0, &cAudioManager::GetWhiteBusinessFemaleTalkSfx, PATCH_JUMP); +InjectHook(0x572170, &cAudioManager::GetWhiteCasualFemaleTalkSfx, PATCH_JUMP); +InjectHook(0x574290, &cAudioManager::GetWhiteConstructionWorkerTalkSfx, PATCH_JUMP); +InjectHook(0x571E60, &cAudioManager::GetWhiteCriminalTalkSfx, PATCH_JUMP); +InjectHook(0x5734F0, &cAudioManager::GetWhiteDockerMaleTalkSfx, PATCH_JUMP); +InjectHook(0x5727B0, &cAudioManager::GetWhiteFatFemaleTalkSfx, PATCH_JUMP); +InjectHook(0x5725D0, &cAudioManager::GetWhiteFatMaleTalkSfx, PATCH_JUMP); +InjectHook(0x5729D0, &cAudioManager::GetWhiteFemaleProstituteTalkSfx, PATCH_JUMP); +InjectHook(0x5738D0, &cAudioManager::GetWhiteWorkerMaleTalkSfx, PATCH_JUMP); +InjectHook(0x5718D0, &cAudioManager::GetYakuzaTalkSfx, PATCH_JUMP); +InjectHook(0x5719E0, &cAudioManager::GetYardieTalkSfx, PATCH_JUMP); +InjectHook(0x56CAB0, &cAudioManager::HasAirBrakes, PATCH_JUMP); +InjectHook(0x57A0E0, &cAudioManager::Initialise, PATCH_JUMP); +// InjectHook(0x57EAC0, &cAudioManager::InitialisePoliceRadioZones, PATCH_JUMP); +InjectHook(0x57B030, &cAudioManager::InterrogateAudioEntities, PATCH_JUMP); +InjectHook(0x57AA50, &cAudioManager::IsAudioInitialised, PATCH_JUMP); +InjectHook(0x579650, &cAudioManager::IsMissionAudioSampleFinished, PATCH_JUMP); +InjectHook(0x57A9C0, &cAudioManager::IsMP3RadioChannelAvailable, PATCH_JUMP); +InjectHook(0x579520, &cAudioManager::MissionScriptAudioUsesPoliceChannel, PATCH_JUMP); +InjectHook(0x56AD10, &cAudioManager::PlayerJustGotInCar, PATCH_JUMP); +InjectHook(0x56AD20, &cAudioManager::PlayerJustLeftCar, PATCH_JUMP); +InjectHook(0x579620, &cAudioManager::PlayLoadedMissionAudio, PATCH_JUMP); +InjectHook(0x569420, &cAudioManager::PostInitialiseGameSpecificSetup, PATCH_JUMP); +InjectHook(0x569640, &cAudioManager::PostTerminateGameSpecificShutdown, PATCH_JUMP); +InjectHook(0x569400, &cAudioManager::PreInitialiseGameSpecificSetup, PATCH_JUMP); +InjectHook(0x569570, &cAudioManager::PreTerminateGameSpecificShutdown, PATCH_JUMP); // InjectHook(0x57BA60, &cAudioManager::ProcessActiveQueues, PATCH_JUMP); InjectHook(0x56C940, &cAudioManager::ProcessAirBrakes, PATCH_JUMP); InjectHook(0x577B30, &cAudioManager::ProcessAirportScriptObject, PATCH_JUMP); @@ -8515,6 +8426,34 @@ InjectHook(0x56DBF0, &cAudioManager::ProcessTrainNoise, PATCH_JUMP); InjectHook(0x56C770, &cAudioManager::ProcessVehicleDoors, PATCH_JUMP); InjectHook(0x56C640, &cAudioManager::ProcessVehicleReverseWarning, PATCH_JUMP); InjectHook(0x56A230, &cAudioManager::ProcessVehicleRoadNoise, PATCH_JUMP); +InjectHook(0x578370, &cAudioManager::ProcessWeather, PATCH_JUMP); +InjectHook(0x56A440, &cAudioManager::ProcessWetRoadNoise, PATCH_JUMP); InjectHook(0x577530, &cAudioManager::ProcessWorkShopScriptObject, PATCH_JUMP); +InjectHook(0x57AF90, &cAudioManager::RandomDisplacement, PATCH_JUMP); +InjectHook(0x57A9F0, &cAudioManager::ReacquireDigitalHandle, PATCH_JUMP); +InjectHook(0x57A9E0, &cAudioManager::ReleaseDigitalHandle, PATCH_JUMP); +InjectHook(0x569650, &cAudioManager::ResetAudioLogicTimers, PATCH_JUMP); +InjectHook(0x57EFF0, &cAudioManager::ResetPoliceRadio, PATCH_JUMP); +InjectHook(0x57AA00, &cAudioManager::SetDynamicAcousticModelingStatus, PATCH_JUMP); +InjectHook(0x57A770, &cAudioManager::SetEffectsFadeVolume, PATCH_JUMP); +InjectHook(0x57A730, &cAudioManager::SetEffectsMasterVolume, PATCH_JUMP); +InjectHook(0x57A4C0, &cAudioManager::SetEntityStatus, PATCH_JUMP); +InjectHook(0x5795F0, &cAudioManager::SetMissionAudioLocation, PATCH_JUMP); +InjectHook(0x57F020, &cAudioManager::SetMissionScriptPoliceAudio, PATCH_JUMP); +InjectHook(0x57A790, &cAudioManager::SetMusicFadeVolume, PATCH_JUMP); +InjectHook(0x57A750, &cAudioManager::SetMusicMasterVolume, PATCH_JUMP); +InjectHook(0x57A9A0, &cAudioManager::SetSpeakerConfig, PATCH_JUMP); +InjectHook(0x56F230, &cAudioManager::SetupJumboFlySound, PATCH_JUMP); +InjectHook(0x56F310, &cAudioManager::SetupJumboRumbleSound, PATCH_JUMP); +InjectHook(0x56EF20, &cAudioManager::SetupJumboTaxiSound, PATCH_JUMP); +InjectHook(0x56F070, &cAudioManager::SetupJumboWhineSound, PATCH_JUMP); InjectHook(0x570690, &cAudioManager::SetupPedComments, PATCH_JUMP); +InjectHook(0x57A150, &cAudioManager::Terminate, PATCH_JUMP); +InjectHook(0x57AC60, &cAudioManager::TranslateEntity, PATCH_JUMP); +InjectHook(0x56AC80, &cAudioManager::UpdateGasPedalAudio, PATCH_JUMP); +InjectHook(0x56C600, &cAudioManager::UsesReverseWarning, PATCH_JUMP); +InjectHook(0x56C3C0, &cAudioManager::UsesSiren, PATCH_JUMP); +InjectHook(0x56C3F0, &cAudioManager::UsesSirenSwitching, PATCH_JUMP); +InjectHook(0x5755C0, &cPedComments::Add, PATCH_JUMP); +InjectHook(0x575730, &cPedComments::Process, PATCH_JUMP); ENDPATCHES diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index 5ad14050..c765bfd4 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -49,8 +49,8 @@ public: uint8 field_89; uint8 field_90; uint8 field_91; - - // no methods + + // no methods }; static_assert(sizeof(tActiveSample) == 92, "tActiveSample: error"); @@ -88,8 +88,8 @@ public: float m_afVolume[4]; uint8 m_Loops; uint8 field_25[3]; - - // no methods + + // no methods }; static_assert(sizeof(tAudioEntity) == 40, "tAudioEntity: error"); @@ -104,8 +104,8 @@ public: uint8 m_bVolume; int8 field_25; // allocated time? uint8 gap_26[2]; - - // no methods + + // no methods }; static_assert(sizeof(tPedComment) == 28, "tPedComment: error"); @@ -119,7 +119,7 @@ public: uint8 activeBank; uint8 gap_1163[1]; - // reversed all methods + // reversed all methods void Add(tPedComment *com); /// ok void Process(); /// ok }; @@ -142,8 +142,8 @@ public: CVector m_vecPosition; float m_fDistance; int32 m_nBaseVolume; - - // no methods + + // no methods }; static_assert(sizeof(cAudioCollision) == 40, "cAudioCollision: error"); @@ -157,6 +157,8 @@ public: uint8 m_bCollisionsInQueue; uint8 gap_811; cAudioCollision m_sQueue; + + void AddCollisionToRequestedQueue(); // todo }; static_assert(sizeof(cAudioCollisionManager) == 852, "cAudioCollisionManager: error"); @@ -177,6 +179,7 @@ public: uint8 field_29; uint8 field_30; uint8 field_31; + // no methods }; static_assert(sizeof(cMissionAudio) == 32, "cMissionAudio: error"); @@ -188,7 +191,8 @@ class CPed; class cPedParams; class cTransmission; -class cAudioScriptObject { +class cAudioScriptObject +{ public: int16 AudioId; char _pad0[2]; @@ -220,22 +224,14 @@ enum { MAX_REFLECTIONS, }; -<<<<<<< HEAD -enum AudioEntityHandle -{ - AEHANDLE_NONE = -5, - AEHANDLE_ERROR_NOAUDIOSYS = -4, - AEHANDLE_ERROR_NOFREESLOT = -3, - AEHANDLE_ERROR_NOENTITY = -2, +enum AudioEntityHandle { + AEHANDLE_NONE = -5, + AEHANDLE_ERROR_NOAUDIOSYS = -4, + AEHANDLE_ERROR_NOFREESLOT = -3, + AEHANDLE_ERROR_NOENTITY = -2, AEHANDLE_ERROR_BADAUDIOTYPE = -1, }; -#define AEHANDLE_IS_FAILED(h) ((h)<0) -#define AEHANDLE_IS_OK(h) ((h)>=0) - - -======= ->>>>>>> Cleanup class cAudioManager { public: @@ -285,22 +281,10 @@ public: uint8 field_19195; // time? uint32 m_FrameCounter; -<<<<<<< HEAD - inline uint32 GetFrameCounter(void) { return m_FrameCounter; } - float GetReflectionsDistance(int32 idx) { return m_afReflectionsDistances[idx]; } -<<<<<<< HEAD - int32 GetRandomNumber(int32 idx) { return m_anRandomTable[idx]; } -======= - int32 GetRandomTabe(int32 idx) { return m_anRandomTable[idx]; } - ->>>>>>> Cleanup - // -======= // getters uint32 GetFrameCounter() const { return m_FrameCounter; } float GetReflectionsDistance(int32 idx) const { return m_afReflectionsDistances[idx]; } - int32 GetRandomTabe(int32 idx) const { return m_anRandomTable[idx]; } ->>>>>>> More more more audio + int32 GetRandomNumber(int32 idx) const { return m_anRandomTable[idx]; } // "Should" be in alphabetic order, except "getXTalkSfx" void AddDetailsToRequestedOrderList(uint8 sample); /// ok @@ -312,80 +296,22 @@ public: void AgeCrimes(); // todo void CalculateDistance(bool *ptr, float dist); /// ok - bool CheckForAnAudioFileOnCD() const; /// ok + bool CheckForAnAudioFileOnCD() const; /// ok void ClearMissionAudio(); /// ok void ClearRequestedQueue(); /// ok int32 ComputeDopplerEffectedFrequency(uint32 oldFreq, float position1, float position2, - float speedMultiplier) const; /// ok - int32 ComputePan(float, CVector *); // todo -<<<<<<< HEAD - uint32 ComputeVolume(int emittingVolume, float soundIntensity, float distance); /// ok - int32 CreateEntity(int32 type, void *entity); /// ok -======= + float speedMultiplier) const; /// ok + int32 ComputePan(float, CVector *); // todo uint32 ComputeVolume(int emittingVolume, float soundIntensity, float distance) const; /// ok - int32 CreateEntity(int32 type, CPhysical *entity); /// ok ->>>>>>> More more more audio + int32 CreateEntity(int32 type, CPhysical *entity); /// ok void DestroyAllGameCreatedEntities(); /// ok void DestroyEntity(int32 id); /// ok + void DoJumboVolOffset() const; /// ok void DoPoliceRadioCrackle(); /// ok - void GenerateIntegerRandomNumberTable(); /// ok - - void TranslateEntity(CVector *v1, CVector *v2) const ; /// ok - - void ResetAudioLogicTimers(int32 timer); /// ok - - void Terminate(); - uint8 GetNum3DProvidersAvailable() const; - bool IsMP3RadioChannelAvailable() const; - uint8 GetCDAudioDriveLetter() const; - - void SetEffectsMasterVolume(uint8 volume) const; - void SetMusicMasterVolume(uint8 volume) const; - void SetEffectsFadeVolume(uint8 volume) const; - void SetMusicFadeVolume(uint8 volume) const; - - void SetSpeakerConfig(int32 conf) const; - - bool SetupJumboEngineSound(uint8, int32); // todo - void PreInitialiseGameSpecificSetup() const; - void SetMissionScriptPoliceAudio(int32 sfx) const; - - bool UsesSiren(int32 model) const; - bool UsesSirenSwitching(int32 model) const; - - char *Get3DProviderName(uint8 id) const; - - bool SetupJumboFlySound(uint8 emittingVol); /// ok - bool SetupJumboRumbleSound(uint8 emittingVol); /// ok - bool SetupJumboTaxiSound(uint8 vol); /// ok - bool SetupJumboWhineSound(uint8 emittingVol, int32 freq); /// ok - - void SetMissionAudioLocation(float x, float y, float z); - - void ResetPoliceRadio(); - - bool UsesReverseWarning(int32 model) const; - - int32 RandomDisplacement(uint32 seed) const; - - void ReleaseDigitalHandle() const; - void ReacquireDigitalHandle() const; - void SetDynamicAcousticModelingStatus(bool status); - - bool IsAudioInitialised() const; - - void SetEntityStatus(int32 id, bool status); - - void Service(); - void GetPhrase(uint32 *phrase, uint32 *prevPhrase, uint32 sample, uint32 maxOffset) const; - - void DoJumboVolOffset() const; - - int32 GetPedCommentSfx(CPed *ped, int32 sound); - - // order from GetPedCommentSfx + // functions returning talk sfx, + // order from GetPedCommentSfx uint32 GetPlayerTalkSfx(int16 sound); uint32 GetCopTalkSfx(int16 sound); uint32 GetSwatTalkSfx(int16 sound); @@ -462,15 +388,22 @@ public: uint32 GetGenericMaleTalkSfx(int16 sound); uint32 GetGenericFemaleTalkSfx(int16 sound); + // end of functions returning talk sfx + void GenerateIntegerRandomNumberTable(); /// ok + char *Get3DProviderName(uint8 id) const; + uint8 GetCDAudioDriveLetter() const; int8 GetCurrent3DProviderIndex() const; /// ok - float GetCollisionLoopingRatio(uint32 a, uint32 b, float c) const; // todo hook - float GetCollisionOneShotRatio(uint32 a, float b) const; // todo hook - float GetCollisionRatio(float a, float b, float c, float d) const; // todo hook + float GetCollisionLoopingRatio(uint32 a, uint32 b, float c) const; // not used + float GetCollisionOneShotRatio(uint32 a, float b) const; /// ok + float GetCollisionRatio(float a, float b, float c, float d) const; /// ok float GetDistanceSquared(CVector *v) const; /// ok int32 GetJumboTaxiFreq() const; /// ok bool GetMissionAudioLoadingStatus() const; /// ok char GetMissionScriptPoliceAudioPlayingStatus() const; /// ok + uint8 GetNum3DProvidersAvailable() const; + int32 GetPedCommentSfx(CPed *ped, int32 sound); + void GetPhrase(uint32 *phrase, uint32 *prevPhrase, uint32 sample, uint32 maxOffset) const; float GetVehicleDriveWheelSkidValue(uint8 a1, CAutomobile *a2, cTransmission *a3, float a4); // todo int32 GetVehicleNonDriveWheelSkidValue(float a1, int a2, int a3, int a4, float a5); // todo @@ -481,19 +414,22 @@ public: void InitialisePoliceRadio(); // todo void InitialisePoliceRadioZones(); // todo void InterrogateAudioEntities(); /// ok + bool IsAudioInitialised() const; /// ok bool IsMissionAudioSampleFinished(); /// ok + bool IsMP3RadioChannelAvailable() const; bool MissionScriptAudioUsesPoliceChannel(int32 soundMission) const; /// ok void PlayLoadedMissionAudio(); /// ok void PlayOneShot(int32 index, int16 sound, float vol); // todo - uint32 PlaySuspectLastSeen(float x, float y, float z); // todo - void PlayerJustGotInCar() const; /// ok - void PlayerJustLeftCar() const; /// ok + uint32 PlaySuspectLastSeen(float x, float y, float z); // todo + void PlayerJustGotInCar() const; /// ok + void PlayerJustLeftCar() const; /// ok void PostInitialiseGameSpecificSetup(); /// ok void PostTerminateGameSpecificShutdown(); /// ok - void PreTerminateGameSpecificShutdown(); /// ok - void PreloadMissionAudio(char *); // todo + void PreInitialiseGameSpecificSetup() const; + void PreloadMissionAudio(char *); // todo + void PreTerminateGameSpecificShutdown(); /// ok /// processX - main logic of adding new sounds void ProcessActiveQueues(); // todo bool ProcessAirBrakes(cVehicleParams *params); /// ok @@ -541,7 +477,7 @@ public: void ProcessPornCinema(uint8 sound); /// ok void ProcessProjectiles(); // todo requires CProjectileInfo void ProcessRainOnVehicle(cVehicleParams *params); /// ok - void ProcessReverb() const; /// ok + void ProcessReverb() const; /// ok bool ProcessReverseGear(cVehicleParams *a2); /// ok void ProcessSawMillScriptObject(uint8 sound); /// ok void ProcessScriptObject(int32 id); /// ok @@ -558,11 +494,55 @@ public: // void ProcessVehicleSirenOrAlarm(void *); // void ProcessVehicleSkidding(void *); void ProcessWaterCannon(int32); // todo - void ProcessWeather(int32 id); // todo - bool ProcessWetRoadNoise(cVehicleParams *params); // todo hook + void ProcessWeather(int32 id); /// ok + bool ProcessWetRoadNoise(cVehicleParams *params); /// ok void ProcessWorkShopScriptObject(uint8 sound); /// ok - void SetupPedComments(cPedParams *params, uint32 sound); /// ok + int32 RandomDisplacement(uint32 seed) const; + void ReacquireDigitalHandle() const; + void ReleaseDigitalHandle() const; + int32 ReportCollision(CEntity *a2, CEntity *a3, uint8 a4, uint8 a5, float a6, + float a7); // todo + int32 ReportCrime(int a2, int *a3); // todo + void ResetAudioLogicTimers(int32 timer); /// ok + void ResetPoliceRadio(); + void ResetTimers(unsigned int a2); // todo + + void Service(); // todo + void ServiceCollisions(); // todo + void ServicePoliceRadio(); // todo + void ServicePoliceRadioChannel(int a2); // todo + void ServiceSoundEffects(); // todo + void SetCurrent3DProvider(uint8); + void SetDynamicAcousticModelingStatus(bool status); + void SetEffectsFadeVolume(uint8 volume) const; + void SetEffectsMasterVolume(uint8 volume) const; + void SetEntityStatus(int32 id, bool status); + uint32 SetLoopingCollisionRequestedSfxFreqAndGetVol(int32); // todo + void SetMissionAudioLocation(float x, float y, float z); + void SetMissionScriptPoliceAudio(int32 sfx) const; + void SetMonoMode(uint8); // todo + void SetMusicFadeVolume(uint8 volume) const; + void SetMusicMasterVolume(uint8 volume) const; + void SetSpeakerConfig(int32 conf) const; + void SetUpLoopingCollisionSound(int a2, int a3); // todo + void SetUpOneShotCollisionSound(int a2); // todo + void SetupCrimeReport(); // todo + bool SetupJumboEngineSound(uint8, int32); // todo + bool SetupJumboFlySound(uint8 emittingVol); /// ok + bool SetupJumboRumbleSound(uint8 emittingVol); /// ok + bool SetupJumboTaxiSound(uint8 vol); /// ok + bool SetupJumboWhineSound(uint8 emittingVol, int32 freq); /// ok + void SetupPedComments(cPedParams *params, uint32 sound); /// ok + void SetupSuspectLastSeenReport(); // todo + + void Terminate(); + void TranslateEntity(CVector *v1, CVector *v2) const; /// ok + + void UpdateGasPedalAudio(CAutomobile *automobile); // todo hook + bool UsesReverseWarning(int32 model) const; + bool UsesSiren(int32 model) const; + bool UsesSirenSwitching(int32 model) const; }; static_assert(sizeof(cAudioManager) == 19220, "cAudioManager: error"); diff --git a/src/audio/AudioManager.h.autosave b/src/audio/AudioManager.h.autosave new file mode 100644 index 00000000..2ea78476 --- /dev/null +++ b/src/audio/AudioManager.h.autosave @@ -0,0 +1,549 @@ +#pragma once + +#include "AudioSamples.h" +#include "DMAudio.h" +#include "common.h" + +class tActiveSample +{ +public: + int32 m_nEntityIndex; + int32 m_counter; + int32 m_nSampleIndex; + uint8 m_bBankIndex; + uint8 m_bIsDistant; + uint8 field_14; + uint8 field_15; + int32 field_16; + int32 m_nFrequency; + uint8 m_bVolume; + uint8 field_25; + uint8 field_26; + uint8 field_27; + float m_fDistance; + int32 m_nLoopCount; + int32 m_nLoopStart; + int32 m_nLoopEnd; + uint8 m_bEmittingVolume; + uint8 field_45; + uint8 field_46; + uint8 field_47; + float field_48; + float m_fSoundIntensity; + uint8 field_56; + uint8 field_57; + uint8 field_58; + uint8 field_59; + CVector m_vecPos; + uint8 m_bReverbFlag; + uint8 m_bLoopsRemaining; + uint8 m_bRequireReflection; + uint8 m_bOffset; + int32 field_76; + uint8 m_bIsProcessed; + uint8 m_bLoopEnded; + uint8 field_82; + uint8 field_83; + int32 calculatedVolume; + uint8 field_88; + uint8 field_89; + uint8 field_90; + uint8 field_91; + + // no methods +}; + +static_assert(sizeof(tActiveSample) == 92, "tActiveSample: error"); + +enum eAudioType : int32 { + AUDIOTYPE_PHYSICAL = 0, + AUDIOTYPE_EXPLOSION = 1, + AUDIOTYPE_FIRE = 2, + AUDIOTYPE_WEATHER = 3, + AUDIOTYPE_CRANE = 4, + AUDIOTYPE_SCRIPTOBJECT = 5, + AUDIOTYPE_BRIDGE = 6, + AUDIOTYPE_COLLISION = 7, + AUDIOTYPE_FRONTEND = 8, + AUDIOTYPE_PROJECTILE = 9, + AUDIOTYPE_GARAGE = 10, + AUDIOTYPE_FIREHYDRANT = 11, + AUDIOTYPE_WATERCANNON = 12, + AUDIOTYPE_POLICERADIO = 13, + TOTAL_AUDIO_TYPES = 14, +}; + +class CPhysical; +class CAutomobile; + +class tAudioEntity +{ +public: + eAudioType m_nType; + void *m_pEntity; + bool m_bIsUsed; + uint8 m_bStatus; + int16 m_awAudioEvent[4]; + uint8 gap_18[2]; + float m_afVolume[4]; + uint8 m_Loops; + uint8 field_25[3]; + + // no methods +}; + +static_assert(sizeof(tAudioEntity) == 40, "tAudioEntity: error"); + +class tPedComment +{ +public: + int32 m_nSampleIndex; + int32 m_entityIndex; + CVector m_vecPos; + float m_fDistance; + uint8 m_bVolume; + int8 field_25; // allocated time? + uint8 gap_26[2]; + + // no methods +}; + +static_assert(sizeof(tPedComment) == 28, "tPedComment: error"); + +class cPedComments +{ +public: + tPedComment m_asPedComments[2][20]; + uint8 indexMap[2][20]; + uint8 nrOfCommentsInBank[2]; + uint8 activeBank; + uint8 gap_1163[1]; + + // reversed all methods + void Add(tPedComment *com); /// ok + void Process(); /// ok +}; + +static_assert(sizeof(cPedComments) == 1164, "cPedComments: error"); + +class CEntity; + +class cAudioCollision +{ +public: + CEntity *m_pEntity1; + CEntity *m_pEntity2; + uint8 m_bSurface1; + uint8 m_bSurface2; + uint8 field_10; + uint8 field_11; + float m_fIntensity1; + float m_fIntensity2; + CVector m_vecPosition; + float m_fDistance; + int32 m_nBaseVolume; + + // no methods +}; + +static_assert(sizeof(cAudioCollision) == 40, "cAudioCollision: error"); + +class cAudioCollisionManager +{ +public: + cAudioCollision m_asCollisions1[10]; + cAudioCollision m_asCollisions2[10]; + uint8 m_bIndicesTable[10]; + uint8 m_bCollisionsInQueue; + uint8 gap_811; + cAudioCollision m_sQueue; + + void AddCollisionToRequestedQueue(); // todo +}; + +static_assert(sizeof(cAudioCollisionManager) == 852, "cAudioCollisionManager: error"); + +class cMissionAudio +{ +public: + CVector m_vecPos; + uint8 field_12; + uint8 gap_13[3]; + int m_nSampleIndex; + uint8 m_bLoadingStatus; + uint8 m_bPlayStatus; + uint8 field_22; + uint8 field_23; + int field_24; + bool m_bIsPlayed; + uint8 field_29; + uint8 field_30; + uint8 field_31; + // no methods +}; + +static_assert(sizeof(cMissionAudio) == 32, "cMissionAudio: error"); + +class cVehicleParams; +class CPlane; +class CVehicle; +class CPed; +class cPedParams; +class cTransmission; + +class cAudioScriptObject { +public: + int16 AudioId; + char _pad0[2]; + CVector Posn; + int32 AudioEntity; + + static void *operator new(size_t); + static void *operator new(size_t, int); + static void operator delete(void *, size_t); + static void operator delete(void *, int); +}; + +static_assert(sizeof(cAudioScriptObject) == 20, "cAudioScriptObject: error"); + +enum { + /* + REFLECTION_YMAX = 0, top + REFLECTION_YMIN = 1, bottom + REFLECTION_XMIN = 2, left + REFLECTION_XMAX = 3, right + REFLECTION_ZMAX = 4, + */ + + REFLECTION_TOP = 0, + REFLECTION_BOTTOM, + REFLECTION_LEFT, + REFLECTION_RIGHT, + REFLECTION_UP, + MAX_REFLECTIONS, +}; + +enum AudioEntityHandle +{ + AEHANDLE_NONE = -5, + AEHANDLE_ERROR_NOAUDIOSYS = -4, + AEHANDLE_ERROR_NOFREESLOT = -3, + AEHANDLE_ERROR_NOENTITY = -2, + AEHANDLE_ERROR_BADAUDIOTYPE = -1, +}; + +class cAudioManager +{ +public: + bool m_bIsInitialised; + uint8 field_1; + uint8 field_2; + uint8 m_bActiveSamples; + uint8 field_4; + bool m_bDynamicAcousticModelingStatus; + uint8 field_6; + uint8 field_7; + float speedOfSound; + bool m_bTimerJustReset; + uint8 field_13; + uint8 field_14; + uint8 field_15; + int32 m_nTimer; + tActiveSample m_sQueueSample; + uint8 m_bActiveSampleQueue; + uint8 gap_109[3]; + tActiveSample m_asSamples[2][27]; + uint8 m_abSampleQueueIndexTable[2][27]; + uint8 m_bSampleRequestQueuesStatus[2]; + tActiveSample m_asActiveSamples[27]; + tAudioEntity m_asAudioEntities[200]; + int32 m_anAudioEntityIndices[200]; + int32 m_nAudioEntitiesTotal; + CVector m_avecReflectionsPos[5]; + float m_afReflectionsDistances[5]; + int32 m_anScriptObjectEntityIndices[40]; + int32 m_nScriptObjectEntityTotal; + cPedComments m_sPedComments; + int32 m_nFireAudioEntity; + int32 m_nWaterCannonEntity; + int32 m_nPoliceChannelEntity; + uint8 gap45B8[444]; + int32 m_nFrontEndEntity; + int32 m_nCollisionEntity; + cAudioCollisionManager m_sCollisionManager; + int32 m_nProjectileEntity; + int32 m_nBridgeEntity; + cMissionAudio m_sMissionAudio; + int32 m_anRandomTable[5]; + uint8 field_19192; + uint8 m_bUserPause; + uint8 m_bPreviousUserPause; + uint8 field_19195; // time? + uint32 m_FrameCounter; + + // getters + uint32 GetFrameCounter() const { return m_FrameCounter; } + float GetReflectionsDistance(int32 idx) const { return m_afReflectionsDistances[idx]; } + int32 GetRandomTabe(int32 idx) const { return m_anRandomTable[idx]; } + + // "Should" be in alphabetic order, except "getXTalkSfx" + void AddDetailsToRequestedOrderList(uint8 sample); /// ok + void AddPlayerCarSample(uint8 emittingVolume, int32 freq, uint32 sample, uint8 unk1, + uint8 counter, bool notLooping); /// ok + void AddReflectionsToRequestedQueue(); /// ok (check value) + void AddReleasingSounds(); // todo (difficult) + void AddSampleToRequestedQueue(); /// ok + void AgeCrimes(); // todo + + void CalculateDistance(bool *ptr, float dist); /// ok + bool CheckForAnAudioFileOnCD() const; /// ok + void ClearMissionAudio(); /// ok + void ClearRequestedQueue(); /// ok + int32 ComputeDopplerEffectedFrequency(uint32 oldFreq, float position1, float position2, + float speedMultiplier) const; /// ok + int32 ComputePan(float, CVector *); // todo + uint32 ComputeVolume(int emittingVolume, float soundIntensity, float distance) const; /// ok + int32 CreateEntity(int32 type, CPhysical *entity); /// ok + + void DestroyAllGameCreatedEntities(); /// ok + void DestroyEntity(int32 id); /// ok + void DoJumboVolOffset() const; /// ok + void DoPoliceRadioCrackle(); /// ok + + // functions returning talk sfx, + // order from GetPedCommentSfx + uint32 GetPlayerTalkSfx(int16 sound); + uint32 GetCopTalkSfx(int16 sound); + uint32 GetSwatTalkSfx(int16 sound); + uint32 GetFBITalkSfx(int16 sound); + uint32 GetArmyTalkSfx(int16 sound); + uint32 GetMedicTalkSfx(int16 sound); + uint32 GetFiremanTalkSfx(int16 sound); + uint32 GetNormalMaleTalkSfx(int16 sound); + uint32 GetTaxiDriverTalkSfx(int16 sound); + uint32 GetPimpTalkSfx(int16 sound); + uint32 GetMafiaTalkSfx(int16 sound); + uint32 GetTriadTalkSfx(int16 sound); + uint32 GetDiabloTalkSfx(int16 sound); + uint32 GetYakuzaTalkSfx(int16 sound); + uint32 GetYardieTalkSfx(int16 sound); + uint32 GetColumbianTalkSfx(int16 sound); + uint32 GetHoodTalkSfx(int16 sound); + uint32 GetBlackCriminalTalkSfx(int16 sound); + uint32 GetWhiteCriminalTalkSfx(int16 sound); + uint32 GetMaleNo2TalkSfx(int16 sound); + uint32 GetBlackProjectMaleTalkSfx(int16 sound, int32 model); + uint32 GetWhiteFatMaleTalkSfx(int16 sound); + uint32 GetBlackFatMaleTalkSfx(int16 sound); + uint32 GetBlackCasualFemaleTalkSfx(int16 sound); + uint32 GetWhiteCasualFemaleTalkSfx(int16 sound); + uint32 GetFemaleNo3TalkSfx(int16 sound); + uint32 GetBlackFatFemaleTalkSfx(int16 sound); + uint32 GetWhiteFatFemaleTalkSfx(int16 sound); + uint32 GetBlackFemaleProstituteTalkSfx(int16 sound); + uint32 GetWhiteFemaleProstituteTalkSfx(int16 sound); + uint32 GetBlackProjectFemaleOldTalkSfx(int16 sound); + uint32 GetBlackProjectFemaleYoungTalkSfx(int16 sound); + uint32 GetChinatownMaleOldTalkSfx(int16 sound); + uint32 GetChinatownMaleYoungTalkSfx(int16 sound); + uint32 GetChinatownFemaleOldTalkSfx(int16 sound); + uint32 GetChinatownFemaleYoungTalkSfx(int16 sound); + uint32 GetLittleItalyMaleTalkSfx(int16 sound); + uint32 GetLittleItalyFemaleOldTalkSfx(int16 sound); + uint32 GetLittleItalyFemaleYoungTalkSfx(int16 sound); + uint32 GetWhiteDockerMaleTalkSfx(int16 sound); + uint32 GetBlackDockerMaleTalkSfx(int16 sound); + uint32 GetScumMaleTalkSfx(int16 sound); + uint32 GetScumFemaleTalkSfx(int16 sound); + uint32 GetWhiteWorkerMaleTalkSfx(int16 sound); + uint32 GetBlackWorkerMaleTalkSfx(int16 sound); + uint32 GetBusinessMaleYoungTalkSfx(int16 sound, int32 model); + uint32 GetBusinessMaleOldTalkSfx(int16 sound); + uint32 GetWhiteBusinessFemaleTalkSfx(int16 sound, int32 model); + uint32 GetBlackBusinessFemaleTalkSfx(int16 sound); + uint32 GetSupermodelMaleTalkSfx(int16 sound); + uint32 GetSupermodelFemaleTalkSfx(int16 sound); + uint32 GetStewardMaleTalkSfx(int16 sound); + uint32 GetStewardFemaleTalkSfx(int16 sound); + uint32 GetFanMaleTalkSfx(int16 sound, int32 model); + uint32 GetFanFemaleTalkSfx(int16 sound); + uint32 GetHospitalMaleTalkSfx(int16 sound); + uint32 GetHospitalFemaleTalkSfx(int16 sound); + uint32 GetWhiteConstructionWorkerTalkSfx(int16 sound); + uint32 GetBlackConstructionWorkerTalkSfx(int16 sound); + uint32 GetShopperFemaleTalkSfx(int16 sound, int32 model); + uint32 GetStudentMaleTalkSfx(int16 sound); + uint32 GetStudentFemaleTalkSfx(int16 sound); + uint32 GetCasualMaleOldTalkSfx(int16 sound); + + uint32 GetSpecialCharacterTalkSfx(int32 modelIndex, int32 sound); + uint32 GetEightTalkSfx(int16 sound); + uint32 GetFrankieTalkSfx(int16 sound); + uint32 GetMistyTalkSfx(int16 sound); + uint32 GetOJGTalkSfx(int16 sound); + uint32 GetCatatalinaTalkSfx(int16 sound); + uint32 GetBomberTalkSfx(int16 sound); + uint32 GetSecurityGuardTalkSfx(int16 sound); + uint32 GetChunkyTalkSfx(int16 sound); + + uint32 GetGenericMaleTalkSfx(int16 sound); + uint32 GetGenericFemaleTalkSfx(int16 sound); + // end of functions returning talk sfx + + void GenerateIntegerRandomNumberTable(); /// ok + char *Get3DProviderName(uint8 id) const; + uint8 GetCDAudioDriveLetter() const; + int8 GetCurrent3DProviderIndex() const; /// ok + float GetCollisionLoopingRatio(uint32 a, uint32 b, float c) const; // not used + float GetCollisionOneShotRatio(uint32 a, float b) const; /// ok + float GetCollisionRatio(float a, float b, float c, float d) const; /// ok + float GetDistanceSquared(CVector *v) const; /// ok + int32 GetJumboTaxiFreq() const; /// ok + bool GetMissionAudioLoadingStatus() const; /// ok + char GetMissionScriptPoliceAudioPlayingStatus() const; /// ok + uint8 GetNum3DProvidersAvailable() const; + int32 GetPedCommentSfx(CPed *ped, int32 sound); + void GetPhrase(uint32 *phrase, uint32 *prevPhrase, uint32 sample, uint32 maxOffset) const; + float GetVehicleDriveWheelSkidValue(uint8 a1, CAutomobile *a2, cTransmission *a3, + float a4); // todo + int32 GetVehicleNonDriveWheelSkidValue(float a1, int a2, int a3, int a4, float a5); // todo + + bool HasAirBrakes(int32 model) const; /// ok + + void Initialise(); /// ok + void InitialisePoliceRadio(); // todo + void InitialisePoliceRadioZones(); // todo + void InterrogateAudioEntities(); /// ok + bool IsAudioInitialised() const; /// ok + bool IsMissionAudioSampleFinished(); /// ok + bool IsMP3RadioChannelAvailable() const; + + bool MissionScriptAudioUsesPoliceChannel(int32 soundMission) const; /// ok + + void PlayLoadedMissionAudio(); /// ok + void PlayOneShot(int32 index, int16 sound, float vol); // todo + uint32 PlaySuspectLastSeen(float x, float y, float z); // todo + void PlayerJustGotInCar() const; /// ok + void PlayerJustLeftCar() const; /// ok + void PostInitialiseGameSpecificSetup(); /// ok + void PostTerminateGameSpecificShutdown(); /// ok + void PreInitialiseGameSpecificSetup() const; + void PreloadMissionAudio(char *); // todo + void PreTerminateGameSpecificShutdown(); /// ok + /// processX - main logic of adding new sounds + void ProcessActiveQueues(); // todo + bool ProcessAirBrakes(cVehicleParams *params); /// ok + void ProcessAirportScriptObject(uint8 sound); /// ok + bool ProcessBoatEngine(cVehicleParams *params); /// ok + bool ProcessBoatMovingOverWater(cVehicleParams *params); /// ok + void ProcessBridge(); /// ok + void ProcessBridgeMotor(); /// ok + void ProcessBridgeOneShots(); /// ok + void ProcessBridgeWarning(); /// ok + bool ProcessCarBombTick(cVehicleParams *params); /// ok + void ProcessCesna(void *); // todo requires CPlane + void ProcessCinemaScriptObject(uint8 sound); /// ok + void ProcessCrane(); // todo requires CCrane + void ProcessDocksScriptObject(uint8 sound); /// ok + bool ProcessEngineDamage(cVehicleParams *params); /// ok + void ProcessEntity(int32 sound); /// ok + void ProcessExplosions(int32 explosion); /// ok + void ProcessFireHydrant(); /// ok + void ProcessFires(int32 entity); // todo requires gFireManager + void ProcessFrontEnd(); /// ok + void ProcessGarages(); // todo requires CGarages::aGarages + bool ProcessHelicopter(cVehicleParams *params); /// ok + void ProcessHomeScriptObject(uint8 sound); /// ok + void ProcessJumbo(cVehicleParams *); /// ok + void ProcessJumboAccel(CPlane *plane); /// ok + void ProcessJumboDecel(CPlane *plane); /// ok + void ProcessJumboFlying(); /// ok + void ProcessJumboLanding(CPlane *plane); /// ok + void ProcessJumboTakeOff(CPlane *plane); /// ok + void ProcessJumboTaxi(); /// ok + void ProcessLaunderetteScriptObject(uint8 sound); /// ok + void ProcessLoopingScriptObject(uint8 sound); /// ok + void ProcessMissionAudio(); /// ok + void ProcessModelCarEngine(cVehicleParams *params); /// ok (check float comparisons) + void ProcessOneShotScriptObject(uint8 sound); /// ok + void ProcessPed(CPhysical *ped); /// ok + void ProcessPedHeadphones(cPedParams *params); /// ok + void ProcessPedOneShots(cPedParams *params); // todo later (weird) + void ProcessPhysical(int32 id); /// ok + void ProcessPlane(cVehicleParams *params); /// ok + void ProcessPlayersVehicleEngine(cVehicleParams *params, + CAutomobile *automobile); /// ok (check float comparisons) + void ProcessPoliceCellBeatingScriptObject(uint8 sound); // todo + void ProcessPornCinema(uint8 sound); /// ok + void ProcessProjectiles(); // todo requires CProjectileInfo + void ProcessRainOnVehicle(cVehicleParams *params); /// ok + void ProcessReverb() const; /// ok + bool ProcessReverseGear(cVehicleParams *a2); /// ok + void ProcessSawMillScriptObject(uint8 sound); /// ok + void ProcessScriptObject(int32 id); /// ok + void ProcessShopScriptObject(uint8 sound); /// ok + void ProcessSpecial(); /// ok + bool ProcessTrainNoise(cVehicleParams *params); /// ok + void ProcessVehicle(CVehicle *); // todo + bool ProcessVehicleDoors(cVehicleParams *params); /// ok + // bool ProcessVehicleEngine(void *); + // void ProcessVehicleHorn(cVehicleParams *params); + // void ProcessVehicleOneShots(void *); + bool ProcessVehicleReverseWarning(cVehicleParams *params); /// ok + bool ProcessVehicleRoadNoise(cVehicleParams *params); /// ok + // void ProcessVehicleSirenOrAlarm(void *); + // void ProcessVehicleSkidding(void *); + void ProcessWaterCannon(int32); // todo + void ProcessWeather(int32 id); /// ok + bool ProcessWetRoadNoise(cVehicleParams *params); /// ok + void ProcessWorkShopScriptObject(uint8 sound); /// ok + + int32 RandomDisplacement(uint32 seed) const; + void ReacquireDigitalHandle() const; + void ReleaseDigitalHandle() const; + int32 ReportCollision(CEntity *a2, CEntity *a3, uint8 a4, uint8 a5, float a6, + float a7); // todo + int32 ReportCrime(int a2, int *a3); // todo + void ResetAudioLogicTimers(int32 timer); /// ok + void ResetPoliceRadio(); + void ResetTimers(unsigned int a2); // todo + + void Service(); // todo + void ServiceCollisions(); // todo + void ServicePoliceRadio(); // todo + void ServicePoliceRadioChannel(int a2); // todo + void ServiceSoundEffects(); // todo + void SetDynamicAcousticModelingStatus(bool status); + void SetEffectsFadeVolume(uint8 volume) const; + void SetEffectsMasterVolume(uint8 volume) const; + void SetEntityStatus(int32 id, bool status); + uint32 SetLoopingCollisionRequestedSfxFreqAndGetVol(int32); // todo + void SetMissionAudioLocation(float x, float y, float z); + void SetMissionScriptPoliceAudio(int32 sfx) const; + void SetMonoMode(uint8); // todo + void SetMusicFadeVolume(uint8 volume) const; + void SetMusicMasterVolume(uint8 volume) const; + void SetSpeakerConfig(int32 conf) const; + void SetUpLoopingCollisionSound(int a2, int a3); // todo + void SetUpOneShotCollisionSound(int a2); // todo + void SetupCrimeReport(); // todo + bool SetupJumboEngineSound(uint8, int32); // todo + bool SetupJumboFlySound(uint8 emittingVol); /// ok + bool SetupJumboRumbleSound(uint8 emittingVol); /// ok + bool SetupJumboTaxiSound(uint8 vol); /// ok + bool SetupJumboWhineSound(uint8 emittingVol, int32 freq); /// ok + void SetupPedComments(cPedParams *params, uint32 sound); /// ok + void SetupSuspectLastSeenReport(); // todo + + void Terminate(); + void TranslateEntity(CVector *v1, CVector *v2) const; /// ok + + void UpdateGasPedalAudio(CAutomobile *automobile); // todo hook + bool UsesReverseWarning(int32 model) const; + bool UsesSiren(int32 model) const; + bool UsesSirenSwitching(int32 model) const; +}; + +static_assert(sizeof(cAudioManager) == 19220, "cAudioManager: error"); + +extern cAudioManager &AudioManager; diff --git a/src/audio/DMAudio.cpp b/src/audio/DMAudio.cpp index 076c1178..08ec3bc5 100644 --- a/src/audio/DMAudio.cpp +++ b/src/audio/DMAudio.cpp @@ -31,7 +31,7 @@ cDMAudio::Service(void) int32 cDMAudio::CreateEntity(eAudioType type, void *UID) { - return AudioManager.CreateEntity(type, UID); + return AudioManager.CreateEntity(type, (CPhysical *)UID); } void @@ -82,7 +82,7 @@ cDMAudio::SetEffectsFadeVol(uint8 volume) uint8 vol = volume; if ( vol > MAX_VOLUME ) vol = MAX_VOLUME; - AudioManager.SetEffectsFadeVol(vol); + AudioManager.SetEffectsFadeVolume(vol); } void @@ -91,7 +91,7 @@ cDMAudio::SetMusicFadeVol(uint8 volume) uint8 vol = volume; if ( vol > MAX_VOLUME ) vol = MAX_VOLUME; - AudioManager.SetMusicFadeVol(vol); + AudioManager.SetMusicFadeVolume(vol); } uint8 @@ -169,13 +169,13 @@ cDMAudio::IsAudioInitialised(void) void cDMAudio::ReportCrime(eCrimeType crime, CVector const &pos) { - AudioManager.ReportCrime(crime, pos); + AudioManager.ReportCrime(crime, &pos); } int32 cDMAudio::CreateLoopingScriptObject(cAudioScriptObject *scriptObject) { - int32 audioEntity = AudioManager.CreateEntity(AUDIOTYPE_SCRIPTOBJECT, scriptObject); + int32 audioEntity = AudioManager.CreateEntity(AUDIOTYPE_SCRIPTOBJECT, (CPhysical *)scriptObject); if ( AEHANDLE_IS_OK(audioEntity) ) AudioManager.SetEntityStatus(audioEntity, true); @@ -192,7 +192,7 @@ cDMAudio::DestroyLoopingScriptObject(int32 audioEntity) void cDMAudio::CreateOneShotScriptObject(cAudioScriptObject *scriptObject) { - int32 audioEntity = AudioManager.CreateEntity(AUDIOTYPE_SCRIPTOBJECT, scriptObject); + int32 audioEntity = AudioManager.CreateEntity(AUDIOTYPE_SCRIPTOBJECT, (CPhysical *)scriptObject); if ( AEHANDLE_IS_OK(audioEntity) ) { -- cgit v1.2.3 From 5a36d466929ac9ba5612d577904773e3bd58bfe5 Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Tue, 27 Aug 2019 22:46:41 +0200 Subject: Audio fixes --- src/audio/AudioManager.cpp | 42 ++- src/audio/AudioManager.h | 12 +- src/audio/AudioManager.h.autosave | 549 -------------------------------------- src/audio/DMAudio.cpp | 5 +- src/audio/DMAudio.h | 3 + src/audio/sampman.cpp | 35 ++- 6 files changed, 70 insertions(+), 576 deletions(-) delete mode 100644 src/audio/AudioManager.h.autosave (limited to 'src/audio') diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index 1e4b9c3b..d32d4207 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -498,7 +498,7 @@ cAudioManager::CreateEntity(int32 type, CPhysical *entity) m_asAudioEntities[i].m_bIsUsed = true; m_asAudioEntities[i].m_bStatus = 0; m_asAudioEntities[i].m_nType = (eAudioType)type; - m_asAudioEntities[i].m_pEntity = (void*)entity; + m_asAudioEntities[i].m_pEntity = (void *)entity; m_asAudioEntities[i].m_awAudioEvent[0] = SOUND_TOTAL_PED_SOUNDS; m_asAudioEntities[i].m_awAudioEvent[1] = SOUND_TOTAL_PED_SOUNDS; m_asAudioEntities[i].m_awAudioEvent[2] = SOUND_TOTAL_PED_SOUNDS; @@ -2823,7 +2823,6 @@ cAudioManager::GetNum3DProvidersAvailable() const return 0; } - int32 cAudioManager::GetPedCommentSfx(CPed *ped, int32 sound) { @@ -3038,6 +3037,13 @@ cAudioManager::PlayOneShot(int32 index, int16 sound, float vol) EAXJMP(0x57A500); } +WRAPPER +uint32 +cAudioManager::PlaySuspectLastSeen(float x, float y, float z) +{ + EAXJMP(0x580500); +} + void cAudioManager::PlayerJustGotInCar() const { @@ -3092,7 +3098,6 @@ cAudioManager::PostTerminateGameSpecificShutdown() ; } - void cAudioManager::PreInitialiseGameSpecificSetup() const { @@ -3100,6 +3105,13 @@ cAudioManager::PreInitialiseGameSpecificSetup() const BankStartOffset[1] = AUDIO_SAMPLE_POLICE_COP_1_ARREST_1; } +WRAPPER +void +cAudioManager::PreloadMissionAudio(char *) +{ + EAXJMP(0x579550); +} + void cAudioManager::PreTerminateGameSpecificShutdown() { @@ -7790,6 +7802,20 @@ cAudioManager::ReleaseDigitalHandle() const if(m_bIsInitialised) { SampleManager.ReleaseDigitalHandle(); } } +WRAPPER +int32 +cAudioManager::ReportCollision(CEntity *a2, CEntity *a3, uint8 a4, uint8 a5, float a6, float a7) +{ + EAXJMP(0x568410); +} + +WRAPPER +int32 +cAudioManager::ReportCrime(eCrimeType crime, const CVector *pos) +{ + EAXJMP(0x5803D0); +} + void cAudioManager::ResetAudioLogicTimers(int32 timer) { @@ -7824,12 +7850,21 @@ cAudioManager::ResetPoliceRadio() } } +WRAPPER +void +cAudioManager::ResetTimers(uint32 a2) +{ + EAXJMP(0x57A7B0); +} + WRAPPER void cAudioManager::Service() { EAXJMP(0x57A2A0); } +WRAPPER +int8 cAudioManager::SetCurrent3DProvider(uint8) { EAXJMP(0x57A910); } void cAudioManager::SetDynamicAcousticModelingStatus(bool status) @@ -7891,7 +7926,6 @@ cAudioManager::SetMusicMasterVolume(uint8 volume) const SampleManager.SetMusicMasterVolume(volume); } - void cAudioManager::SetSpeakerConfig(int32 conf) const { diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index c765bfd4..fb462e94 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -502,18 +502,18 @@ public: void ReacquireDigitalHandle() const; void ReleaseDigitalHandle() const; int32 ReportCollision(CEntity *a2, CEntity *a3, uint8 a4, uint8 a5, float a6, - float a7); // todo - int32 ReportCrime(int a2, int *a3); // todo - void ResetAudioLogicTimers(int32 timer); /// ok - void ResetPoliceRadio(); - void ResetTimers(unsigned int a2); // todo + float a7); // todo + int32 ReportCrime(eCrimeType crime, const CVector *pos); // todo + void ResetAudioLogicTimers(int32 timer); /// ok + void ResetPoliceRadio(); /// ok + void ResetTimers(uint32 a2); // todo void Service(); // todo void ServiceCollisions(); // todo void ServicePoliceRadio(); // todo void ServicePoliceRadioChannel(int a2); // todo void ServiceSoundEffects(); // todo - void SetCurrent3DProvider(uint8); + int8 SetCurrent3DProvider(uint8); // todo void SetDynamicAcousticModelingStatus(bool status); void SetEffectsFadeVolume(uint8 volume) const; void SetEffectsMasterVolume(uint8 volume) const; diff --git a/src/audio/AudioManager.h.autosave b/src/audio/AudioManager.h.autosave deleted file mode 100644 index 2ea78476..00000000 --- a/src/audio/AudioManager.h.autosave +++ /dev/null @@ -1,549 +0,0 @@ -#pragma once - -#include "AudioSamples.h" -#include "DMAudio.h" -#include "common.h" - -class tActiveSample -{ -public: - int32 m_nEntityIndex; - int32 m_counter; - int32 m_nSampleIndex; - uint8 m_bBankIndex; - uint8 m_bIsDistant; - uint8 field_14; - uint8 field_15; - int32 field_16; - int32 m_nFrequency; - uint8 m_bVolume; - uint8 field_25; - uint8 field_26; - uint8 field_27; - float m_fDistance; - int32 m_nLoopCount; - int32 m_nLoopStart; - int32 m_nLoopEnd; - uint8 m_bEmittingVolume; - uint8 field_45; - uint8 field_46; - uint8 field_47; - float field_48; - float m_fSoundIntensity; - uint8 field_56; - uint8 field_57; - uint8 field_58; - uint8 field_59; - CVector m_vecPos; - uint8 m_bReverbFlag; - uint8 m_bLoopsRemaining; - uint8 m_bRequireReflection; - uint8 m_bOffset; - int32 field_76; - uint8 m_bIsProcessed; - uint8 m_bLoopEnded; - uint8 field_82; - uint8 field_83; - int32 calculatedVolume; - uint8 field_88; - uint8 field_89; - uint8 field_90; - uint8 field_91; - - // no methods -}; - -static_assert(sizeof(tActiveSample) == 92, "tActiveSample: error"); - -enum eAudioType : int32 { - AUDIOTYPE_PHYSICAL = 0, - AUDIOTYPE_EXPLOSION = 1, - AUDIOTYPE_FIRE = 2, - AUDIOTYPE_WEATHER = 3, - AUDIOTYPE_CRANE = 4, - AUDIOTYPE_SCRIPTOBJECT = 5, - AUDIOTYPE_BRIDGE = 6, - AUDIOTYPE_COLLISION = 7, - AUDIOTYPE_FRONTEND = 8, - AUDIOTYPE_PROJECTILE = 9, - AUDIOTYPE_GARAGE = 10, - AUDIOTYPE_FIREHYDRANT = 11, - AUDIOTYPE_WATERCANNON = 12, - AUDIOTYPE_POLICERADIO = 13, - TOTAL_AUDIO_TYPES = 14, -}; - -class CPhysical; -class CAutomobile; - -class tAudioEntity -{ -public: - eAudioType m_nType; - void *m_pEntity; - bool m_bIsUsed; - uint8 m_bStatus; - int16 m_awAudioEvent[4]; - uint8 gap_18[2]; - float m_afVolume[4]; - uint8 m_Loops; - uint8 field_25[3]; - - // no methods -}; - -static_assert(sizeof(tAudioEntity) == 40, "tAudioEntity: error"); - -class tPedComment -{ -public: - int32 m_nSampleIndex; - int32 m_entityIndex; - CVector m_vecPos; - float m_fDistance; - uint8 m_bVolume; - int8 field_25; // allocated time? - uint8 gap_26[2]; - - // no methods -}; - -static_assert(sizeof(tPedComment) == 28, "tPedComment: error"); - -class cPedComments -{ -public: - tPedComment m_asPedComments[2][20]; - uint8 indexMap[2][20]; - uint8 nrOfCommentsInBank[2]; - uint8 activeBank; - uint8 gap_1163[1]; - - // reversed all methods - void Add(tPedComment *com); /// ok - void Process(); /// ok -}; - -static_assert(sizeof(cPedComments) == 1164, "cPedComments: error"); - -class CEntity; - -class cAudioCollision -{ -public: - CEntity *m_pEntity1; - CEntity *m_pEntity2; - uint8 m_bSurface1; - uint8 m_bSurface2; - uint8 field_10; - uint8 field_11; - float m_fIntensity1; - float m_fIntensity2; - CVector m_vecPosition; - float m_fDistance; - int32 m_nBaseVolume; - - // no methods -}; - -static_assert(sizeof(cAudioCollision) == 40, "cAudioCollision: error"); - -class cAudioCollisionManager -{ -public: - cAudioCollision m_asCollisions1[10]; - cAudioCollision m_asCollisions2[10]; - uint8 m_bIndicesTable[10]; - uint8 m_bCollisionsInQueue; - uint8 gap_811; - cAudioCollision m_sQueue; - - void AddCollisionToRequestedQueue(); // todo -}; - -static_assert(sizeof(cAudioCollisionManager) == 852, "cAudioCollisionManager: error"); - -class cMissionAudio -{ -public: - CVector m_vecPos; - uint8 field_12; - uint8 gap_13[3]; - int m_nSampleIndex; - uint8 m_bLoadingStatus; - uint8 m_bPlayStatus; - uint8 field_22; - uint8 field_23; - int field_24; - bool m_bIsPlayed; - uint8 field_29; - uint8 field_30; - uint8 field_31; - // no methods -}; - -static_assert(sizeof(cMissionAudio) == 32, "cMissionAudio: error"); - -class cVehicleParams; -class CPlane; -class CVehicle; -class CPed; -class cPedParams; -class cTransmission; - -class cAudioScriptObject { -public: - int16 AudioId; - char _pad0[2]; - CVector Posn; - int32 AudioEntity; - - static void *operator new(size_t); - static void *operator new(size_t, int); - static void operator delete(void *, size_t); - static void operator delete(void *, int); -}; - -static_assert(sizeof(cAudioScriptObject) == 20, "cAudioScriptObject: error"); - -enum { - /* - REFLECTION_YMAX = 0, top - REFLECTION_YMIN = 1, bottom - REFLECTION_XMIN = 2, left - REFLECTION_XMAX = 3, right - REFLECTION_ZMAX = 4, - */ - - REFLECTION_TOP = 0, - REFLECTION_BOTTOM, - REFLECTION_LEFT, - REFLECTION_RIGHT, - REFLECTION_UP, - MAX_REFLECTIONS, -}; - -enum AudioEntityHandle -{ - AEHANDLE_NONE = -5, - AEHANDLE_ERROR_NOAUDIOSYS = -4, - AEHANDLE_ERROR_NOFREESLOT = -3, - AEHANDLE_ERROR_NOENTITY = -2, - AEHANDLE_ERROR_BADAUDIOTYPE = -1, -}; - -class cAudioManager -{ -public: - bool m_bIsInitialised; - uint8 field_1; - uint8 field_2; - uint8 m_bActiveSamples; - uint8 field_4; - bool m_bDynamicAcousticModelingStatus; - uint8 field_6; - uint8 field_7; - float speedOfSound; - bool m_bTimerJustReset; - uint8 field_13; - uint8 field_14; - uint8 field_15; - int32 m_nTimer; - tActiveSample m_sQueueSample; - uint8 m_bActiveSampleQueue; - uint8 gap_109[3]; - tActiveSample m_asSamples[2][27]; - uint8 m_abSampleQueueIndexTable[2][27]; - uint8 m_bSampleRequestQueuesStatus[2]; - tActiveSample m_asActiveSamples[27]; - tAudioEntity m_asAudioEntities[200]; - int32 m_anAudioEntityIndices[200]; - int32 m_nAudioEntitiesTotal; - CVector m_avecReflectionsPos[5]; - float m_afReflectionsDistances[5]; - int32 m_anScriptObjectEntityIndices[40]; - int32 m_nScriptObjectEntityTotal; - cPedComments m_sPedComments; - int32 m_nFireAudioEntity; - int32 m_nWaterCannonEntity; - int32 m_nPoliceChannelEntity; - uint8 gap45B8[444]; - int32 m_nFrontEndEntity; - int32 m_nCollisionEntity; - cAudioCollisionManager m_sCollisionManager; - int32 m_nProjectileEntity; - int32 m_nBridgeEntity; - cMissionAudio m_sMissionAudio; - int32 m_anRandomTable[5]; - uint8 field_19192; - uint8 m_bUserPause; - uint8 m_bPreviousUserPause; - uint8 field_19195; // time? - uint32 m_FrameCounter; - - // getters - uint32 GetFrameCounter() const { return m_FrameCounter; } - float GetReflectionsDistance(int32 idx) const { return m_afReflectionsDistances[idx]; } - int32 GetRandomTabe(int32 idx) const { return m_anRandomTable[idx]; } - - // "Should" be in alphabetic order, except "getXTalkSfx" - void AddDetailsToRequestedOrderList(uint8 sample); /// ok - void AddPlayerCarSample(uint8 emittingVolume, int32 freq, uint32 sample, uint8 unk1, - uint8 counter, bool notLooping); /// ok - void AddReflectionsToRequestedQueue(); /// ok (check value) - void AddReleasingSounds(); // todo (difficult) - void AddSampleToRequestedQueue(); /// ok - void AgeCrimes(); // todo - - void CalculateDistance(bool *ptr, float dist); /// ok - bool CheckForAnAudioFileOnCD() const; /// ok - void ClearMissionAudio(); /// ok - void ClearRequestedQueue(); /// ok - int32 ComputeDopplerEffectedFrequency(uint32 oldFreq, float position1, float position2, - float speedMultiplier) const; /// ok - int32 ComputePan(float, CVector *); // todo - uint32 ComputeVolume(int emittingVolume, float soundIntensity, float distance) const; /// ok - int32 CreateEntity(int32 type, CPhysical *entity); /// ok - - void DestroyAllGameCreatedEntities(); /// ok - void DestroyEntity(int32 id); /// ok - void DoJumboVolOffset() const; /// ok - void DoPoliceRadioCrackle(); /// ok - - // functions returning talk sfx, - // order from GetPedCommentSfx - uint32 GetPlayerTalkSfx(int16 sound); - uint32 GetCopTalkSfx(int16 sound); - uint32 GetSwatTalkSfx(int16 sound); - uint32 GetFBITalkSfx(int16 sound); - uint32 GetArmyTalkSfx(int16 sound); - uint32 GetMedicTalkSfx(int16 sound); - uint32 GetFiremanTalkSfx(int16 sound); - uint32 GetNormalMaleTalkSfx(int16 sound); - uint32 GetTaxiDriverTalkSfx(int16 sound); - uint32 GetPimpTalkSfx(int16 sound); - uint32 GetMafiaTalkSfx(int16 sound); - uint32 GetTriadTalkSfx(int16 sound); - uint32 GetDiabloTalkSfx(int16 sound); - uint32 GetYakuzaTalkSfx(int16 sound); - uint32 GetYardieTalkSfx(int16 sound); - uint32 GetColumbianTalkSfx(int16 sound); - uint32 GetHoodTalkSfx(int16 sound); - uint32 GetBlackCriminalTalkSfx(int16 sound); - uint32 GetWhiteCriminalTalkSfx(int16 sound); - uint32 GetMaleNo2TalkSfx(int16 sound); - uint32 GetBlackProjectMaleTalkSfx(int16 sound, int32 model); - uint32 GetWhiteFatMaleTalkSfx(int16 sound); - uint32 GetBlackFatMaleTalkSfx(int16 sound); - uint32 GetBlackCasualFemaleTalkSfx(int16 sound); - uint32 GetWhiteCasualFemaleTalkSfx(int16 sound); - uint32 GetFemaleNo3TalkSfx(int16 sound); - uint32 GetBlackFatFemaleTalkSfx(int16 sound); - uint32 GetWhiteFatFemaleTalkSfx(int16 sound); - uint32 GetBlackFemaleProstituteTalkSfx(int16 sound); - uint32 GetWhiteFemaleProstituteTalkSfx(int16 sound); - uint32 GetBlackProjectFemaleOldTalkSfx(int16 sound); - uint32 GetBlackProjectFemaleYoungTalkSfx(int16 sound); - uint32 GetChinatownMaleOldTalkSfx(int16 sound); - uint32 GetChinatownMaleYoungTalkSfx(int16 sound); - uint32 GetChinatownFemaleOldTalkSfx(int16 sound); - uint32 GetChinatownFemaleYoungTalkSfx(int16 sound); - uint32 GetLittleItalyMaleTalkSfx(int16 sound); - uint32 GetLittleItalyFemaleOldTalkSfx(int16 sound); - uint32 GetLittleItalyFemaleYoungTalkSfx(int16 sound); - uint32 GetWhiteDockerMaleTalkSfx(int16 sound); - uint32 GetBlackDockerMaleTalkSfx(int16 sound); - uint32 GetScumMaleTalkSfx(int16 sound); - uint32 GetScumFemaleTalkSfx(int16 sound); - uint32 GetWhiteWorkerMaleTalkSfx(int16 sound); - uint32 GetBlackWorkerMaleTalkSfx(int16 sound); - uint32 GetBusinessMaleYoungTalkSfx(int16 sound, int32 model); - uint32 GetBusinessMaleOldTalkSfx(int16 sound); - uint32 GetWhiteBusinessFemaleTalkSfx(int16 sound, int32 model); - uint32 GetBlackBusinessFemaleTalkSfx(int16 sound); - uint32 GetSupermodelMaleTalkSfx(int16 sound); - uint32 GetSupermodelFemaleTalkSfx(int16 sound); - uint32 GetStewardMaleTalkSfx(int16 sound); - uint32 GetStewardFemaleTalkSfx(int16 sound); - uint32 GetFanMaleTalkSfx(int16 sound, int32 model); - uint32 GetFanFemaleTalkSfx(int16 sound); - uint32 GetHospitalMaleTalkSfx(int16 sound); - uint32 GetHospitalFemaleTalkSfx(int16 sound); - uint32 GetWhiteConstructionWorkerTalkSfx(int16 sound); - uint32 GetBlackConstructionWorkerTalkSfx(int16 sound); - uint32 GetShopperFemaleTalkSfx(int16 sound, int32 model); - uint32 GetStudentMaleTalkSfx(int16 sound); - uint32 GetStudentFemaleTalkSfx(int16 sound); - uint32 GetCasualMaleOldTalkSfx(int16 sound); - - uint32 GetSpecialCharacterTalkSfx(int32 modelIndex, int32 sound); - uint32 GetEightTalkSfx(int16 sound); - uint32 GetFrankieTalkSfx(int16 sound); - uint32 GetMistyTalkSfx(int16 sound); - uint32 GetOJGTalkSfx(int16 sound); - uint32 GetCatatalinaTalkSfx(int16 sound); - uint32 GetBomberTalkSfx(int16 sound); - uint32 GetSecurityGuardTalkSfx(int16 sound); - uint32 GetChunkyTalkSfx(int16 sound); - - uint32 GetGenericMaleTalkSfx(int16 sound); - uint32 GetGenericFemaleTalkSfx(int16 sound); - // end of functions returning talk sfx - - void GenerateIntegerRandomNumberTable(); /// ok - char *Get3DProviderName(uint8 id) const; - uint8 GetCDAudioDriveLetter() const; - int8 GetCurrent3DProviderIndex() const; /// ok - float GetCollisionLoopingRatio(uint32 a, uint32 b, float c) const; // not used - float GetCollisionOneShotRatio(uint32 a, float b) const; /// ok - float GetCollisionRatio(float a, float b, float c, float d) const; /// ok - float GetDistanceSquared(CVector *v) const; /// ok - int32 GetJumboTaxiFreq() const; /// ok - bool GetMissionAudioLoadingStatus() const; /// ok - char GetMissionScriptPoliceAudioPlayingStatus() const; /// ok - uint8 GetNum3DProvidersAvailable() const; - int32 GetPedCommentSfx(CPed *ped, int32 sound); - void GetPhrase(uint32 *phrase, uint32 *prevPhrase, uint32 sample, uint32 maxOffset) const; - float GetVehicleDriveWheelSkidValue(uint8 a1, CAutomobile *a2, cTransmission *a3, - float a4); // todo - int32 GetVehicleNonDriveWheelSkidValue(float a1, int a2, int a3, int a4, float a5); // todo - - bool HasAirBrakes(int32 model) const; /// ok - - void Initialise(); /// ok - void InitialisePoliceRadio(); // todo - void InitialisePoliceRadioZones(); // todo - void InterrogateAudioEntities(); /// ok - bool IsAudioInitialised() const; /// ok - bool IsMissionAudioSampleFinished(); /// ok - bool IsMP3RadioChannelAvailable() const; - - bool MissionScriptAudioUsesPoliceChannel(int32 soundMission) const; /// ok - - void PlayLoadedMissionAudio(); /// ok - void PlayOneShot(int32 index, int16 sound, float vol); // todo - uint32 PlaySuspectLastSeen(float x, float y, float z); // todo - void PlayerJustGotInCar() const; /// ok - void PlayerJustLeftCar() const; /// ok - void PostInitialiseGameSpecificSetup(); /// ok - void PostTerminateGameSpecificShutdown(); /// ok - void PreInitialiseGameSpecificSetup() const; - void PreloadMissionAudio(char *); // todo - void PreTerminateGameSpecificShutdown(); /// ok - /// processX - main logic of adding new sounds - void ProcessActiveQueues(); // todo - bool ProcessAirBrakes(cVehicleParams *params); /// ok - void ProcessAirportScriptObject(uint8 sound); /// ok - bool ProcessBoatEngine(cVehicleParams *params); /// ok - bool ProcessBoatMovingOverWater(cVehicleParams *params); /// ok - void ProcessBridge(); /// ok - void ProcessBridgeMotor(); /// ok - void ProcessBridgeOneShots(); /// ok - void ProcessBridgeWarning(); /// ok - bool ProcessCarBombTick(cVehicleParams *params); /// ok - void ProcessCesna(void *); // todo requires CPlane - void ProcessCinemaScriptObject(uint8 sound); /// ok - void ProcessCrane(); // todo requires CCrane - void ProcessDocksScriptObject(uint8 sound); /// ok - bool ProcessEngineDamage(cVehicleParams *params); /// ok - void ProcessEntity(int32 sound); /// ok - void ProcessExplosions(int32 explosion); /// ok - void ProcessFireHydrant(); /// ok - void ProcessFires(int32 entity); // todo requires gFireManager - void ProcessFrontEnd(); /// ok - void ProcessGarages(); // todo requires CGarages::aGarages - bool ProcessHelicopter(cVehicleParams *params); /// ok - void ProcessHomeScriptObject(uint8 sound); /// ok - void ProcessJumbo(cVehicleParams *); /// ok - void ProcessJumboAccel(CPlane *plane); /// ok - void ProcessJumboDecel(CPlane *plane); /// ok - void ProcessJumboFlying(); /// ok - void ProcessJumboLanding(CPlane *plane); /// ok - void ProcessJumboTakeOff(CPlane *plane); /// ok - void ProcessJumboTaxi(); /// ok - void ProcessLaunderetteScriptObject(uint8 sound); /// ok - void ProcessLoopingScriptObject(uint8 sound); /// ok - void ProcessMissionAudio(); /// ok - void ProcessModelCarEngine(cVehicleParams *params); /// ok (check float comparisons) - void ProcessOneShotScriptObject(uint8 sound); /// ok - void ProcessPed(CPhysical *ped); /// ok - void ProcessPedHeadphones(cPedParams *params); /// ok - void ProcessPedOneShots(cPedParams *params); // todo later (weird) - void ProcessPhysical(int32 id); /// ok - void ProcessPlane(cVehicleParams *params); /// ok - void ProcessPlayersVehicleEngine(cVehicleParams *params, - CAutomobile *automobile); /// ok (check float comparisons) - void ProcessPoliceCellBeatingScriptObject(uint8 sound); // todo - void ProcessPornCinema(uint8 sound); /// ok - void ProcessProjectiles(); // todo requires CProjectileInfo - void ProcessRainOnVehicle(cVehicleParams *params); /// ok - void ProcessReverb() const; /// ok - bool ProcessReverseGear(cVehicleParams *a2); /// ok - void ProcessSawMillScriptObject(uint8 sound); /// ok - void ProcessScriptObject(int32 id); /// ok - void ProcessShopScriptObject(uint8 sound); /// ok - void ProcessSpecial(); /// ok - bool ProcessTrainNoise(cVehicleParams *params); /// ok - void ProcessVehicle(CVehicle *); // todo - bool ProcessVehicleDoors(cVehicleParams *params); /// ok - // bool ProcessVehicleEngine(void *); - // void ProcessVehicleHorn(cVehicleParams *params); - // void ProcessVehicleOneShots(void *); - bool ProcessVehicleReverseWarning(cVehicleParams *params); /// ok - bool ProcessVehicleRoadNoise(cVehicleParams *params); /// ok - // void ProcessVehicleSirenOrAlarm(void *); - // void ProcessVehicleSkidding(void *); - void ProcessWaterCannon(int32); // todo - void ProcessWeather(int32 id); /// ok - bool ProcessWetRoadNoise(cVehicleParams *params); /// ok - void ProcessWorkShopScriptObject(uint8 sound); /// ok - - int32 RandomDisplacement(uint32 seed) const; - void ReacquireDigitalHandle() const; - void ReleaseDigitalHandle() const; - int32 ReportCollision(CEntity *a2, CEntity *a3, uint8 a4, uint8 a5, float a6, - float a7); // todo - int32 ReportCrime(int a2, int *a3); // todo - void ResetAudioLogicTimers(int32 timer); /// ok - void ResetPoliceRadio(); - void ResetTimers(unsigned int a2); // todo - - void Service(); // todo - void ServiceCollisions(); // todo - void ServicePoliceRadio(); // todo - void ServicePoliceRadioChannel(int a2); // todo - void ServiceSoundEffects(); // todo - void SetDynamicAcousticModelingStatus(bool status); - void SetEffectsFadeVolume(uint8 volume) const; - void SetEffectsMasterVolume(uint8 volume) const; - void SetEntityStatus(int32 id, bool status); - uint32 SetLoopingCollisionRequestedSfxFreqAndGetVol(int32); // todo - void SetMissionAudioLocation(float x, float y, float z); - void SetMissionScriptPoliceAudio(int32 sfx) const; - void SetMonoMode(uint8); // todo - void SetMusicFadeVolume(uint8 volume) const; - void SetMusicMasterVolume(uint8 volume) const; - void SetSpeakerConfig(int32 conf) const; - void SetUpLoopingCollisionSound(int a2, int a3); // todo - void SetUpOneShotCollisionSound(int a2); // todo - void SetupCrimeReport(); // todo - bool SetupJumboEngineSound(uint8, int32); // todo - bool SetupJumboFlySound(uint8 emittingVol); /// ok - bool SetupJumboRumbleSound(uint8 emittingVol); /// ok - bool SetupJumboTaxiSound(uint8 vol); /// ok - bool SetupJumboWhineSound(uint8 emittingVol, int32 freq); /// ok - void SetupPedComments(cPedParams *params, uint32 sound); /// ok - void SetupSuspectLastSeenReport(); // todo - - void Terminate(); - void TranslateEntity(CVector *v1, CVector *v2) const; /// ok - - void UpdateGasPedalAudio(CAutomobile *automobile); // todo hook - bool UsesReverseWarning(int32 model) const; - bool UsesSiren(int32 model) const; - bool UsesSirenSwitching(int32 model) const; -}; - -static_assert(sizeof(cAudioManager) == 19220, "cAudioManager: error"); - -extern cAudioManager &AudioManager; diff --git a/src/audio/DMAudio.cpp b/src/audio/DMAudio.cpp index 08ec3bc5..82267858 100644 --- a/src/audio/DMAudio.cpp +++ b/src/audio/DMAudio.cpp @@ -7,9 +7,6 @@ cDMAudio &DMAudio = *(cDMAudio*)0x95CDBE; -#define AEHANDLE_IS_FAILED(h) ((h)<0) -#define AEHANDLE_IS_OK(h) ((h)>=0) - void cDMAudio::Initialise(void) { @@ -167,7 +164,7 @@ cDMAudio::IsAudioInitialised(void) } void -cDMAudio::ReportCrime(eCrimeType crime, CVector const &pos) +cDMAudio::ReportCrime(eCrimeType crime, const CVector &pos) { AudioManager.ReportCrime(crime, &pos); } diff --git a/src/audio/DMAudio.h b/src/audio/DMAudio.h index 0932e581..42dd9ef4 100644 --- a/src/audio/DMAudio.h +++ b/src/audio/DMAudio.h @@ -174,6 +174,9 @@ enum eSound : int16 SOUND_TOTAL_PED_SOUNDS = 167, }; +#define AEHANDLE_IS_FAILED(h) ((h)<0) +#define AEHANDLE_IS_OK(h) ((h)>=0) + class cAudioScriptObject; class CEntity; enum eCrimeType; diff --git a/src/audio/sampman.cpp b/src/audio/sampman.cpp index 58da6f64..de222493 100644 --- a/src/audio/sampman.cpp +++ b/src/audio/sampman.cpp @@ -158,14 +158,14 @@ release_existing() if ( opened_samples[i] ) { AIL_release_3D_sample_handle(opened_samples[i]); - opened_samples[i] = 0; + opened_samples[i] = NULL; } } if ( opened_provider ) { AIL_close_3D_provider(opened_provider); - opened_provider = 0; + opened_provider = NULL; } _fPrevEaxRatioDestination = 0.0f; @@ -879,7 +879,7 @@ cSampleManager::Initialise(void) _maxSamples = 0; - opened_provider = 0; + opened_provider = NULL; DIG = NULL; for ( int32 i = 0; i < MAXCHANNELS; i++ ) @@ -2020,9 +2020,10 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) { uint32 i = 0; + if ( !_bIsMp3Active ) goto FIND_MP3TRACK; + do { - if(_bIsMp3Active){ if ( ++_CurMP3Index >= nNumMP3s ) _CurMP3Index = 0; @@ -2058,15 +2059,21 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) AIL_pause_stream(mp3Stream[nStream], 0); return true; } - } - if(nPos > nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER]) position = 0; - - tMP3Entry *e; - if(!_GetMP3PosFromStreamPos(&position, &e)) { - if(e == NULL) { - nFile = 0; - goto PLAY_STREAMEDTRACK; - } + + goto NEXT_MP3TRACK; + +FIND_MP3TRACK: + if ( nPos > nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] ) + position = 0; + + tMP3Entry *e; + if ( !_GetMP3PosFromStreamPos(&position, &e) ) + { + if ( e == NULL ) + { + nFile = 0; + goto PLAY_STREAMEDTRACK; + } } if ( e->pLinkPath != NULL ) @@ -2090,12 +2097,14 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) return true; } +NEXT_MP3TRACK: _bIsMp3Active = false; } while ( ++i < nNumMP3s ); position = 0; nFile = 0; + goto PLAY_STREAMEDTRACK; } PLAY_STREAMEDTRACK: -- cgit v1.2.3