Cleanup audio code

This commit is contained in:
Filip Gawin 2020-04-12 02:39:27 +02:00
parent 727a64e316
commit 7d137d8f2d
4 changed files with 270 additions and 242 deletions

View File

@ -151,7 +151,7 @@ cAudioManager::SetUpLoopingCollisionSound(cAudioCollision *col, uint8 counter)
m_sQueueSample.m_bVolume = m_sQueueSample.m_bVolume =
ComputeVolume(emittingVol, CollisionSoundIntensity, m_sQueueSample.m_fDistance); ComputeVolume(emittingVol, CollisionSoundIntensity, m_sQueueSample.m_fDistance);
if(m_sQueueSample.m_bVolume) { if(m_sQueueSample.m_bVolume) {
m_sQueueSample.m_counter = counter; m_sQueueSample.m_nCounter = counter;
m_sQueueSample.m_vecPos = col->m_vecPosition; m_sQueueSample.m_vecPos = col->m_vecPosition;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_bIs2D = false;
@ -164,7 +164,7 @@ cAudioManager::SetUpLoopingCollisionSound(cAudioCollision *col, uint8 counter)
SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex);
m_sQueueSample.m_fSpeedMultiplier = 4.0f; m_sQueueSample.m_fSpeedMultiplier = 4.0f;
m_sQueueSample.m_fSoundIntensity = CollisionSoundIntensity; m_sQueueSample.m_fSoundIntensity = CollisionSoundIntensity;
m_sQueueSample.m_bReleasingSoundFlag = 0; m_sQueueSample.m_bReleasingSoundFlag = false;
m_sQueueSample.m_nReleasingVolumeDivider = 5; m_sQueueSample.m_nReleasingVolumeDivider = 5;
m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_bReverbFlag = true;
m_sQueueSample.m_bRequireReflection = false; m_sQueueSample.m_bRequireReflection = false;
@ -270,7 +270,7 @@ cAudioManager::SetUpOneShotCollisionSound(cAudioCollision *col)
break; break;
} }
m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 16); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 16);
m_sQueueSample.m_counter = counter++; m_sQueueSample.m_nCounter = counter++;
if(counter >= 255) counter = 28; if(counter >= 255) counter = 28;
m_sQueueSample.m_vecPos = col->m_vecPosition; m_sQueueSample.m_vecPos = col->m_vecPosition;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
@ -282,7 +282,7 @@ cAudioManager::SetUpOneShotCollisionSound(cAudioCollision *col)
m_sQueueSample.m_nLoopEnd = -1; m_sQueueSample.m_nLoopEnd = -1;
m_sQueueSample.m_fSpeedMultiplier = 4.0f; m_sQueueSample.m_fSpeedMultiplier = 4.0f;
m_sQueueSample.m_fSoundIntensity = CollisionSoundIntensity; m_sQueueSample.m_fSoundIntensity = CollisionSoundIntensity;
m_sQueueSample.m_bReleasingSoundFlag = 1; m_sQueueSample.m_bReleasingSoundFlag = true;
m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_bReverbFlag = true;
m_sQueueSample.m_bRequireReflection = false; m_sQueueSample.m_bRequireReflection = false;
AddSampleToRequestedQueue(); AddSampleToRequestedQueue();

File diff suppressed because it is too large Load Diff

View File

