Port audio changes from master

This commit is contained in:
Sergeanur 2021-08-18 15:49:06 +03:00
parent dff327df40
commit a13089cd2e
10 changed files with 271 additions and 237 deletions

View File

@ -205,7 +205,7 @@ cAudioManager::SetUpOneShotCollisionSound(const cAudioCollision &col)
m_sQueueSample.m_fDistance = Sqrt(col.m_fDistance); m_sQueueSample.m_fDistance = Sqrt(col.m_fDistance);
m_sQueueSample.m_nVolume = m_sQueueSample.m_nVolume =
ComputeVolume(emittingVol, CollisionSoundIntensity, m_sQueueSample.m_fDistance); ComputeVolume(emittingVol, CollisionSoundIntensity, m_sQueueSample.m_fDistance);
if(m_sQueueSample.m_nVolume) { if(m_sQueueSample.m_nVolume > 0) {
m_sQueueSample.m_nSampleIndex = gOneShotCol[s1]; m_sQueueSample.m_nSampleIndex = gOneShotCol[s1];
switch(m_sQueueSample.m_nSampleIndex) { switch(m_sQueueSample.m_nSampleIndex) {
case SFX_COL_TARMAC_1: case SFX_COL_TARMAC_1:
@ -271,7 +271,7 @@ cAudioManager::SetUpOneShotCollisionSound(const cAudioCollision &col)
m_sQueueSample.m_SoundIntensity = CollisionSoundIntensity; m_sQueueSample.m_SoundIntensity = CollisionSoundIntensity;
m_sQueueSample.m_bReleasingSoundFlag = TRUE; m_sQueueSample.m_bReleasingSoundFlag = TRUE;
m_sQueueSample.m_bReverbFlag = TRUE; m_sQueueSample.m_bReverbFlag = TRUE;
m_sQueueSample.m_bRequireReflection = FALSE; SET_SOUND_REFLECTION(FALSE);
AddSampleToRequestedQueue(); AddSampleToRequestedQueue();
} }
} }
@ -287,7 +287,7 @@ cAudioManager::SetUpLoopingCollisionSound(const cAudioCollision &col, uint8 coun
if(emittingVol) { if(emittingVol) {
CalculateDistance(distCalculated, m_sQueueSample.m_fDistance); CalculateDistance(distCalculated, m_sQueueSample.m_fDistance);
m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, CollisionSoundIntensity, m_sQueueSample.m_fDistance); m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, CollisionSoundIntensity, m_sQueueSample.m_fDistance);
if(m_sQueueSample.m_nVolume) { if(m_sQueueSample.m_nVolume > 0) {
m_sQueueSample.m_nCounter = counter; m_sQueueSample.m_nCounter = counter;
m_sQueueSample.m_vecPos = col.m_vecPosition; m_sQueueSample.m_vecPos = col.m_vecPosition;
m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nBankIndex = SFX_BANK_0;
@ -301,7 +301,7 @@ cAudioManager::SetUpLoopingCollisionSound(const cAudioCollision &col, uint8 coun
m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_bReleasingSoundFlag = FALSE;
m_sQueueSample.m_nReleasingVolumeDivider = 5; m_sQueueSample.m_nReleasingVolumeDivider = 5;
m_sQueueSample.m_bReverbFlag = TRUE; m_sQueueSample.m_bReverbFlag = TRUE;
m_sQueueSample.m_bRequireReflection = FALSE; SET_SOUND_REFLECTION(FALSE);
AddSampleToRequestedQueue(); AddSampleToRequestedQueue();
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -32,7 +32,9 @@ cAudioManager::cAudioManager()
ClearActiveSamples(); ClearActiveSamples();
GenerateIntegerRandomNumberTable(); GenerateIntegerRandomNumberTable();
m_bDoubleVolume = FALSE; m_bDoubleVolume = FALSE;
#ifdef AUDIO_REFLECTIONS
m_bDynamicAcousticModelingStatus = TRUE; m_bDynamicAcousticModelingStatus = TRUE;
#endif
for (int i = 0; i < NUM_AUDIOENTITIES; i++) { for (int i = 0; i < NUM_AUDIOENTITIES; i++) {
m_asAudioEntities[i].m_bIsUsed = FALSE; m_asAudioEntities[i].m_bIsUsed = FALSE;
@ -116,7 +118,9 @@ cAudioManager::Service()
if (m_bIsInitialised) { if (m_bIsInitialised) {
m_nPreviousUserPause = m_nUserPause; m_nPreviousUserPause = m_nUserPause;
m_nUserPause = CTimer::GetIsUserPaused(); m_nUserPause = CTimer::GetIsUserPaused();
#ifdef AUDIO_REFLECTIONS
UpdateReflections(); UpdateReflections();
#endif
ServiceSoundEffects(); ServiceSoundEffects();
MusicManager.Service(); MusicManager.Service();
} }
@ -451,11 +455,13 @@ cAudioManager::ReacquireDigitalHandle()
} }
} }
#ifdef AUDIO_REFLECTIONS
void void
cAudioManager::SetDynamicAcousticModelingStatus(bool8 status) cAudioManager::SetDynamicAcousticModelingStatus(bool8 status)
{ {
m_bDynamicAcousticModelingStatus = status; m_bDynamicAcousticModelingStatus = status;
} }
#endif
bool8 bool8
cAudioManager::CheckForAnAudioFileOnCD() cAudioManager::CheckForAnAudioFileOnCD()
@ -628,9 +634,11 @@ cAudioManager::InterrogateAudioEntities()
void void
cAudioManager::AddSampleToRequestedQueue() cAudioManager::AddSampleToRequestedQueue()
{ {
int32 calculatedVolume; uint32 calculatedVolume;
uint8 sampleIndex; uint8 sampleIndex;
#ifdef AUDIO_REFLECTIONS
bool8 bReflections; bool8 bReflections;
#endif
if (m_sQueueSample.m_nSampleIndex < TOTAL_AUDIO_SAMPLES) { if (m_sQueueSample.m_nSampleIndex < TOTAL_AUDIO_SAMPLES) {
calculatedVolume = m_sQueueSample.m_nReleasingVolumeModificator * (MAX_VOLUME - m_sQueueSample.m_nVolume); calculatedVolume = m_sQueueSample.m_nReleasingVolumeModificator * (MAX_VOLUME - m_sQueueSample.m_nVolume);
@ -644,11 +652,12 @@ cAudioManager::AddSampleToRequestedQueue()
} }
m_sQueueSample.m_nCalculatedVolume = calculatedVolume; m_sQueueSample.m_nCalculatedVolume = calculatedVolume;
m_sQueueSample.m_bLoopEnded = FALSE; m_sQueueSample.m_bLoopEnded = FALSE;
#ifdef AUDIO_REFLECTIONS
if (m_sQueueSample.m_bIs2D || CCullZones::InRoomForAudio()) { if (m_sQueueSample.m_bIs2D || CCullZones::InRoomForAudio()) {
m_sQueueSample.m_bRequireReflection = FALSE; m_sQueueSample.m_bRequireReflection = FALSE;
m_sQueueSample.m_nLoopsRemaining = 0; 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; bReflections = m_sQueueSample.m_bRequireReflection;
} else { } else {
bReflections = FALSE; bReflections = FALSE;
@ -657,16 +666,19 @@ cAudioManager::AddSampleToRequestedQueue()
m_sQueueSample.m_bRequireReflection = FALSE; m_sQueueSample.m_bRequireReflection = FALSE;
if ( m_bReverb && m_sQueueSample.m_bIs2D ) if ( m_bReverb && m_sQueueSample.m_bIs2D )
m_sQueueSample.field_4C = 30; m_sQueueSample.m_nFrontRearOffset = 30;
if (!m_bDynamicAcousticModelingStatus) if (!m_bDynamicAcousticModelingStatus)
m_sQueueSample.m_bReverbFlag = FALSE; m_sQueueSample.m_bReverbFlag = FALSE;
#endif
m_asSamples[m_nActiveSampleQueue][sampleIndex] = m_sQueueSample; m_asSamples[m_nActiveSampleQueue][sampleIndex] = m_sQueueSample;
AddDetailsToRequestedOrderList(sampleIndex); AddDetailsToRequestedOrderList(sampleIndex);
#ifdef AUDIO_REFLECTIONS
if (bReflections) if (bReflections)
AddReflectionsToRequestedQueue(); AddReflectionsToRequestedQueue();
#endif
} }
} }
@ -674,7 +686,7 @@ void
cAudioManager::AddDetailsToRequestedOrderList(uint8 sample) cAudioManager::AddDetailsToRequestedOrderList(uint8 sample)
{ {
uint32 i = 0; uint32 i = 0;
if (sample != 0) { if (sample > 0) {
for (; i < sample; i++) { for (; i < sample; i++) {
if (m_asSamples[m_nActiveSampleQueue][m_abSampleQueueIndexTable[m_nActiveSampleQueue][i]].m_nCalculatedVolume > if (m_asSamples[m_nActiveSampleQueue][m_abSampleQueueIndexTable[m_nActiveSampleQueue][i]].m_nCalculatedVolume >
m_asSamples[m_nActiveSampleQueue][sample].m_nCalculatedVolume) m_asSamples[m_nActiveSampleQueue][sample].m_nCalculatedVolume)
@ -687,6 +699,7 @@ cAudioManager::AddDetailsToRequestedOrderList(uint8 sample)
m_abSampleQueueIndexTable[m_nActiveSampleQueue][i] = sample; m_abSampleQueueIndexTable[m_nActiveSampleQueue][i] = sample;
} }
#ifdef AUDIO_REFLECTIONS
void void
cAudioManager::AddReflectionsToRequestedQueue() cAudioManager::AddReflectionsToRequestedQueue()
{ {
@ -710,7 +723,7 @@ cAudioManager::AddReflectionsToRequestedQueue()
} }
m_sQueueSample.m_SoundIntensity /= 2.f; m_sQueueSample.m_SoundIntensity /= 2.f;
int halfOldFreq = oldFreq >> 1; uint32 halfOldFreq = oldFreq >> 1;
for (uint32 i = 0; i < ARRAY_SIZE(m_afReflectionsDistances); i++) { for (uint32 i = 0; i < ARRAY_SIZE(m_afReflectionsDistances); i++) {
if ( CTimer::GetIsSlowMotionActive() ) if ( CTimer::GetIsSlowMotionActive() )
@ -726,15 +739,15 @@ cAudioManager::AddReflectionsToRequestedQueue()
if (m_sQueueSample.m_nVolume > emittingVolume / 16) { if (m_sQueueSample.m_nVolume > emittingVolume / 16) {
m_sQueueSample.m_nCounter = oldCounter + (i + 1) * 256; m_sQueueSample.m_nCounter = oldCounter + (i + 1) * 256;
if (m_sQueueSample.m_nLoopCount) { if (m_sQueueSample.m_nLoopCount > 0) {
if ( CTimer::GetIsSlowMotionActive() ) { if ( CTimer::GetIsSlowMotionActive() ) {
m_sQueueSample.m_nFrequency = halfOldFreq + ((halfOldFreq * i) / ARRAY_SIZE(m_afReflectionsDistances)); m_sQueueSample.m_nFrequency = halfOldFreq + ((halfOldFreq * i) / ARRAY_SIZE(m_afReflectionsDistances));
} else { } else {
noise = RandomDisplacement(m_sQueueSample.m_nFrequency / 32); noise = RandomDisplacement(m_sQueueSample.m_nFrequency / 32);
if (noise <= 0) if (noise > 0)
m_sQueueSample.m_nFrequency += noise;
else
m_sQueueSample.m_nFrequency -= noise; m_sQueueSample.m_nFrequency -= noise;
else
m_sQueueSample.m_nFrequency += noise;
} }
} }
m_sQueueSample.m_nReleasingVolumeModificator += 20; m_sQueueSample.m_nReleasingVolumeModificator += 20;
@ -869,6 +882,7 @@ cAudioManager::UpdateReflections()
} }
#endif #endif
} }
#endif // AUDIO_REFLECTIONS
void void
cAudioManager::AddReleasingSounds() cAudioManager::AddReleasingSounds()
@ -895,8 +909,11 @@ cAudioManager::AddReleasingSounds()
break; break;
} }
} }
if (!toProcess[i]) { 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) if (sample.m_nReleasingVolumeDivider == 0)
continue; continue;
if (sample.m_nLoopCount == 0) { if (sample.m_nLoopCount == 0) {
@ -1064,14 +1081,17 @@ cAudioManager::ProcessActiveQueues()
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]]; 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_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_nLoopsRemaining--;
sample.m_nReleasingVolumeDivider = 1; sample.m_nReleasingVolumeDivider = 1;
} else { } else
#endif
{
for (uint8 j = 0; j < m_nActiveSamples; j++) { for (uint8 j = 0; j < m_nActiveSamples; j++) {
uint8 k = (j + field_6) % m_nActiveSamples; uint8 k = (j + field_6) % m_nActiveSamples;
if (!m_asActiveSamples[k].m_bIsProcessed) { if (!m_asActiveSamples[k].m_bIsProcessed) {
if (sample.m_nLoopCount != 0) { if (sample.m_nLoopCount > 0) {
samplesPerFrame = sample.m_nFrequency / m_nTimeSpent; samplesPerFrame = sample.m_nFrequency / m_nTimeSpent;
samplesToPlay = sample.m_nLoopCount * SampleManager.GetSampleLength(sample.m_nSampleIndex); samplesToPlay = sample.m_nLoopCount * SampleManager.GetSampleLength(sample.m_nSampleIndex);
if (samplesPerFrame == 0) if (samplesPerFrame == 0)
@ -1191,8 +1211,10 @@ cAudioManager::ClearActiveSamples()
m_asActiveSamples[i].m_nVolumeChange = -1; m_asActiveSamples[i].m_nVolumeChange = -1;
m_asActiveSamples[i].m_vecPos = CVector(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_bReverbFlag = FALSE;
#ifdef AUDIO_REFLECTIONS
m_asActiveSamples[i].m_nLoopsRemaining = 0; m_asActiveSamples[i].m_nLoopsRemaining = 0;
m_asActiveSamples[i].m_bRequireReflection = FALSE; m_asActiveSamples[i].m_bRequireReflection = FALSE;
#endif
} }
} }

View File

@ -10,17 +10,17 @@ class tSound
{ {
public: public:
int32 m_nEntityIndex; int32 m_nEntityIndex;
int32 m_nCounter; uint32 m_nCounter;
int32 m_nSampleIndex; uint32 m_nSampleIndex;
uint8 m_nBankIndex; uint8 m_nBankIndex;
bool8 m_bIs2D; bool8 m_bIs2D;
int32 m_nReleasingVolumeModificator; uint32 m_nReleasingVolumeModificator;
uint32 m_nFrequency; uint32 m_nFrequency;
uint8 m_nVolume; uint8 m_nVolume;
float m_fDistance; float m_fDistance;
int32 m_nLoopCount; uint32 m_nLoopCount;
#ifndef GTA_PS2 #ifndef GTA_PS2
int32 m_nLoopStart; uint32 m_nLoopStart;
int32 m_nLoopEnd; int32 m_nLoopEnd;
#endif #endif
#ifdef EXTERNAL_3D_SOUND #ifdef EXTERNAL_3D_SOUND
@ -33,14 +33,16 @@ public:
#ifndef GTA_PS2 #ifndef GTA_PS2
bool8 m_bReverbFlag; // TODO: ifdef all the occurrences bool8 m_bReverbFlag; // TODO: ifdef all the occurrences
#endif #endif
#ifdef AUDIO_REFLECTIONS
uint8 m_nLoopsRemaining; uint8 m_nLoopsRemaining;
bool8 m_bRequireReflection; // Used for oneshots bool8 m_bRequireReflection; // Used for oneshots
#endif
uint8 m_nOffset; uint8 m_nOffset;
uint8 field_4C; uint8 m_nFrontRearOffset;
int32 m_nReleasingVolumeDivider; uint32 m_nReleasingVolumeDivider;
bool8 m_bIsProcessed; bool8 m_bIsProcessed;
bool8 m_bLoopEnded; bool8 m_bLoopEnded;
int32 m_nCalculatedVolume; uint32 m_nCalculatedVolume;
int8 m_nVolumeChange; int8 m_nVolumeChange;
}; };
@ -120,7 +122,7 @@ class cMissionAudio
public: public:
CVector m_vecPos[MISSION_AUDIO_SLOTS]; CVector m_vecPos[MISSION_AUDIO_SLOTS];
bool8 m_bPredefinedProperties[MISSION_AUDIO_SLOTS]; bool8 m_bPredefinedProperties[MISSION_AUDIO_SLOTS];
int32 m_nSampleIndex[MISSION_AUDIO_SLOTS]; uint32 m_nSampleIndex[MISSION_AUDIO_SLOTS];
uint8 m_nLoadingStatus[MISSION_AUDIO_SLOTS]; uint8 m_nLoadingStatus[MISSION_AUDIO_SLOTS];
uint8 m_nPlayStatus[MISSION_AUDIO_SLOTS]; uint8 m_nPlayStatus[MISSION_AUDIO_SLOTS];
bool8 m_bIsPlaying[MISSION_AUDIO_SLOTS]; bool8 m_bIsPlaying[MISSION_AUDIO_SLOTS];
@ -170,7 +172,7 @@ public:
float m_fDistance; float m_fDistance;
CVehicle *m_pVehicle; CVehicle *m_pVehicle;
cTransmission *m_pTransmission; cTransmission *m_pTransmission;
int32 m_nIndex; uint32 m_nIndex;
float m_fVelocityChange; float m_fVelocityChange;
cVehicleParams() cVehicleParams()
@ -225,10 +227,10 @@ class cAudioManager
{ {
public: public:
bool8 m_bIsInitialised; bool8 m_bIsInitialised;
uint8 m_bReverb; // unused bool8 m_bReverb; // unused
bool8 m_bFifthFrameFlag; bool8 m_bFifthFrameFlag;
uint8 m_nActiveSamples; uint8 m_nActiveSamples;
uint8 m_bDoubleVolume; // unused bool8 m_bDoubleVolume; // unused
bool8 m_bDynamicAcousticModelingStatus; bool8 m_bDynamicAcousticModelingStatus;
int8 field_6; int8 field_6;
float m_fSpeedOfSound; float m_fSpeedOfSound;
@ -243,8 +245,10 @@ public:
tAudioEntity m_asAudioEntities[NUM_AUDIOENTITIES]; tAudioEntity m_asAudioEntities[NUM_AUDIOENTITIES];
int32 m_anAudioEntityIndices[NUM_AUDIOENTITIES]; int32 m_anAudioEntityIndices[NUM_AUDIOENTITIES];
int32 m_nAudioEntitiesTotal; int32 m_nAudioEntitiesTotal;
#ifdef AUDIO_REFLECTIONS
CVector m_avecReflectionsPos[MAX_REFLECTIONS]; CVector m_avecReflectionsPos[MAX_REFLECTIONS];
float m_afReflectionsDistances[MAX_REFLECTIONS]; float m_afReflectionsDistances[MAX_REFLECTIONS];
#endif
cAudioScriptObjectManager m_sAudioScriptObjectManager; cAudioScriptObjectManager m_sAudioScriptObjectManager;
// miami // miami
@ -272,8 +276,8 @@ public:
uint8 field_5538; // something related to phone dialogues uint8 field_5538; // something related to phone dialogues
int32 m_anRandomTable[5]; int32 m_anRandomTable[5];
uint8 m_nTimeSpent; uint8 m_nTimeSpent;
uint8 m_nUserPause; bool8 m_nUserPause;
uint8 m_nPreviousUserPause; bool8 m_nPreviousUserPause;
uint32 m_FrameCounter; uint32 m_FrameCounter;
cAudioManager(); cAudioManager();
@ -307,7 +311,9 @@ public:
bool8 IsMP3RadioChannelAvailable(); bool8 IsMP3RadioChannelAvailable();
void ReleaseDigitalHandle(); void ReleaseDigitalHandle();
void ReacquireDigitalHandle(); void ReacquireDigitalHandle();
#ifdef AUDIO_REFLECTIONS
void SetDynamicAcousticModelingStatus(bool8 status); void SetDynamicAcousticModelingStatus(bool8 status);
#endif
bool8 CheckForAnAudioFileOnCD(); bool8 CheckForAnAudioFileOnCD();
char GetCDAudioDriveLetter(); char GetCDAudioDriveLetter();
bool8 IsAudioInitialised(); bool8 IsAudioInitialised();
@ -323,8 +329,10 @@ public:
void InterrogateAudioEntities(); // inlined void InterrogateAudioEntities(); // inlined
void AddSampleToRequestedQueue(); void AddSampleToRequestedQueue();
void AddDetailsToRequestedOrderList(uint8 sample); // inlined in vc void AddDetailsToRequestedOrderList(uint8 sample); // inlined in vc
#ifdef AUDIO_REFLECTIONS
void AddReflectionsToRequestedQueue(); void AddReflectionsToRequestedQueue();
void UpdateReflections(); void UpdateReflections();
#endif
void AddReleasingSounds(); void AddReleasingSounds();
void ProcessActiveQueues(); void ProcessActiveQueues();
void ClearRequestedQueue(); // inlined in vc void ClearRequestedQueue(); // inlined in vc
@ -603,6 +611,11 @@ public:
#else #else
#define SET_EMITTING_VOLUME(vol) #define SET_EMITTING_VOLUME(vol)
#endif #endif
#ifdef AUDIO_REFLECTIONS
#define SET_SOUND_REFLECTION(b) m_sQueueSample.m_bRequireReflection = b
#else
#define SET_SOUND_REFLECTION(b)
#endif
#if defined(AUDIO_MSS) && !defined(PS2_AUDIO_CHANNELS) #if defined(AUDIO_MSS) && !defined(PS2_AUDIO_CHANNELS)
static_assert(sizeof(cAudioManager) == 0x5558, "cAudioManager: error"); static_assert(sizeof(cAudioManager) == 0x5558, "cAudioManager: error");

View File

@ -169,7 +169,9 @@ cDMAudio::ReacquireDigitalHandle(void)
void void
cDMAudio::SetDynamicAcousticModelingStatus(bool8 status) cDMAudio::SetDynamicAcousticModelingStatus(bool8 status)
{ {
#ifdef AUDIO_REFLECTIONS
AudioManager.SetDynamicAcousticModelingStatus(status); AudioManager.SetDynamicAcousticModelingStatus(status);
#endif
} }
bool8 bool8

View File

@ -263,7 +263,7 @@ cMusicManager::GetRadioInCar(void)
CVehicle* veh = AudioManager.FindVehicleOfPlayer(); CVehicle* veh = AudioManager.FindVehicleOfPlayer();
if (veh != nil) { if (veh != nil) {
if (UsesPoliceRadio(veh) || UsesTaxiRadio(veh)) { if (UsesPoliceRadio(veh) || UsesTaxiRadio(veh)) {
if (m_nRadioInCar == NO_TRACK || (CReplay::IsPlayingBack() && AudioManager.m_nUserPause == 0)) if (m_nRadioInCar == NO_TRACK || (CReplay::IsPlayingBack() && !AudioManager.m_nUserPause))
return STREAMED_SOUND_RADIO_POLICE; return STREAMED_SOUND_RADIO_POLICE;
return m_nRadioInCar; return m_nRadioInCar;
} }
@ -271,7 +271,7 @@ cMusicManager::GetRadioInCar(void)
} }
} }
if (m_nRadioInCar == NO_TRACK || (CReplay::IsPlayingBack() && AudioManager.m_nUserPause == 0)) if (m_nRadioInCar == NO_TRACK || (CReplay::IsPlayingBack() && !AudioManager.m_nUserPause))
return RADIO_OFF; return RADIO_OFF;
return m_nRadioInCar; return m_nRadioInCar;
} }
@ -461,7 +461,7 @@ cMusicManager::ServiceFrontEndMode()
} else { } else {
if (m_nPlayingTrack == STREAMED_SOUND_RADIO_MP3_PLAYER) if (m_nPlayingTrack == STREAMED_SOUND_RADIO_MP3_PLAYER)
SampleManager.StartStreamedFile(STREAMED_SOUND_RADIO_MP3_PLAYER, 0); SampleManager.StartStreamedFile(STREAMED_SOUND_RADIO_MP3_PLAYER, 0);
else if (m_nPlayingTrack == STREAMED_SOUND_MISSION_COMPLETED && AudioManager.m_nUserPause == 0) else if (m_nPlayingTrack == STREAMED_SOUND_MISSION_COMPLETED && !AudioManager.m_nUserPause)
ChangeMusicMode(MUSICMODE_GAME); ChangeMusicMode(MUSICMODE_GAME);
} }
} else { } else {

View File

@ -24,8 +24,8 @@ struct tPoliceRadioZone {
tPoliceRadioZone ZoneSfx[NUMAUDIOZONES]; tPoliceRadioZone ZoneSfx[NUMAUDIOZONES];
uint32 g_nMissionAudioSfx = TOTAL_AUDIO_SAMPLES; uint32 g_nMissionAudioSfx = TOTAL_AUDIO_SAMPLES;
int8 g_nMissionAudioPlayingStatus = 2; int8 g_nMissionAudioPlayingStatus = PLAY_STATUS_FINISHED;
uint8 gSpecialSuspectLastSeenReport; bool8 gSpecialSuspectLastSeenReport;
uint32 gMinTimeToNextReport[NUM_CRIME_TYPES]; uint32 gMinTimeToNextReport[NUM_CRIME_TYPES];
void void
@ -83,8 +83,8 @@ void
cAudioManager::SetMissionScriptPoliceAudio(uint32 sfx) cAudioManager::SetMissionScriptPoliceAudio(uint32 sfx)
{ {
if (!m_bIsInitialised) return; if (!m_bIsInitialised) return;
if (g_nMissionAudioPlayingStatus != 1) { if (g_nMissionAudioPlayingStatus != PLAY_STATUS_PLAYING) {
g_nMissionAudioPlayingStatus = 0; g_nMissionAudioPlayingStatus = PLAY_STATUS_STOPPED;
g_nMissionAudioSfx = sfx; g_nMissionAudioSfx = sfx;
} }
} }
@ -113,7 +113,7 @@ cAudioManager::DoPoliceRadioCrackle()
m_sQueueSample.m_bReverbFlag = FALSE; m_sQueueSample.m_bReverbFlag = FALSE;
m_sQueueSample.m_nOffset = 63; m_sQueueSample.m_nOffset = 63;
m_sQueueSample.m_nReleasingVolumeDivider = 3; m_sQueueSample.m_nReleasingVolumeDivider = 3;
m_sQueueSample.m_bRequireReflection = FALSE; SET_SOUND_REFLECTION(FALSE);
AddSampleToRequestedQueue(); AddSampleToRequestedQueue();
} }
@ -125,7 +125,7 @@ cAudioManager::ServicePoliceRadio()
if(!m_bIsInitialised) return; if(!m_bIsInitialised) return;
if(m_nUserPause == 0) { if(!m_nUserPause) {
bool8 crimeReport = SetupCrimeReport(); bool8 crimeReport = SetupCrimeReport();
#ifdef FIX_BUGS // Crash at 0x5fe6ef #ifdef FIX_BUGS // Crash at 0x5fe6ef
if(CReplay::IsPlayingBack() || !FindPlayerPed() || !FindPlayerPed()->m_pWanted) if(CReplay::IsPlayingBack() || !FindPlayerPed() || !FindPlayerPed()->m_pWanted)
@ -162,20 +162,20 @@ cAudioManager::ServicePoliceRadioChannel(uint8 wantedLevel)
static int cWait = 0; static int cWait = 0;
static bool8 bChannelOpen = FALSE; static bool8 bChannelOpen = FALSE;
static uint8 bMissionAudioPhysicalPlayingStatus = 0; static uint8 bMissionAudioPhysicalPlayingStatus = PLAY_STATUS_STOPPED;
static int32 PoliceChannelFreq = 22050; static int32 PoliceChannelFreq = 22050;
if (!m_bIsInitialised) return; if (!m_bIsInitialised) return;
if (m_nUserPause != 0) { if (m_nUserPause) {
if (SampleManager.GetChannelUsedFlag(CHANNEL_POLICE_RADIO)) SampleManager.StopChannel(CHANNEL_POLICE_RADIO); if (SampleManager.GetChannelUsedFlag(CHANNEL_POLICE_RADIO)) SampleManager.StopChannel(CHANNEL_POLICE_RADIO);
if (g_nMissionAudioSfx != NO_SAMPLE && bMissionAudioPhysicalPlayingStatus == 1 && if (g_nMissionAudioSfx != NO_SAMPLE && bMissionAudioPhysicalPlayingStatus == PLAY_STATUS_PLAYING &&
SampleManager.IsStreamPlaying(1)) { SampleManager.IsStreamPlaying(1)) {
SampleManager.PauseStream(TRUE, 1); SampleManager.PauseStream(TRUE, 1);
} }
} else { } else {
if (m_nPreviousUserPause && g_nMissionAudioSfx != NO_SAMPLE && if (m_nPreviousUserPause && g_nMissionAudioSfx != NO_SAMPLE &&
bMissionAudioPhysicalPlayingStatus == 1) { bMissionAudioPhysicalPlayingStatus == PLAY_STATUS_PLAYING) {
SampleManager.PauseStream(FALSE, 1); SampleManager.PauseStream(FALSE, 1);
} }
if (m_sPoliceRadioQueue.policeChannelTimer == 0) bChannelOpen = FALSE; if (m_sPoliceRadioQueue.policeChannelTimer == 0) bChannelOpen = FALSE;
@ -188,17 +188,17 @@ cAudioManager::ServicePoliceRadioChannel(uint8 wantedLevel)
return; return;
} }
if (g_nMissionAudioSfx != NO_SAMPLE && !bChannelOpen) { if (g_nMissionAudioSfx != NO_SAMPLE && !bChannelOpen) {
if (g_nMissionAudioPlayingStatus) { if (g_nMissionAudioPlayingStatus != PLAY_STATUS_STOPPED) {
if (g_nMissionAudioPlayingStatus == 1 && !bMissionAudioPhysicalPlayingStatus && if (g_nMissionAudioPlayingStatus == PLAY_STATUS_PLAYING && bMissionAudioPhysicalPlayingStatus == PLAY_STATUS_STOPPED &&
SampleManager.IsStreamPlaying(1)) { SampleManager.IsStreamPlaying(1)) {
bMissionAudioPhysicalPlayingStatus = 1; bMissionAudioPhysicalPlayingStatus = PLAY_STATUS_PLAYING;
} }
if (bMissionAudioPhysicalPlayingStatus == 1) { if (bMissionAudioPhysicalPlayingStatus == PLAY_STATUS_PLAYING) {
if (SampleManager.IsStreamPlaying(1)) { if (SampleManager.IsStreamPlaying(1)) {
DoPoliceRadioCrackle(); DoPoliceRadioCrackle();
} else { } else {
bMissionAudioPhysicalPlayingStatus = 2; bMissionAudioPhysicalPlayingStatus = PLAY_STATUS_FINISHED;
g_nMissionAudioPlayingStatus = 2; g_nMissionAudioPlayingStatus = PLAY_STATUS_FINISHED;
g_nMissionAudioSfx = NO_SAMPLE; g_nMissionAudioSfx = NO_SAMPLE;
cWait = 30; cWait = 30;
} }
@ -208,13 +208,13 @@ cAudioManager::ServicePoliceRadioChannel(uint8 wantedLevel)
SampleManager.PreloadStreamedFile(g_nMissionAudioSfx, 1); SampleManager.PreloadStreamedFile(g_nMissionAudioSfx, 1);
SampleManager.SetStreamedVolumeAndPan(MAX_VOLUME, 63, TRUE, 1); SampleManager.SetStreamedVolumeAndPan(MAX_VOLUME, 63, TRUE, 1);
SampleManager.StartPreloadedStreamedFile(1); SampleManager.StartPreloadedStreamedFile(1);
g_nMissionAudioPlayingStatus = 1; g_nMissionAudioPlayingStatus = PLAY_STATUS_PLAYING;
bMissionAudioPhysicalPlayingStatus = 0; bMissionAudioPhysicalPlayingStatus = PLAY_STATUS_STOPPED;
return; return;
} }
} }
if (bChannelOpen) DoPoliceRadioCrackle(); if (bChannelOpen) DoPoliceRadioCrackle();
if ((g_nMissionAudioSfx == NO_SAMPLE || g_nMissionAudioPlayingStatus != 1) && if ((g_nMissionAudioSfx == NO_SAMPLE || g_nMissionAudioPlayingStatus != PLAY_STATUS_PLAYING) &&
!SampleManager.GetChannelUsedFlag(CHANNEL_POLICE_RADIO) && m_sPoliceRadioQueue.policeChannelTimer) { !SampleManager.GetChannelUsedFlag(CHANNEL_POLICE_RADIO) && m_sPoliceRadioQueue.policeChannelTimer) {
if (m_sPoliceRadioQueue.policeChannelTimer) { if (m_sPoliceRadioQueue.policeChannelTimer) {
sample = m_sPoliceRadioQueue.crimesSamples[m_sPoliceRadioQueue.policeChannelCounterSeconds]; sample = m_sPoliceRadioQueue.crimesSamples[m_sPoliceRadioQueue.policeChannelCounterSeconds];
@ -225,7 +225,7 @@ cAudioManager::ServicePoliceRadioChannel(uint8 wantedLevel)
} }
if (wantedLevel == 0) { if (wantedLevel == 0) {
if (gSpecialSuspectLastSeenReport) { if (gSpecialSuspectLastSeenReport) {
gSpecialSuspectLastSeenReport = 0; gSpecialSuspectLastSeenReport = FALSE;
} else if (sample == SFX_POLICE_RADIO_MESSAGE_NOISE_1) { } else if (sample == SFX_POLICE_RADIO_MESSAGE_NOISE_1) {
bChannelOpen = FALSE; bChannelOpen = FALSE;
processed = TRUE; processed = TRUE;

View File

@ -1706,6 +1706,7 @@ cSampleManager::UpdateReverb(void)
float fRatio = 0.0f; float fRatio = 0.0f;
#ifdef AUDIO_REFLECTIONS
#define MIN_DIST 0.5f #define MIN_DIST 0.5f
#define CALCULATE_RATIO(value, maxDist, maxRatio) (value > MIN_DIST && value < maxDist ? value / maxDist * maxRatio : 0) #define CALCULATE_RATIO(value, maxDist, maxRatio) (value > MIN_DIST && value < maxDist ? value / maxDist * maxRatio : 0)
@ -1719,6 +1720,7 @@ cSampleManager::UpdateReverb(void)
#undef CALCULATE_RATIO #undef CALCULATE_RATIO
#undef MIN_DIST #undef MIN_DIST
#endif
fRatio = Clamp(fRatio, 0.0f, 0.6f); fRatio = Clamp(fRatio, 0.0f, 0.6f);

View File

@ -1390,6 +1390,7 @@ bool8 cSampleManager::UpdateReverb(void)
float fRatio = 0.0f; float fRatio = 0.0f;
#ifdef AUDIO_REFLECTIONS
#define MIN_DIST 0.5f #define MIN_DIST 0.5f
#define CALCULATE_RATIO(value, maxDist, maxRatio) (value > MIN_DIST && value < maxDist ? value / maxDist * maxRatio : 0) #define CALCULATE_RATIO(value, maxDist, maxRatio) (value > MIN_DIST && value < maxDist ? value / maxDist * maxRatio : 0)
@ -1403,6 +1404,7 @@ bool8 cSampleManager::UpdateReverb(void)
#undef CALCULATE_RATIO #undef CALCULATE_RATIO
#undef MIN_DIST #undef MIN_DIST
#endif
fRatio = Clamp(fRatio, 0.0f, 0.6f); fRatio = Clamp(fRatio, 0.0f, 0.6f);

View File

@ -227,6 +227,7 @@ enum Config {
#define DONT_FIX_REPLAY_BUGS #define DONT_FIX_REPLAY_BUGS
#define USE_TXD_CDIMAGE // generate and load textures from txd.img #define USE_TXD_CDIMAGE // generate and load textures from txd.img
//#define USE_TEXTURE_POOL // not possible because R* used custom RW33 //#define USE_TEXTURE_POOL // not possible because R* used custom RW33
#define AUDIO_REFLECTIONS
#else #else
// This enables things from the PS2 version on PC // This enables things from the PS2 version on PC
#define GTA_PS2_STUFF #define GTA_PS2_STUFF
@ -438,6 +439,7 @@ static_assert(false, "SUPPORT_XBOX_SCRIPT and SUPPORT_MOBILE_SCRIPT are mutually
// Audio // Audio
#define EXTERNAL_3D_SOUND // use external engine to simulate 3d audio spatialization. OpenAL would not work without it (because it works in a 3d space #define EXTERNAL_3D_SOUND // use external engine to simulate 3d audio spatialization. OpenAL would not work without it (because it works in a 3d space
// originally and making it work in 2d only requires more resource). Will not work on PS2 // originally and making it work in 2d only requires more resource). Will not work on PS2
#define AUDIO_REFLECTIONS // Enable audio reflections. This is enabled in all vanilla versions
#define RADIO_SCROLL_TO_PREV_STATION // Won't work without FIX_BUGS #define RADIO_SCROLL_TO_PREV_STATION // Won't work without FIX_BUGS
#define AUDIO_CACHE // cache sound lengths to speed up the cold boot #define AUDIO_CACHE // cache sound lengths to speed up the cold boot
#define PS2_AUDIO_CHANNELS // increases the maximum number of audio channels to PS2 value of 43 (PC has 28 originally) #define PS2_AUDIO_CHANNELS // increases the maximum number of audio channels to PS2 value of 43 (PC has 28 originally)