road noise

This commit is contained in:
Roman Masanin 2020-10-17 02:22:02 +03:00
parent 894a1ae93a
commit 97fc5224e7
2 changed files with 102 additions and 72 deletions

View file

@ -972,7 +972,7 @@ cAudioManager::ProcessModelCarEngine(cVehicleParams *params)
bool bool
cAudioManager::ProcessVehicleRoadNoise(cVehicleParams *params) cAudioManager::ProcessVehicleRoadNoise(cVehicleParams* params)
{ {
const float SOUND_INTENSITY = 95.0f; const float SOUND_INTENSITY = 95.0f;
@ -981,51 +981,66 @@ cAudioManager::ProcessVehicleRoadNoise(cVehicleParams *params)
float modificator; float modificator;
int sampleFreq; int sampleFreq;
float velocity; float velocity;
uint8 wheelsOnGround;
if (params->m_fDistance >= SQR(SOUND_INTENSITY)) if (params->m_fDistance >= SQR(SOUND_INTENSITY))
return false; return false;
if (params->m_pTransmission != nil) {
if (((CAutomobile*)params->m_pVehicle)->m_nDriveWheelsOnGround != 0) { if (params->m_fDistance >= SQR(SOUND_INTENSITY))
velocity = Abs(params->m_fVelocityChange); return false;
if (velocity > 0.0f) { switch (params->m_VehicleType) {
CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); case VEHICLE_TYPE_CAR:
emittingVol = 30.f * Min(1.f, velocity / (0.5f * params->m_pTransmission->fMaxVelocity)); wheelsOnGround = ((CAutomobile*)params->m_pVehicle)->m_nWheelsOnGround;
m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance); break;
if (m_sQueueSample.m_nVolume != 0) { case VEHICLE_TYPE_BIKE:
m_sQueueSample.m_nCounter = 0; wheelsOnGround = ((CBike*)params->m_pVehicle)->m_nWheelsOnGround;
m_sQueueSample.m_nBankIndex = SFX_BANK_0; break;
m_sQueueSample.m_bIs2D = false; default:
m_sQueueSample.m_nReleasingVolumeModificator = 3; wheelsOnGround = 4;
if (params->m_pVehicle->m_nSurfaceTouched == SURFACE_WATER) { break;
m_sQueueSample.m_nSampleIndex = SFX_BOAT_WATER_LOOP; }
freq = 6050 * emittingVol / 30 + 16000; if (params->m_pTransmission == nil || wheelsOnGround == 0)
} else { return true;
m_sQueueSample.m_nSampleIndex = SFX_ROAD_NOISE;
modificator = m_sQueueSample.m_fDistance / 190.f; velocity = Abs(params->m_fVelocityChange);
sampleFreq = SampleManager.GetSampleBaseFrequency(SFX_ROAD_NOISE); if (velocity > 0.0f) {
freq = (sampleFreq * modificator) + ((3 * sampleFreq) / 4); CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);
} emittingVol = 30.f * Min(1.f, velocity / (0.5f * params->m_pTransmission->fMaxVelocity));
m_sQueueSample.m_nFrequency = freq; m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance);
m_sQueueSample.m_nLoopCount = 0; if (m_sQueueSample.m_nVolume != 0) {
m_sQueueSample.m_nEmittingVolume = emittingVol; m_sQueueSample.m_nCounter = 0;
m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nBankIndex = SFX_BANK_0;
m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_fSpeedMultiplier = 6.0f; m_sQueueSample.m_nReleasingVolumeModificator = 3;
m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; if (params->m_pVehicle->m_nSurfaceTouched == SURFACE_WATER) {
m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_nSampleIndex = SFX_BOAT_WATER_LOOP;
m_sQueueSample.m_nReleasingVolumeDivider = 4; freq = 6050 * emittingVol / 30 + 16000;
m_sQueueSample.m_bReverbFlag = true; } else {
m_sQueueSample.m_bRequireReflection = false; m_sQueueSample.m_nSampleIndex = SFX_ROAD_NOISE;
AddSampleToRequestedQueue(); modificator = (m_sQueueSample.m_fDistance / 95.0f) * 0.5f; //mb SOUND_INTENSITY?
} sampleFreq = SampleManager.GetSampleBaseFrequency(SFX_ROAD_NOISE);
freq = (sampleFreq * modificator) + ((3 * sampleFreq) / 4);
} }
m_sQueueSample.m_nFrequency = freq;
m_sQueueSample.m_nLoopCount = 0;
m_sQueueSample.m_nEmittingVolume = emittingVol;
m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_fSpeedMultiplier = 6.0f;
m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY;
m_sQueueSample.m_bReleasingSoundFlag = false;
m_sQueueSample.m_nReleasingVolumeDivider = 4;
m_sQueueSample.m_bReverbFlag = true;
m_sQueueSample.m_bRequireReflection = false;
AddSampleToRequestedQueue();
} }
} }
return true; return true;
} }
bool bool
cAudioManager::ProcessWetRoadNoise(cVehicleParams *params) cAudioManager::ProcessWetRoadNoise(cVehicleParams* params)
{ {
const float SOUND_INTENSITY = 30.0f; const float SOUND_INTENSITY = 30.0f;
@ -1033,42 +1048,54 @@ cAudioManager::ProcessWetRoadNoise(cVehicleParams *params)
int32 emittingVol; int32 emittingVol;
float modificator; float modificator;
int freq; int freq;
float velChange; float velocity;
uint8 wheelsOnGround;
if (params->m_fDistance >= SQR(SOUND_INTENSITY)) if (params->m_fDistance >= SQR(SOUND_INTENSITY))
return false; return false;
if (params->m_pTransmission != nil) { switch (params->m_VehicleType) {
if (((CAutomobile *)params->m_pVehicle)->m_nDriveWheelsOnGround != 0) { case VEHICLE_TYPE_CAR:
velChange = Abs(params->m_fVelocityChange); wheelsOnGround = ((CAutomobile*)params->m_pVehicle)->m_nWheelsOnGround;
if (velChange > 0.f) { break;
CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); case VEHICLE_TYPE_BIKE:
relativeVelocity = Min(1.0f, velChange / (0.5f * params->m_pTransmission->fMaxVelocity)); wheelsOnGround = ((CBike*)params->m_pVehicle)->m_nWheelsOnGround;
emittingVol = 23.0f * relativeVelocity * CWeather::WetRoads; break;
m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance); default:
if (m_sQueueSample.m_nVolume != 0) { wheelsOnGround = 4;
m_sQueueSample.m_nCounter = 1; break;
m_sQueueSample.m_nSampleIndex = SFX_ROAD_NOISE; }
m_sQueueSample.m_nBankIndex = SFX_BANK_0; if (params->m_pTransmission == nil || wheelsOnGround == 0)
m_sQueueSample.m_bIs2D = false; return true;
m_sQueueSample.m_nReleasingVolumeModificator = 3;
modificator = m_sQueueSample.m_fDistance / 6.f; velocity = Abs(params->m_fVelocityChange);
freq = SampleManager.GetSampleBaseFrequency(SFX_ROAD_NOISE); if (velocity > 0.0f) {
m_sQueueSample.m_nFrequency = freq + freq * modificator; CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);
m_sQueueSample.m_nLoopCount = 0; relativeVelocity = Min(1.0f, velocity / (0.5f * params->m_pTransmission->fMaxVelocity));
m_sQueueSample.m_nEmittingVolume = emittingVol; emittingVol = 23.0f * relativeVelocity * CWeather::WetRoads;
m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance);
m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); if (m_sQueueSample.m_nVolume != 0) {
m_sQueueSample.m_fSpeedMultiplier = 6.0f; m_sQueueSample.m_nCounter = 1;
m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; m_sQueueSample.m_nSampleIndex = SFX_ROAD_NOISE;
m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_nBankIndex = SFX_BANK_0;
m_sQueueSample.m_nReleasingVolumeDivider = 4; m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_nReleasingVolumeModificator = 3;
m_sQueueSample.m_bRequireReflection = false; modificator = (m_sQueueSample.m_fDistance / 30.0f) * 0.5f; //need recheck in III, mb sount_intensity?
AddSampleToRequestedQueue(); freq = SampleManager.GetSampleBaseFrequency(SFX_ROAD_NOISE);
} m_sQueueSample.m_nFrequency = freq + freq * modificator;
} m_sQueueSample.m_nLoopCount = 0;
m_sQueueSample.m_nEmittingVolume = emittingVol;
m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_fSpeedMultiplier = 6.0f;
m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY;
m_sQueueSample.m_bReleasingSoundFlag = false;
m_sQueueSample.m_nReleasingVolumeDivider = 4;
m_sQueueSample.m_bReverbFlag = true;
m_sQueueSample.m_bRequireReflection = false;
AddSampleToRequestedQueue();
} }
} }
return true; return true;
} }
@ -2132,13 +2159,15 @@ cAudioManager::ProcessVehicleReverseWarning(cVehicleParams *params)
const float SOUND_INTENSITY = 50.0f; const float SOUND_INTENSITY = 50.0f;
CVehicle *veh = params->m_pVehicle; CVehicle *veh = params->m_pVehicle;
uint8 volume;
if (params->m_fDistance >= SQR(SOUND_INTENSITY)) if (params->m_fDistance >= SQR(SOUND_INTENSITY))
return false; return false;
if (veh->bEngineOn && veh->m_fGasPedal < 0.0f) { if (veh->bEngineOn && veh->m_fGasPedal < 0.0f) {
CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);
m_sQueueSample.m_nVolume = ComputeVolume(60, SOUND_INTENSITY, m_sQueueSample.m_fDistance); volume = veh->bIsDrowning ? 15 : 60;
m_sQueueSample.m_nVolume = ComputeVolume(volume, SOUND_INTENSITY, m_sQueueSample.m_fDistance);
if (m_sQueueSample.m_nVolume != 0) { if (m_sQueueSample.m_nVolume != 0) {
m_sQueueSample.m_nCounter = 12; m_sQueueSample.m_nCounter = 12;
m_sQueueSample.m_nSampleIndex = SFX_REVERSE_WARNING; m_sQueueSample.m_nSampleIndex = SFX_REVERSE_WARNING;
@ -2147,7 +2176,7 @@ cAudioManager::ProcessVehicleReverseWarning(cVehicleParams *params)
m_sQueueSample.m_nReleasingVolumeModificator = 2; m_sQueueSample.m_nReleasingVolumeModificator = 2;
m_sQueueSample.m_nFrequency = (100 * m_sQueueSample.m_nEntityIndex & 1023) + SampleManager.GetSampleBaseFrequency(SFX_REVERSE_WARNING); m_sQueueSample.m_nFrequency = (100 * m_sQueueSample.m_nEntityIndex & 1023) + SampleManager.GetSampleBaseFrequency(SFX_REVERSE_WARNING);
m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nLoopCount = 0;
m_sQueueSample.m_nEmittingVolume = 60; m_sQueueSample.m_nEmittingVolume = 60; //mb bug?
m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_fSpeedMultiplier = 3.0f; m_sQueueSample.m_fSpeedMultiplier = 3.0f;
@ -2803,6 +2832,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params)
} }
} }
} }
#ifdef GTA_TRAIN #ifdef GTA_TRAIN
bool bool
cAudioManager::ProcessTrainNoise(cVehicleParams *params) cAudioManager::ProcessTrainNoise(cVehicleParams *params)

