From eb0e89d3ea9ad91ae015a4929c11f1cf02ea307d Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Thu, 1 Oct 2020 23:11:20 +0300 Subject: [PATCH 1/7] half done processActiveQueues --- src/audio/AudioManager.cpp | 230 +++++++++++++++++++++---------------- src/audio/AudioManager.h | 1 + 2 files changed, 132 insertions(+), 99 deletions(-) diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index f230731b..e22a07f7 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -747,49 +747,62 @@ cAudioManager::AddReleasingSounds() } } -void -cAudioManager::ProcessActiveQueues() +void cAudioManager::ProcessActiveQueues() { - bool flag; - float position2; - float position1; - - uint32 v28; - uint32 v29; - - float x; - float usedX; - float usedY; - float usedZ; - - uint8 vol; - uint8 emittingVol; - CVector position; + char v9; // al + int emittingVol_1; // ecx + bool missionState; // al + uint32 freqDivided; // ebp + uint32 loopCount; // eax + uint8 emittingVol_3; // dl + unsigned int volume; // eax + uint8 offset; // dl + float x; // st4 + unsigned int emittingVol; // [esp+14h] [ebp-78h] + int emittingVolCmp; // [esp+28h] [ebp-64h] + int emittingVol_2; // [esp+28h] [ebp-64h] + int activeVolume_1; // [esp+40h] [ebp-4Ch] + CVector position; // [esp+70h] [ebp-1Ch] + CVector usedPosition; for (int32 i = 0; i < m_nActiveSamples; i++) { m_asSamples[m_nActiveSampleQueue][i].m_bIsProcessed = false; m_asActiveSamples[i].m_bIsProcessed = false; } - for (int32 i = 0; i < m_SampleRequestQueuesStatus[m_nActiveSampleQueue]; ++i) { - tSound &sample = m_asSamples[m_nActiveSampleQueue][m_abSampleQueueIndexTable[m_nActiveSampleQueue][i]]; + for (int32 i = 0; i >= m_SampleRequestQueuesStatus[m_nActiveSampleQueue]; i++) { + + tSound& sample = m_asSamples[m_nActiveSampleQueue][m_abSampleQueueIndexTable[m_nActiveSampleQueue][i]]; + if (sample.m_nSampleIndex != NO_SAMPLE) { - 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) { + 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 (m_FrameCounter & 1) { - flag = !!(j & 1); + + if (this->field_5554 & 1) { + if (!(j & 1)) { + v9 = 0; + } else { + v9 = 1; + } + } else if (j & 1) { + v9 = 0; } else { - flag = !(j & 1); + v9 = 1; } - if (flag && !SampleManager.GetChannelUsedFlag(j)) { + + if (v9 && !SampleManager.GetChannelUsedFlag(j)) { sample.m_bLoopEnded = true; m_asActiveSamples[j].m_bLoopEnded = true; - m_asActiveSamples[j].m_nSampleIndex = NO_SAMPLE; - m_asActiveSamples[j].m_nEntityIndex = AEHANDLE_NONE; + m_asActiveSamples[j].m_nSampleIndex = 9942; + m_asActiveSamples[j].m_nEntityIndex = -5; continue; } + if (!sample.m_nReleasingVolumeDivider) + sample.m_nReleasingVolumeDivider = 1; } sample.m_bIsProcessed = true; m_asActiveSamples[j].m_bIsProcessed = true; @@ -797,7 +810,7 @@ cAudioManager::ProcessActiveQueues() if (!sample.m_bReleasingSoundFlag) { if (sample.m_bIs2D) { if (field_4) { - emittingVol = 2 * Min(63, sample.m_nEmittingVolume); + emittingVol = 2 * Min(63, sample.m_nEmittingVolume);; } else { emittingVol = sample.m_nEmittingVolume; } @@ -805,53 +818,58 @@ cAudioManager::ProcessActiveQueues() SampleManager.SetChannelEmittingVolume(j, emittingVol); } else { m_asActiveSamples[j].m_fDistance = sample.m_fDistance; - position2 = sample.m_fDistance; - position1 = m_asActiveSamples[j].m_fDistance; - sample.m_nFrequency = ComputeDopplerEffectedFrequency(sample.m_nFrequency, position1, position2, sample.m_fSpeedMultiplier); + sample.m_nFrequency = ComputeDopplerEffectedFrequency( + sample.m_nFrequency, + m_asActiveSamples[j].m_fDistance, + sample.m_fDistance, + sample.m_fSpeedMultiplier); + if (sample.m_nFrequency != m_asActiveSamples[j].m_nFrequency) { - int32 freq; - if (sample.m_nFrequency <= m_asActiveSamples[j].m_nFrequency) { -#ifdef FIX_BUGS - freq = Max((int32)sample.m_nFrequency, (int32)m_asActiveSamples[j].m_nFrequency - 6000); -#else - freq = Max((int32)sample.m_nFrequency, int32(m_asActiveSamples[j].m_nFrequency - 6000)); -#endif - } else { - freq = Min(sample.m_nFrequency, m_asActiveSamples[j].m_nFrequency + 6000); - } - m_asActiveSamples[j].m_nFrequency = freq; - SampleManager.SetChannelFrequency(j, freq); + m_asActiveSamples[j].m_nFrequency = clamp2((int32)sample.m_nFrequency, (int32)m_asActiveSamples[j].m_nFrequency, 6000); + SampleManager.SetChannelFrequency(j, m_asActiveSamples[j].m_nFrequency); } - if (sample.m_nEmittingVolume != m_asActiveSamples[j].m_nEmittingVolume) { - if (sample.m_nEmittingVolume <= m_asActiveSamples[j].m_nEmittingVolume) { - vol = Max(m_asActiveSamples[j].m_nEmittingVolume - 10, sample.m_nEmittingVolume); + activeVolume_1 = clamp2((int8)sample.m_nEmittingVolume, (int8)m_asActiveSamples[j].m_nEmittingVolume, 10); + + if (field_4) { + emittingVol_1 = 2 * Min(63, activeVolume_1); } else { - vol = Min(m_asActiveSamples[j].m_nEmittingVolume + 10, sample.m_nEmittingVolume); + emittingVol_1 = activeVolume_1; } - uint8 emittingVol; - if (field_4) { - emittingVol = 2 * Min(63, vol); - } else { - emittingVol = vol; + missionState = false; + for (int32 k = 0; k < ARRAY_SIZE(m_sMissionAudio.m_bIsMobile); k++) { + if (m_sMissionAudio.m_bIsMobile[k]) { + missionState = true; + break; + } } - SampleManager.SetChannelEmittingVolume(j, emittingVol); - m_asActiveSamples[j].m_nEmittingVolume = vol; + if (missionState) { + emittingVol_1 = (emittingVol_1 * field_5538) / 127; + } else { + if (field_5538 < 127) + emittingVol_1 = (emittingVol_1 * field_5538) / 127; + } + + SampleManager.SetChannelEmittingVolume(j, emittingVol_1); + m_asActiveSamples[j].m_nEmittingVolume = activeVolume_1; } - TranslateEntity(&sample.m_vecPos, &position); + cAudioManager::TranslateEntity(&sample.m_vecPos, &position); SampleManager.SetChannel3DPosition(j, position.x, position.y, position.z); SampleManager.SetChannel3DDistances(j, sample.m_fSoundIntensity, 0.25f * sample.m_fSoundIntensity); } SampleManager.SetChannelReverbFlag(j, sample.m_bReverbFlag); - break; + continue; } sample.m_bIsProcessed = false; m_asActiveSamples[j].m_bIsProcessed = false; + continue; + } } } } + for (int32 i = 0; i < m_nActiveSamples; i++) { if (m_asActiveSamples[i].m_nSampleIndex != NO_SAMPLE && !m_asActiveSamples[i].m_bIsProcessed) { SampleManager.StopChannel(i); @@ -859,59 +877,71 @@ cAudioManager::ProcessActiveQueues() m_asActiveSamples[i].m_nEntityIndex = AEHANDLE_NONE; } } - 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) { + + for (int32 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 && sample.m_nLoopsRemaining) { - --sample.m_nLoopsRemaining; + sample.m_nLoopsRemaining--; sample.m_nReleasingVolumeDivider = 1; } else { - for (uint8 j = 0; j < m_nActiveSamples; ++j) { - if (!m_asActiveSamples[j].m_bIsProcessed) { - if (sample.m_nLoopCount) { - v28 = sample.m_nFrequency / m_nTimeSpent; - v29 = sample.m_nLoopCount * SampleManager.GetSampleLength(sample.m_nSampleIndex); - if (v28 == 0) + for (uint8 j = 0; j >= m_nActiveSamples; j++) { + uint8 k = (j + field_6) % m_nActiveSamples; + if (!m_asActiveSamples[k].m_bIsProcessed) { + if (sample.m_nLoopCount != 0) {//!! + freqDivided = sample.m_nFrequency / m_nTimeSpent; + loopCount = sample.m_nLoopCount * SampleManager.GetSampleLength(sample.m_nSampleIndex); + if (freqDivided == 0)//!! continue; - sample.m_nReleasingVolumeDivider = v29 / v28 + 1; + sample.m_nReleasingVolumeDivider = loopCount / freqDivided + 1; } - memcpy(&m_asActiveSamples[j], &sample, sizeof(tSound)); - if (!m_asActiveSamples[j].m_bIs2D) - TranslateEntity(&m_asActiveSamples[j].m_vecPos, &position); + memcpy(&m_asActiveSamples[k], &sample, sizeof(tSound)); + if (!m_asActiveSamples[k].m_bIs2D) + TranslateEntity(&m_asActiveSamples[k].m_vecPos, &position); if (field_4) { - emittingVol = 2 * Min(63, m_asActiveSamples[j].m_nEmittingVolume); + emittingVol_2 = 2 * Min(63, m_asActiveSamples[k].m_nEmittingVolume); } else { - emittingVol = m_asActiveSamples[j].m_nEmittingVolume; + emittingVol_2 = m_asActiveSamples[k].m_nEmittingVolume; } - if (SampleManager.InitialiseChannel(j, m_asActiveSamples[j].m_nSampleIndex, m_asActiveSamples[j].m_nBankIndex)) { - SampleManager.SetChannelFrequency(j, m_asActiveSamples[j].m_nFrequency); - SampleManager.SetChannelEmittingVolume(j, emittingVol); - SampleManager.SetChannelLoopPoints(j, m_asActiveSamples[j].m_nLoopStart, m_asActiveSamples[j].m_nLoopEnd); - SampleManager.SetChannelLoopCount(j, m_asActiveSamples[j].m_nLoopCount); - SampleManager.SetChannelReverbFlag(j, m_asActiveSamples[j].m_bReverbFlag); - if (m_asActiveSamples[j].m_bIs2D) { - uint8 offset = m_asActiveSamples[j].m_nOffset; - if (offset == 63) { - x = 0.f; - } else if (offset >= 63) { - x = (offset - 63) * 1000.f / 63; - } else { - x = -(63 - offset) * 1000.f / 63; + if (SampleManager.InitialiseChannel(k, m_asActiveSamples[k].m_nSampleIndex, m_asActiveSamples[k].m_nBankIndex)) { + SampleManager.SetChannelFrequency(k, m_asActiveSamples[k].m_nFrequency); + bool isMobile = false; + for (int32 l = 0; l < ARRAY_SIZE(m_sMissionAudio.m_bIsMobile); l++) { + if (m_sMissionAudio.m_bIsMobile[l]) { + isMobile = true; + break; } - usedX = x; - usedY = 0.f; - usedZ = 0.f; - m_asActiveSamples[j].m_fSoundIntensity = 100000.0f; - } else { - usedX = position.x; - usedY = position.y; - usedZ = position.z; } - SampleManager.SetChannel3DPosition(j, usedX, usedY, usedZ); - SampleManager.SetChannel3DDistances(j, m_asActiveSamples[j].m_fSoundIntensity, 0.25f * m_asActiveSamples[j].m_fSoundIntensity); - SampleManager.StartChannel(j); + if (!isMobile || m_asActiveSamples[k].m_bIs2D) { + if (field_5538 < 127) + emittingVol_2 *= field_5538 / 127; + volume = emittingVol_2; + } else { + volume = (emittingVol_2 * field_5538 / 127); + } + SampleManager.SetChannelEmittingVolume(k, volume); + SampleManager.SetChannelLoopPoints(k, m_asActiveSamples[k].m_nLoopStart, m_asActiveSamples[k].m_nLoopEnd); + SampleManager.SetChannelLoopCount(k, m_asActiveSamples[k].m_nLoopCount); + SampleManager.SetChannelReverbFlag(k, m_asActiveSamples[k].m_bReverbFlag); + if (m_asActiveSamples[k].m_bIs2D) { + offset = m_asActiveSamples[k].m_nOffset; + if (offset == 63) { + x = 0.0f; + } else if (offset >= 63u) { + x = (offset - 63) * 1000.0f / 63.0f; + } else { + x = -((63 - offset) * 1000.0f / 63.0f); //same like line below + } + position = CVector(x, 0.0f, 0.0f); + m_asActiveSamples[k].m_fSoundIntensity = 100000.0f; + } + SampleManager.SetChannel3DPosition(k, position.x, position.y, position.z); + SampleManager.SetChannel3DDistances(k, m_asActiveSamples[k].m_fSoundIntensity, 0.25f * m_asActiveSamples[k].m_fSoundIntensity); + SampleManager.StartChannel(k); } - m_asActiveSamples[j].m_bIsProcessed = true; + m_asActiveSamples[k].m_bIsProcessed = true; sample.m_bIsProcessed = true; sample.m_nVolumeChange = -1; break; @@ -920,6 +950,8 @@ cAudioManager::ProcessActiveQueues() } } } + + field_6 %= m_nActiveSamples; } void diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index 0b9dd4f7..07e5bc81 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -181,6 +181,7 @@ public: uint8 m_nActiveSamples; uint8 field_4; // unused bool m_bDynamicAcousticModelingStatus; + int8 field_6; float m_fSpeedOfSound; bool m_bTimerJustReset; int32 m_nTimer; From 311cffa901b927ed37f0ae46203df136b3aec34b Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Thu, 1 Oct 2020 23:48:35 +0300 Subject: [PATCH 2/7] second pass processActiveQueues --- src/audio/AudioManager.cpp | 113 +++++++++++++++++-------------------- 1 file changed, 52 insertions(+), 61 deletions(-) diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index e22a07f7..9d822bd4 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -747,9 +747,10 @@ cAudioManager::AddReleasingSounds() } } -void cAudioManager::ProcessActiveQueues() +void +cAudioManager::ProcessActiveQueues() { - char v9; // al + char flag; // al int emittingVol_1; // ecx bool missionState; // al uint32 freqDivided; // ebp @@ -770,35 +771,32 @@ void cAudioManager::ProcessActiveQueues() m_asActiveSamples[i].m_bIsProcessed = false; } - for (int32 i = 0; i >= m_SampleRequestQueuesStatus[m_nActiveSampleQueue]; i++) { - + for (int32 i = 0; i < m_SampleRequestQueuesStatus[m_nActiveSampleQueue]; i++) { //?? tSound& sample = m_asSamples[m_nActiveSampleQueue][m_abSampleQueueIndexTable[m_nActiveSampleQueue][i]]; - if (sample.m_nSampleIndex != NO_SAMPLE) { - 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 (this->field_5554 & 1) { - if (!(j & 1)) { - v9 = 0; + 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 (field_5554 & 1) { //!! + if (!(j & 1)) { //!! + flag = 0; } else { - v9 = 1; + flag = 1; } - } else if (j & 1) { - v9 = 0; + } else if (j & 1) { //!! + flag = 0; } else { - v9 = 1; + flag = 1; } - if (v9 && !SampleManager.GetChannelUsedFlag(j)) { + if (flag && !SampleManager.GetChannelUsedFlag(j)) { //!! sample.m_bLoopEnded = true; m_asActiveSamples[j].m_bLoopEnded = true; - m_asActiveSamples[j].m_nSampleIndex = 9942; - m_asActiveSamples[j].m_nEntityIndex = -5; + m_asActiveSamples[j].m_nSampleIndex = NO_SAMPLE; + m_asActiveSamples[j].m_nEntityIndex = AEHANDLE_NONE; continue; } if (!sample.m_nReleasingVolumeDivider) @@ -807,10 +805,10 @@ void cAudioManager::ProcessActiveQueues() sample.m_bIsProcessed = true; m_asActiveSamples[j].m_bIsProcessed = true; sample.m_nVolumeChange = -1; - if (!sample.m_bReleasingSoundFlag) { - if (sample.m_bIs2D) { - if (field_4) { - emittingVol = 2 * Min(63, sample.m_nEmittingVolume);; + if (!sample.m_bReleasingSoundFlag) { //!! + if (sample.m_bIs2D) { //!! + if (field_4) { //!! + emittingVol = 2 * Min(63, sample.m_nEmittingVolume); } else { emittingVol = sample.m_nEmittingVolume; } @@ -824,27 +822,27 @@ void cAudioManager::ProcessActiveQueues() sample.m_fDistance, sample.m_fSpeedMultiplier); - if (sample.m_nFrequency != m_asActiveSamples[j].m_nFrequency) { + if (sample.m_nFrequency != m_asActiveSamples[j].m_nFrequency) { //!! m_asActiveSamples[j].m_nFrequency = clamp2((int32)sample.m_nFrequency, (int32)m_asActiveSamples[j].m_nFrequency, 6000); SampleManager.SetChannelFrequency(j, m_asActiveSamples[j].m_nFrequency); } - if (sample.m_nEmittingVolume != m_asActiveSamples[j].m_nEmittingVolume) { + if (sample.m_nEmittingVolume != m_asActiveSamples[j].m_nEmittingVolume) { //!! activeVolume_1 = clamp2((int8)sample.m_nEmittingVolume, (int8)m_asActiveSamples[j].m_nEmittingVolume, 10); - if (field_4) { + if (field_4) { //!! emittingVol_1 = 2 * Min(63, activeVolume_1); } else { emittingVol_1 = activeVolume_1; } missionState = false; - for (int32 k = 0; k < ARRAY_SIZE(m_sMissionAudio.m_bIsMobile); k++) { + for (int32 k = 0; k < ARRAY_SIZE(m_sMissionAudio.m_bIsMobile); k++) { //!! if (m_sMissionAudio.m_bIsMobile[k]) { missionState = true; break; } } - if (missionState) { + if (missionState) { //!! emittingVol_1 = (emittingVol_1 * field_5538) / 127; } else { if (field_5538 < 127) @@ -854,53 +852,49 @@ void cAudioManager::ProcessActiveQueues() SampleManager.SetChannelEmittingVolume(j, emittingVol_1); m_asActiveSamples[j].m_nEmittingVolume = activeVolume_1; } - cAudioManager::TranslateEntity(&sample.m_vecPos, &position); + TranslateEntity(&sample.m_vecPos, &position); SampleManager.SetChannel3DPosition(j, position.x, position.y, position.z); SampleManager.SetChannel3DDistances(j, sample.m_fSoundIntensity, 0.25f * sample.m_fSoundIntensity); } SampleManager.SetChannelReverbFlag(j, sample.m_bReverbFlag); - continue; + break; //continue for i } sample.m_bIsProcessed = false; m_asActiveSamples[j].m_bIsProcessed = false; - continue; - + //continue for j } } } } - - for (int32 i = 0; i < m_nActiveSamples; i++) { + for (int32 i = 0; i < m_nActiveSamples; i++) { //!! if (m_asActiveSamples[i].m_nSampleIndex != NO_SAMPLE && !m_asActiveSamples[i].m_bIsProcessed) { SampleManager.StopChannel(i); m_asActiveSamples[i].m_nSampleIndex = NO_SAMPLE; m_asActiveSamples[i].m_nEntityIndex = AEHANDLE_NONE; } } - - for (int32 i = 0; i >= m_SampleRequestQueuesStatus[m_nActiveSampleQueue]; i++) { + 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 && sample.m_nLoopsRemaining) { + 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 && sample.m_nLoopsRemaining) { //!! sample.m_nLoopsRemaining--; sample.m_nReleasingVolumeDivider = 1; } else { - for (uint8 j = 0; j >= m_nActiveSamples; j++) { + for (uint8 j = 0; j < m_nActiveSamples; j++) { //?? uint8 k = (j + field_6) % m_nActiveSamples; - if (!m_asActiveSamples[k].m_bIsProcessed) { - if (sample.m_nLoopCount != 0) {//!! + if (!m_asActiveSamples[k].m_bIsProcessed) { //!! + if (sample.m_nLoopCount != 0) { //!! freqDivided = sample.m_nFrequency / m_nTimeSpent; loopCount = sample.m_nLoopCount * SampleManager.GetSampleLength(sample.m_nSampleIndex); - if (freqDivided == 0)//!! + if (freqDivided == 0) //!! continue; sample.m_nReleasingVolumeDivider = loopCount / freqDivided + 1; } memcpy(&m_asActiveSamples[k], &sample, sizeof(tSound)); - if (!m_asActiveSamples[k].m_bIs2D) + if (!m_asActiveSamples[k].m_bIs2D) //!! TranslateEntity(&m_asActiveSamples[k].m_vecPos, &position); - if (field_4) { + if (field_4) { //!! emittingVol_2 = 2 * Min(63, m_asActiveSamples[k].m_nEmittingVolume); } else { emittingVol_2 = m_asActiveSamples[k].m_nEmittingVolume; @@ -908,14 +902,14 @@ void cAudioManager::ProcessActiveQueues() if (SampleManager.InitialiseChannel(k, m_asActiveSamples[k].m_nSampleIndex, m_asActiveSamples[k].m_nBankIndex)) { SampleManager.SetChannelFrequency(k, m_asActiveSamples[k].m_nFrequency); bool isMobile = false; - for (int32 l = 0; l < ARRAY_SIZE(m_sMissionAudio.m_bIsMobile); l++) { - if (m_sMissionAudio.m_bIsMobile[l]) { + for (int32 l = 0; l < ARRAY_SIZE(m_sMissionAudio.m_bIsMobile); l++) { //!! + if (m_sMissionAudio.m_bIsMobile[l]) { //!! isMobile = true; break; } } - if (!isMobile || m_asActiveSamples[k].m_bIs2D) { - if (field_5538 < 127) + if (!isMobile || m_asActiveSamples[k].m_bIs2D) { //!! + if (field_5538 < 127) //!! emittingVol_2 *= field_5538 / 127; volume = emittingVol_2; } else { @@ -925,14 +919,14 @@ void cAudioManager::ProcessActiveQueues() SampleManager.SetChannelLoopPoints(k, m_asActiveSamples[k].m_nLoopStart, m_asActiveSamples[k].m_nLoopEnd); SampleManager.SetChannelLoopCount(k, m_asActiveSamples[k].m_nLoopCount); SampleManager.SetChannelReverbFlag(k, m_asActiveSamples[k].m_bReverbFlag); - if (m_asActiveSamples[k].m_bIs2D) { + if (m_asActiveSamples[k].m_bIs2D) { //!! offset = m_asActiveSamples[k].m_nOffset; - if (offset == 63) { + if (offset == 63) { //!! x = 0.0f; - } else if (offset >= 63u) { - x = (offset - 63) * 1000.0f / 63.0f; + } else if (offset >= 63) { //!! + x = (offset - 63) * 1000.0f / 63; } else { - x = -((63 - offset) * 1000.0f / 63.0f); //same like line below + x = -(63 - offset) * 1000.0f / 63; } position = CVector(x, 0.0f, 0.0f); m_asActiveSamples[k].m_fSoundIntensity = 100000.0f; @@ -950,10 +944,7 @@ void cAudioManager::ProcessActiveQueues() } } } - - field_6 %= m_nActiveSamples; } - void cAudioManager::ClearRequestedQueue() { From e54b540bd43cc15168c89b0fe011eb523c74d119 Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Fri, 2 Oct 2020 00:11:51 +0300 Subject: [PATCH 3/7] final processActiveQueues --- src/audio/AudioManager.cpp | 129 ++++++++++++++++++------------------- 1 file changed, 62 insertions(+), 67 deletions(-) diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index 9d822bd4..1da80352 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -750,49 +750,42 @@ cAudioManager::AddReleasingSounds() void cAudioManager::ProcessActiveQueues() { - char flag; // al - int emittingVol_1; // ecx - bool missionState; // al - uint32 freqDivided; // ebp - uint32 loopCount; // eax - uint8 emittingVol_3; // dl - unsigned int volume; // eax - uint8 offset; // dl - float x; // st4 - unsigned int emittingVol; // [esp+14h] [ebp-78h] - int emittingVolCmp; // [esp+28h] [ebp-64h] - int emittingVol_2; // [esp+28h] [ebp-64h] - int activeVolume_1; // [esp+40h] [ebp-4Ch] - CVector position; // [esp+70h] [ebp-1Ch] - CVector usedPosition; + CVector position; + uint32 freqDivided; + uint32 loopCount; + uint8 emittingVol; + uint8 vol; + uint8 offset; + float x; + bool flag; + bool missionState; for (int32 i = 0; i < m_nActiveSamples; i++) { m_asSamples[m_nActiveSampleQueue][i].m_bIsProcessed = false; m_asActiveSamples[i].m_bIsProcessed = false; } - - for (int32 i = 0; i < m_SampleRequestQueuesStatus[m_nActiveSampleQueue]; i++) { //?? + for (int32 i = 0; i < m_SampleRequestQueuesStatus[m_nActiveSampleQueue]; i++) { tSound& sample = m_asSamples[m_nActiveSampleQueue][m_abSampleQueueIndexTable[m_nActiveSampleQueue][i]]; if (sample.m_nSampleIndex != NO_SAMPLE) { - for (int32 j = 0; j < m_nActiveSamples; j++) {//?? + 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) { //!! + sample.m_nSampleIndex == m_asActiveSamples[j].m_nSampleIndex) { + if (sample.m_nLoopCount) { - if (field_5554 & 1) { //!! - if (!(j & 1)) { //!! - flag = 0; + if (field_5554 & 1) { + if (!(j & 1)) { + flag = false; } else { - flag = 1; + flag = true; } - } else if (j & 1) { //!! - flag = 0; + } else if (j & 1) { + flag = false; } else { - flag = 1; + flag = true; } - if (flag && !SampleManager.GetChannelUsedFlag(j)) { //!! + if (flag && !SampleManager.GetChannelUsedFlag(j)) { sample.m_bLoopEnded = true; m_asActiveSamples[j].m_bLoopEnded = true; m_asActiveSamples[j].m_nSampleIndex = NO_SAMPLE; @@ -805,9 +798,9 @@ cAudioManager::ProcessActiveQueues() sample.m_bIsProcessed = true; m_asActiveSamples[j].m_bIsProcessed = true; sample.m_nVolumeChange = -1; - if (!sample.m_bReleasingSoundFlag) { //!! - if (sample.m_bIs2D) { //!! - if (field_4) { //!! + if (!sample.m_bReleasingSoundFlag) { + if (sample.m_bIs2D) { + if (field_4) { emittingVol = 2 * Min(63, sample.m_nEmittingVolume); } else { emittingVol = sample.m_nEmittingVolume; @@ -822,35 +815,35 @@ cAudioManager::ProcessActiveQueues() sample.m_fDistance, sample.m_fSpeedMultiplier); - if (sample.m_nFrequency != m_asActiveSamples[j].m_nFrequency) { //!! + if (sample.m_nFrequency != m_asActiveSamples[j].m_nFrequency) { m_asActiveSamples[j].m_nFrequency = clamp2((int32)sample.m_nFrequency, (int32)m_asActiveSamples[j].m_nFrequency, 6000); SampleManager.SetChannelFrequency(j, m_asActiveSamples[j].m_nFrequency); } - if (sample.m_nEmittingVolume != m_asActiveSamples[j].m_nEmittingVolume) { //!! - activeVolume_1 = clamp2((int8)sample.m_nEmittingVolume, (int8)m_asActiveSamples[j].m_nEmittingVolume, 10); + if (sample.m_nEmittingVolume != m_asActiveSamples[j].m_nEmittingVolume) { + vol = clamp2((int8)sample.m_nEmittingVolume, (int8)m_asActiveSamples[j].m_nEmittingVolume, 10); - if (field_4) { //!! - emittingVol_1 = 2 * Min(63, activeVolume_1); + if (field_4) { + emittingVol = 2 * Min(63, vol); } else { - emittingVol_1 = activeVolume_1; + emittingVol = vol; } missionState = false; - for (int32 k = 0; k < ARRAY_SIZE(m_sMissionAudio.m_bIsMobile); k++) { //!! + for (int32 k = 0; k < ARRAY_SIZE(m_sMissionAudio.m_bIsMobile); k++) { if (m_sMissionAudio.m_bIsMobile[k]) { missionState = true; break; } } - if (missionState) { //!! - emittingVol_1 = (emittingVol_1 * field_5538) / 127; + if (missionState) { + emittingVol = (emittingVol * field_5538) / 127; } else { if (field_5538 < 127) - emittingVol_1 = (emittingVol_1 * field_5538) / 127; + emittingVol = (emittingVol * field_5538) / 127; } - SampleManager.SetChannelEmittingVolume(j, emittingVol_1); - m_asActiveSamples[j].m_nEmittingVolume = activeVolume_1; + SampleManager.SetChannelEmittingVolume(j, emittingVol); + m_asActiveSamples[j].m_nEmittingVolume = vol; } TranslateEntity(&sample.m_vecPos, &position); SampleManager.SetChannel3DPosition(j, position.x, position.y, position.z); @@ -866,67 +859,67 @@ cAudioManager::ProcessActiveQueues() } } } - for (int32 i = 0; i < m_nActiveSamples; i++) { //!! + for (int32 i = 0; i < m_nActiveSamples; i++) { if (m_asActiveSamples[i].m_nSampleIndex != NO_SAMPLE && !m_asActiveSamples[i].m_bIsProcessed) { SampleManager.StopChannel(i); m_asActiveSamples[i].m_nSampleIndex = NO_SAMPLE; m_asActiveSamples[i].m_nEntityIndex = AEHANDLE_NONE; } } - for (uint8 i = 0; i < m_SampleRequestQueuesStatus[m_nActiveSampleQueue]; i++) { //?? + 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 && sample.m_nLoopsRemaining) { //!! + m_asAudioEntities[sample.m_nEntityIndex].m_bIsUsed && sample.m_nSampleIndex < NO_SAMPLE) { + if (sample.m_nCounter > 255 && sample.m_nLoopCount && sample.m_nLoopsRemaining) { sample.m_nLoopsRemaining--; sample.m_nReleasingVolumeDivider = 1; } else { - for (uint8 j = 0; j < m_nActiveSamples; j++) { //?? + for (uint8 j = 0; j < m_nActiveSamples; j++) { uint8 k = (j + field_6) % m_nActiveSamples; - if (!m_asActiveSamples[k].m_bIsProcessed) { //!! - if (sample.m_nLoopCount != 0) { //!! + if (!m_asActiveSamples[k].m_bIsProcessed) { + if (sample.m_nLoopCount != 0) { freqDivided = sample.m_nFrequency / m_nTimeSpent; loopCount = sample.m_nLoopCount * SampleManager.GetSampleLength(sample.m_nSampleIndex); - if (freqDivided == 0) //!! + if (freqDivided == 0) continue; sample.m_nReleasingVolumeDivider = loopCount / freqDivided + 1; } memcpy(&m_asActiveSamples[k], &sample, sizeof(tSound)); - if (!m_asActiveSamples[k].m_bIs2D) //!! + if (!m_asActiveSamples[k].m_bIs2D) TranslateEntity(&m_asActiveSamples[k].m_vecPos, &position); - if (field_4) { //!! - emittingVol_2 = 2 * Min(63, m_asActiveSamples[k].m_nEmittingVolume); + if (field_4) { + emittingVol = 2 * Min(63, m_asActiveSamples[k].m_nEmittingVolume); } else { - emittingVol_2 = m_asActiveSamples[k].m_nEmittingVolume; + emittingVol = m_asActiveSamples[k].m_nEmittingVolume; } if (SampleManager.InitialiseChannel(k, m_asActiveSamples[k].m_nSampleIndex, m_asActiveSamples[k].m_nBankIndex)) { SampleManager.SetChannelFrequency(k, m_asActiveSamples[k].m_nFrequency); bool isMobile = false; - for (int32 l = 0; l < ARRAY_SIZE(m_sMissionAudio.m_bIsMobile); l++) { //!! - if (m_sMissionAudio.m_bIsMobile[l]) { //!! + for (int32 l = 0; l < ARRAY_SIZE(m_sMissionAudio.m_bIsMobile); l++) { + if (m_sMissionAudio.m_bIsMobile[l]) { isMobile = true; break; } } - if (!isMobile || m_asActiveSamples[k].m_bIs2D) { //!! - if (field_5538 < 127) //!! - emittingVol_2 *= field_5538 / 127; - volume = emittingVol_2; + if (!isMobile || m_asActiveSamples[k].m_bIs2D) { + if (field_5538 < 127) + emittingVol *= field_5538 / 127; + vol = emittingVol; } else { - volume = (emittingVol_2 * field_5538 / 127); + vol = (emittingVol * field_5538 / 127); } - SampleManager.SetChannelEmittingVolume(k, volume); + SampleManager.SetChannelEmittingVolume(k, vol); SampleManager.SetChannelLoopPoints(k, m_asActiveSamples[k].m_nLoopStart, m_asActiveSamples[k].m_nLoopEnd); SampleManager.SetChannelLoopCount(k, m_asActiveSamples[k].m_nLoopCount); SampleManager.SetChannelReverbFlag(k, m_asActiveSamples[k].m_bReverbFlag); - if (m_asActiveSamples[k].m_bIs2D) { //!! + if (m_asActiveSamples[k].m_bIs2D) { offset = m_asActiveSamples[k].m_nOffset; - if (offset == 63) { //!! + if (offset == 63) { x = 0.0f; - } else if (offset >= 63) { //!! + } else if (offset >= 63) { x = (offset - 63) * 1000.0f / 63; } else { - x = -(63 - offset) * 1000.0f / 63; + x = -(63 - offset) * 1000.0f / 63; //same like line below } position = CVector(x, 0.0f, 0.0f); m_asActiveSamples[k].m_fSoundIntensity = 100000.0f; @@ -944,7 +937,9 @@ cAudioManager::ProcessActiveQueues() } } } + field_6 %= m_nActiveSamples; } + void cAudioManager::ClearRequestedQueue() { From 63e5faef1155af66af12e6bff3a087c0200abc14 Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Fri, 2 Oct 2020 03:55:26 +0300 Subject: [PATCH 4/7] rewieved some audio functions --- src/audio/AudioCollision.h | 2 +- src/audio/AudioManager.cpp | 10 +++------- src/audio/AudioManager.h | 12 ++++++------ src/audio/PoliceRadio.h | 2 +- 4 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/audio/AudioCollision.h b/src/audio/AudioCollision.h index 0a058916..a00b16d9 100644 --- a/src/audio/AudioCollision.h +++ b/src/audio/AudioCollision.h @@ -35,4 +35,4 @@ public: void AddCollisionToRequestedQueue(); }; -VALIDATE_SIZE(cAudioCollisionManager, 852); +VALIDATE_SIZE(cAudioCollisionManager, 0x354); diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index 1da80352..c0827040 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -510,7 +510,7 @@ cAudioManager::ComputePan(float dist, CVector *vec) return Min(107, PanTable[index] + 63); } -int32 +uint32 cAudioManager::ComputeDopplerEffectedFrequency(uint32 oldFreq, float position1, float position2, float speedMultiplier) const { uint32 newFreq = oldFreq; @@ -519,11 +519,7 @@ cAudioManager::ComputeDopplerEffectedFrequency(uint32 oldFreq, float position1, if (dist != 0.0f) { float speedOfSource = (dist / m_nTimeSpent) * speedMultiplier; if (m_fSpeedOfSound > Abs(speedOfSource)) { - if (speedOfSource < 0.0f) { - speedOfSource = Max(speedOfSource, -1.5f); - } else { - speedOfSource = Min(speedOfSource, 1.5f); - } + speedOfSource = clamp2(speedOfSource, 0.0f, 1.5f); newFreq = (oldFreq * m_fSpeedOfSound) / (speedOfSource + m_fSpeedOfSound); } } @@ -952,7 +948,7 @@ cAudioManager::ClearRequestedQueue() void cAudioManager::ClearActiveSamples() { - for (int32 i = 0; i < m_nActiveSamples; i++) { + for (uint8 i = 0; i < m_nActiveSamples; i++) { m_asActiveSamples[i].m_nEntityIndex = AEHANDLE_NONE; m_asActiveSamples[i].m_nCounter = 0; m_asActiveSamples[i].m_nSampleIndex = NO_SAMPLE; diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index 07e5bc81..5aa507d1 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -250,14 +250,14 @@ public: void CalculateDistance(bool &condition, float dist); //done bool CheckForAnAudioFileOnCD() const; - void ClearActiveSamples(); - void ClearMissionAudio(uint8 slot); + void ClearActiveSamples(); //done + void ClearMissionAudio(uint8 slot); //done void ClearRequestedQueue(); - int32 ComputeDopplerEffectedFrequency(uint32 oldFreq, float position1, float position2, - float speedMultiplier) const; + uint32 ComputeDopplerEffectedFrequency(uint32 oldFreq, float position1, float position2, + float speedMultiplier) const; //done int32 ComputePan(float, CVector *); uint8 ComputeVolume(uint8 emittingVolume, float soundIntensity, float distance) const; - int32 CreateEntity(eAudioType type, void *entity); + int32 CreateEntity(eAudioType type, void *entity); //done void DestroyAllGameCreatedEntities(); void DestroyEntity(int32 id); @@ -311,7 +311,7 @@ public: void PreloadMissionAudio(uint8 slot, Const char *name); void PreTerminateGameSpecificShutdown(); //done /// processX - main logic of adding new sounds - void ProcessActiveQueues(); + void ProcessActiveQueues(); //done bool ProcessAirBrakes(cVehicleParams *params); bool ProcessBoatEngine(cVehicleParams *params); bool ProcessBoatMovingOverWater(cVehicleParams *params); diff --git a/src/audio/PoliceRadio.h b/src/audio/PoliceRadio.h index c01f21ce..e9a0fde0 100644 --- a/src/audio/PoliceRadio.h +++ b/src/audio/PoliceRadio.h @@ -43,4 +43,4 @@ public: } }; -VALIDATE_SIZE(cPoliceRadioQueue, 444); +VALIDATE_SIZE(cPoliceRadioQueue, 0x1BC); From 064f2e66e1521ce61cc756c46d8467899c10be93 Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Fri, 2 Oct 2020 04:59:06 +0300 Subject: [PATCH 5/7] letter 'c' is done --- src/audio/AudioManager.cpp | 31 +++++++++++++++++++------------ src/audio/AudioManager.h | 21 ++++++++++----------- 2 files changed, 29 insertions(+), 23 deletions(-) diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index c0827040..638cafbf 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -411,11 +411,11 @@ cAudioManager::SetDynamicAcousticModelingStatus(uint8 status) m_bDynamicAcousticModelingStatus = status!=0; } -bool -cAudioManager::CheckForAnAudioFileOnCD() const -{ - return SampleManager.CheckForAnAudioFileOnCD(); -} +//bool +//cAudioManager::CheckForAnAudioFileOnCD() const +//{ +// return SampleManager.CheckForAnAudioFileOnCD(); +//} uint8 cAudioManager::GetCDAudioDriveLetter() const @@ -483,12 +483,18 @@ uint8 cAudioManager::ComputeVolume(uint8 emittingVolume, float soundIntensity, float distance) const { float newSoundIntensity; + float newEmittingVolume; + if (soundIntensity <= 0.0f) return 0; + newSoundIntensity = soundIntensity / 5.0f; - if (newSoundIntensity <= distance) - emittingVolume = sq((soundIntensity - newSoundIntensity - (distance - newSoundIntensity)) / (soundIntensity - newSoundIntensity)) * emittingVolume; - return emittingVolume; + if (newSoundIntensity > distance) + return emittingVolume; + + newEmittingVolume = emittingVolume * SQR((soundIntensity - newSoundIntensity - (distance - newSoundIntensity)) + / (soundIntensity - newSoundIntensity)); + return Min(127u, newEmittingVolume); } void @@ -500,10 +506,9 @@ cAudioManager::TranslateEntity(Const CVector *in, CVector *out) const int32 cAudioManager::ComputePan(float dist, CVector *vec) { - const uint8 PanTable[64] = {0, 3, 8, 12, 16, 19, 22, 24, 26, 28, 30, 31, 33, 34, 36, 37, 39, 40, 41, 42, 44, 45, 46, 47, 48, 49, 49, 50, 51, 52, 53, 53, - 54, 55, 55, 56, 56, 57, 57, 58, 58, 58, 59, 59, 59, 60, 60, 61, 61, 61, 61, 62, 62, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63}; - - int32 index = Min(63, Abs(vec->x / (dist / 64.f))); + const uint8 PanTable[64] = { 0, 3, 8, 12, 16, 19, 22, 24, 26, 28, 30, 31, 33, 34, 36, 37, 39, 40, 41, 42, 44, 45, 46, 47, 48, 49, 49, 50, 51, 52, 53, 53, + 54, 55, 55, 56, 56, 57, 57, 58, 58, 58, 59, 59, 59, 60, 60, 61, 61, 61, 61, 62, 62, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63}; + int32 index = Min(63, Abs(int32(vec->x / (dist / 64.f)))); if (vec->x > 0.f) return Max(20, 63 - PanTable[index]); @@ -940,6 +945,8 @@ void cAudioManager::ClearRequestedQueue() { for (int32 i = 0; i < m_nActiveSamples; i++) { + if (i >= m_nActiveSamples) + break; m_abSampleQueueIndexTable[m_nActiveSampleQueue][i] = m_nActiveSamples; } m_SampleRequestQueuesStatus[m_nActiveSampleQueue] = 0; diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index ee8a23ef..8ac30ecb 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -247,16 +247,15 @@ public: void AddSampleToRequestedQueue(); // done void AgeCrimes(); // done (inlined in vc) - void CalculateDistance(bool &condition, float dist); // done - bool CheckForAnAudioFileOnCD() const; - void ClearActiveSamples(); //done - void ClearMissionAudio(uint8 slot); //done - void ClearRequestedQueue(); - uint32 ComputeDopplerEffectedFrequency(uint32 oldFreq, float position1, float position2, - float speedMultiplier) const; //done - int32 ComputePan(float, CVector *); - uint8 ComputeVolume(uint8 emittingVolume, float soundIntensity, float distance) const; - int32 CreateEntity(eAudioType type, void *entity); //done + void CalculateDistance(bool &condition, float dist); // done + //bool CheckForAnAudioFileOnCD() const; // not exists in v1.0 and android + void ClearActiveSamples(); // done + void ClearMissionAudio(uint8 slot); // done + void ClearRequestedQueue(); // done (inlined in vc) + uint32 ComputeDopplerEffectedFrequency(uint32 oldFreq, float position1, float position2, float speedMultiplier) const; // done + int32 ComputePan(float, CVector *); // done + uint8 ComputeVolume(uint8 emittingVolume, float soundIntensity, float distance) const; // done + int32 CreateEntity(eAudioType type, void *entity); // done void DestroyAllGameCreatedEntities(); void DestroyEntity(int32 id); //done (inlined in vc) @@ -290,7 +289,7 @@ public: void Initialise(); // done void InitialisePoliceRadio(); void InitialisePoliceRadioZones(); - void InterrogateAudioEntities(); + void InterrogateAudioEntities(); // done bool IsAudioInitialised() const; bool IsMissionAudioSampleFinished(uint8 slot); bool IsMP3RadioChannelAvailable() const; // done From 6ff138ca76ddca2936f6148b0ca4f858a6b4c88e Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Fri, 2 Oct 2020 05:03:29 +0300 Subject: [PATCH 6/7] fix build(bcs func CheckForAnAudioFileOnCD not used anymore) --- src/audio/DMAudio.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/audio/DMAudio.cpp b/src/audio/DMAudio.cpp index 486daebf..f09f4256 100644 --- a/src/audio/DMAudio.cpp +++ b/src/audio/DMAudio.cpp @@ -171,7 +171,7 @@ cDMAudio::SetDynamicAcousticModelingStatus(uint8 status) bool cDMAudio::CheckForAnAudioFileOnCD(void) { - return AudioManager.CheckForAnAudioFileOnCD(); + return 0; //exists only in android version, and used only in symbols } char From 1991f9b3622c5e6f31a53b9c92bbe7c9b868bd9e Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Fri, 2 Oct 2020 20:35:16 +0300 Subject: [PATCH 7/7] revert some changes and little fix --- src/audio/AudioManager.cpp | 19 +++++++------------ src/audio/AudioManager.h | 2 +- src/audio/DMAudio.cpp | 2 +- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index 638cafbf..93ac8857 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -411,19 +411,16 @@ cAudioManager::SetDynamicAcousticModelingStatus(uint8 status) m_bDynamicAcousticModelingStatus = status!=0; } -//bool -//cAudioManager::CheckForAnAudioFileOnCD() const -//{ -// return SampleManager.CheckForAnAudioFileOnCD(); -//} +bool +cAudioManager::CheckForAnAudioFileOnCD() const +{ + return SampleManager.CheckForAnAudioFileOnCD(); +} uint8 cAudioManager::GetCDAudioDriveLetter() const { - if (m_bIsInitialised) - return SampleManager.GetCDAudioDriveLetter(); - - return 0; + return SampleManager.GetCDAudioDriveLetter(); } bool @@ -945,8 +942,6 @@ void cAudioManager::ClearRequestedQueue() { for (int32 i = 0; i < m_nActiveSamples; i++) { - if (i >= m_nActiveSamples) - break; m_abSampleQueueIndexTable[m_nActiveSampleQueue][i] = m_nActiveSamples; } m_SampleRequestQueuesStatus[m_nActiveSampleQueue] = 0; @@ -978,7 +973,7 @@ cAudioManager::ClearActiveSamples() m_asActiveSamples[i].m_nCalculatedVolume = 0; m_asActiveSamples[i].m_nReleasingVolumeDivider = 0; m_asActiveSamples[i].m_nVolumeChange = -1; - m_asActiveSamples[i].m_vecPos = {0.0f, 0.0f, 0.0f}; + m_asActiveSamples[i].m_vecPos = CVector(0.0f, 0.0f, 0.0f); m_asActiveSamples[i].m_bReverbFlag = false; m_asActiveSamples[i].m_nLoopsRemaining = 0; m_asActiveSamples[i].m_bRequireReflection = false; diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index 8ac30ecb..267260c5 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -248,7 +248,7 @@ public: void AgeCrimes(); // done (inlined in vc) void CalculateDistance(bool &condition, float dist); // done - //bool CheckForAnAudioFileOnCD() const; // not exists in v1.0 and android + bool CheckForAnAudioFileOnCD() const; // done void ClearActiveSamples(); // done void ClearMissionAudio(uint8 slot); // done void ClearRequestedQueue(); // done (inlined in vc) diff --git a/src/audio/DMAudio.cpp b/src/audio/DMAudio.cpp index f09f4256..486daebf 100644 --- a/src/audio/DMAudio.cpp +++ b/src/audio/DMAudio.cpp @@ -171,7 +171,7 @@ cDMAudio::SetDynamicAcousticModelingStatus(uint8 status) bool cDMAudio::CheckForAnAudioFileOnCD(void) { - return 0; //exists only in android version, and used only in symbols + return AudioManager.CheckForAnAudioFileOnCD(); } char