Add AUDIO_REFLECTIONS define, fix a bunch of types, fix heli chatter intensity

This commit is contained in:
Sergeanur 2021-08-17 13:58:48 +03:00
parent 2526503743
commit 16ff379ebe
11 changed files with 313 additions and 211 deletions

View File

@ -203,7 +203,7 @@ cAudioManager::SetUpOneShotCollisionSound(const cAudioCollision &col)
m_sQueueSample.m_fDistance = Sqrt(col.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_nSampleIndex = gOneShotCol[s1];
switch(m_sQueueSample.m_nSampleIndex) {
case SFX_COL_TARMAC_1:
@ -269,7 +269,7 @@ cAudioManager::SetUpOneShotCollisionSound(const cAudioCollision &col)
m_sQueueSample.m_SoundIntensity = CollisionSoundIntensity;
m_sQueueSample.m_bReleasingSoundFlag = TRUE;
m_sQueueSample.m_bReverbFlag = TRUE;
m_sQueueSample.m_bRequireReflection = FALSE;
SET_SOUND_REFLECTION(FALSE);
AddSampleToRequestedQueue();
}
}
@ -285,7 +285,7 @@ cAudioManager::SetUpLoopingCollisionSound(const cAudioCollision &col, uint8 coun
m_sQueueSample.m_fDistance = Sqrt(col.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_vecPos = col.m_vecPosition;
m_sQueueSample.m_nBankIndex = SFX_BANK_0;
@ -299,7 +299,7 @@ cAudioManager::SetUpLoopingCollisionSound(const cAudioCollision &col, uint8 coun
m_sQueueSample.m_bReleasingSoundFlag = FALSE;
m_sQueueSample.m_nReleasingVolumeDivider = 5;
m_sQueueSample.m_bReverbFlag = TRUE;
m_sQueueSample.m_bRequireReflection = FALSE;
SET_SOUND_REFLECTION(FALSE);
AddSampleToRequestedQueue();
}
}

File diff suppressed because it is too large Load Diff

View File

@ -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

View File

@ -9,20 +9,20 @@ class tSound
public:
int32 m_nEntityIndex;
#if GTA_VERSION >= GTA3_PC_10
int32 m_nCounter;
uint32 m_nCounter;
#else
uint8 m_nCounter;
#endif
int32 m_nSampleIndex;
uint32 m_nSampleIndex;
uint8 m_nBankIndex;
bool8 m_bIs2D;
int32 m_nReleasingVolumeModificator;
uint32 m_nReleasingVolumeModificator;
uint32 m_nFrequency;
uint8 m_nVolume;
float m_fDistance;
int32 m_nLoopCount;
uint32 m_nLoopCount;
#ifndef GTA_PS2
int32 m_nLoopStart;
uint32 m_nLoopStart;
int32 m_nLoopEnd;
#endif
#ifdef EXTERNAL_3D_SOUND
@ -37,18 +37,18 @@ public:
bool8 m_bReleasingSoundFlag;
CVector m_vecPos;
bool8 m_bReverbFlag;
#if GTA_VERSION >= GTA3_PC_10
#ifdef AUDIO_REFLECTIONS
uint8 m_nLoopsRemaining;
bool8 m_bRequireReflection; // Used for oneshots
#endif
uint8 m_nOffset;
int32 m_nReleasingVolumeDivider;
uint32 m_nReleasingVolumeDivider;
bool8 m_bIsProcessed;
bool8 m_bLoopEnded;
#if GTA_VERSION < GTA3_PC_10
int32 unk; // only on PS2, seems unused
#endif
int32 m_nCalculatedVolume;
uint32 m_nCalculatedVolume;
int8 m_nVolumeChange;
};
@ -74,7 +74,7 @@ VALIDATE_SIZE(tAudioEntity, 40);
class tPedComment
{
public:
int32 m_nSampleIndex;
uint32 m_nSampleIndex;
int32 m_nEntityIndex;
CVector m_vecPos;
float m_fDistance;
@ -120,7 +120,7 @@ class cMissionAudio
public:
CVector m_vecPos;
bool8 m_bPredefinedProperties;
int32 m_nSampleIndex;
uint32 m_nSampleIndex;
uint8 m_nLoadingStatus;
uint8 m_nPlayStatus;
bool8 m_bIsPlaying;
@ -168,7 +168,7 @@ public:
float m_fDistance;
CVehicle *m_pVehicle;
cTransmission *m_pTransmission;
int32 m_nIndex;
uint32 m_nIndex;
float m_fVelocityChange;
cVehicleParams()
@ -211,8 +211,10 @@ public:
bool8 m_bReverb; // unused
bool8 m_bFifthFrameFlag;
uint8 m_nActiveSamples;
uint8 m_bDoubleVolume; // unused
bool8 m_bDoubleVolume; // unused
#if GTA_VERSION >= GTA3_PC_10
bool8 m_bDynamicAcousticModelingStatus;
#endif
float m_fSpeedOfSound;
bool8 m_bTimerJustReset;
int32 m_nTimer;
@ -225,7 +227,7 @@ public:
tAudioEntity m_asAudioEntities[NUM_AUDIOENTITIES];
int32 m_anAudioEntityIndices[NUM_AUDIOENTITIES];
int32 m_nAudioEntitiesTotal;
#if GTA_VERSION >= GTA3_PC_10
#ifdef AUDIO_REFLECTIONS
CVector m_avecReflectionsPos[MAX_REFLECTIONS];
float m_afReflectionsDistances[MAX_REFLECTIONS];
#endif
@ -276,7 +278,9 @@ public:
bool8 IsMP3RadioChannelAvailable();
void ReleaseDigitalHandle();
void ReacquireDigitalHandle();
#ifdef AUDIO_REFLECTIONS
void SetDynamicAcousticModelingStatus(bool8 status);
#endif
bool8 CheckForAnAudioFileOnCD();
char GetCDAudioDriveLetter();
bool8 IsAudioInitialised();
@ -292,7 +296,7 @@ public:
void InterrogateAudioEntities(); // inlined on PS2
void AddSampleToRequestedQueue();
void AddDetailsToRequestedOrderList(uint8 sample); // inlined on PS2
#if GTA_VERSION >= GTA3_PC_10
#ifdef AUDIO_REFLECTIONS
void AddReflectionsToRequestedQueue();
void UpdateReflections();
#endif
@ -548,6 +552,11 @@ public:
#else
#define SET_EMITTING_VOLUME(vol)
#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)
static_assert(sizeof(cAudioManager) == 19220, "cAudioManager: error");

View File

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

View File

@ -139,7 +139,7 @@ cAudioManager::DoPoliceRadioCrackle()
m_sQueueSample.m_bReverbFlag = FALSE;
m_sQueueSample.m_nOffset = 63;
m_sQueueSample.m_nReleasingVolumeDivider = 3;
m_sQueueSample.m_bRequireReflection = FALSE;
SET_SOUND_REFLECTION(FALSE);
AddSampleToRequestedQueue();
}

