summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/audio/AudioLogic.cpp160
-rw-r--r--src/audio/AudioManager.cpp19
-rw-r--r--src/audio/PolRadio.h2
-rw-r--r--src/core/config.h1
4 files changed, 108 insertions, 74 deletions
diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp
index d09352be..0ba2190d 100644
--- a/src/audio/AudioLogic.cpp
+++ b/src/audio/AudioLogic.cpp
@@ -6077,96 +6077,110 @@ cPedComments::Process()
if (m_nCommentsInBank[m_nActiveBank]) {
sampleIndex = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nSampleIndex;
- if (!SampleManager.IsPedCommentLoaded(sampleIndex))
+ switch (SampleManager.IsPedCommentLoaded(sampleIndex)) // yes, this was a switch
+ {
+ case FALSE:
SampleManager.LoadPedComment(sampleIndex);
-
- AudioManager.m_sQueueSample.m_nEntityIndex = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nEntityIndex;
- AudioManager.m_sQueueSample.m_nCounter = 0;
- AudioManager.m_sQueueSample.m_nSampleIndex = sampleIndex;
- AudioManager.m_sQueueSample.m_nBankIndex = SFX_BANK_PED_COMMENTS;
- AudioManager.m_sQueueSample.m_nPriority = 3;
- AudioManager.m_sQueueSample.m_nVolume = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nVolume;
- AudioManager.m_sQueueSample.m_fDistance = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_fDistance;
- AudioManager.m_sQueueSample.m_nLoopCount = 1;
+ // BUG? no break, VC has break in here
+ case TRUE:
+ AudioManager.m_sQueueSample.m_nEntityIndex = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nEntityIndex;
+ AudioManager.m_sQueueSample.m_nCounter = 0;
+ AudioManager.m_sQueueSample.m_nSampleIndex = sampleIndex;
+ AudioManager.m_sQueueSample.m_nBankIndex = SFX_BANK_PED_COMMENTS;
+ AudioManager.m_sQueueSample.m_nPriority = 3;
+ AudioManager.m_sQueueSample.m_nVolume = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nVolume;
+ AudioManager.m_sQueueSample.m_fDistance = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_fDistance;
+ AudioManager.m_sQueueSample.m_nLoopCount = 1;
#ifndef GTA_PS2
- AudioManager.m_sQueueSample.m_nLoopStart = 0;
- AudioManager.m_sQueueSample.m_nLoopEnd = -1;
+ AudioManager.m_sQueueSample.m_nLoopStart = 0;
+ AudioManager.m_sQueueSample.m_nLoopEnd = -1;
#endif // !GTA_PS2
#ifdef EXTERNAL_3D_SOUND
- #ifdef FIX_BUGS
- AudioManager.m_sQueueSample.m_nEmittingVolume = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nEmittingVolume;
- #else
- AudioManager.m_sQueueSample.m_nEmittingVolume = MAX_VOLUME;
- #endif // FIX_BUGS
+#ifdef FIX_BUGS
+ AudioManager.m_sQueueSample.m_nEmittingVolume = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nEmittingVolume;
+#else
+ AudioManager.m_sQueueSample.m_nEmittingVolume = MAX_VOLUME;
+#endif // FIX_BUGS
#endif // EXTERNAL_3D_SOUND
- AudioManager.m_sQueueSample.m_fSpeedMultiplier = 3.0f;
- switch (sampleIndex) {
- case SFX_POLICE_HELI_1:
- case SFX_POLICE_HELI_2:
- case SFX_POLICE_HELI_3:
+#ifdef ATTACH_PED_COMMENTS_TO_ENTITIES
+ // let's disable doppler because if sounds funny as the sound moves
+ // originally position of ped comment doesn't change so this has no effect anyway
+ AudioManager.m_sQueueSample.m_fSpeedMultiplier = 0.0f;
+#else
+ AudioManager.m_sQueueSample.m_fSpeedMultiplier = 3.0f;
+#endif
+ switch (sampleIndex) {
+ case SFX_POLICE_HELI_1:
+ case SFX_POLICE_HELI_2:
+ case SFX_POLICE_HELI_3:
#ifdef FIX_BUGS
- case SFX_POLICE_HELI_4:
- case SFX_POLICE_HELI_5:
- case SFX_POLICE_HELI_6:
- case SFX_POLICE_HELI_7:
- case SFX_POLICE_HELI_8:
- case SFX_POLICE_HELI_9:
- case SFX_POLICE_HELI_10:
- case SFX_POLICE_HELI_11:
- case SFX_POLICE_HELI_12:
- case SFX_POLICE_HELI_13:
- case SFX_POLICE_HELI_14:
- case SFX_POLICE_HELI_15:
- case SFX_POLICE_HELI_16:
- case SFX_POLICE_HELI_17:
- case SFX_POLICE_HELI_18:
- case SFX_POLICE_HELI_19:
- case SFX_POLICE_HELI_20:
- case SFX_POLICE_HELI_21:
- case SFX_POLICE_HELI_22:
- case SFX_POLICE_HELI_23:
- case SFX_POLICE_HELI_24:
- case SFX_POLICE_HELI_25:
- case SFX_POLICE_HELI_26:
- case SFX_POLICE_HELI_27:
- case SFX_POLICE_HELI_28:
- case SFX_POLICE_HELI_29:
+ case SFX_POLICE_HELI_4:
+ case SFX_POLICE_HELI_5:
+ case SFX_POLICE_HELI_6:
+ case SFX_POLICE_HELI_7:
+ case SFX_POLICE_HELI_8:
+ case SFX_POLICE_HELI_9:
+ case SFX_POLICE_HELI_10:
+ case SFX_POLICE_HELI_11:
+ case SFX_POLICE_HELI_12:
+ case SFX_POLICE_HELI_13:
+ case SFX_POLICE_HELI_14:
+ case SFX_POLICE_HELI_15:
+ case SFX_POLICE_HELI_16:
+ case SFX_POLICE_HELI_17:
+ case SFX_POLICE_HELI_18:
+ case SFX_POLICE_HELI_19:
+ case SFX_POLICE_HELI_20:
+ case SFX_POLICE_HELI_21:
+ case SFX_POLICE_HELI_22:
+ case SFX_POLICE_HELI_23:
+ case SFX_POLICE_HELI_24:
+ case SFX_POLICE_HELI_25:
+ case SFX_POLICE_HELI_26:
+ case SFX_POLICE_HELI_27:
+ case SFX_POLICE_HELI_28:
+ case SFX_POLICE_HELI_29:
#endif
- AudioManager.m_sQueueSample.m_MaxDistance = 400.0f;
- break;
- default:
- AudioManager.m_sQueueSample.m_MaxDistance = 50.0f;
- break;
- }
- AudioManager.m_sQueueSample.m_bStatic = TRUE;
- AudioManager.m_sQueueSample.m_vecPos = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_vecPos;
+ AudioManager.m_sQueueSample.m_MaxDistance = 400.0f;
+ break;
+ default:
+ AudioManager.m_sQueueSample.m_MaxDistance = 50.0f;
+ break;
+ }
+ AudioManager.m_sQueueSample.m_bStatic = TRUE;
+ AudioManager.m_sQueueSample.m_vecPos = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_vecPos;
- if (sampleIndex >= SFX_AMMU_D && sampleIndex <= SFX_AMMU_F) {
- AudioManager.m_sQueueSample.m_bReverb = FALSE;
+ if (sampleIndex >= SFX_AMMU_D && sampleIndex <= SFX_AMMU_F) {
+ AudioManager.m_sQueueSample.m_bReverb = FALSE;
#ifdef AUDIO_REFLECTIONS
- AudioManager.m_sQueueSample.m_bReflections = FALSE;
+ AudioManager.m_sQueueSample.m_bReflections = FALSE;
#endif
#ifdef FIX_BUGS
- } else if (sampleIndex >= SFX_POLICE_HELI_1 && sampleIndex <= SFX_POLICE_HELI_29) {
- AudioManager.m_sQueueSample.m_bReverb = TRUE;
+ }
+ else if (sampleIndex >= SFX_POLICE_HELI_1 && sampleIndex <= SFX_POLICE_HELI_29) {
+ AudioManager.m_sQueueSample.m_bReverb = TRUE;
#ifdef AUDIO_REFLECTIONS
- AudioManager.m_sQueueSample.m_bReflections = FALSE;
+ AudioManager.m_sQueueSample.m_bReflections = FALSE;
#endif // AUDIO_REFLECTIONS
#endif // FIX_BUGS
- } else {
- AudioManager.m_sQueueSample.m_bReverb = TRUE;
+ }
+ else {
+ AudioManager.m_sQueueSample.m_bReverb = TRUE;
#ifdef AUDIO_REFLECTIONS
- AudioManager.m_sQueueSample.m_bReflections = TRUE;
+ AudioManager.m_sQueueSample.m_bReflections = TRUE;
#endif
- }
+ }
- AudioManager.m_sQueueSample.m_bIs2D = FALSE;
- AudioManager.m_sQueueSample.m_nFrequency =
- SampleManager.GetSampleBaseFrequency(AudioManager.m_sQueueSample.m_nSampleIndex) + AudioManager.RandomDisplacement(750);
- if (CTimer::GetIsSlowMotionActive())
- AudioManager.m_sQueueSample.m_nFrequency /= 2;
- m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nProcess = -1;
- AudioManager.AddSampleToRequestedQueue();
+ AudioManager.m_sQueueSample.m_bIs2D = FALSE;
+ AudioManager.m_sQueueSample.m_nFrequency =
+ SampleManager.GetSampleBaseFrequency(AudioManager.m_sQueueSample.m_nSampleIndex) + AudioManager.RandomDisplacement(750);
+ if (CTimer::GetIsSlowMotionActive())
+ AudioManager.m_sQueueSample.m_nFrequency /= 2;
+ m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nProcess = -1;
+ AudioManager.AddSampleToRequestedQueue();
+ default:
+ break;
+ }
}
// Switch bank
diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp
index 425a897d..eeebcebb 100644
--- a/src/audio/AudioManager.cpp
+++ b/src/audio/AudioManager.cpp
@@ -10,6 +10,7 @@
#include "sampman.h"
#include "Camera.h"
#include "World.h"
+#include "Entity.h"
cAudioManager AudioManager;
@@ -903,6 +904,24 @@ cAudioManager::ProcessActiveQueues()
SampleManager.SetChannelVolume(j, sample.m_nVolume);
#endif
} else {
+#ifdef ATTACH_PED_COMMENTS_TO_ENTITIES
+ if (sample.m_nCounter <= 255 && sample.m_nSampleIndex >= SAMPLEBANK_PED_START && sample.m_nSampleIndex <= SAMPLEBANK_PED_END) {
+ CEntity* entity = (CEntity*)GetEntityPointer(sample.m_nEntityIndex);
+ if (entity && m_asAudioEntities[sample.m_nEntityIndex].m_nType == AUDIOTYPE_PHYSICAL) {
+ sample.m_vecPos = entity->GetPosition();
+ sample.m_fDistance = Sqrt(GetDistanceSquared(sample.m_vecPos));
+ uint8 vol;
+ if (CWorld::GetIsLineOfSightClear(TheCamera.GetPosition(), sample.m_vecPos, true, false, false, false, false, false))
+ vol = MAX_VOLUME;
+ else
+ vol = 31;
+#ifdef EXTERNAL_3D_SOUND
+ sample.m_nEmittingVolume = vol;
+#endif
+ sample.m_nVolume = ComputeVolume(vol, sample.m_MaxDistance, sample.m_fDistance);
+ }
+ }
+#endif
position2 = sample.m_fDistance;
position1 = m_asActiveSamples[j].m_fDistance;
m_asActiveSamples[j].m_fDistance = sample.m_fDistance;
diff --git a/src/audio/PolRadio.h b/src/audio/PolRadio.h
index f402c200..c7b0bcc8 100644
--- a/src/audio/PolRadio.h
+++ b/src/audio/PolRadio.h
@@ -23,7 +23,7 @@ VALIDATE_SIZE(cAMCrime, 20);
class cPoliceRadioQueue
{
public:
- int32 m_aSamples[POLICE_RADIO_QUEUE_MAX_SAMPLES];
+ uint32 m_aSamples[POLICE_RADIO_QUEUE_MAX_SAMPLES];
uint8 m_nSamplesInQueue;
uint8 m_nAddOffset;
uint8 m_nRemoveOffset;
diff --git a/src/core/config.h b/src/core/config.h
index 5ec6f3ee..c04dfdf1 100644
--- a/src/core/config.h
+++ b/src/core/config.h
@@ -438,6 +438,7 @@ enum Config {
//#define AUDIO_OAL_USE_SNDFILE // use libsndfile to decode WAVs instead of our internal decoder
#define AUDIO_OAL_USE_MPG123 // use mpg123 to support mp3 files
#define PAUSE_RADIO_IN_FRONTEND // pause radio when game is paused
+#define ATTACH_PED_COMMENTS_TO_ENTITIES // ped comments coordinates would update following ped entity
#define MULTITHREADED_AUDIO // for streams. requires C++11 or later
#ifdef AUDIO_OPUS