summaryrefslogtreecommitdiffstats
path: root/src/audio/AudioManager.cpp
diff options
context:
space:
mode:
authorSergeanur <s.anureev@yandex.ua>2021-08-17 12:58:48 +0200
committerSergeanur <s.anureev@yandex.ua>2021-08-17 12:58:48 +0200
commit16ff379ebeca2092e9609eb3163a6bd2ffd68060 (patch)
tree75d6ec09e36174454e8bcf66867b9b0ea46ada2b /src/audio/AudioManager.cpp
parentRemove FIX_BUGS that wasn't needed (diff)
downloadre3-16ff379ebeca2092e9609eb3163a6bd2ffd68060.tar
re3-16ff379ebeca2092e9609eb3163a6bd2ffd68060.tar.gz
re3-16ff379ebeca2092e9609eb3163a6bd2ffd68060.tar.bz2
re3-16ff379ebeca2092e9609eb3163a6bd2ffd68060.tar.lz
re3-16ff379ebeca2092e9609eb3163a6bd2ffd68060.tar.xz
re3-16ff379ebeca2092e9609eb3163a6bd2ffd68060.tar.zst
re3-16ff379ebeca2092e9609eb3163a6bd2ffd68060.zip
Diffstat (limited to 'src/audio/AudioManager.cpp')
-rw-r--r--src/audio/AudioManager.cpp46
1 files changed, 31 insertions, 15 deletions
diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp
index 9b1337c9..15c8c00e 100644
--- a/src/audio/AudioManager.cpp
+++ b/src/audio/AudioManager.cpp
@@ -30,7 +30,9 @@ cAudioManager::cAudioManager()
ClearActiveSamples();
GenerateIntegerRandomNumberTable();
m_bDoubleVolume = FALSE;
+#ifdef AUDIO_REFLECTIONS
m_bDynamicAcousticModelingStatus = TRUE;
+#endif
for (int i = 0; i < NUM_AUDIOENTITIES; i++) {
m_asAudioEntities[i].m_bIsUsed = FALSE;
@@ -114,7 +116,7 @@ cAudioManager::Service()
if (m_bIsInitialised) {
m_nPreviousUserPause = m_nUserPause;
m_nUserPause = CTimer::GetIsUserPaused();
-#if GTA_VERSION >= GTA3_PC_10
+#ifdef AUDIO_REFLECTIONS
UpdateReflections();
#endif
ServiceSoundEffects();
@@ -434,11 +436,13 @@ cAudioManager::ReacquireDigitalHandle()
}
}
+#ifdef AUDIO_REFLECTIONS
void
cAudioManager::SetDynamicAcousticModelingStatus(bool8 status)
{
m_bDynamicAcousticModelingStatus = status;
}
+#endif
bool8
cAudioManager::CheckForAnAudioFileOnCD()
@@ -601,9 +605,11 @@ cAudioManager::InterrogateAudioEntities()
void
cAudioManager::AddSampleToRequestedQueue()
{
- int32 calculatedVolume;
+ uint32 calculatedVolume;
uint8 sampleIndex;
+#ifdef AUDIO_REFLECTIONS
bool8 bReflections;
+#endif
if (m_sQueueSample.m_nSampleIndex < TOTAL_AUDIO_SAMPLES) {
calculatedVolume = m_sQueueSample.m_nReleasingVolumeModificator * (MAX_VOLUME - m_sQueueSample.m_nVolume);
@@ -617,11 +623,12 @@ cAudioManager::AddSampleToRequestedQueue()
}
m_sQueueSample.m_nCalculatedVolume = calculatedVolume;
m_sQueueSample.m_bLoopEnded = FALSE;
+#ifdef AUDIO_REFLECTIONS
if (m_sQueueSample.m_bIs2D) {
m_sQueueSample.m_bRequireReflection = FALSE;
m_sQueueSample.m_nLoopsRemaining = 0;
}
- if (m_bDynamicAcousticModelingStatus && m_sQueueSample.m_nLoopCount) {
+ if (m_bDynamicAcousticModelingStatus && m_sQueueSample.m_nLoopCount > 0) {
bReflections = m_sQueueSample.m_bRequireReflection;
} else {
bReflections = FALSE;
@@ -631,12 +638,15 @@ cAudioManager::AddSampleToRequestedQueue()
if (!m_bDynamicAcousticModelingStatus)
m_sQueueSample.m_bReverbFlag = FALSE;
+#endif
m_asSamples[m_nActiveSampleQueue][sampleIndex] = m_sQueueSample;
AddDetailsToRequestedOrderList(sampleIndex);
+#ifdef AUDIO_REFLECTIONS
if (bReflections)
AddReflectionsToRequestedQueue();
+#endif
}
}
@@ -657,7 +667,7 @@ cAudioManager::AddDetailsToRequestedOrderList(uint8 sample)
m_abSampleQueueIndexTable[m_nActiveSampleQueue][i] = sample;
}
-#if GTA_VERSION >= GTA3_PC_10
+#ifdef AUDIO_REFLECTIONS
void
cAudioManager::AddReflectionsToRequestedQueue()
{
@@ -675,12 +685,12 @@ cAudioManager::AddReflectionsToRequestedQueue()
m_sQueueSample.m_nVolume = ComputeVolume(emittingVolume, m_sQueueSample.m_SoundIntensity, m_sQueueSample.m_fDistance);
if (m_sQueueSample.m_nVolume > emittingVolume / 16) {
m_sQueueSample.m_nCounter += (i + 1) * 256;
- if (m_sQueueSample.m_nLoopCount) {
+ if (m_sQueueSample.m_nLoopCount > 0) {
noise = RandomDisplacement(m_sQueueSample.m_nFrequency / 32);
- if (noise <= 0)
- m_sQueueSample.m_nFrequency += noise;
- else
+ if (noise > 0)
m_sQueueSample.m_nFrequency -= noise;
+ else
+ m_sQueueSample.m_nFrequency += noise;
}
m_sQueueSample.m_nReleasingVolumeModificator += 20;
m_sQueueSample.m_vecPos = m_avecReflectionsPos[i];
@@ -740,7 +750,7 @@ cAudioManager::UpdateReflections()
m_afReflectionsDistances[4] = 50.0f;
}
}
-#endif // GTA_VERSION >= GTA3_PC_10
+#endif // AUDIO_REFLECTIONS
void
cAudioManager::AddReleasingSounds()
@@ -768,7 +778,10 @@ cAudioManager::AddReleasingSounds()
}
}
if (!toProcess[i]) {
- if (sample.m_nCounter <= 255 || sample.m_nLoopsRemaining == 0) {
+#ifdef AUDIO_REFLECTIONS
+ if (sample.m_nCounter <= 255 || sample.m_nLoopsRemaining == 0) // check if not reflection
+#endif
+ {
if (sample.m_nReleasingVolumeDivider == 0)
continue;
if (sample.m_nLoopCount == 0) {
@@ -831,7 +844,7 @@ cAudioManager::ProcessActiveQueues()
for (int32 j = 0; j < m_nActiveSamples; j++) {
if (sample.m_nEntityIndex == m_asActiveSamples[j].m_nEntityIndex && sample.m_nCounter == m_asActiveSamples[j].m_nCounter &&
sample.m_nSampleIndex == m_asActiveSamples[j].m_nSampleIndex) {
- if (sample.m_nLoopCount) {
+ if (sample.m_nLoopCount > 0) {
if (m_FrameCounter & 1)
flag = !!(j & 1);
else
@@ -914,13 +927,16 @@ cAudioManager::ProcessActiveQueues()
for (uint8 i = 0; i < m_SampleRequestQueuesStatus[m_nActiveSampleQueue]; i++) {
tSound &sample = m_asSamples[m_nActiveSampleQueue][m_abSampleQueueIndexTable[m_nActiveSampleQueue][i]];
if (!sample.m_bIsProcessed && !sample.m_bLoopEnded && m_asAudioEntities[sample.m_nEntityIndex].m_bIsUsed && sample.m_nSampleIndex < NO_SAMPLE) {
- if (sample.m_nCounter > 255 && sample.m_nLoopCount != 0 && sample.m_nLoopsRemaining != 0) {
+#ifdef AUDIO_REFLECTIONS
+ if (sample.m_nCounter > 255 && sample.m_nLoopCount > 0 && sample.m_nLoopsRemaining > 0) { // check if reflection
sample.m_nLoopsRemaining--;
sample.m_nReleasingVolumeDivider = 1;
- } else {
+ } else
+#endif
+ {
for (uint8 j = 0; j < m_nActiveSamples; j++) {
if (!m_asActiveSamples[j].m_bIsProcessed) {
- if (sample.m_nLoopCount != 0) {
+ if (sample.m_nLoopCount > 0) {
samplesPerFrame = sample.m_nFrequency / m_nTimeSpent;
samplesToPlay = sample.m_nLoopCount * SampleManager.GetSampleLength(sample.m_nSampleIndex);
if (samplesPerFrame == 0)
@@ -1028,7 +1044,7 @@ cAudioManager::ClearActiveSamples()
m_asActiveSamples[i].m_nVolumeChange = -1;
m_asActiveSamples[i].m_vecPos = CVector(0.0f, 0.0f, 0.0f);
m_asActiveSamples[i].m_bReverbFlag = FALSE;
-#if GTA_VERSION >= GTA3_PC_10
+#ifdef AUDIO_REFLECTIONS
m_asActiveSamples[i].m_nLoopsRemaining = 0;
m_asActiveSamples[i].m_bRequireReflection = FALSE;
#endif