View File

@ -1652,10 +1652,16 @@ cSampleManager::UpdateReverb(void)
if ( AudioManager.m_FrameCounter & 15 )
return FALSE;
#ifdef AUDIO_REFLECTIONS
float y = AudioManager.m_afReflectionsDistances[REFLECTION_TOP] + AudioManager.m_afReflectionsDistances[REFLECTION_BOTTOM];
float x = AudioManager.m_afReflectionsDistances[REFLECTION_LEFT] + AudioManager.m_afReflectionsDistances[REFLECTION_RIGHT];
float z = AudioManager.m_afReflectionsDistances[REFLECTION_UP];
#else
float x = 0.0f;
float y = 0.0f;
float z = 0.0f;
#endif
float normy = norm(y, 5.0f, 40.0f);
float normx = norm(x, 5.0f, 40.0f);
@ -2169,7 +2175,7 @@ cSampleManager::StartPreloadedStreamedFile(uint8 nStream)
bool8
cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream)
{
int i = 0;
uint32 i = 0;
uint32 position = nPos;
char filename[MAX_PATH];
@ -2250,7 +2256,7 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream)
if ( !_pMP3List )
{
nFile = 0;
_bIsMp3Active = 0;
_bIsMp3Active = FALSE;
#ifdef PS2_AUDIO_PATHS
strcpy(filename, m_szCDRomRootPath);
strcat(filename, PS2StreamedNameTable[nFile]);
@ -2295,7 +2301,7 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream)
}
}
_bIsMp3Active = 0;
_bIsMp3Active = FALSE;
}
while ( ++i < nNumMP3s );
position = 0;

View File

