summaryrefslogtreecommitdiffstats
path: root/src/audio
diff options
context:
space:
mode:
authorFilip Gawin <filip.gawin@zoho.com>2019-10-19 13:21:35 +0200
committerFilip Gawin <filip.gawin@zoho.com>2019-10-26 13:05:00 +0200
commitfef3b5f978856c5ebabcdc27340de163173f3883 (patch)
tree77c8f3981174accae5a07314b7622b7880b53b7e /src/audio
parentFixes for nitpicks (diff)
downloadre3-fef3b5f978856c5ebabcdc27340de163173f3883.tar
re3-fef3b5f978856c5ebabcdc27340de163173f3883.tar.gz
re3-fef3b5f978856c5ebabcdc27340de163173f3883.tar.bz2
re3-fef3b5f978856c5ebabcdc27340de163173f3883.tar.lz
re3-fef3b5f978856c5ebabcdc27340de163173f3883.tar.xz
re3-fef3b5f978856c5ebabcdc27340de163173f3883.tar.zst
re3-fef3b5f978856c5ebabcdc27340de163173f3883.zip
Diffstat (limited to 'src/audio')
-rw-r--r--src/audio/AudioManager.cpp44
-rw-r--r--src/audio/AudioManager.h24
2 files changed, 41 insertions, 27 deletions
diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp
index edcf4255..c51d53d5 100644
--- a/src/audio/AudioManager.cpp
+++ b/src/audio/AudioManager.cpp
@@ -9092,7 +9092,7 @@ cAudioManager::ServiceSoundEffects()
ServiceCollisions();
AddReleasingSounds();
ProcessMissionAudio();
- sub_57C2B0();
+ AdjustSamplesVolume();
ProcessActiveQueues();
for(int32 i = 0; i < m_nScriptObjectEntityTotal; ++i) {
object = (cAudioScriptObject *)m_asAudioEntities[m_anScriptObjectEntityIndices[i]]
@@ -10242,27 +10242,31 @@ cAudioManager::UsesSirenSwitching(int32 model) const
}
}
-WRAPPER
void
-cAudioManager::sub_57C2B0()
+cAudioManager::AdjustSamplesVolume()
{
- EAXJMP(0x57C2B0);
+ for(int i = 0; i < m_bSampleRequestQueuesStatus[m_bActiveSampleQueue];
+ i++) {
+ tActiveSample *pSample =
+ &m_asSamples[i][(int32)m_abSampleQueueIndexTable[i] + 1];
+
+ if(!pSample->m_bBankIndex) // all non-speech sounds on PC
+ pSample->m_bEmittingVolume = ComputeEmittingVolume(
+ pSample->m_bEmittingVolume,
+ pSample->m_fSoundIntensity, pSample->m_fDistance);
+ }
}
int32
-cAudioManager::sub_57C320(uint8 a1, float a2, float a3)
-{
- float v4;
- float v5;
- int32 v6;
-
- v4 = 0.25f * a2;
- v5 = a2 - v4;
- if(a3 <= v5)
- v6 = a1;
- else
- v6 = ((v4 - (a3 - v5)) * (float)a1 / v4);
- return v6;
+cAudioManager::ComputeEmittingVolume(uint8 emittingVolume, float intensity,
+ float dist)
+{
+ float quatIntensity = intensity / 4.0f;
+ float diffIntensity = intensity - quatIntensity;
+ if(dist > diffIntensity)
+ return (quatIntensity - (dist - diffIntensity)) *
+ (float)emittingVolume / quatIntensity;
+ return emittingVolume;
}
STARTPATCHES
@@ -10487,7 +10491,11 @@ 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(0x57C320, &cAudioManager::sub_57C320, PATCH_JUMP);
+
+InjectHook(0x57C2B0, &cAudioManager::AdjustSamplesVolume, PATCH_JUMP);
+InjectHook(0x57C320, &cAudioManager::ComputeEmittingVolume, PATCH_JUMP);
+
+
InjectHook(0x5755C0, &cPedComments::Add, PATCH_JUMP);
InjectHook(0x575730, &cPedComments::Process, PATCH_JUMP);
InjectHook(0x5685E0, &cAudioCollisionManager::AddCollisionToRequestedQueue, PATCH_JUMP);
diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h
index 84062e0a..d9224ced 100644
--- a/src/audio/AudioManager.h
+++ b/src/audio/AudioManager.h
@@ -4,7 +4,9 @@
#include "DMAudio.h"
#include "common.h"
-struct tActiveSample {
+class tActiveSample
+{
+public:
int32 m_nEntityIndex;
int32 m_counter;
int32 m_nSampleIndex;
@@ -53,7 +55,8 @@ struct tActiveSample {
static_assert(sizeof(tActiveSample) == 92, "tActiveSample: error");
-enum eAudioType : int32 {
+enum eAudioType : int32
+{
AUDIOTYPE_PHYSICAL = 0,
AUDIOTYPE_EXPLOSION = 1,
AUDIOTYPE_FIRE = 2,
@@ -74,7 +77,9 @@ enum eAudioType : int32 {
class CPhysical;
class CAutomobile;
-struct tAudioEntity {
+class tAudioEntity
+{
+public:
eAudioType m_nType;
void *m_pEntity;
bool m_bIsUsed;
@@ -90,7 +95,9 @@ struct tAudioEntity {
static_assert(sizeof(tAudioEntity) == 40, "tAudioEntity: error");
-struct tPedComment {
+class tPedComment
+{
+public:
int32 m_nSampleIndex;
int32 m_entityIndex;
CVector m_vecPos;
@@ -254,13 +261,10 @@ public:
uint8 field_13;
uint8 field_14;
uint8 field_15;
- // 100
int32 m_nTimer;
tActiveSample m_sQueueSample;
- // 224
bool m_bActiveSampleQueue;
uint8 gap_109[3];
- // 264
tActiveSample m_asSamples[2][27];
uint8 m_abSampleQueueIndexTable[2][27];
uint8 m_bSampleRequestQueuesStatus[2];
@@ -563,8 +567,10 @@ public:
bool UsesSiren(int32 model) const;
bool UsesSirenSwitching(int32 model) const;
- void sub_57C2B0(); // todo (weird) and obtain name
- int32 sub_57C320(uint8 a1, float a2, float a3); /// ok (get name)
+ // only used in pc
+ void AdjustSamplesVolume(); /// ok
+ int32 ComputeEmittingVolume(uint8 emittingVolume, float intensity,
+ float dist); /// ok
};
static_assert(sizeof(cAudioManager) == 19220, "cAudioManager: error");