diff options
author | Filip Gawin <filip.gawin@zoho.com> | 2019-07-12 18:27:12 +0200 |
---|---|---|
committer | Filip Gawin <filip.gawin@zoho.com> | 2019-07-19 16:23:03 +0200 |
commit | 113abec6facd9161149c0c6ee45d05e13426b5ba (patch) | |
tree | 34a773946cce7d4be1bbfc54ef01129a92885363 /src/audio | |
parent | ComputeDopplerEffectedFrequency (diff) | |
download | re3-113abec6facd9161149c0c6ee45d05e13426b5ba.tar re3-113abec6facd9161149c0c6ee45d05e13426b5ba.tar.gz re3-113abec6facd9161149c0c6ee45d05e13426b5ba.tar.bz2 re3-113abec6facd9161149c0c6ee45d05e13426b5ba.tar.lz re3-113abec6facd9161149c0c6ee45d05e13426b5ba.tar.xz re3-113abec6facd9161149c0c6ee45d05e13426b5ba.tar.zst re3-113abec6facd9161149c0c6ee45d05e13426b5ba.zip |
Diffstat (limited to '')
-rw-r--r-- | src/audio/AudioManager.cpp | 377 | ||||
-rw-r--r-- | src/audio/AudioManager.h | 198 | ||||
-rw-r--r-- | src/audio/SampleManager.cpp | 38 | ||||
-rw-r--r-- | src/audio/SampleManager.h | 18 |
4 files changed, 510 insertions, 121 deletions
diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index a76c475d..5b42dbd8 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -103,21 +103,22 @@ char &g_nMissionAudioPlayingStatus = *(char *)0x60ED88; void cAudioManager::AddDetailsToRequestedOrderList(uint8 sample) { - int32 offset; uint32 i = 0; if(sample != 0) { for(; i < sample; i++) { - offset = 27 * m_bActiveSampleQueue; - if(m_asSamples[offset + m_abSampleQueueIndexTable[i + offset]] - .calculatedVolume > m_asSamples[offset + sample].calculatedVolume) + if(m_asSamples[m_bActiveSampleQueue] + [m_abSampleQueueIndexTable[m_bActiveSampleQueue][i]] + .calculatedVolume > + m_asSamples[m_bActiveSampleQueue][sample].calculatedVolume) break; } if(i < sample) { - memmove(&m_abSampleQueueIndexTable[offset + 1 + i], - &m_abSampleQueueIndexTable[offset + i], m_bActiveSamples - i - 1); + memmove(&m_abSampleQueueIndexTable[m_bActiveSampleQueue][i + 1], + &m_abSampleQueueIndexTable[m_bActiveSampleQueue][i], + m_bActiveSamples - i - 1); } } - m_abSampleQueueIndexTable[27 * m_bActiveSampleQueue + i] = sample; + m_abSampleQueueIndexTable[m_bActiveSampleQueue][i] = sample; } void @@ -193,7 +194,7 @@ cAudioManager::AddReflectionsToRequestedQueue() } } } -#if 0 +#if 1 WRAPPER void cAudioManager::AddReleasingSounds() { @@ -271,17 +272,17 @@ cAudioManager::AddSampleToRequestedQueue() { int32 calculatedVolume; tActiveSample *sample; - int32 unknown1; - uint8 unknown2; + uint8 sampleIndex; bool bReflections; if(m_sQueueSample.m_nSampleIndex < TOTAL_AUDIO_SAMPLES) { calculatedVolume = m_sQueueSample.field_16 * (maxVolume - m_sQueueSample.m_bVolume); - unknown2 = m_bSampleRequestQueuesStatus[m_bActiveSampleQueue]; - if(unknown2 >= m_bActiveSamples) { - unknown1 = 27 * m_bActiveSampleQueue; - unknown2 = *(&m_asSamples[53].field_91 + m_bActiveSamples + unknown1); - if(m_asSamples[unknown1 + unknown2].calculatedVolume <= calculatedVolume) + sampleIndex = m_bSampleRequestQueuesStatus[m_bActiveSampleQueue]; + if(sampleIndex >= m_bActiveSamples) { + sampleIndex = *(&m_asSamples[1][26].field_91 + m_bActiveSamples + + 27 * m_bActiveSampleQueue); + if(m_asSamples[m_bActiveSampleQueue][sampleIndex].calculatedVolume <= + calculatedVolume) return; } else { ++m_bSampleRequestQueuesStatus[m_bActiveSampleQueue]; @@ -302,7 +303,7 @@ cAudioManager::AddSampleToRequestedQueue() if(!m_bDynamicAcousticModelingStatus) m_sQueueSample.m_bReverbFlag = 0; - sample = &m_asSamples[27 * m_bActiveSampleQueue + unknown2]; + 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; @@ -330,7 +331,7 @@ cAudioManager::AddSampleToRequestedQueue() sample->calculatedVolume = m_sQueueSample.calculatedVolume; sample->field_88 = m_sQueueSample.field_88; - AddDetailsToRequestedOrderList(unknown2); + AddDetailsToRequestedOrderList(sampleIndex); if(bReflections) AddReflectionsToRequestedQueue(); } } @@ -383,7 +384,7 @@ void cAudioManager::ClearRequestedQueue() { for(int32 i = 0; i < m_bActiveSamples; i++) { - m_abSampleQueueIndexTable[i + 27 * m_bActiveSampleQueue] = m_bActiveSamples; + m_abSampleQueueIndexTable[m_bActiveSampleQueue][i] = m_bActiveSamples; } m_bSampleRequestQueuesStatus[m_bActiveSampleQueue] = 0; } @@ -555,6 +556,21 @@ cAudioManager::GetDistanceSquared(CVector *v) } void +cAudioManager::TranslateEntity(CVector *v1, CVector *v2) +{ + 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; +} + +void cAudioManager::Initialise() { if(!m_bIsInitialised) { @@ -3118,6 +3134,8 @@ cAudioManager::GetGenericFemaleTalkSfx(int16 sound) return sfx; } +#if 1 + WRAPPER void cAudioManager::ProcessActiveQueues() @@ -3125,6 +3143,320 @@ cAudioManager::ProcessActiveQueues() EAXJMP(0x57BA60); } +#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_nTimeOfRecentCrime & 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 && !cSampleManager.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; + } + cSampleManager.SetChannelFrequency(j, v5->m_nFrequency); + cSampleManager.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; + cSampleManager.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; + } + cSampleManager.SetChannelEmittingVolume(j, v19); + v7->m_bEmittingVolume = v41; + } + TranslateEntity(&v5->m_vecPos, &a2); + cSampleManager.SetChannel3DPosition(j, a2.x, a2.y, a2.z); + v20 = 0.25f * v5->m_fSoundIntensity; + cSampleManager.SetChannel3DDistances( + j, v5->m_fSoundIntensity, v20); + } + cSampleManager.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) { + cSampleManager.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 * + cSampleManager.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(cSampleManager.InitialiseChannel( + l, + v27->m_asActiveSamples[0] + .m_nSampleIndex, + v27->m_asActiveSamples[0] + .m_bBankIndex)) { + cSampleManager.SetChannelFrequency( + l, v27->m_asActiveSamples[0] + .m_nFrequency); + cSampleManager + .SetChannelEmittingVolume(l, + v45); + cSampleManager.SetChannelLoopPoints( + l, + v27->m_asActiveSamples[0] + .m_nLoopStart, + v27->m_asActiveSamples[0] + .m_nLoopEnd); + cSampleManager.SetChannelLoopCount( + l, v27->m_asActiveSamples[0] + .m_nLoopCount); + cSampleManager.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; + cSampleManager.SetChannel3DPosition( + l, v37, v36, v35); + v38 = 0.25f * + v27->m_asActiveSamples[0] + .m_fSoundIntensity; + cSampleManager + .SetChannel3DDistances( + l, + v27->m_asActiveSamples[0] + .m_fSoundIntensity, + v38); + cSampleManager.StartChannel(l); + } + v27->m_asActiveSamples[0].m_bIsProcessed = + 1; + v26->m_bIsProcessed = 1; + v26->field_88 = -1; + break; + } + } + v27 = (v27 + 92); + } + } + } + } +} +#endif + #if 1 bool cAudioManager::ProcessAirBrakes(cVehicleParams *params) @@ -3730,12 +4062,12 @@ WRAPPER void cAudioManager::ProcessGarages() { - EAXJMP(0x578C20); + EAXJMP(0x578C20); } -void cAudioManager::ProcessHomeScriptObject(uint8 sound) +void +cAudioManager::ProcessHomeScriptObject(uint8 sound) { - } void @@ -3820,7 +4152,7 @@ STARTPATCHES 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(0x57B8D0, &cAudioManager::AddReleasingSounds, PATCH_JUMP); InjectHook(0x57B070, &cAudioManager::AddSampleToRequestedQueue, PATCH_JUMP); InjectHook(0x57A8F0, &cAudioManager::AutoDetect3DProviders, PATCH_JUMP); // InjectHook(0x580AF0, &cAudioManager::AgeCrimes, PATCH_JUMP); @@ -3977,6 +4309,7 @@ InjectHook(0x575460, &cAudioManager::GetGenericMaleTalkSfx, PATCH_JUMP); InjectHook(0x575510, &cAudioManager::GetGenericFemaleTalkSfx, PATCH_JUMP); // Process stuff +// InjectHook(0x57BA60, &cAudioManager::ProcessActiveQueues, PATCH_JUMP); InjectHook(0x577B30, &cAudioManager::ProcessAirportScriptObject, PATCH_JUMP); InjectHook(0x579250, &cAudioManager::ProcessBridgeMotor, PATCH_JUMP); InjectHook(0x579170, &cAudioManager::ProcessBridgeWarning, PATCH_JUMP); diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index fb13d18a..4c02d07f 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -7,48 +7,48 @@ class tActiveSample { public: - int m_nEntityIndex; - int field_4; - int m_nSampleIndex; - char m_bBankIndex; - char m_bIsDistant; - char field_14; - char field_15; - int field_16; - int m_nFrequency; + int32 m_nEntityIndex; + int32 field_4; + int32 m_nSampleIndex; + uint8 m_bBankIndex; + uint8 m_bIsDistant; + uint8 field_14; + uint8 field_15; + int32 field_16; + int32 m_nFrequency; uint8 m_bVolume; - char field_25; - char field_26; - char field_27; + uint8 field_25; + uint8 field_26; + uint8 field_27; float m_fDistance; - int m_nLoopCount; - int m_nLoopStart; - int m_nLoopEnd; + int32 m_nLoopCount; + int32 m_nLoopStart; + int32 m_nLoopEnd; uint8 m_bEmittingVolume; - char field_45; - char field_46; - char field_47; + uint8 field_45; + uint8 field_46; + uint8 field_47; float field_48; float m_fSoundIntensity; - char field_56; - char field_57; - char field_58; - char field_59; + uint8 field_56; + uint8 field_57; + uint8 field_58; + uint8 field_59; CVector m_vecPos; - char m_bReverbFlag; - char m_bLoopsRemaining; - char m_bRequireReflection; + uint8 m_bReverbFlag; + uint8 m_bLoopsRemaining; + uint8 m_bRequireReflection; uint8 m_bOffset; - int field_76; - char m_bIsProcessed; - char m_bLoopEnded; - char field_82; - char field_83; - int calculatedVolume; - char field_88; - char field_89; - char field_90; - char field_91; + 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; }; static_assert(sizeof(tActiveSample) == 0x5c, "tActiveSample: error"); @@ -79,12 +79,12 @@ public: eAudioType m_nType; CPhysical *m_pEntity; bool m_bIsUsed; - char m_bStatus; + uint8 m_bStatus; int16 m_awAudioEvent[4]; - char gap_18[2]; + uint8 gap_18[2]; float m_afVolume[4]; - char field_24; - char field_25[3]; + uint8 field_24; + uint8 field_25[3]; }; static_assert(sizeof(tAudioEntity) == 0x28, "tAudioEntity: error"); @@ -96,9 +96,9 @@ public: int field_4; CVector m_vecPos; float m_fDistance; - char m_bVolume; - char field_25; - char gap_26[2]; + uint8 m_bVolume; + uint8 field_25; + uint8 gap_26[2]; }; static_assert(sizeof(tPedComment) == 0x1c, "tPedComment: error"); @@ -107,10 +107,10 @@ class cPedComments { public: tPedComment m_asPedComments[40]; - char field_1120[40]; - char field_1160[2]; - char field_1162; - char gap_1163[1]; + uint8 field_1120[40]; + uint8 field_1160[2]; + uint8 field_1162; + uint8 gap_1163[1]; }; static_assert(sizeof(cPedComments) == 0x48c, "cPedComments: error"); @@ -122,15 +122,15 @@ class cAudioCollision public: CEntity *m_pEntity1; CEntity *m_pEntity2; - char m_bSurface1; - char m_bSurface2; - char field_10; - char field_11; + uint8 m_bSurface1; + uint8 m_bSurface2; + uint8 field_10; + uint8 field_11; float m_fIntensity1; float m_fIntensity2; CVector m_vecPosition; float m_fDistance; - int m_nBaseVolume; + int32 m_nBaseVolume; }; static_assert(sizeof(cAudioCollision) == 0x28, "cAudioCollision: error"); @@ -140,9 +140,9 @@ class cAudioCollisionManager public: cAudioCollision m_asCollisions1[10]; cAudioCollision m_asCollisions2[10]; - char m_bIndicesTable[10]; - char m_bCollisionsInQueue; - char gap_811; + uint8 m_bIndicesTable[10]; + uint8 m_bCollisionsInQueue; + uint8 gap_811; cAudioCollision m_sQueue; }; @@ -152,18 +152,18 @@ class cMissionAudio { public: CVector m_vecPos; - char field_12; - char gap_13[3]; + uint8 field_12; + uint8 gap_13[3]; int m_nSampleIndex; - char m_bLoadingStatus; - char m_bPlayStatus; - char field_22; - char field_23; + uint8 m_bLoadingStatus; + uint8 m_bPlayStatus; + uint8 field_22; + uint8 field_23; int field_24; bool m_bIsPlayed; - char field_29; - char field_30; - char field_31; + uint8 field_29; + uint8 field_30; + uint8 field_31; }; class cVehicleParams; @@ -174,50 +174,50 @@ class cAudioManager { public: bool m_bIsInitialised; - char field_1; - char field_2; - char m_bActiveSamples; - char field_4; + uint8 field_1; + uint8 field_2; + uint8 m_bActiveSamples; + uint8 field_4; bool m_bDynamicAcousticModelingStatus; - char field_6; - char field_7; + uint8 field_6; + uint8 field_7; float speedOfSound; bool m_bTimerJustReset; - char field_13; - char field_14; - char field_15; - int m_nTimer; + uint8 field_13; + uint8 field_14; + uint8 field_15; + int32 m_nTimer; tActiveSample m_sQueueSample; uint8 m_bActiveSampleQueue; - char gap_109[3]; - tActiveSample m_asSamples[54]; - char m_abSampleQueueIndexTable[54]; - char m_bSampleRequestQueuesStatus[2]; + 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]; - int m_anAudioEntityIndices[200]; - int m_nAudioEntitiesTotal; + int32 m_anAudioEntityIndices[200]; + int32 m_nAudioEntitiesTotal; CVector m_avecReflectionsPos[5]; float m_afReflectionsDistances[5]; - int m_anScriptObjectEntityIndices[40]; - int m_nScriptObjectEntityTotal; + int32 m_anScriptObjectEntityIndices[40]; + int32 m_nScriptObjectEntityTotal; cPedComments m_sPedComments; - int m_nFireAudioEntity; - int m_nWaterCannonEntity; - int m_nPoliceChannelEntity; - char gap45B8[444]; - int m_nFrontEndEntity; - int m_nCollisionEntity; + int32 m_nFireAudioEntity; + int32 m_nWaterCannonEntity; + int32 m_nPoliceChannelEntity; + uint8 gap45B8[444]; + int32 m_nFrontEndEntity; + int32 m_nCollisionEntity; cAudioCollisionManager m_sCollisionManager; - int m_nProjectileEntity; - int m_nBridgeEntity; + int32 m_nProjectileEntity; + int32 m_nBridgeEntity; cMissionAudio m_sMissionAudio; - int m_anRandomTable[5]; - char field_19192; - char m_bUserPause; - char m_bPreviousUserPause; - char field_19195; - int m_nTimeOfRecentCrime; + int32 m_anRandomTable[5]; + uint8 field_19192; + uint8 m_bUserPause; + uint8 m_bPreviousUserPause; + uint8 field_19195; + int32 m_nTimeOfRecentCrime; void AddDetailsToRequestedOrderList(uint8 sample); void AddPlayerCarSample(uint8 emittingVolume, int32 freq, uint32 sample, uint8 unk1, @@ -248,6 +248,8 @@ public: // done + void TranslateEntity(CVector *v1, CVector *v2); // todo hook + void Initialise(); void PostInitialiseGameSpecificSetup(); void InitialisePoliceRadioZones(); // todo @@ -419,7 +421,7 @@ public: void ProcessFrontEnd(); // done void ProcessGarages(); // todo // bool ProcessHelicopter(void *); // todo requires CVehicle - void ProcessHomeScriptObject(uint8 sound); + void ProcessHomeScriptObject(uint8 sound); // void ProcessJumbo(void *); // void ProcessJumboAccel(void *); // void ProcessJumboDecel(void *); @@ -460,8 +462,8 @@ public: // void ProcessVehicleSkidding(void *); void ProcessWaterCannon(int32); // todo void ProcessWeather(int32 id); // todo - // bool ProcessWetRoadNoise(void *); - // void ProcessWorkShopScriptObject(uint8 sound); + // bool ProcessWetRoadNoise(void *); + // void ProcessWorkShopScriptObject(uint8 sound); }; static_assert(sizeof(cAudioManager) == 0x4B14, "cAudioManager: error"); diff --git a/src/audio/SampleManager.cpp b/src/audio/SampleManager.cpp index 2e11532e..f3e25f0f 100644 --- a/src/audio/SampleManager.cpp +++ b/src/audio/SampleManager.cpp @@ -15,6 +15,37 @@ CSampleManager::IsMP3RadioChannelAvailable() } WRAPPER +void CSampleManager::SetChannelFrequency(int32, int32) { EAXJMP(0x5679D0); } + +WRAPPER +void CSampleManager::SetChannelEmittingVolume(int32, uint32) { EAXJMP(0x567820); } + +WRAPPER +void +CSampleManager::SetChannel3DPosition(int32, float, float, float) +{ + EAXJMP(0x567890); +} + +WRAPPER +void CSampleManager::SetChannelLoopCount(int32, int32) { EAXJMP(0x567AA0); } + +WRAPPER +void CSampleManager::SetChannel3DDistances(int32, int32, int32) { EAXJMP(0x5678D0); } + +WRAPPER +void CSampleManager::SetChannelReverbFlag(int32, uint8) { EAXJMP(0x567630); } + +WRAPPER +int32 CSampleManager::GetSampleLength(int32) { EAXJMP(0x567300); } + +WRAPPER +bool CSampleManager::InitialiseChannel(int32, int32, uint32, uint32) { EAXJMP(0x5676A0); } + +WRAPPER +void CSampleManager::SetChannelLoopPoints(int32, int32, int32) { EAXJMP(0x567A30); } + +WRAPPER bool CSampleManager::CheckForAnAudioFileOnCD() { @@ -128,6 +159,13 @@ CSampleManager::GetChannelUsedFlag(int32 id) WRAPPER void +CSampleManager::StartChannel(int32 id) +{ + EAXJMP(0x567B80); +} + +WRAPPER +void CSampleManager::StopChannel(int32 id) { EAXJMP(0x567BE0); diff --git a/src/audio/SampleManager.h b/src/audio/SampleManager.h index 8db6c7d2..e6c4e36f 100644 --- a/src/audio/SampleManager.h +++ b/src/audio/SampleManager.h @@ -13,6 +13,20 @@ struct tSample { class CSampleManager { public: + void SetChannelFrequency(int32, int32); + void SetChannelEmittingVolume(int32, uint32); + void SetChannel3DPosition(int32, float, float, float); + void SetChannelLoopCount(int32, int32); + + void SetChannel3DDistances(int32, int32, int32); + void SetChannelReverbFlag(int32, uint8); + + int32 GetSampleLength(int32); + + bool InitialiseChannel(int32, int32, uint32, uint32 something = 0); + + void SetChannelLoopPoints(int32, int32, int32); + bool CheckForAnAudioFileOnCD(); int32 GetSampleBaseFrequency(int32); @@ -40,6 +54,8 @@ public: void SetSpeakerConfig(uint32 config); bool GetChannelUsedFlag(int32 id); + + void StartChannel(int32 id); void StopChannel(int32 id); static bool IsMP3RadioChannelAvailable(); @@ -47,6 +63,6 @@ public: extern uint32 &nNumOfMp3Files; extern uint8 &num3DProvidersAvailable; -extern uint32* asName3DProviders; +extern uint32 *asName3DProviders; extern CSampleManager &cSampleManager;
\ No newline at end of file |