1
0
Fork 0
mirror of https://github.com/halpz/re3.git synced 2024-12-22 17:35:29 +00:00

Audio: refactoring, type fixes, renaming cAudioManager fields

This commit is contained in:
Sergeanur 2021-08-25 08:49:42 +03:00
parent 9ecca45bf3
commit ee93e4bc7d
8 changed files with 230 additions and 240 deletions

View file

@ -18,7 +18,7 @@ cAudioManager::ReportCollision(CEntity *entity1, CEntity *entity2, uint8 surface
CVector v1; CVector v1;
CVector v2; CVector v2;
if(!m_bIsInitialised || m_nCollisionEntity < 0 || m_nUserPause || if(!m_bIsInitialised || m_nCollisionEntity < 0 || m_bIsPaused ||
(velocity < 0.0016f && collisionPower < 0.01f)) (velocity < 0.0016f && collisionPower < 0.01f))
return; return;

View file

@ -215,9 +215,9 @@ cAudioManager::ResetAudioLogicTimers(uint32 timer)
gAirportNextTime = timer; gAirportNextTime = timer;
gDocksNextTime = timer; gDocksNextTime = timer;
gCinemaNextTime = timer; gCinemaNextTime = timer;
for (int32 i = 0; i < m_nAudioEntitiesTotal; i++) { for (uint32 i = 0; i < m_nAudioEntitiesCount; i++) {
if (m_asAudioEntities[m_anAudioEntityIndices[i]].m_nType == AUDIOTYPE_PHYSICAL) { if (m_asAudioEntities[m_aAudioEntityOrderList[i]].m_nType == AUDIOTYPE_PHYSICAL) {
CPed *ped = (CPed *)m_asAudioEntities[m_anAudioEntityIndices[i]].m_pEntity; CPed *ped = (CPed *)m_asAudioEntities[m_aAudioEntityOrderList[i]].m_pEntity;
if (ped->IsPed()) { if (ped->IsPed()) {
ped->m_lastSoundStart = timer; ped->m_lastSoundStart = timer;
ped->m_soundStart = timer + m_anRandomTable[0] % 3000; ped->m_soundStart = timer + m_anRandomTable[0] % 3000;
@ -278,14 +278,14 @@ cAudioManager::CalculateDistance(bool8 &distCalculated, float dist)
void void
cAudioManager::ProcessSpecial() cAudioManager::ProcessSpecial()
{ {
if (m_nUserPause) { if (m_bIsPaused) {
if (!m_nPreviousUserPause) { if (!m_bWasPaused) {
MusicManager.ChangeMusicMode(MUSICMODE_FRONTEND); MusicManager.ChangeMusicMode(MUSICMODE_FRONTEND);
SampleManager.SetEffectsFadeVolume(MAX_VOLUME); SampleManager.SetEffectsFadeVolume(MAX_VOLUME);
SampleManager.SetMusicFadeVolume(MAX_VOLUME); SampleManager.SetMusicFadeVolume(MAX_VOLUME);
} }
} else { } else {
if (m_nPreviousUserPause) { if (m_bWasPaused) {
MusicManager.StopFrontEndTrack(); MusicManager.StopFrontEndTrack();
MusicManager.ChangeMusicMode(MUSICMODE_GAME); MusicManager.ChangeMusicMode(MUSICMODE_GAME);
} }
@ -304,43 +304,43 @@ cAudioManager::ProcessEntity(int32 id)
m_sQueueSample.m_nEntityIndex = id; m_sQueueSample.m_nEntityIndex = id;
switch (m_asAudioEntities[id].m_nType) { switch (m_asAudioEntities[id].m_nType) {
case AUDIOTYPE_PHYSICAL: case AUDIOTYPE_PHYSICAL:
if (!m_nUserPause) { if (!m_bIsPaused) {
m_sQueueSample.m_bReverb = TRUE; m_sQueueSample.m_bReverb = TRUE;
ProcessPhysical(id); ProcessPhysical(id);
} }
break; break;
case AUDIOTYPE_EXPLOSION: case AUDIOTYPE_EXPLOSION:
if (!m_nUserPause) { if (!m_bIsPaused) {
m_sQueueSample.m_bReverb = TRUE; m_sQueueSample.m_bReverb = TRUE;
ProcessExplosions(id); ProcessExplosions(id);
} }
break; break;
case AUDIOTYPE_FIRE: case AUDIOTYPE_FIRE:
if (!m_nUserPause) { if (!m_bIsPaused) {
m_sQueueSample.m_bReverb = TRUE; m_sQueueSample.m_bReverb = TRUE;
ProcessFires(id); ProcessFires(id);
} }
break; break;
case AUDIOTYPE_WEATHER: case AUDIOTYPE_WEATHER:
if (!m_nUserPause) { if (!m_bIsPaused) {
m_sQueueSample.m_bReverb = TRUE; m_sQueueSample.m_bReverb = TRUE;
ProcessWeather(id); ProcessWeather(id);
} }
break; break;
case AUDIOTYPE_CRANE: case AUDIOTYPE_CRANE:
if (!m_nUserPause) { if (!m_bIsPaused) {
m_sQueueSample.m_bReverb = TRUE; m_sQueueSample.m_bReverb = TRUE;
ProcessCrane(); ProcessCrane();
} }
break; break;
case AUDIOTYPE_SCRIPTOBJECT: case AUDIOTYPE_SCRIPTOBJECT:
if (!m_nUserPause) { if (!m_bIsPaused) {
m_sQueueSample.m_bReverb = TRUE; m_sQueueSample.m_bReverb = TRUE;
ProcessScriptObject(id); ProcessScriptObject(id);
} }
break; break;
case AUDIOTYPE_BRIDGE: case AUDIOTYPE_BRIDGE:
if (!m_nUserPause) { if (!m_bIsPaused) {
m_sQueueSample.m_bReverb = TRUE; m_sQueueSample.m_bReverb = TRUE;
ProcessBridge(); ProcessBridge();
} }
@ -350,23 +350,23 @@ cAudioManager::ProcessEntity(int32 id)
ProcessFrontEnd(); ProcessFrontEnd();
break; break;
case AUDIOTYPE_PROJECTILE: case AUDIOTYPE_PROJECTILE:
if (!m_nUserPause) { if (!m_bIsPaused) {
m_sQueueSample.m_bReverb = TRUE; m_sQueueSample.m_bReverb = TRUE;
ProcessProjectiles(); ProcessProjectiles();
} }
break; break;
case AUDIOTYPE_GARAGE: case AUDIOTYPE_GARAGE:
if (!m_nUserPause) if (!m_bIsPaused)
ProcessGarages(); ProcessGarages();
break; break;
case AUDIOTYPE_FIREHYDRANT: case AUDIOTYPE_FIREHYDRANT:
if (!m_nUserPause) { if (!m_bIsPaused) {
m_sQueueSample.m_bReverb = TRUE; m_sQueueSample.m_bReverb = TRUE;
ProcessFireHydrant(); ProcessFireHydrant();
} }
break; break;
case AUDIOTYPE_WATERCANNON: case AUDIOTYPE_WATERCANNON:
if (!m_nUserPause) { if (!m_bIsPaused) {
m_sQueueSample.m_bReverb = TRUE; m_sQueueSample.m_bReverb = TRUE;
ProcessWaterCannon(id); ProcessWaterCannon(id);
} }
@ -564,7 +564,7 @@ const tVehicleSampleData aVehicleSettings[MAX_CARS] = {
bool8 bPlayerJustEnteredCar; bool8 bPlayerJustEnteredCar;
const bool8 hornPatternsArray[8][44] = { const bool8 HornPattern[8][44] = {
{FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, {FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE,
FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE}, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE},
{FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, {FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
@ -679,7 +679,7 @@ cAudioManager::ProcessRainOnVehicle(cVehicleParams& params)
const int rainOnVehicleIntensity = 22; const int rainOnVehicleIntensity = 22;
if (params.m_fDistance < SQR(rainOnVehicleIntensity) && CWeather::Rain > 0.01f && (!CCullZones::CamNoRain() || !CCullZones::PlayerNoRain())) { if (params.m_fDistance < SQR(rainOnVehicleIntensity) && CWeather::Rain > 0.01f && (!CCullZones::CamNoRain() || !CCullZones::PlayerNoRain())) {
CVehicle *veh = params.m_pVehicle; CVehicle *veh = params.m_pVehicle;
++veh->m_bRainAudioCounter; veh->m_bRainAudioCounter++;
if (veh->m_bRainAudioCounter >= 2) { if (veh->m_bRainAudioCounter >= 2) {
veh->m_bRainAudioCounter = 0; veh->m_bRainAudioCounter = 0;
CalculateDistance(params.m_bDistanceCalculated, params.m_fDistance); CalculateDistance(params.m_bDistanceCalculated, params.m_fDistance);
@ -960,7 +960,7 @@ cAudioManager::ProcessVehicleEngine(cVehicleParams& params)
} else { } else {
switch (transmission->nDriveType) { switch (transmission->nDriveType) {
case '4': case '4':
for (int32 i = 0; i < ARRAY_SIZE(automobile->m_aWheelState); i++) { for (uint8 i = 0; i < ARRAY_SIZE(automobile->m_aWheelState); i++) {
if (automobile->m_aWheelState[i] == WHEEL_STATE_SPINNING) if (automobile->m_aWheelState[i] == WHEEL_STATE_SPINNING)
traction += 0.05f; traction += 0.05f;
} }
@ -1125,10 +1125,10 @@ cAudioManager::ProcessCesna(cVehicleParams& params)
if (FindPlayerVehicle() == params.m_pVehicle) { if (FindPlayerVehicle() == params.m_pVehicle) {
if (params.m_nIndex == DODO) { if (params.m_nIndex == DODO) {
if (Pads[0].GetAccelerate() <= 0) { if (Pads[0].GetAccelerate() <= 0) {
if (nAccel != 0) if (nAccel > 0)
--nAccel; nAccel--;
} else if (nAccel < 60) { } else if (nAccel < 60) {
++nAccel; nAccel++;
} }
AddPlayerCarSample(85 * (60 - nAccel) / 60 + 20, 8500 * nAccel / 60 + 17000, SFX_CESNA_IDLE, SFX_BANK_0, 52, TRUE); AddPlayerCarSample(85 * (60 - nAccel) / 60 + 20, 8500 * nAccel / 60 + 17000, SFX_CESNA_IDLE, SFX_BANK_0, 52, TRUE);
AddPlayerCarSample(85 * nAccel / 60 + 20, 8500 * nAccel / 60 + 17000, SFX_CESNA_REV, SFX_BANK_0, 2, TRUE); AddPlayerCarSample(85 * nAccel / 60 + 20, 8500 * nAccel / 60 + 17000, SFX_CESNA_REV, SFX_BANK_0, 2, TRUE);
@ -1193,7 +1193,6 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CAutomobile *
float time; float time;
int baseFreq; int baseFreq;
uint8 vol; uint8 vol;
int gearNr;
int32 freq; int32 freq;
int freqModifier; int freqModifier;
@ -1213,7 +1212,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CAutomobile *
static uint8 CurrentPretendGear = 1; static uint8 CurrentPretendGear = 1;
static bool8 bLostTractionLastFrame = FALSE; static bool8 bLostTractionLastFrame = FALSE;
static bool8 bHandbrakeOnLastFrame = FALSE; static bool8 bHandbrakeOnLastFrame = FALSE;
static int32 nCruising = 0; static uint32 nCruising = 0;
static bool8 bAccelSampleStopped = TRUE; static bool8 bAccelSampleStopped = TRUE;
lostTraction = FALSE; lostTraction = FALSE;
@ -1249,7 +1248,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CAutomobile *
wheelInUseCounter = 0; wheelInUseCounter = 0;
for (uint8 i = 0; i < ARRAY_SIZE(automobile->m_aWheelState); i++) { for (uint8 i = 0; i < ARRAY_SIZE(automobile->m_aWheelState); i++) {
if (automobile->m_aWheelState[i] != WHEEL_STATE_NORMAL) if (automobile->m_aWheelState[i] != WHEEL_STATE_NORMAL)
++wheelInUseCounter; wheelInUseCounter++;
} }
if (wheelInUseCounter > 2) if (wheelInUseCounter > 2)
lostTraction = TRUE; lostTraction = TRUE;
@ -1305,124 +1304,116 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CAutomobile *
if (gasPedalAudio > 0.05f) { if (gasPedalAudio > 0.05f) {
freq = (5000.f * (gasPedalAudio - 0.05f) * 20.f / 19) + 19000; freq = (5000.f * (gasPedalAudio - 0.05f) * 20.f / 19) + 19000;
if (engineSoundType == SFX_BANK_TRUCK) if (engineSoundType == SFX_BANK_TRUCK)
freq /= 2; freq >>= 1;
AddPlayerCarSample((25.f * (gasPedalAudio - 0.05f) * 20.f / 19) + 40, freq, (soundOffset + SFX_CAR_FINGER_OFF_ACCEL_1), engineSoundType, 63, AddPlayerCarSample((25.f * (gasPedalAudio - 0.05f) * 20.f / 19) + 40, freq, (soundOffset + SFX_CAR_FINGER_OFF_ACCEL_1), engineSoundType, 63,
FALSE); FALSE);
} }
} }
freq = (10000.f * gasPedalAudio) + 22050; freq = (10000.f * gasPedalAudio) + 22050;
if (engineSoundType == SFX_BANK_TRUCK) if (engineSoundType == SFX_BANK_TRUCK)
freq /= 2; freq >>= 1;
AddPlayerCarSample(110 - (40.f * gasPedalAudio), freq, (engineSoundType - CAR_SFX_BANKS_OFFSET + SFX_CAR_IDLE_1), SFX_BANK_0, 52, TRUE); AddPlayerCarSample(110 - (40.f * gasPedalAudio), freq, (engineSoundType - CAR_SFX_BANKS_OFFSET + SFX_CAR_IDLE_1), SFX_BANK_0, 52, TRUE);
CurrentPretendGear = Max(1, currentGear); CurrentPretendGear = Max(1, currentGear);
} else if (nCruising > 0) {
PlayCruising:
bAccelSampleStopped = TRUE;
if (accelerateState < 150 || automobile->m_nWheelsOnGround == 0 || automobile->bIsHandbrakeOn || lostTraction ||
currentGear < params.m_pTransmission->nNumberOfGears - 1) {
nCruising = 0;
} else {
if (accelerateState >= 220 && params.m_fVelocityChange + 0.001f < automobile->m_fVelocityChangeForAudio) {
if (nCruising < 800)
nCruising++;
} else if (nCruising > 3)
nCruising--;
freq = 27 * nCruising + freqModifier + 22050;
if (engineSoundType == SFX_BANK_TRUCK)
freq >>= 1;
AddPlayerCarSample(85, freq, (soundOffset + SFX_CAR_AFTER_ACCEL_1), engineSoundType, 64, TRUE);
}
} else { } else {
while (nCruising == 0) { if (accelerateState < 150 || automobile->m_nWheelsOnGround == 0 || automobile->bIsHandbrakeOn || lostTraction ||
if (accelerateState < 150 || automobile->m_nWheelsOnGround == 0 || automobile->bIsHandbrakeOn || lostTraction || currentGear < 2 && velocityChange - automobile->m_fVelocityChangeForAudio < 0.01f) { // here could be used abs
currentGear < 2 && velocityChange - automobile->m_fVelocityChangeForAudio < 0.01f) { // here could be used abs if (automobile->m_nWheelsOnGround == 0 || automobile->bIsHandbrakeOn || lostTraction) {
if (automobile->m_nWheelsOnGround == 0 || automobile->bIsHandbrakeOn || lostTraction) { if (automobile->m_nWheelsOnGround == 0 && automobile->m_nDriveWheelsOnGround != 0 ||
if (automobile->m_nWheelsOnGround == 0 && automobile->m_nDriveWheelsOnGround != 0 || (automobile->bIsHandbrakeOn && !bHandbrakeOnLastFrame || lostTraction && !bLostTractionLastFrame) && automobile->m_nWheelsOnGround != 0) {
(automobile->bIsHandbrakeOn && !bHandbrakeOnLastFrame || lostTraction && !bLostTractionLastFrame) && automobile->m_nWheelsOnGround != 0) { automobile->m_fGasPedalAudio *= 0.6f;
automobile->m_fGasPedalAudio *= 0.6f;
}
freqModifier = 0;
baseFreq = (15000.f * automobile->m_fGasPedalAudio) + 14000;
vol = (25.0f * automobile->m_fGasPedalAudio) + 60;
} else {
baseFreq = (8000.f * accelerationMultipler) + 16000;
vol = (25.0f * accelerationMultipler) + 60;
automobile->m_fGasPedalAudio = accelerationMultipler;
} }
freq = freqModifier + baseFreq; freqModifier = 0;
if (engineSoundType == SFX_BANK_TRUCK) baseFreq = (15000 * automobile->m_fGasPedalAudio) + 14000;
freq /= 2; vol = (25.0f * automobile->m_fGasPedalAudio) + 60;
if (channelUsed) {
SampleManager.StopChannel(CHANNEL_PLAYER_VEHICLE_ENGINE);
bAccelSampleStopped = TRUE;
}
AddPlayerCarSample(vol, freq, (engineSoundType - CAR_SFX_BANKS_OFFSET + SFX_CAR_REV_1), SFX_BANK_0, 2, TRUE);
} else { } else {
TranslateEntity(&m_sQueueSample.m_vecPos, &pos); baseFreq = (8000 * accelerationMultipler) + 16000;
vol = (25.0f * accelerationMultipler) + 60;
automobile->m_fGasPedalAudio = accelerationMultipler;
}
freq = freqModifier + baseFreq;
if (engineSoundType == SFX_BANK_TRUCK)
freq >>= 1;
if (channelUsed) {
SampleManager.StopChannel(CHANNEL_PLAYER_VEHICLE_ENGINE);
bAccelSampleStopped = TRUE;
}
AddPlayerCarSample(vol, freq, (engineSoundType - CAR_SFX_BANKS_OFFSET + SFX_CAR_REV_1), SFX_BANK_0, 2, TRUE);
} else {
TranslateEntity(&m_sQueueSample.m_vecPos, &pos);
#ifndef EXTERNAL_3D_SOUND #ifndef EXTERNAL_3D_SOUND
m_sQueueSample.m_nPan = ComputePan(m_sQueueSample.m_fDistance, &pos); m_sQueueSample.m_nPan = ComputePan(m_sQueueSample.m_fDistance, &pos);
#endif #endif
if (bAccelSampleStopped) { if (bAccelSampleStopped) {
if (CurrentPretendGear != 1 || currentGear != 2) { if (CurrentPretendGear != 1 || currentGear != 2)
gearNr = currentGear - 1; CurrentPretendGear = Max(1, currentGear - 1);
if (gearNr < 1) processedAccelSampleStopped = TRUE;
gearNr = 1; bAccelSampleStopped = FALSE;
CurrentPretendGear = gearNr; }
}
processedAccelSampleStopped = TRUE;
bAccelSampleStopped = FALSE;
}
if (!channelUsed) { if (!channelUsed) {
if (!processedAccelSampleStopped) { if (!processedAccelSampleStopped) {
if (CurrentPretendGear < params.m_pTransmission->nNumberOfGears - 1) if (CurrentPretendGear < params.m_pTransmission->nNumberOfGears - 1)
++CurrentPretendGear; CurrentPretendGear++;
else { else {
nCruising = 1; nCruising = 1;
break; // while was used just for this fucking place goto PlayCruising;
}
} }
}
#ifdef GTA_PS2 #ifdef GTA_PS2
SampleManager.InitialiseChannel(CHANNEL_PLAYER_VEHICLE_ENGINE, soundOffset + SFX_CAR_ACCEL_1, SFX_BANK_0); SampleManager.InitialiseChannel(CHANNEL_PLAYER_VEHICLE_ENGINE, soundOffset + SFX_CAR_ACCEL_1, SFX_BANK_0);
#else #else
if (!SampleManager.InitialiseChannel(CHANNEL_PLAYER_VEHICLE_ENGINE, soundOffset + SFX_CAR_ACCEL_1, SFX_BANK_0)) if (!SampleManager.InitialiseChannel(CHANNEL_PLAYER_VEHICLE_ENGINE, soundOffset + SFX_CAR_ACCEL_1, SFX_BANK_0))
return; return;
#endif #endif
SampleManager.SetChannelLoopCount(CHANNEL_PLAYER_VEHICLE_ENGINE, 1); SampleManager.SetChannelLoopCount(CHANNEL_PLAYER_VEHICLE_ENGINE, 1);
#ifndef GTA_PS2 #ifndef GTA_PS2
SampleManager.SetChannelLoopPoints(CHANNEL_PLAYER_VEHICLE_ENGINE, 0, -1); SampleManager.SetChannelLoopPoints(CHANNEL_PLAYER_VEHICLE_ENGINE, 0, -1);
#endif #endif
} }
#ifdef EXTERNAL_3D_SOUND #ifdef EXTERNAL_3D_SOUND
SampleManager.SetChannelEmittingVolume(CHANNEL_PLAYER_VEHICLE_ENGINE, 85); SampleManager.SetChannelEmittingVolume(CHANNEL_PLAYER_VEHICLE_ENGINE, 85);
SampleManager.SetChannel3DPosition(CHANNEL_PLAYER_VEHICLE_ENGINE, pos.x, pos.y, pos.z); SampleManager.SetChannel3DPosition(CHANNEL_PLAYER_VEHICLE_ENGINE, pos.x, pos.y, pos.z);
SampleManager.SetChannel3DDistances(CHANNEL_PLAYER_VEHICLE_ENGINE, 50.0f, 50.0f * 0.25f); SampleManager.SetChannel3DDistances(CHANNEL_PLAYER_VEHICLE_ENGINE, 50.0f, 50.0f * 0.25f);
#else #else
SampleManager.SetChannelVolume(CHANNEL_PLAYER_VEHICLE_ENGINE, ComputeVolume(85, 50.0f, m_sQueueSample.m_fDistance)); SampleManager.SetChannelVolume(CHANNEL_PLAYER_VEHICLE_ENGINE, ComputeVolume(85, 50.0f, m_sQueueSample.m_fDistance));
SampleManager.SetChannelPan(CHANNEL_PLAYER_VEHICLE_ENGINE, m_sQueueSample.m_nPan); SampleManager.SetChannelPan(CHANNEL_PLAYER_VEHICLE_ENGINE, m_sQueueSample.m_nPan);
#endif #endif
freq = GearFreqAdj[CurrentPretendGear] + freqModifier + 22050; freq = GearFreqAdj[CurrentPretendGear] + freqModifier + 22050;
if (engineSoundType == SFX_BANK_TRUCK) if (engineSoundType == SFX_BANK_TRUCK)
freq /= 2; freq >>= 1;
#ifdef USE_TIME_SCALE_FOR_AUDIO #ifdef USE_TIME_SCALE_FOR_AUDIO
SampleManager.SetChannelFrequency(CHANNEL_PLAYER_VEHICLE_ENGINE, freq * CTimer::GetTimeScale()); SampleManager.SetChannelFrequency(CHANNEL_PLAYER_VEHICLE_ENGINE, freq * CTimer::GetTimeScale());
#else #else
SampleManager.SetChannelFrequency(CHANNEL_PLAYER_VEHICLE_ENGINE, freq); SampleManager.SetChannelFrequency(CHANNEL_PLAYER_VEHICLE_ENGINE, freq);
#endif #endif
if (!channelUsed) { if (!channelUsed) {
#if GTA_VERSION >= GTA3_PC_10 #if GTA_VERSION >= GTA3_PC_10
SampleManager.SetChannelReverbFlag(CHANNEL_PLAYER_VEHICLE_ENGINE, m_bDynamicAcousticModelingStatus != FALSE); SampleManager.SetChannelReverbFlag(CHANNEL_PLAYER_VEHICLE_ENGINE, m_bDynamicAcousticModelingStatus != FALSE);
#else #else
SampleManager.SetChannelReverbFlag(CHANNEL_PLAYER_VEHICLE_ENGINE, TRUE); SampleManager.SetChannelReverbFlag(CHANNEL_PLAYER_VEHICLE_ENGINE, TRUE);
#endif #endif
SampleManager.StartChannel(CHANNEL_PLAYER_VEHICLE_ENGINE); SampleManager.StartChannel(CHANNEL_PLAYER_VEHICLE_ENGINE);
}
}
break;
}
if (nCruising != 0) {
bAccelSampleStopped = TRUE;
if (accelerateState < 150 || automobile->m_nWheelsOnGround == 0 || automobile->bIsHandbrakeOn || lostTraction ||
currentGear < params.m_pTransmission->nNumberOfGears - 1) {
nCruising = 0;
} else {
if (accelerateState >= 220 && params.m_fVelocityChange + 0.001f < automobile->m_fVelocityChangeForAudio) {
if (nCruising < 800)
++nCruising;
} else if (nCruising > 3) {
--nCruising;
}
freq = 27 * nCruising + freqModifier + 22050;
if (engineSoundType == SFX_BANK_TRUCK)
freq /= 2;
AddPlayerCarSample(85, freq, (soundOffset + SFX_CAR_AFTER_ACCEL_1), engineSoundType, 64, TRUE);
} }
} }
} }
@ -1449,7 +1440,7 @@ cAudioManager::ProcessVehicleSkidding(cVehicleParams& params)
if (automobile->m_nWheelsOnGround == 0) if (automobile->m_nWheelsOnGround == 0)
return TRUE; return TRUE;
CalculateDistance(params.m_bDistanceCalculated, params.m_fDistance); CalculateDistance(params.m_bDistanceCalculated, params.m_fDistance);
for (int32 i = 0; i < ARRAY_SIZE(automobile->m_aWheelState); i++) { for (uint8 i = 0; i < ARRAY_SIZE(automobile->m_aWheelState); i++) {
if (automobile->m_aWheelState[i] == WHEEL_STATE_NORMAL || automobile->Damage.GetWheelStatus(i) == WHEEL_STATUS_MISSING) if (automobile->m_aWheelState[i] == WHEEL_STATE_NORMAL || automobile->Damage.GetWheelStatus(i) == WHEEL_STATUS_MISSING)
continue; continue;
transmission = params.m_pTransmission; transmission = params.m_pTransmission;
@ -1584,7 +1575,7 @@ cAudioManager::ProcessVehicleHorn(cVehicleParams& params)
automobile->m_nCarHornTimer = Min(44, automobile->m_nCarHornTimer); automobile->m_nCarHornTimer = Min(44, automobile->m_nCarHornTimer);
if (automobile->m_nCarHornTimer == 44) if (automobile->m_nCarHornTimer == 44)
automobile->m_nCarHornPattern = (m_FrameCounter + m_sQueueSample.m_nEntityIndex) & 7; automobile->m_nCarHornPattern = (m_FrameCounter + m_sQueueSample.m_nEntityIndex) & 7;
if (!hornPatternsArray[automobile->m_nCarHornPattern][44 - automobile->m_nCarHornTimer]) if (!HornPattern[automobile->m_nCarHornPattern][44 - automobile->m_nCarHornTimer])
return; return;
} }
@ -1751,7 +1742,7 @@ cAudioManager::ProcessVehicleDoors(cVehicleParams& params)
automobile = (CAutomobile *)params.m_pVehicle; automobile = (CAutomobile *)params.m_pVehicle;
CalculateDistance(params.m_bDistanceCalculated, params.m_fDistance); CalculateDistance(params.m_bDistanceCalculated, params.m_fDistance);
for (int32 i = 0; i < ARRAY_SIZE(automobile->Doors); i++) { for (uint8 i = 0; i < ARRAY_SIZE(automobile->Doors); i++) {
if (automobile->Damage.GetDoorStatus(i) == DOOR_STATUS_SWINGING) { if (automobile->Damage.GetDoorStatus(i) == DOOR_STATUS_SWINGING) {
doorState = automobile->Doors[i].m_nDoorState; doorState = automobile->Doors[i].m_nDoorState;
if (doorState == DOORST_OPEN || doorState == DOORST_CLOSED) { if (doorState == DOORST_OPEN || doorState == DOORST_CLOSED) {
@ -2296,7 +2287,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams& params)
m_sQueueSample.m_nPriority = 1; m_sQueueSample.m_nPriority = 1;
m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_fSpeedMultiplier = 0.0f;
m_sQueueSample.m_MaxDistance = 40.0f; m_sQueueSample.m_MaxDistance = 40.0f;
++CrunchOffset; CrunchOffset++;
maxDist = SQR(SOUND_INTENSITY); maxDist = SQR(SOUND_INTENSITY);
emittingVol = m_anRandomTable[4] % 20 + 55; emittingVol = m_anRandomTable[4] % 20 + 55;
CrunchOffset %= 2; CrunchOffset %= 2;
@ -3197,7 +3188,7 @@ cAudioManager::ProcessPedOneShots(cPedParams &params)
m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nBankIndex = SFX_BANK_0;
m_sQueueSample.m_nCounter = iSound; m_sQueueSample.m_nCounter = iSound;
narrowSoundRange = TRUE; narrowSoundRange = TRUE;
++iSound; iSound++;
m_sQueueSample.m_nPriority = 3; m_sQueueSample.m_nPriority = 3;
m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_fSpeedMultiplier = 0.0f;
m_sQueueSample.m_MaxDistance = 30.0f; m_sQueueSample.m_MaxDistance = 30.0f;
@ -3566,15 +3557,14 @@ cAudioManager::ProcessPedOneShots(cPedParams &params)
AddSampleToRequestedQueue(); AddSampleToRequestedQueue();
if (stereo) { if (stereo) {
m_sQueueSample.m_nPan = 127; m_sQueueSample.m_nPan = 127;
++m_sQueueSample.m_nSampleIndex; m_sQueueSample.m_nSampleIndex++;
if (m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_awAudioEvent[i] != SOUND_WEAPON_SHOT_FIRED || if (m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_awAudioEvent[i] != SOUND_WEAPON_SHOT_FIRED ||
weapon->m_eWeaponType != WEAPONTYPE_FLAMETHROWER) { weapon->m_eWeaponType != WEAPONTYPE_FLAMETHROWER) {
m_sQueueSample.m_nCounter = iSound++; m_sQueueSample.m_nCounter = iSound++;
if (iSound > 60) if (iSound > 60)
iSound = 21; iSound = 21;
} else { } else
++m_sQueueSample.m_nCounter; m_sQueueSample.m_nCounter++;
}
AddSampleToRequestedQueue(); AddSampleToRequestedQueue();
} }
} }
@ -6051,18 +6041,16 @@ cPedComments::Add(tPedComment *com)
index = m_nIndexMap[m_nActiveBank][NUM_PED_COMMENTS_SLOTS - 1]; index = m_nIndexMap[m_nActiveBank][NUM_PED_COMMENTS_SLOTS - 1];
if (m_asPedComments[m_nActiveBank][index].m_nVolume > com->m_nVolume) if (m_asPedComments[m_nActiveBank][index].m_nVolume > com->m_nVolume)
return; return;
} else { } else
index = m_nCommentsInBank[m_nActiveBank]++; index = m_nCommentsInBank[m_nActiveBank]++;
}
m_asPedComments[m_nActiveBank][index] = *com; m_asPedComments[m_nActiveBank][index] = *com;
uint32 i = 0; uint8 i = 0;
if (index != 0) { if (index != 0) {
for (i = 0; i < index; i++) { for (i = 0; i < index; i++) {
if (m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][i]].m_nVolume < m_asPedComments[m_nActiveBank][index].m_nVolume) { if (m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][i]].m_nVolume < m_asPedComments[m_nActiveBank][index].m_nVolume)
break; break;
}
} }
if (i < index) if (i < index)
@ -6079,7 +6067,7 @@ cPedComments::Process()
uint8 actualUsedBank; uint8 actualUsedBank;
tPedComment *comment; tPedComment *comment;
if (AudioManager.m_nUserPause) return; if (AudioManager.m_bIsPaused) return;
if (m_nCommentsInBank[m_nActiveBank]) { if (m_nCommentsInBank[m_nActiveBank]) {
sampleIndex = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nSampleIndex; sampleIndex = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nSampleIndex;
@ -6202,7 +6190,7 @@ cPedComments::Process()
comment = m_asPedComments[actualUsedBank]; comment = m_asPedComments[actualUsedBank];
for (uint32 i = 0; i < m_nCommentsInBank[actualUsedBank]; i++) { for (uint32 i = 0; i < m_nCommentsInBank[actualUsedBank]; i++) {
if (m_asPedComments[actualUsedBank][m_nIndexMap[actualUsedBank][i]].m_nProcess > 0) { if (m_asPedComments[actualUsedBank][m_nIndexMap[actualUsedBank][i]].m_nProcess > 0) {
--m_asPedComments[actualUsedBank][m_nIndexMap[actualUsedBank][i]].m_nProcess; m_asPedComments[actualUsedBank][m_nIndexMap[actualUsedBank][i]].m_nProcess--;
Add(&comment[m_nIndexMap[actualUsedBank][i]]); Add(&comment[m_nIndexMap[actualUsedBank][i]]);
} }
} }
@ -6361,7 +6349,7 @@ cAudioManager::ProcessWaterCannon(int32)
{ {
const float SOUND_INTENSITY = 30.0f; const float SOUND_INTENSITY = 30.0f;
for (int32 i = 0; i < NUM_WATERCANNONS; i++) { for (uint32 i = 0; i < NUM_WATERCANNONS; i++) {
if (CWaterCannons::aCannons[i].m_nId) { if (CWaterCannons::aCannons[i].m_nId) {
m_sQueueSample.m_vecPos = CWaterCannons::aCannons[0].m_avecPos[CWaterCannons::aCannons[i].m_nCur]; m_sQueueSample.m_vecPos = CWaterCannons::aCannons[0].m_avecPos[CWaterCannons::aCannons[i].m_nCur];
float distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos); float distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos);
@ -8033,7 +8021,7 @@ cAudioManager::ProcessFrontEnd()
SET_SOUND_REFLECTION(FALSE); SET_SOUND_REFLECTION(FALSE);
AddSampleToRequestedQueue(); AddSampleToRequestedQueue();
if (stereo) { if (stereo) {
++m_sQueueSample.m_nSampleIndex; m_sQueueSample.m_nSampleIndex++;
m_sQueueSample.m_nCounter = iSound++; m_sQueueSample.m_nCounter = iSound++;
m_sQueueSample.m_nPan = 127 - m_sQueueSample.m_nPan; m_sQueueSample.m_nPan = 127 - m_sQueueSample.m_nPan;
AddSampleToRequestedQueue(); AddSampleToRequestedQueue();
@ -8099,7 +8087,7 @@ cAudioManager::ProcessProjectiles()
const int molotovVolume = 50; const int molotovVolume = 50;
uint8 emittingVol; uint8 emittingVol;
for (int32 i = 0; i < NUM_PROJECTILES; i++) { for (uint8 i = 0; i < NUM_PROJECTILES; i++) {
if (CProjectileInfo::GetProjectileInfo(i)->m_bInUse) { if (CProjectileInfo::GetProjectileInfo(i)->m_bInUse) {
switch (CProjectileInfo::GetProjectileInfo(i)->m_eWeaponType) { switch (CProjectileInfo::GetProjectileInfo(i)->m_eWeaponType) {
case WEAPONTYPE_ROCKETLAUNCHER: case WEAPONTYPE_ROCKETLAUNCHER:
@ -8158,7 +8146,11 @@ cAudioManager::ProcessGarages()
static uint8 iSound = 32; static uint8 iSound = 32;
for (uint32 i = 0; i < CGarages::NumGarages; ++i) { #ifdef FIX_BUGS
for (uint32 i = 0; i < CGarages::NumGarages; i++) {
#else
for (uint8 i = 0; i < CGarages::NumGarages; i++) {
#endif
if (CGarages::aGarages[i].m_eGarageType == GARAGE_NONE) if (CGarages::aGarages[i].m_eGarageType == GARAGE_NONE)
continue; continue;
entity = CGarages::aGarages[i].m_pDoor1; entity = CGarages::aGarages[i].m_pDoor1;
@ -8223,7 +8215,7 @@ cAudioManager::ProcessGarages()
break; break;
} }
} }
for (j = 0; j < m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_AudioEvents; ++j) { for (j = 0; j < m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_AudioEvents; j++) {
switch (m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_awAudioEvent[j]) { switch (m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_awAudioEvent[j]) {
case SOUND_GARAGE_DOOR_CLOSED: case SOUND_GARAGE_DOOR_CLOSED:
case SOUND_GARAGE_DOOR_OPENED: case SOUND_GARAGE_DOOR_OPENED:
@ -8465,7 +8457,7 @@ const MissionAudioData MissionAudioNameSfxAssoc[] = {
int32 int32
FindMissionAudioSfx(const char *name) FindMissionAudioSfx(const char *name)
{ {
for (uint32 i = 0; MissionAudioNameSfxAssoc[i].m_pName != nil; ++i) { for (uint32 i = 0; MissionAudioNameSfxAssoc[i].m_pName != nil; i++) {
if (!CGeneral::faststricmp(MissionAudioNameSfxAssoc[i].m_pName, name)) if (!CGeneral::faststricmp(MissionAudioNameSfxAssoc[i].m_pName, name))
return MissionAudioNameSfxAssoc[i].m_nId; return MissionAudioNameSfxAssoc[i].m_nId;
} }
@ -8597,7 +8589,7 @@ cAudioManager::ProcessMissionAudio()
nFramesForPretendPlaying = 0; nFramesForPretendPlaying = 0;
nCheckPlayingDelay = 0; nCheckPlayingDelay = 0;
nFramesUntilFailedLoad = 0; nFramesUntilFailedLoad = 0;
} else if (!m_nUserPause) { } else if (!m_bIsPaused) {
if (++nFramesForPretendPlaying < 120) { if (++nFramesForPretendPlaying < 120) {
m_nMissionAudioPlayStatus = PLAY_STATUS_PLAYING; m_nMissionAudioPlayStatus = PLAY_STATUS_PLAYING;
} else { } else {
@ -8612,7 +8604,7 @@ cAudioManager::ProcessMissionAudio()
if (MissionScriptAudioUsesPoliceChannel(m_nMissionAudioSampleIndex)) { if (MissionScriptAudioUsesPoliceChannel(m_nMissionAudioSampleIndex)) {
SetMissionScriptPoliceAudio(m_nMissionAudioSampleIndex); SetMissionScriptPoliceAudio(m_nMissionAudioSampleIndex);
} else { } else {
if (m_nUserPause) if (m_bIsPaused)
SampleManager.PauseStream(TRUE, 1); SampleManager.PauseStream(TRUE, 1);
if (m_bIsMissionAudio2D) { if (m_bIsMissionAudio2D) {
SampleManager.SetStreamedVolumeAndPan(80, 63, TRUE, 1); SampleManager.SetStreamedVolumeAndPan(80, 63, TRUE, 1);
@ -8641,9 +8633,9 @@ cAudioManager::ProcessMissionAudio()
break; break;
} }
if (MissionScriptAudioUsesPoliceChannel(m_nMissionAudioSampleIndex)) { if (MissionScriptAudioUsesPoliceChannel(m_nMissionAudioSampleIndex)) {
if (!m_nUserPause) { if (!m_bIsPaused) {
if (nCheckPlayingDelay) { if (nCheckPlayingDelay > 0) {
--nCheckPlayingDelay; nCheckPlayingDelay--;
} else if (GetMissionScriptPoliceAudioPlayingStatus() == PLAY_STATUS_FINISHED || m_nMissionAudioFramesToPlay-- == 0) { } else if (GetMissionScriptPoliceAudioPlayingStatus() == PLAY_STATUS_FINISHED || m_nMissionAudioFramesToPlay-- == 0) {
m_nMissionAudioPlayStatus = PLAY_STATUS_FINISHED; m_nMissionAudioPlayStatus = PLAY_STATUS_FINISHED;
m_nMissionAudioSampleIndex = NO_SAMPLE; m_nMissionAudioSampleIndex = NO_SAMPLE;
@ -8652,8 +8644,8 @@ cAudioManager::ProcessMissionAudio()
} }
} }
} else if (m_bIsMissionAudioPlaying) { } else if (m_bIsMissionAudioPlaying) {
if (SampleManager.IsStreamPlaying(1) || m_nUserPause || m_nPreviousUserPause) { if (SampleManager.IsStreamPlaying(1) || m_bIsPaused || m_bWasPaused) {
if (m_nUserPause) if (m_bIsPaused)
SampleManager.PauseStream(TRUE, 1); SampleManager.PauseStream(TRUE, 1);
else else
SampleManager.PauseStream(FALSE, 1); SampleManager.PauseStream(FALSE, 1);
@ -8664,7 +8656,7 @@ cAudioManager::ProcessMissionAudio()
m_nMissionAudioFramesToPlay = 0; m_nMissionAudioFramesToPlay = 0;
} }
} else { } else {
if (m_nUserPause) if (m_bIsPaused)
break; break;
if (nCheckPlayingDelay--) { if (nCheckPlayingDelay--) {
if (!SampleManager.IsStreamPlaying(1)) if (!SampleManager.IsStreamPlaying(1))

View file

@ -24,9 +24,9 @@ cAudioManager::cAudioManager()
m_fSpeedOfSound = SPEED_OF_SOUND / TIME_SPENT; m_fSpeedOfSound = SPEED_OF_SOUND / TIME_SPENT;
m_nTimeSpent = TIME_SPENT; m_nTimeSpent = TIME_SPENT;
m_nActiveSamples = NUM_CHANNELS_GENERIC; m_nActiveSamples = NUM_CHANNELS_GENERIC;
m_nActiveSampleQueue = 1; m_nActiveQueue = 1;
ClearRequestedQueue(); ClearRequestedQueue();
m_nActiveSampleQueue = 0; m_nActiveQueue = 0;
ClearRequestedQueue(); ClearRequestedQueue();
ClearActiveSamples(); ClearActiveSamples();
GenerateIntegerRandomNumberTable(); GenerateIntegerRandomNumberTable();
@ -35,11 +35,11 @@ cAudioManager::cAudioManager()
m_bDynamicAcousticModelingStatus = TRUE; m_bDynamicAcousticModelingStatus = TRUE;
#endif #endif
for (int i = 0; i < NUM_AUDIOENTITIES; i++) { for (uint32 i = 0; i < NUM_AUDIOENTITIES; i++) {
m_asAudioEntities[i].m_bIsUsed = FALSE; m_asAudioEntities[i].m_bIsUsed = FALSE;
m_anAudioEntityIndices[i] = NUM_AUDIOENTITIES; m_aAudioEntityOrderList[i] = NUM_AUDIOENTITIES;
} }
m_nAudioEntitiesTotal = 0; m_nAudioEntitiesCount = 0;
m_FrameCounter = 0; m_FrameCounter = 0;
m_bReduceReleasingPriority = FALSE; m_bReduceReleasingPriority = FALSE;
m_bTimerJustReset = FALSE; m_bTimerJustReset = FALSE;
@ -64,7 +64,7 @@ cAudioManager::Initialise()
if (m_nActiveSamples <= 1) { if (m_nActiveSamples <= 1) {
Terminate(); Terminate();
} else { } else {
--m_nActiveSamples; m_nActiveSamples--;
#else #else
{ {
m_nActiveSamples = NUM_CHANNELS_GENERIC; m_nActiveSamples = NUM_CHANNELS_GENERIC;
@ -86,10 +86,10 @@ cAudioManager::Terminate()
for (uint32 i = 0; i < NUM_AUDIOENTITIES; i++) { for (uint32 i = 0; i < NUM_AUDIOENTITIES; i++) {
m_asAudioEntities[i].m_bIsUsed = FALSE; m_asAudioEntities[i].m_bIsUsed = FALSE;
m_anAudioEntityIndices[i] = ARRAY_SIZE(m_anAudioEntityIndices); m_aAudioEntityOrderList[i] = ARRAY_SIZE(m_aAudioEntityOrderList);
} }
m_nAudioEntitiesTotal = 0; m_nAudioEntitiesCount = 0;
m_sAudioScriptObjectManager.m_nScriptObjectEntityTotal = 0; m_sAudioScriptObjectManager.m_nScriptObjectEntityTotal = 0;
PreTerminateGameSpecificShutdown(); PreTerminateGameSpecificShutdown();
@ -115,8 +115,8 @@ cAudioManager::Service()
m_bTimerJustReset = FALSE; m_bTimerJustReset = FALSE;
} }
if (m_bIsInitialised) { if (m_bIsInitialised) {
m_nPreviousUserPause = m_nUserPause; m_bWasPaused = m_bIsPaused;
m_nUserPause = CTimer::GetIsUserPaused(); m_bIsPaused = CTimer::GetIsUserPaused();
#ifdef AUDIO_REFLECTIONS #ifdef AUDIO_REFLECTIONS
UpdateReflections(); UpdateReflections();
#endif #endif
@ -138,12 +138,12 @@ cAudioManager::CreateEntity(eAudioType type, void *entity)
#ifdef FIX_BUGS #ifdef FIX_BUGS
// since sound could still play after entity deletion let's make sure we don't override one that is in use // since sound could still play after entity deletion let's make sure we don't override one that is in use
// find all the free entity IDs that are being used by queued samples // find all the free entity IDs that are being used by queued samples
int32 stillUsedEntities[NUM_CHANNELS_GENERIC * NUM_SOUNDS_SAMPLES_BANKS]; int32 stillUsedEntities[NUM_CHANNELS_GENERIC * NUM_SOUND_QUEUES];
uint32 stillUsedEntitiesCount = 0; uint32 stillUsedEntitiesCount = 0;
for (uint8 i = 0; i < NUM_SOUNDS_SAMPLES_BANKS; i++) for (uint8 i = 0; i < NUM_SOUND_QUEUES; i++)
for (uint8 j = 0; j < m_SampleRequestQueuesStatus[i]; j++) { for (uint8 j = 0; j < m_nRequestedCount[i]; j++) {
tSound &sound = m_asSamples[i][m_abSampleQueueIndexTable[i][j]]; tSound &sound = m_aRequestedQueue[i][m_aRequestedOrderList[i][j]];
if (sound.m_nEntityIndex < 0) continue; if (sound.m_nEntityIndex < 0) continue;
if (!m_asAudioEntities[sound.m_nEntityIndex].m_bIsUsed) { if (!m_asAudioEntities[sound.m_nEntityIndex].m_bIsUsed) {
bool found = false; bool found = false;
@ -159,7 +159,7 @@ cAudioManager::CreateEntity(eAudioType type, void *entity)
} }
#endif #endif
for (uint32 i = 0; i < ARRAY_SIZE(m_asAudioEntities); i++) { for (uint32 i = 0; i < NUM_AUDIOENTITIES; i++) {
if (!m_asAudioEntities[i].m_bIsUsed) { if (!m_asAudioEntities[i].m_bIsUsed) {
#ifdef FIX_BUGS #ifdef FIX_BUGS
// skip if ID is still used by queued sample // skip if ID is still used by queued sample
@ -184,7 +184,7 @@ cAudioManager::CreateEntity(eAudioType type, void *entity)
m_asAudioEntities[i].m_awAudioEvent[2] = SOUND_NO_SOUND; m_asAudioEntities[i].m_awAudioEvent[2] = SOUND_NO_SOUND;
m_asAudioEntities[i].m_awAudioEvent[3] = SOUND_NO_SOUND; m_asAudioEntities[i].m_awAudioEvent[3] = SOUND_NO_SOUND;
m_asAudioEntities[i].m_AudioEvents = 0; m_asAudioEntities[i].m_AudioEvents = 0;
m_anAudioEntityIndices[m_nAudioEntitiesTotal++] = i; m_aAudioEntityOrderList[m_nAudioEntitiesCount++] = i;
return i; return i;
} }
} }
@ -196,11 +196,11 @@ cAudioManager::DestroyEntity(int32 id)
{ {
if (m_bIsInitialised && id >= 0 && id < NUM_AUDIOENTITIES && m_asAudioEntities[id].m_bIsUsed) { if (m_bIsInitialised && id >= 0 && id < NUM_AUDIOENTITIES && m_asAudioEntities[id].m_bIsUsed) {
m_asAudioEntities[id].m_bIsUsed = FALSE; m_asAudioEntities[id].m_bIsUsed = FALSE;
for (int32 i = 0; i < m_nAudioEntitiesTotal; ++i) { for (uint32 i = 0; i < m_nAudioEntitiesCount; i++) {
if (id == m_anAudioEntityIndices[i]) { if (id == m_aAudioEntityOrderList[i]) {
if (i < NUM_AUDIOENTITIES - 1) if (i < NUM_AUDIOENTITIES - 1)
memmove(&m_anAudioEntityIndices[i], &m_anAudioEntityIndices[i + 1], NUM_AUDIOENTITY_EVENTS * (m_nAudioEntitiesTotal - (i + 1))); memmove(&m_aAudioEntityOrderList[i], &m_aAudioEntityOrderList[i + 1], NUM_AUDIOENTITY_EVENTS * (m_nAudioEntitiesCount - (i + 1)));
m_anAudioEntityIndices[--m_nAudioEntitiesTotal] = NUM_AUDIOENTITIES; m_aAudioEntityOrderList[--m_nAudioEntitiesCount] = NUM_AUDIOENTITIES;
return; return;
} }
} }
@ -257,13 +257,13 @@ cAudioManager::PlayOneShot(int32 index, uint16 sound, float vol)
if (entity.m_AudioEvents < ARRAY_SIZE(entity.m_awAudioEvent)) { if (entity.m_AudioEvents < ARRAY_SIZE(entity.m_awAudioEvent)) {
entity.m_awAudioEvent[i] = sound; entity.m_awAudioEvent[i] = sound;
entity.m_afVolume[i] = vol; entity.m_afVolume[i] = vol;
++entity.m_AudioEvents; entity.m_AudioEvents++;
} }
return; return;
} }
if (OneShotPriority[entity.m_awAudioEvent[i]] > OneShotPriority[sound]) if (OneShotPriority[entity.m_awAudioEvent[i]] > OneShotPriority[sound])
break; break;
++i; i++;
} }
if (i < NUM_AUDIOENTITY_EVENTS - 1) { if (i < NUM_AUDIOENTITY_EVENTS - 1) {
memmove(&entity.m_awAudioEvent[i + 1], &entity.m_awAudioEvent[i], (NUM_AUDIOENTITY_EVENTS - 1 - i) * NUM_AUDIOENTITY_EVENTS / 2); memmove(&entity.m_awAudioEvent[i + 1], &entity.m_awAudioEvent[i], (NUM_AUDIOENTITY_EVENTS - 1 - i) * NUM_AUDIOENTITY_EVENTS / 2);
@ -272,7 +272,7 @@ cAudioManager::PlayOneShot(int32 index, uint16 sound, float vol)
entity.m_awAudioEvent[i] = sound; entity.m_awAudioEvent[i] = sound;
entity.m_afVolume[i] = vol; entity.m_afVolume[i] = vol;
if (entity.m_AudioEvents < ARRAY_SIZE(entity.m_awAudioEvent)) if (entity.m_AudioEvents < ARRAY_SIZE(entity.m_awAudioEvent))
++entity.m_AudioEvents; entity.m_AudioEvents++;
} }
} }
} }
@ -317,14 +317,14 @@ cAudioManager::ResetTimers(uint32 time)
m_bTimerJustReset = TRUE; m_bTimerJustReset = TRUE;
m_nTimer = time; m_nTimer = time;
ClearRequestedQueue(); ClearRequestedQueue();
if (m_nActiveSampleQueue) { if (m_nActiveQueue) {
m_nActiveSampleQueue = 0; m_nActiveQueue = 0;
ClearRequestedQueue(); ClearRequestedQueue();
m_nActiveSampleQueue = 1; m_nActiveQueue = 1;
} else { } else {
m_nActiveSampleQueue = 1; m_nActiveQueue = 1;
ClearRequestedQueue(); ClearRequestedQueue();
m_nActiveSampleQueue = 0; m_nActiveQueue = 0;
} }
ClearActiveSamples(); ClearActiveSamples();
ClearMissionAudio(); ClearMissionAudio();
@ -344,7 +344,7 @@ cAudioManager::DestroyAllGameCreatedEntities()
cAudioScriptObject *entity; cAudioScriptObject *entity;
if (m_bIsInitialised) { if (m_bIsInitialised) {
for (uint32 i = 0; i < ARRAY_SIZE(m_asAudioEntities); i++) { for (uint32 i = 0; i < NUM_AUDIOENTITIES; i++) {
if (m_asAudioEntities[i].m_bIsUsed) { if (m_asAudioEntities[i].m_bIsUsed) {
switch (m_asAudioEntities[i].m_nType) { switch (m_asAudioEntities[i].m_nType) {
case AUDIOTYPE_PHYSICAL: case AUDIOTYPE_PHYSICAL:
@ -422,13 +422,13 @@ cAudioManager::SetCurrent3DProvider(uint8 which)
#else #else
if (!m_bIsInitialised) if (!m_bIsInitialised)
return -1; return -1;
for (uint8 i = 0; i < m_nActiveSamples + 1; ++i) for (uint8 i = 0; i < m_nActiveSamples + 1; i++)
SampleManager.StopChannel(i); SampleManager.StopChannel(i);
ClearRequestedQueue(); ClearRequestedQueue();
if (m_nActiveSampleQueue == 0) if (m_nActiveQueue == 0)
m_nActiveSampleQueue = 1; m_nActiveQueue = 1;
else else
m_nActiveSampleQueue = 0; m_nActiveQueue = 0;
ClearRequestedQueue(); ClearRequestedQueue();
ClearActiveSamples(); ClearActiveSamples();
int8 current = SampleManager.SetCurrent3DProvider(which); int8 current = SampleManager.SetCurrent3DProvider(which);
@ -436,7 +436,7 @@ cAudioManager::SetCurrent3DProvider(uint8 which)
#ifdef EXTERNAL_3D_SOUND #ifdef EXTERNAL_3D_SOUND
m_nActiveSamples = SampleManager.GetMaximumSupportedChannels(); m_nActiveSamples = SampleManager.GetMaximumSupportedChannels();
if (m_nActiveSamples > 1) if (m_nActiveSamples > 1)
--m_nActiveSamples; m_nActiveSamples--;
#endif #endif
} }
return current; return current;
@ -514,23 +514,23 @@ cAudioManager::ServiceSoundEffects()
if(CTimer::GetLogicalFramesPassed() != 0) if(CTimer::GetLogicalFramesPassed() != 0)
#endif #endif
m_bReduceReleasingPriority = (m_FrameCounter++ % 5) == 0; m_bReduceReleasingPriority = (m_FrameCounter++ % 5) == 0;
if (m_nUserPause && !m_nPreviousUserPause) { if (m_bIsPaused && !m_bWasPaused) {
for (int32 i = 0; i < NUM_CHANNELS; i++) for (int32 i = 0; i < NUM_CHANNELS; i++)
SampleManager.StopChannel(i); SampleManager.StopChannel(i);
ClearRequestedQueue(); ClearRequestedQueue();
if (m_nActiveSampleQueue) { if (m_nActiveQueue) {
m_nActiveSampleQueue = 0; m_nActiveQueue = 0;
ClearRequestedQueue(); ClearRequestedQueue();
m_nActiveSampleQueue = 1; m_nActiveQueue = 1;
} else { } else {
m_nActiveSampleQueue = 1; m_nActiveQueue = 1;
ClearRequestedQueue(); ClearRequestedQueue();
m_nActiveSampleQueue = 0; m_nActiveQueue = 0;
} }
ClearActiveSamples(); ClearActiveSamples();
} }
m_nActiveSampleQueue = m_nActiveSampleQueue == 1 ? 0 : 1; m_nActiveQueue = m_nActiveQueue == 1 ? 0 : 1;
ProcessReverb(); ProcessReverb();
ProcessSpecial(); ProcessSpecial();
ClearRequestedQueue(); ClearRequestedQueue();
@ -547,7 +547,7 @@ cAudioManager::ServiceSoundEffects()
#ifdef AUDIO_OAL #ifdef AUDIO_OAL
SampleManager.Service(); SampleManager.Service();
#endif #endif
for (int32 i = 0; i < m_sAudioScriptObjectManager.m_nScriptObjectEntityTotal; ++i) { for (int32 i = 0; i < m_sAudioScriptObjectManager.m_nScriptObjectEntityTotal; i++) {
cAudioScriptObject *object = (cAudioScriptObject *)m_asAudioEntities[m_sAudioScriptObjectManager.m_anScriptObjectEntityIndices[i]].m_pEntity; cAudioScriptObject *object = (cAudioScriptObject *)m_asAudioEntities[m_sAudioScriptObjectManager.m_anScriptObjectEntityIndices[i]].m_pEntity;
delete object; delete object;
m_asAudioEntities[m_sAudioScriptObjectManager.m_anScriptObjectEntityIndices[i]].m_pEntity = nil; m_asAudioEntities[m_sAudioScriptObjectManager.m_anScriptObjectEntityIndices[i]].m_pEntity = nil;
@ -636,9 +636,9 @@ cAudioManager::RandomDisplacement(uint32 seed)
void void
cAudioManager::InterrogateAudioEntities() cAudioManager::InterrogateAudioEntities()
{ {
for (int32 i = 0; i < m_nAudioEntitiesTotal; i++) { for (uint32 i = 0; i < m_nAudioEntitiesCount; i++) {
ProcessEntity(m_anAudioEntityIndices[i]); ProcessEntity(m_aAudioEntityOrderList[i]);
m_asAudioEntities[m_anAudioEntityIndices[i]].m_AudioEvents = 0; m_asAudioEntities[m_aAudioEntityOrderList[i]].m_AudioEvents = 0;
} }
} }
@ -653,13 +653,13 @@ cAudioManager::AddSampleToRequestedQueue()
if (m_sQueueSample.m_nSampleIndex < TOTAL_AUDIO_SAMPLES) { if (m_sQueueSample.m_nSampleIndex < TOTAL_AUDIO_SAMPLES) {
finalPriority = m_sQueueSample.m_nPriority * (MAX_VOLUME - m_sQueueSample.m_nVolume); finalPriority = m_sQueueSample.m_nPriority * (MAX_VOLUME - m_sQueueSample.m_nVolume);
sampleIndex = m_SampleRequestQueuesStatus[m_nActiveSampleQueue]; sampleIndex = m_nRequestedCount[m_nActiveQueue];
if (sampleIndex >= m_nActiveSamples) { if (sampleIndex >= m_nActiveSamples) {
sampleIndex = m_abSampleQueueIndexTable[m_nActiveSampleQueue][m_nActiveSamples - 1]; sampleIndex = m_aRequestedOrderList[m_nActiveQueue][m_nActiveSamples - 1];
if (m_asSamples[m_nActiveSampleQueue][sampleIndex].m_nFinalPriority <= finalPriority) if (m_aRequestedQueue[m_nActiveQueue][sampleIndex].m_nFinalPriority <= finalPriority)
return; return;
} else { } else {
++m_SampleRequestQueuesStatus[m_nActiveSampleQueue]; m_nRequestedCount[m_nActiveQueue]++;
} }
#if GTA_VERSION < GTA3_PC_10 #if GTA_VERSION < GTA3_PC_10
if (m_sQueueSample.m_bStatic) { if (m_sQueueSample.m_bStatic) {
@ -688,7 +688,7 @@ cAudioManager::AddSampleToRequestedQueue()
m_sQueueSample.m_bReverb = FALSE; m_sQueueSample.m_bReverb = FALSE;
#endif #endif
m_asSamples[m_nActiveSampleQueue][sampleIndex] = m_sQueueSample; m_aRequestedQueue[m_nActiveQueue][sampleIndex] = m_sQueueSample;
AddDetailsToRequestedOrderList(sampleIndex); AddDetailsToRequestedOrderList(sampleIndex);
#ifdef AUDIO_REFLECTIONS #ifdef AUDIO_REFLECTIONS
@ -704,15 +704,15 @@ 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_nFinalPriority > if (m_aRequestedQueue[m_nActiveQueue][m_aRequestedOrderList[m_nActiveQueue][i]].m_nFinalPriority >
m_asSamples[m_nActiveSampleQueue][sample].m_nFinalPriority) m_aRequestedQueue[m_nActiveQueue][sample].m_nFinalPriority)
break; break;
} }
if (i < sample) { if (i < sample) {
memmove(&m_abSampleQueueIndexTable[m_nActiveSampleQueue][i + 1], &m_abSampleQueueIndexTable[m_nActiveSampleQueue][i], m_nActiveSamples - i - 1); memmove(&m_aRequestedOrderList[m_nActiveQueue][i + 1], &m_aRequestedOrderList[m_nActiveQueue][i], m_nActiveSamples - i - 1);
} }
} }
m_abSampleQueueIndexTable[m_nActiveSampleQueue][i] = sample; m_aRequestedOrderList[m_nActiveQueue][i] = sample;
} }
#ifdef AUDIO_REFLECTIONS #ifdef AUDIO_REFLECTIONS
@ -810,17 +810,17 @@ cAudioManager::AddReleasingSounds()
bool8 toProcess[44]; bool8 toProcess[44];
#endif #endif
int8 queue = m_nActiveSampleQueue == 0 ? 1 : 0; uint8 queue = m_nActiveQueue == 0 ? 1 : 0;
for (int32 i = 0; i < m_SampleRequestQueuesStatus[queue]; i++) { for (uint8 i = 0; i < m_nRequestedCount[queue]; i++) {
tSound &sample = m_asSamples[queue][m_abSampleQueueIndexTable[queue][i]]; tSound &sample = m_aRequestedQueue[queue][m_aRequestedOrderList[queue][i]];
if (sample.m_bIsPlayingFinished) if (sample.m_bIsPlayingFinished)
continue; continue;
toProcess[i] = FALSE; toProcess[i] = FALSE;
for (int32 j = 0; j < m_SampleRequestQueuesStatus[m_nActiveSampleQueue]; j++) { for (uint8 j = 0; j < m_nRequestedCount[m_nActiveQueue]; j++) {
if (sample.m_nEntityIndex == m_asSamples[m_nActiveSampleQueue][m_abSampleQueueIndexTable[m_nActiveSampleQueue][j]].m_nEntityIndex && if (sample.m_nEntityIndex == m_aRequestedQueue[m_nActiveQueue][m_aRequestedOrderList[m_nActiveQueue][j]].m_nEntityIndex &&
sample.m_nCounter == m_asSamples[m_nActiveSampleQueue][m_abSampleQueueIndexTable[m_nActiveSampleQueue][j]].m_nCounter) { sample.m_nCounter == m_aRequestedQueue[m_nActiveQueue][m_aRequestedOrderList[m_nActiveQueue][j]].m_nCounter) {
toProcess[i] = TRUE; toProcess[i] = TRUE;
break; break;
} }
@ -954,18 +954,18 @@ cAudioManager::ProcessActiveQueues()
#endif #endif
#ifdef USE_TIME_SCALE_FOR_AUDIO #ifdef USE_TIME_SCALE_FOR_AUDIO
float timeScale = m_nUserPause ? 1.0f : CTimer::GetTimeScale(); float timeScale = m_bIsPaused ? 1.0f : CTimer::GetTimeScale();
#endif #endif
for (int32 i = 0; i < m_nActiveSamples; i++) { for (uint8 i = 0; i < m_nActiveSamples; i++) {
m_asSamples[m_nActiveSampleQueue][i].m_bIsBeingPlayed = FALSE; m_aRequestedQueue[m_nActiveQueue][i].m_bIsBeingPlayed = FALSE;
m_asActiveSamples[i].m_bIsBeingPlayed = FALSE; m_asActiveSamples[i].m_bIsBeingPlayed = FALSE;
} }
for (int32 i = 0; i < m_SampleRequestQueuesStatus[m_nActiveSampleQueue]; i++) { for (uint8 i = 0; i < m_nRequestedCount[m_nActiveQueue]; i++) {
tSound &sample = m_asSamples[m_nActiveSampleQueue][m_abSampleQueueIndexTable[m_nActiveSampleQueue][i]]; tSound &sample = m_aRequestedQueue[m_nActiveQueue][m_aRequestedOrderList[m_nActiveQueue][i]];
if (sample.m_nSampleIndex != NO_SAMPLE) { if (sample.m_nSampleIndex != NO_SAMPLE) {
for (int32 j = 0; j < m_nActiveSamples; j++) { for (uint8 j = 0; j < m_nActiveSamples; j++) {
if (sample.m_nEntityIndex == m_asActiveSamples[j].m_nEntityIndex && sample.m_nCounter == m_asActiveSamples[j].m_nCounter && 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) { sample.m_nSampleIndex == m_asActiveSamples[j].m_nSampleIndex) {
if (sample.m_nLoopCount > 0) { if (sample.m_nLoopCount > 0) {
@ -1052,15 +1052,15 @@ cAudioManager::ProcessActiveQueues()
} }
} }
} }
for (int32 i = 0; i < m_nActiveSamples; i++) { for (uint8 i = 0; i < m_nActiveSamples; i++) {
if (m_asActiveSamples[i].m_nSampleIndex != NO_SAMPLE && !m_asActiveSamples[i].m_bIsBeingPlayed) { if (m_asActiveSamples[i].m_nSampleIndex != NO_SAMPLE && !m_asActiveSamples[i].m_bIsBeingPlayed) {
SampleManager.StopChannel(i); SampleManager.StopChannel(i);
m_asActiveSamples[i].m_nSampleIndex = NO_SAMPLE; m_asActiveSamples[i].m_nSampleIndex = NO_SAMPLE;
m_asActiveSamples[i].m_nEntityIndex = AEHANDLE_NONE; m_asActiveSamples[i].m_nEntityIndex = AEHANDLE_NONE;
} }
} }
for (uint8 i = 0; i < m_SampleRequestQueuesStatus[m_nActiveSampleQueue]; i++) { for (uint8 i = 0; i < m_nRequestedCount[m_nActiveQueue]; i++) {
tSound &sample = m_asSamples[m_nActiveSampleQueue][m_abSampleQueueIndexTable[m_nActiveSampleQueue][i]]; tSound &sample = m_aRequestedQueue[m_nActiveQueue][m_aRequestedOrderList[m_nActiveQueue][i]];
if (!sample.m_bIsBeingPlayed && !sample.m_bIsPlayingFinished && m_asAudioEntities[sample.m_nEntityIndex].m_bIsUsed && sample.m_nSampleIndex < NO_SAMPLE) { if (!sample.m_bIsBeingPlayed && !sample.m_bIsPlayingFinished && m_asAudioEntities[sample.m_nEntityIndex].m_bIsUsed && sample.m_nSampleIndex < NO_SAMPLE) {
#ifdef AUDIO_REFLECTIONS #ifdef AUDIO_REFLECTIONS
if (sample.m_nCounter > 255 && sample.m_nLoopCount > 0 && sample.m_nReflectionDelay > 0) { // check if reflection if (sample.m_nCounter > 255 && sample.m_nLoopCount > 0 && sample.m_nReflectionDelay > 0) { // check if reflection
@ -1154,10 +1154,9 @@ cAudioManager::ProcessActiveQueues()
void void
cAudioManager::ClearRequestedQueue() cAudioManager::ClearRequestedQueue()
{ {
for (int32 i = 0; i < m_nActiveSamples; i++) { for (uint8 i = 0; i < m_nActiveSamples; i++)
m_abSampleQueueIndexTable[m_nActiveSampleQueue][i] = m_nActiveSamples; m_aRequestedOrderList[m_nActiveQueue][i] = m_nActiveSamples;
} m_nRequestedCount[m_nActiveQueue] = 0;
m_SampleRequestQueuesStatus[m_nActiveSampleQueue] = 0;
} }
void void
@ -1212,17 +1211,16 @@ cAudioManager::LoadBankIfNecessary(uint8 bank)
void void
cAudioManager::GenerateIntegerRandomNumberTable() cAudioManager::GenerateIntegerRandomNumberTable()
{ {
for (int32 i = 0; i < ARRAY_SIZE(m_anRandomTable); i++) { for (uint32 i = 0; i < ARRAY_SIZE(m_anRandomTable); i++)
m_anRandomTable[i] = myrand(); m_anRandomTable[i] = myrand();
}
} }
#ifdef EXTERNAL_3D_SOUND #ifdef EXTERNAL_3D_SOUND
void void
cAudioManager::AdjustSamplesVolume() cAudioManager::AdjustSamplesVolume()
{ {
for (int i = 0; i < m_SampleRequestQueuesStatus[m_nActiveSampleQueue]; i++) { for (uint8 i = 0; i < m_nRequestedCount[m_nActiveQueue]; i++) {
tSound *pSample = &m_asSamples[m_nActiveSampleQueue][m_abSampleQueueIndexTable[m_nActiveSampleQueue][i]]; tSound *pSample = &m_aRequestedQueue[m_nActiveQueue][m_aRequestedOrderList[m_nActiveQueue][i]];
if (!pSample->m_bIs2D) if (!pSample->m_bIs2D)
pSample->m_nEmittingVolume = ComputeEmittingVolume(pSample->m_nEmittingVolume, pSample->m_MaxDistance, pSample->m_fDistance); pSample->m_nEmittingVolume = ComputeEmittingVolume(pSample->m_nEmittingVolume, pSample->m_MaxDistance, pSample->m_fDistance);

View file

@ -58,7 +58,7 @@ public:
bool8 m_bIsBeingPlayed; // Set to TRUE when the sound was added or changed on current frame to avoid it being overwritten bool8 m_bIsBeingPlayed; // Set to TRUE when the sound was added or changed on current frame to avoid it being overwritten
bool8 m_bIsPlayingFinished; // Not sure about the name. Set to TRUE when sampman channel becomes free bool8 m_bIsPlayingFinished; // Not sure about the name. Set to TRUE when sampman channel becomes free
#if GTA_VERSION < GTA3_PC_10 #if GTA_VERSION < GTA3_PC_10
int32 unk; // Only on PS2, used by static non-looped sounds (AFAIK) int32 unk; // (inherited from GTA 2) Only on PS2, used by static non-looped sounds (AFAIK)
// Looks like it's keeping a number of frames left to play with the purpose of setting m_bIsPlayingFinished=TRUE once value reaches 0 // Looks like it's keeping a number of frames left to play with the purpose of setting m_bIsPlayingFinished=TRUE once value reaches 0
// Default value is -3 for whatever reason // Default value is -3 for whatever reason
#endif #endif
@ -219,16 +219,16 @@ public:
#endif #endif
float m_fSpeedOfSound; float m_fSpeedOfSound;
bool8 m_bTimerJustReset; bool8 m_bTimerJustReset;
int32 m_nTimer; uint32 m_nTimer;
tSound m_sQueueSample; tSound m_sQueueSample;
uint8 m_nActiveSampleQueue; uint8 m_nActiveQueue;
tSound m_asSamples[NUM_SOUNDS_SAMPLES_BANKS][NUM_CHANNELS_GENERIC]; tSound m_aRequestedQueue[NUM_SOUND_QUEUES][NUM_CHANNELS_GENERIC];
uint8 m_abSampleQueueIndexTable[NUM_SOUNDS_SAMPLES_BANKS][NUM_CHANNELS_GENERIC]; uint8 m_aRequestedOrderList[NUM_SOUND_QUEUES][NUM_CHANNELS_GENERIC];
uint8 m_SampleRequestQueuesStatus[NUM_SOUNDS_SAMPLES_BANKS]; uint8 m_nRequestedCount[NUM_SOUND_QUEUES];
tSound m_asActiveSamples[NUM_CHANNELS_GENERIC]; tSound m_asActiveSamples[NUM_CHANNELS_GENERIC];
tAudioEntity m_asAudioEntities[NUM_AUDIOENTITIES]; tAudioEntity m_asAudioEntities[NUM_AUDIOENTITIES];
int32 m_anAudioEntityIndices[NUM_AUDIOENTITIES]; uint32 m_aAudioEntityOrderList[NUM_AUDIOENTITIES];
int32 m_nAudioEntitiesTotal; uint32 m_nAudioEntitiesCount;
#ifdef AUDIO_REFLECTIONS #ifdef AUDIO_REFLECTIONS
CVector m_avecReflectionsPos[MAX_REFLECTIONS]; CVector m_avecReflectionsPos[MAX_REFLECTIONS];
float m_afReflectionsDistances[MAX_REFLECTIONS]; float m_afReflectionsDistances[MAX_REFLECTIONS];
@ -253,13 +253,13 @@ public:
uint8 m_nMissionAudioLoadingStatus; uint8 m_nMissionAudioLoadingStatus;
uint8 m_nMissionAudioPlayStatus; uint8 m_nMissionAudioPlayStatus;
bool8 m_bIsMissionAudioPlaying; bool8 m_bIsMissionAudioPlaying;
int32 m_nMissionAudioFramesToPlay; int32 m_nMissionAudioFramesToPlay; // possibly unsigned
bool8 m_bIsMissionAudioAllowedToPlay; bool8 m_bIsMissionAudioAllowedToPlay;
int32 m_anRandomTable[5]; int32 m_anRandomTable[5];
uint8 m_nTimeSpent; uint8 m_nTimeSpent;
bool8 m_nUserPause; bool8 m_bIsPaused;
bool8 m_nPreviousUserPause; bool8 m_bWasPaused;
uint32 m_FrameCounter; uint32 m_FrameCounter;
cAudioManager(); cAudioManager();

View file

@ -363,14 +363,14 @@ cMusicManager::GetRadioInCar(void)
CVehicle *veh = FindPlayerVehicle(); CVehicle *veh = FindPlayerVehicle();
if (veh != nil){ if (veh != nil){
if (UsesPoliceRadio(veh)) { if (UsesPoliceRadio(veh)) {
if (m_nRadioInCar == NO_TRACK || (CReplay::IsPlayingBack() && !AudioManager.m_nUserPause)) if (m_nRadioInCar == NO_TRACK || (CReplay::IsPlayingBack() && !AudioManager.m_bIsPaused))
return POLICE_RADIO; return POLICE_RADIO;
return m_nRadioInCar; return m_nRadioInCar;
} else return veh->m_nRadioStation; } else return veh->m_nRadioStation;
} }
} }
if (m_nRadioInCar == NO_TRACK || (CReplay::IsPlayingBack() && !AudioManager.m_nUserPause)) if (m_nRadioInCar == NO_TRACK || (CReplay::IsPlayingBack() && !AudioManager.m_bIsPaused))
return RADIO_OFF; return RADIO_OFF;
return m_nRadioInCar; return m_nRadioInCar;
} }
@ -418,7 +418,7 @@ cMusicManager::ResetMusicAfterReload()
void void
cMusicManager::ResetTimers(int32 time) cMusicManager::ResetTimers(uint32 time)
{ {
m_bResetTimers = TRUE; m_bResetTimers = TRUE;
m_nResetTime = time; m_nResetTime = time;
@ -469,7 +469,7 @@ cMusicManager::ServiceFrontEndMode()
switch (m_nNextTrack) switch (m_nNextTrack)
{ {
case STREAMED_SOUND_MISSION_COMPLETED: case STREAMED_SOUND_MISSION_COMPLETED:
if (!AudioManager.m_nUserPause) if (!AudioManager.m_bIsPaused)
ChangeMusicMode(MUSICMODE_GAME); ChangeMusicMode(MUSICMODE_GAME);
break; break;
case STREAMED_SOUND_GAME_COMPLETED: case STREAMED_SOUND_GAME_COMPLETED:
@ -543,7 +543,7 @@ cMusicManager::ServiceGameMode()
nFramesSinceCutsceneEnded = -1; nFramesSinceCutsceneEnded = -1;
} }
if (AudioManager.m_nPreviousUserPause) if (AudioManager.m_bWasPaused)
m_bPreviousPlayerInCar = FALSE; m_bPreviousPlayerInCar = FALSE;
if (!m_bPlayerInCar) { if (!m_bPlayerInCar) {
if (m_bPreviousPlayerInCar) { if (m_bPreviousPlayerInCar) {

View file

@ -66,7 +66,7 @@ public:
void ResetMusicAfterReload(); void ResetMusicAfterReload();
void ResetTimers(int32); void ResetTimers(uint32);
void Service(); void Service();
void ServiceFrontEndMode(); void ServiceFrontEndMode();
void ServiceGameMode(); void ServiceGameMode();

View file

@ -149,7 +149,7 @@ cAudioManager::ServicePoliceRadio()
if(!m_bIsInitialised) return; if(!m_bIsInitialised) return;
if(!m_nUserPause) { if(!m_bIsPaused) {
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)
@ -188,14 +188,14 @@ cAudioManager::ServicePoliceRadioChannel(uint8 wantedLevel)
if (!m_bIsInitialised) return; if (!m_bIsInitialised) return;
if (m_nUserPause) { if (m_bIsPaused) {
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 != TOTAL_AUDIO_SAMPLES && bMissionAudioPhysicalPlayingStatus == PLAY_STATUS_PLAYING && if (g_nMissionAudioSfx != TOTAL_AUDIO_SAMPLES && 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 != TOTAL_AUDIO_SAMPLES && if (m_bWasPaused && g_nMissionAudioSfx != TOTAL_AUDIO_SAMPLES &&
bMissionAudioPhysicalPlayingStatus == PLAY_STATUS_PLAYING) { bMissionAudioPhysicalPlayingStatus == PLAY_STATUS_PLAYING) {
SampleManager.PauseStream(FALSE, 1); SampleManager.PauseStream(FALSE, 1);
} }

View file

@ -129,7 +129,7 @@ enum Config {
NUM_PED_COMMENTS_BANKS = 2, NUM_PED_COMMENTS_BANKS = 2,
NUM_PED_COMMENTS_SLOTS = 20, NUM_PED_COMMENTS_SLOTS = 20,
NUM_SOUNDS_SAMPLES_BANKS = 2, NUM_SOUND_QUEUES = 2,
NUM_AUDIOENTITIES = 200, NUM_AUDIOENTITIES = 200,
NUM_SCRIPT_MAX_ENTITIES = 40, NUM_SCRIPT_MAX_ENTITIES = 40,