View file

@ -361,13 +361,13 @@ public:
void UpdateGasPedalAudio(CVehicle* veh, int vehType); // done void UpdateGasPedalAudio(CVehicle* veh, int vehType); // done
bool ProcessVehicleHorn(cVehicleParams *params); // done bool ProcessVehicleHorn(cVehicleParams *params); // done
void ProcessVehicleOneShots(cVehicleParams *params); // void ProcessVehicleOneShots(cVehicleParams *params); //
bool ProcessVehicleReverseWarning(cVehicleParams *params); // bool ProcessVehicleReverseWarning(cVehicleParams *params); // done
bool ProcessVehicleRoadNoise(cVehicleParams *params); // bool ProcessVehicleRoadNoise(cVehicleParams *params); // done
bool ProcessVehicleSirenOrAlarm(cVehicleParams *params); // done bool ProcessVehicleSirenOrAlarm(cVehicleParams *params); // done
bool ProcessVehicleSkidding(cVehicleParams *params); // bool ProcessVehicleSkidding(cVehicleParams *params); //
void ProcessWaterCannon(int32); // void ProcessWaterCannon(int32); //
void ProcessWeather(int32 id); // done void ProcessWeather(int32 id); // done
bool ProcessWetRoadNoise(cVehicleParams *params); // bool ProcessWetRoadNoise(cVehicleParams *params); // done
void ProcessEscalators(); // done void ProcessEscalators(); // done
void ProcessExtraSounds(); // done void ProcessExtraSounds(); // done