@ -138,7 +138,7 @@ class tSound
{ {
public: public:
int32 m_nEntityIndex; int32 m_nEntityIndex;
int32 m_counter; int32 m_nCounter;
int32 m_nSampleIndex; int32 m_nSampleIndex;
uint8 m_bBankIndex; uint8 m_bBankIndex;
bool m_bIs2D; bool m_bIs2D;
@ -170,8 +170,8 @@ public:
bool m_bRequireReflection; // Used for oneshots bool m_bRequireReflection; // Used for oneshots
uint8 m_bOffset; uint8 m_bOffset;
int32 m_nReleasingVolumeDivider; int32 m_nReleasingVolumeDivider;
uint8 m_bIsProcessed; bool m_bIsProcessed;
uint8 m_bLoopEnded; bool m_bLoopEnded;
uint8 field_82; uint8 field_82;
uint8 field_83; uint8 field_83;
int32 calculatedVolume; int32 calculatedVolume;
@ -244,14 +244,14 @@ class cMissionAudio
{ {
public: public:
CVector m_vecPos; CVector m_vecPos;
uint8 field_12; bool m_bPredefinedProperties;
uint8 gap_13[3]; uint8 gap_13[3];
int m_nSampleIndex; int m_nSampleIndex;
uint8 m_bLoadingStatus; uint8 m_bLoadingStatus;
uint8 m_bPlayStatus; uint8 m_bPlayStatus;
uint8 field_22; uint8 field_22;
uint8 field_23; uint8 field_23;
int field_24; int32 m_nMissionAudioCounter;
bool m_bIsPlayed; bool m_bIsPlayed;
uint8 field_29; uint8 field_29;
uint8 field_30; uint8 field_30;
@ -328,7 +328,7 @@ public:
int32 m_nBridgeEntity; int32 m_nBridgeEntity;
cMissionAudio m_sMissionAudio; cMissionAudio m_sMissionAudio;
int32 m_anRandomTable[5]; int32 m_anRandomTable[5];
uint8 field_19192; // time? uint8 m_bTimeSpent;
uint8 m_bUserPause; uint8 m_bUserPause;
uint8 m_bPreviousUserPause; uint8 m_bPreviousUserPause;
uint8 field_19195; // unused uint8 field_19195; // unused

View File

@ -125,7 +125,7 @@ void
cAudioManager::DoPoliceRadioCrackle() cAudioManager::DoPoliceRadioCrackle()
{ {
m_sQueueSample.m_nEntityIndex = m_nPoliceChannelEntity; m_sQueueSample.m_nEntityIndex = m_nPoliceChannelEntity;
m_sQueueSample.m_counter = 0; m_sQueueSample.m_nCounter = 0;
m_sQueueSample.m_nSampleIndex = SFX_POLICE_RADIO_CRACKLE; m_sQueueSample.m_nSampleIndex = SFX_POLICE_RADIO_CRACKLE;
m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN;
m_sQueueSample.m_bIs2D = true; m_sQueueSample.m_bIs2D = true;
@ -136,7 +136,7 @@ cAudioManager::DoPoliceRadioCrackle()
m_sQueueSample.m_bEmittingVolume = m_sQueueSample.m_bVolume; m_sQueueSample.m_bEmittingVolume = m_sQueueSample.m_bVolume;
m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(SFX_POLICE_RADIO_CRACKLE); m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(SFX_POLICE_RADIO_CRACKLE);
m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(SFX_POLICE_RADIO_CRACKLE); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(SFX_POLICE_RADIO_CRACKLE);
m_sQueueSample.m_bReleasingSoundFlag = 0; m_sQueueSample.m_bReleasingSoundFlag = false;
m_sQueueSample.m_bReverbFlag = false; m_sQueueSample.m_bReverbFlag = false;
m_sQueueSample.m_bOffset = 63; m_sQueueSample.m_bOffset = 63;
m_sQueueSample.m_nReleasingVolumeDivider = 3; m_sQueueSample.m_nReleasingVolumeDivider = 3;
@ -147,17 +147,20 @@ cAudioManager::DoPoliceRadioCrackle()
void void
cAudioManager::ServicePoliceRadio() cAudioManager::ServicePoliceRadio()
{ {
int32 wantedLevel = 0; // bug?; int32 wantedLevel = 0; // uninitialized variable
static uint32 nLastSeen = 300; static uint32 nLastSeen = 300;
if (!m_bIsInitialised) return; if(!m_bIsInitialised) return;
if (!m_bUserPause) { if(!m_bUserPause) {
bool crimeReport = SetupCrimeReport(); bool crimeReport = SetupCrimeReport();
#ifdef FIX_BUGS // Crash at 0x5fe6ef
if(!FindPlayerPed() || !FindPlayerPed()->m_pWanted) return;
#endif
wantedLevel = FindPlayerPed()->m_pWanted->m_nWantedLevel; wantedLevel = FindPlayerPed()->m_pWanted->m_nWantedLevel;
if (!crimeReport) { if(!crimeReport) {
if (wantedLevel) { if(wantedLevel) {
if (nLastSeen) { if(nLastSeen) {
--nLastSeen; --nLastSeen;
} else { } else {
nLastSeen = m_anRandomTable[1] % 1000 + 2000; nLastSeen = m_anRandomTable[1] % 1000 + 2000;