@ -1362,10 +1362,16 @@ bool8 cSampleManager::UpdateReverb(void)
if ( AudioManager.m_FrameCounter & 15 )
return FALSE;
#ifdef AUDIO_REFLECTIONS
float y = AudioManager.m_afReflectionsDistances[REFLECTION_TOP] + AudioManager.m_afReflectionsDistances[REFLECTION_BOTTOM];
float x = AudioManager.m_afReflectionsDistances[REFLECTION_LEFT] + AudioManager.m_afReflectionsDistances[REFLECTION_RIGHT];
float z = AudioManager.m_afReflectionsDistances[REFLECTION_UP];
#else
float x = 0.0f;
float y = 0.0f;
float z = 0.0f;
#endif
float normy = norm(y, 5.0f, 40.0f);
float normx = norm(x, 5.0f, 40.0f);
@ -1653,7 +1659,7 @@ cSampleManager::StartPreloadedStreamedFile(uint8 nStream)
bool8
cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream)
{
int i = 0;
uint32 i = 0;
uint32 position = nPos;
char filename[MAX_PATH];
@ -1728,7 +1734,7 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream)
if ( !_pMP3List )
{
nFile = 0;
_bIsMp3Active = 0;
_bIsMp3Active = FALSE;
CStream *stream = aStream[nStream];
#ifdef PS2_AUDIO_PATHS
if(!stream->Open(PS2StreamedNameTable[nFile], IsThisTrackAt16KHz(nFile) ? 16000 : 32000))
@ -1767,7 +1773,7 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream)
}
}
_bIsMp3Active = 0;
_bIsMp3Active = FALSE;
}
while ( ++i < nNumMP3s );
position = 0;

View File

@ -44,7 +44,9 @@ CMenuScreen aScreens[MENUPAGES] = {
MENUACTION_AUDIOHW, "FEA_3DH", SAVESLOT_NONE, MENUPAGE_SOUND_SETTINGS,
MENUACTION_SPEAKERCONF, "FEA_SPK", SAVESLOT_NONE, MENUPAGE_SOUND_SETTINGS,
#endif
#ifdef AUDIO_REFLECTIONS
MENUACTION_DYNAMICACOUSTIC, "FET_DAM", SAVESLOT_NONE, MENUPAGE_SOUND_SETTINGS,
#endif
MENUACTION_RADIO, "FEA_RSS", SAVESLOT_NONE, MENUPAGE_SOUND_SETTINGS,
MENUACTION_RESTOREDEF, "FET_DEF", SAVESLOT_NONE, MENUPAGE_SOUND_SETTINGS,
MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE,

View File

@ -439,7 +439,9 @@ CMenuScreenCustom aScreens[MENUPAGES] = {
MENUACTION_AUDIOHW, "FEA_3DH", { nil, SAVESLOT_NONE, MENUPAGE_SOUND_SETTINGS },
MENUACTION_SPEAKERCONF, "FEA_SPK", { nil, SAVESLOT_NONE, MENUPAGE_SOUND_SETTINGS },
#endif
#ifdef AUDIO_REFLECTIONS
MENUACTION_DYNAMICACOUSTIC, "FET_DAM", { nil, SAVESLOT_NONE, MENUPAGE_SOUND_SETTINGS },
#endif
MENUACTION_RADIO, "FEA_RSS", { nil, SAVESLOT_NONE, MENUPAGE_SOUND_SETTINGS },
MENUACTION_RESTOREDEF, "FET_DEF", { nil, SAVESLOT_NONE, MENUPAGE_SOUND_SETTINGS },
MENUACTION_CHANGEMENU, "FEDS_TB", { nil, SAVESLOT_NONE, MENUPAGE_NONE },

View File

@ -171,6 +171,7 @@ enum Config {
# define PS2_MENU
#elif defined GTA_PC
# define EXTERNAL_3D_SOUND
# define AUDIO_REFLECTIONS
# ifndef GTA_HANDHELD
# define PC_PLAYER_CONTROLS // mouse player/cam mode
# endif
@ -429,6 +430,7 @@ enum Config {
// 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
// originally and making it work in 2d only requires more resource). Will not work on PS2
#define AUDIO_REFLECTIONS // Enable audio reflections. Disabled on mobile, didn't exist yet on PS2.
#define RADIO_SCROLL_TO_PREV_STATION
#define AUDIO_CACHE
#define PS2_AUDIO_CHANNELS // increases the maximum number of audio channels to PS2 value of 44 (PC has 28 originally)
@ -490,3 +492,6 @@ enum Config {
#if defined(GTA_PS2) && defined(EXTERNAL_3D_SOUND)
#error EXTERNAL_3D_SOUND cannot work on PS2
#endif
#if defined(AUDIO_REFLECTIONS) && GTA_VERSION < GTA3_PC_10
#error AUDIO_REFLECTIONS cannot work with versions below GTA3_PC_10
#endif