Audio: fixing bugs, fixing types, making code more accurate to original
This commit is contained in:
parent
af543350db
commit
55e950fe84
@ -8,8 +8,6 @@
|
||||
#include "SurfaceTable.h"
|
||||
#include "sampman.h"
|
||||
|
||||
const int CollisionSoundIntensity = 60;
|
||||
|
||||
void
|
||||
cAudioManager::ReportCollision(CEntity *entity1, CEntity *entity2, uint8 surface1, uint8 surface2, float collisionPower,
|
||||
float velocity)
|
||||
@ -32,7 +30,7 @@ cAudioManager::ReportCollision(CEntity *entity1, CEntity *entity2, uint8 surface
|
||||
}
|
||||
CVector pos = (v1 + v2) * 0.5f;
|
||||
distSquared = GetDistanceSquared(pos);
|
||||
if(distSquared < SQR(CollisionSoundIntensity)) {
|
||||
if(distSquared < SQR(COLLISION_MAX_DIST)) {
|
||||
m_sCollisionManager.m_sQueue.m_pEntity1 = entity1;
|
||||
m_sCollisionManager.m_sQueue.m_pEntity2 = entity2;
|
||||
m_sCollisionManager.m_sQueue.m_bSurface1 = surface1;
|
||||
@ -48,8 +46,8 @@ cAudioManager::ReportCollision(CEntity *entity1, CEntity *entity2, uint8 surface
|
||||
void
|
||||
cAudioCollisionManager::AddCollisionToRequestedQueue()
|
||||
{
|
||||
int32 collisionsIndex;
|
||||
int32 i;
|
||||
uint32 collisionsIndex;
|
||||
uint32 i;
|
||||
|
||||
|
||||
if (m_bCollisionsInQueue < NUMAUDIOCOLLISIONS)
|
||||
@ -139,7 +137,7 @@ cAudioManager::ServiceCollisions()
|
||||
m_sCollisionManager.m_bCollisionsInQueue = 0;
|
||||
}
|
||||
|
||||
static const int32 gOneShotCol[] = {SFX_COL_TARMAC_1,
|
||||
static const uint32 gOneShotCol[] = {SFX_COL_TARMAC_1,
|
||||
SFX_COL_TARMAC_1,
|
||||
SFX_COL_GRASS_1,
|
||||
SFX_COL_GRAVEL_1,
|
||||
@ -179,7 +177,7 @@ cAudioManager::SetUpOneShotCollisionSound(const cAudioCollision &col)
|
||||
uint16 s1;
|
||||
uint16 s2;
|
||||
|
||||
int32 emittingVol;
|
||||
uint32 emittingVol;
|
||||
float ratio;
|
||||
|
||||
static uint16 counter = 28;
|
||||
@ -198,11 +196,11 @@ cAudioManager::SetUpOneShotCollisionSound(const cAudioCollision &col)
|
||||
s1 = SURFACE_CAR_PANEL;
|
||||
ratio = Min(1.f, 2.f * ratio);
|
||||
}
|
||||
emittingVol = 40.f * ratio;
|
||||
emittingVol = 40 * ratio;
|
||||
if(emittingVol) {
|
||||
m_sQueueSample.m_fDistance = Sqrt(col.m_fDistance);
|
||||
m_sQueueSample.m_nVolume =
|
||||
ComputeVolume(emittingVol, CollisionSoundIntensity, m_sQueueSample.m_fDistance);
|
||||
ComputeVolume(emittingVol, COLLISION_MAX_DIST, m_sQueueSample.m_fDistance);
|
||||
if(m_sQueueSample.m_nVolume > 0) {
|
||||
m_sQueueSample.m_nSampleIndex = gOneShotCol[s1];
|
||||
switch(m_sQueueSample.m_nSampleIndex) {
|
||||
@ -266,7 +264,7 @@ cAudioManager::SetUpOneShotCollisionSound(const cAudioCollision &col)
|
||||
SET_EMITTING_VOLUME(emittingVol);
|
||||
RESET_LOOP_OFFSETS
|
||||
m_sQueueSample.m_fSpeedMultiplier = 4.0f;
|
||||
m_sQueueSample.m_MaxDistance = CollisionSoundIntensity;
|
||||
m_sQueueSample.m_MaxDistance = COLLISION_MAX_DIST;
|
||||
m_sQueueSample.m_bStatic = TRUE;
|
||||
m_sQueueSample.m_bReverb = TRUE;
|
||||
SET_SOUND_REFLECTION(FALSE);
|
||||
@ -284,7 +282,7 @@ cAudioManager::SetUpLoopingCollisionSound(const cAudioCollision &col, uint8 coun
|
||||
if(emittingVol) {
|
||||
m_sQueueSample.m_fDistance = Sqrt(col.m_fDistance);
|
||||
m_sQueueSample.m_nVolume =
|
||||
ComputeVolume(emittingVol, CollisionSoundIntensity, m_sQueueSample.m_fDistance);
|
||||
ComputeVolume(emittingVol, COLLISION_MAX_DIST, m_sQueueSample.m_fDistance);
|
||||
if(m_sQueueSample.m_nVolume > 0) {
|
||||
m_sQueueSample.m_nCounter = counter;
|
||||
m_sQueueSample.m_vecPos = col.m_vecPosition;
|
||||
@ -295,7 +293,7 @@ cAudioManager::SetUpLoopingCollisionSound(const cAudioCollision &col, uint8 coun
|
||||
SET_EMITTING_VOLUME(emittingVol);
|
||||
SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex);
|
||||
m_sQueueSample.m_fSpeedMultiplier = 4.0f;
|
||||
m_sQueueSample.m_MaxDistance = CollisionSoundIntensity;
|
||||
m_sQueueSample.m_MaxDistance = COLLISION_MAX_DIST;
|
||||
m_sQueueSample.m_bStatic = FALSE;
|
||||
m_sQueueSample.m_nFramesToPlay = 5;
|
||||
m_sQueueSample.m_bReverb = TRUE;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -86,7 +86,7 @@ cAudioManager::Terminate()
|
||||
|
||||
for (uint32 i = 0; i < NUM_AUDIOENTITIES; i++) {
|
||||
m_asAudioEntities[i].m_bIsUsed = FALSE;
|
||||
m_aAudioEntityOrderList[i] = ARRAY_SIZE(m_aAudioEntityOrderList);
|
||||
m_aAudioEntityOrderList[i] = NUM_AUDIOENTITIES;
|
||||
}
|
||||
|
||||
m_nAudioEntitiesCount = 0;
|
||||
@ -838,9 +838,9 @@ cAudioManager::AddReleasingSounds()
|
||||
if (sample.m_nSampleIndex >= SAMPLEBANK_PED_START && sample.m_nSampleIndex <= SAMPLEBANK_PED_END) { // check if it's ped comment
|
||||
uint8 vol;
|
||||
if (CWorld::GetIsLineOfSightClear(TheCamera.GetPosition(), sample.m_vecPos, true, false, false, false, false, false))
|
||||
vol = MAX_VOLUME;
|
||||
vol = PED_COMMENT_VOLUME;
|
||||
else
|
||||
vol = 31;
|
||||
vol = PED_COMMENT_VOLUME_BEHIND_WALL;
|
||||
#ifdef EXTERNAL_3D_SOUND
|
||||
sample.m_nEmittingVolume = vol;
|
||||
#endif
|
||||
@ -856,7 +856,7 @@ cAudioManager::AddReleasingSounds()
|
||||
if (sample.m_nEmittingVolumeChange > 0)
|
||||
sample.m_nEmittingVolumeChange = volumeDiff * sample.m_nEmittingVolumeChange;
|
||||
#endif
|
||||
sample.m_nVolume = Min(127, newVolume);
|
||||
sample.m_nVolume = Min(MAX_VOLUME, newVolume);
|
||||
}
|
||||
}
|
||||
if (sample.m_nVolume == 0)
|
||||
@ -1030,7 +1030,7 @@ cAudioManager::ProcessActiveQueues()
|
||||
vol = Clamp2((int8)sample.m_nVolume, (int8)m_asActiveSamples[j].m_nVolume, 10);
|
||||
m_asActiveSamples[j].m_nVolume = vol;
|
||||
}
|
||||
SampleManager.SetChannelVolume(j, m_bDoubleVolume ? 2 * Min(63, vol) : vol);
|
||||
SampleManager.SetChannelVolume(j, m_bDoubleVolume ? 2 * Min(63, m_asActiveSamples[j].m_nVolume) : m_asActiveSamples[j].m_nVolume);
|
||||
#endif
|
||||
TranslateEntity(&sample.m_vecPos, &position);
|
||||
#ifdef EXTERNAL_3D_SOUND
|
||||
|
@ -335,7 +335,7 @@ public:
|
||||
float GetDistanceSquared(const CVector &v);
|
||||
void CalculateDistance(bool8 &condition, float dist);
|
||||
void ProcessSpecial();
|
||||
void ProcessEntity(int32 sound);
|
||||
void ProcessEntity(int32 id);
|
||||
void ProcessPhysical(int32 id);
|
||||
|
||||
// vehicles
|
||||
@ -355,7 +355,7 @@ public:
|
||||
bool8 ProcessVehicleSkidding(cVehicleParams ¶ms);
|
||||
float GetVehicleDriveWheelSkidValue(uint8 wheel, CAutomobile *automobile, cTransmission *transmission, float velocityChange);
|
||||
float GetVehicleNonDriveWheelSkidValue(uint8 wheel, CAutomobile *automobile, cTransmission *transmission, float velocityChange); // inlined on PS2
|
||||
void ProcessVehicleHorn(cVehicleParams ¶ms);
|
||||
bool8 ProcessVehicleHorn(cVehicleParams ¶ms);
|
||||
bool8 UsesSiren(uint32 model); // inlined on PS2
|
||||
bool8 UsesSirenSwitching(uint32 model); // inlined on PS2
|
||||
bool8 ProcessVehicleSirenOrAlarm(cVehicleParams ¶ms);
|
||||
@ -473,9 +473,9 @@ public:
|
||||
uint32 GetGenericFemaleTalkSfx(uint16 sound);
|
||||
|
||||
// particles
|
||||
void ProcessExplosions(int32 explosion);
|
||||
void ProcessFires(int32 entity);
|
||||
void ProcessWaterCannon(int32);
|
||||
void ProcessExplosions(int32 id);
|
||||
void ProcessFires(int32 id);
|
||||
void ProcessWaterCannon(int32 id);
|
||||
|
||||
// script objects
|
||||
void ProcessScriptObject(int32 id); // inlined on PS2
|
||||
@ -576,3 +576,10 @@ static_assert(sizeof(cAudioManager) == 19220, "cAudioManager: error");
|
||||
#endif
|
||||
|
||||
extern cAudioManager AudioManager;
|
||||
|
||||
enum
|
||||
{
|
||||
PED_COMMENT_VOLUME = 127,
|
||||
PED_COMMENT_VOLUME_BEHIND_WALL = 31,
|
||||
COLLISION_MAX_DIST = 60,
|
||||
};
|
||||
|
@ -156,13 +156,13 @@ cAudioManager::ServicePoliceRadio()
|
||||
return;
|
||||
#endif
|
||||
wantedLevel = FindPlayerPed()->m_pWanted->GetWantedLevel();
|
||||
if(!crimeReport) {
|
||||
if(wantedLevel != 0) {
|
||||
if(nLastSeen != 0) {
|
||||
if (!crimeReport) {
|
||||
if (wantedLevel != 0) {
|
||||
if (nLastSeen != 0) {
|
||||
#ifdef FIX_BUGS
|
||||
nLastSeen -= CTimer::GetLogicalFramesPassed();
|
||||
#else
|
||||
--nLastSeen;
|
||||
nLastSeen--;
|
||||
#endif
|
||||
} else {
|
||||
nLastSeen = m_anRandomTable[1] % 1000 + 2000;
|
||||
@ -179,12 +179,12 @@ cAudioManager::ServicePoliceRadioChannel(uint8 wantedLevel)
|
||||
{
|
||||
bool8 processed = FALSE;
|
||||
uint32 sample;
|
||||
int32 freq;
|
||||
uint32 freq;
|
||||
|
||||
static int cWait = 0;
|
||||
static bool8 bChannelOpen = FALSE;
|
||||
static uint8 bMissionAudioPhysicalPlayingStatus = PLAY_STATUS_STOPPED;
|
||||
static int32 PoliceChannelFreq = 5500;
|
||||
static uint32 PoliceChannelFreq = 5500;
|
||||
|
||||
if (!m_bIsInitialised) return;
|
||||
|
||||
@ -364,18 +364,7 @@ cAudioManager::SetupCrimeReport()
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
cAudioManager::SetupSuspectLastSeenReport()
|
||||
{
|
||||
CVehicle *veh;
|
||||
uint8 color1;
|
||||
int32 main_color;
|
||||
int32 sample;
|
||||
|
||||
int32 color_pre_modifier;
|
||||
int32 color_post_modifier;
|
||||
|
||||
const int32 gCarColourTable[][3] = {
|
||||
Const uint32 gCarColourTable[][3] = {
|
||||
{TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_BLACK, TOTAL_AUDIO_SAMPLES},
|
||||
{TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_WHITE, TOTAL_AUDIO_SAMPLES},
|
||||
{TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_BLUE, TOTAL_AUDIO_SAMPLES},
|
||||
@ -527,7 +516,18 @@ cAudioManager::SetupSuspectLastSeenReport()
|
||||
{SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES},
|
||||
{SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES},
|
||||
{SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}
|
||||
};
|
||||
};
|
||||
|
||||
void
|
||||
cAudioManager::SetupSuspectLastSeenReport()
|
||||
{
|
||||
CVehicle *veh;
|
||||
uint8 color1;
|
||||
uint32 main_color;
|
||||
uint32 sample;
|
||||
|
||||
uint32 color_pre_modifier;
|
||||
uint32 color_post_modifier;
|
||||
|
||||
if (MusicManager.m_nMusicMode != MUSICMODE_CUTSCENE) {
|
||||
veh = FindPlayerVehicle();
|
||||
@ -713,8 +713,8 @@ cAudioManager::PlaySuspectLastSeen(float x, float y, float z)
|
||||
float halfY;
|
||||
float quarterX;
|
||||
float quarterY;
|
||||
int32 sample;
|
||||
bool8 processed = false;
|
||||
uint32 sample;
|
||||
bool8 processed = FALSE;
|
||||
CVector vec = CVector(x, y, z);
|
||||
|
||||
if (!m_bIsInitialised) return;
|
||||
|
@ -6,10 +6,10 @@
|
||||
#define MAX_FREQ DIGITALRATE
|
||||
|
||||
struct tSample {
|
||||
int32 nOffset;
|
||||
uint32 nOffset;
|
||||
uint32 nSize;
|
||||
int32 nFrequency;
|
||||
int32 nLoopStart;
|
||||
uint32 nFrequency;
|
||||
uint32 nLoopStart;
|
||||
int32 nLoopEnd;
|
||||
};
|
||||
|
||||
@ -188,8 +188,8 @@ public:
|
||||
|
||||
int32 _GetPedCommentSlot(uint32 nComment);
|
||||
|
||||
int32 GetSampleBaseFrequency (uint32 nSample);
|
||||
int32 GetSampleLoopStartOffset(uint32 nSample);
|
||||
uint32 GetSampleBaseFrequency (uint32 nSample);
|
||||
uint32 GetSampleLoopStartOffset(uint32 nSample);
|
||||
int32 GetSampleLoopEndOffset (uint32 nSample);
|
||||
uint32 GetSampleLength (uint32 nSample);
|
||||
|
||||
|
@ -1619,13 +1619,13 @@ cSampleManager::GetBankContainingSound(uint32 offset)
|
||||
return INVALID_SFX_BANK;
|
||||
}
|
||||
|
||||
int32
|
||||
uint32
|
||||
cSampleManager::GetSampleBaseFrequency(uint32 nSample)
|
||||
{
|
||||
return m_aSamples[nSample].nFrequency;
|
||||
}
|
||||
|
||||
int32
|
||||
uint32
|
||||
cSampleManager::GetSampleLoopStartOffset(uint32 nSample)
|
||||
{
|
||||
return m_aSamples[nSample].nLoopStart;
|
||||
|
@ -179,14 +179,14 @@ cSampleManager::GetBankContainingSound(uint32 offset)
|
||||
return INVALID_SFX_BANK;
|
||||
}
|
||||
|
||||
int32
|
||||
uint32
|
||||
cSampleManager::GetSampleBaseFrequency(uint32 nSample)
|
||||
{
|
||||
ASSERT( nSample < TOTAL_AUDIO_SAMPLES );
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32
|
||||
uint32
|
||||
cSampleManager::GetSampleLoopStartOffset(uint32 nSample)
|
||||
{
|
||||
ASSERT( nSample < TOTAL_AUDIO_SAMPLES );
|
||||
|
@ -1327,14 +1327,14 @@ cSampleManager::GetBankContainingSound(uint32 offset)
|
||||
return INVALID_SFX_BANK;
|
||||
}
|
||||
|
||||
int32
|
||||
uint32
|
||||
cSampleManager::GetSampleBaseFrequency(uint32 nSample)
|
||||
{
|
||||
ASSERT( nSample < TOTAL_AUDIO_SAMPLES );
|
||||
return m_aSamples[nSample].nFrequency;
|
||||
}
|
||||
|
||||
int32
|
||||
uint32
|
||||
cSampleManager::GetSampleLoopStartOffset(uint32 nSample)
|
||||
{
|
||||
ASSERT( nSample < TOTAL_AUDIO_SAMPLES );
|
||||
|
@ -212,8 +212,8 @@ enum eScriptSounds {
|
||||
SCRIPT_SOUND_WORK_SHOP_LOOP_L,
|
||||
SCRIPT_SOUND_SAWMILL_LOOP_S,
|
||||
SCRIPT_SOUND_SAWMILL_LOOP_L,
|
||||
SCRIPT_SOUND_38,
|
||||
SCRIPT_SOUND_39,
|
||||
SCRIPT_SOUND_DOG_FOOD_FACTORY_S,
|
||||
SCRIPT_SOUND_DOG_FOOD_FACTORY_L,
|
||||
SCRIPT_SOUND_LAUNDERETTE_LOOP_S,
|
||||
SCRIPT_SOUND_LAUNDERETTE_LOOP_L,
|
||||
SCRIPT_SOUND_CHINATOWN_RESTAURANT_S,
|
||||
|
@ -212,7 +212,7 @@ CEmergencyPed::MedicAI(void)
|
||||
if (!waitUntilMedicEntersCar) {
|
||||
CCarCtrl::JoinCarWithRoadSystem(m_pMyVehicle);
|
||||
m_pMyVehicle->AutoPilot.m_nCarMission = MISSION_CRUISE;
|
||||
m_pMyVehicle->m_bSirenOrAlarm = 0;
|
||||
m_pMyVehicle->m_bSirenOrAlarm = false;
|
||||
m_pMyVehicle->AutoPilot.m_nCruiseSpeed = 12;
|
||||
m_pMyVehicle->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_SLOW_DOWN_FOR_CARS;
|
||||
if (m_pMyVehicle->bIsAmbulanceOnDuty) {
|
||||
|
@ -186,7 +186,7 @@ public:
|
||||
uint8 m_bRainSamplesCounter;
|
||||
uint8 m_nCarHornTimer;
|
||||
uint8 m_nCarHornPattern; // last horn?
|
||||
uint8 m_bSirenOrAlarm;
|
||||
bool m_bSirenOrAlarm;
|
||||
int8 m_comedyControlState;
|
||||
CStoredCollPoly m_aCollPolys[2]; // poly which is under front/rear part of car
|
||||
float m_fSteerInput;
|
||||
|
Loading…
Reference in New Issue
Block a user