summaryrefslogtreecommitdiffstats
path: root/src/audio
diff options
context:
space:
mode:
Diffstat (limited to 'src/audio')
-rw-r--r--src/audio/AudioLogic.cpp26
-rw-r--r--src/audio/AudioManager.cpp8
-rw-r--r--src/audio/MusicManager.cpp17
-rw-r--r--src/audio/oal/stream.cpp10
-rw-r--r--src/audio/sampman_miles.cpp2
-rw-r--r--src/audio/sampman_oal.cpp156
6 files changed, 94 insertions, 125 deletions
diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp
index 6685a47d..31036adc 100644
--- a/src/audio/AudioLogic.cpp
+++ b/src/audio/AudioLogic.cpp
@@ -998,8 +998,8 @@ cAudioManager::ProcessModelVehicle(cVehicleParams& params)
freq = 25000;
}
if (isPlayerVeh) {
- volume = clamp2(volume, prevVolume, 7);
- freq = clamp2(freq, prevFreq, 800);
+ volume = Clamp2(volume, prevVolume, 7);
+ freq = Clamp2(freq, prevFreq, 800);
}
if (volume > 0) {
CalculateDistance(params.m_bDistanceCalculated, params.m_fDistance);
@@ -1047,8 +1047,8 @@ cAudioManager::ProcessModelVehicle(cVehicleParams& params)
freq = Min(22000, (8000 * acceletateState / 255 + 14000) * 3.0f * Abs(params.m_fVelocityChange));
}
if (isPlayerVeh && !vehSlowdown) {
- volume = clamp2(volume, prevVolume, 7);
- freq = clamp2(freq, prevFreq, 800);
+ volume = Clamp2(volume, prevVolume, 7);
+ freq = Clamp2(freq, prevFreq, 800);
}
if (!vehSlowdown)
#ifdef THIS_IS_STUPID
@@ -1127,7 +1127,7 @@ cAudioManager::ProcessModelHeliVehicle(cVehicleParams& params)
}
if (acceletateState < brakeState)
acceletateState = brakeState;
- freq = clamp2(5 * acceletateState + 22050, prevFreq, 30);
+ freq = Clamp2(5 * acceletateState + 22050, prevFreq, 30);
CalculateDistance(params.m_bDistanceCalculated, params.m_fDistance);
m_sQueueSample.m_nVolume = ComputeVolume(70, SOUND_INTENSITY, m_sQueueSample.m_fDistance);
if (m_sQueueSample.m_nVolume != 0) {
@@ -1667,8 +1667,8 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CVehicle* veh
bHandbrakeOnLastFrame = FALSE;
}
if (CReplay::IsPlayingBack()) {
- accelerateState = (255.0f * clamp(params.m_pVehicle->m_fGasPedal, 0.0f, 1.0f));
- brakeState = (255.0f * clamp(params.m_pVehicle->m_fBrakePedal, 0.0f, 1.0f));
+ accelerateState = (255.0f * Clamp(params.m_pVehicle->m_fGasPedal, 0.0f, 1.0f));
+ brakeState = (255.0f * Clamp(params.m_pVehicle->m_fBrakePedal, 0.0f, 1.0f));
} else {
accelerateState = Pads[0].GetAccelerate();
brakeState = Pads[0].GetBrake();
@@ -1820,7 +1820,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CVehicle* veh
}
}
relativeVelocityChange = 2.0f * params.m_fVelocityChange / params.m_pTransmission->fMaxVelocity;
- accelerationMultipler = clamp(relativeVelocityChange, 0.0f, 1.0f);
+ accelerationMultipler = Clamp(relativeVelocityChange, 0.0f, 1.0f);
gasPedalAudio = accelerationMultipler;
/*switch (engineSoundType) {
case SFX_BANK_MOPED:
@@ -3595,7 +3595,7 @@ cAudioManager::ProcessCarHeli(cVehicleParams& params)
m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, freqModifier) * 3713;
if (propellerSpeed < 1.0f)
m_sQueueSample.m_nFrequency = (propellerSpeed + 1.0f) * (m_sQueueSample.m_nFrequency / 2.0f);
- m_sQueueSample.m_nFrequency = clamp2(m_sQueueSample.m_nFrequency, freqFrontPrev, 197);
+ m_sQueueSample.m_nFrequency = Clamp2(m_sQueueSample.m_nFrequency, freqFrontPrev, 197);
freqFrontPrev = m_sQueueSample.m_nFrequency;
m_sQueueSample.m_bIs2D = FALSE;
@@ -3651,7 +3651,7 @@ cAudioManager::ProcessCarHeli(cVehicleParams& params)
if (propellerSpeed < 1.0f)
m_sQueueSample.m_nFrequency = (propellerSpeed + 1) * (m_sQueueSample.m_nFrequency / 2);
- m_sQueueSample.m_nFrequency = clamp2(m_sQueueSample.m_nFrequency, freqPropellerPrev, 98);
+ m_sQueueSample.m_nFrequency = Clamp2(m_sQueueSample.m_nFrequency, freqPropellerPrev, 98);
freqPropellerPrev = m_sQueueSample.m_nFrequency;
} else {
m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_MAI2;
@@ -3720,7 +3720,7 @@ cAudioManager::ProcessCarHeli(cVehicleParams& params)
m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, freqModifier) * 3713;
if (propellerSpeed < 1.0f)
m_sQueueSample.m_nFrequency = (propellerSpeed + 1) * (m_sQueueSample.m_nFrequency / 2.0f);
- m_sQueueSample.m_nFrequency = clamp2(m_sQueueSample.m_nFrequency, freqSkimmerPrev, 197);
+ m_sQueueSample.m_nFrequency = Clamp2(m_sQueueSample.m_nFrequency, freqSkimmerPrev, 197);
freqSkimmerPrev = m_sQueueSample.m_nFrequency;
m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO4;
@@ -11483,8 +11483,10 @@ cAudioManager::ProcessMissionAudioSlot(uint8 slot)
if (!m_nUserPause) {
if (nCheckPlayingDelay[slot]) {
--nCheckPlayingDelay[slot];
- } else if (GetMissionScriptPoliceAudioPlayingStatus() == PLAY_STATUS_FINISHED || m_sMissionAudio.m_nMissionAudioCounter[slot]-- == 0) {
+ } else if ((g_bMissionAudioLoadFailed[slot] && m_sMissionAudio.m_nMissionAudioCounter[slot]-- == 0) || GetMissionScriptPoliceAudioPlayingStatus() == PLAY_STATUS_FINISHED) {
m_sMissionAudio.m_nPlayStatus[slot] = PLAY_STATUS_FINISHED;
+ //if (m_sMissionAudio.m_nSampleIndex[slot] >= STREAMED_SOUND_MISSION_MOB_01A && m_sMissionAudio.m_nSampleIndex[slot] <= STREAMED_SOUND_MISSION_MOB_99A)
+ // m_sMissionAudio.m_bIsMobile[slot] = FALSE;
m_sMissionAudio.m_nSampleIndex[slot] = NO_SAMPLE;
//SampleManager.StopStreamedFile(slot + 1);
SampleManager.StopChannel(slot + CHANNEL_MISSION_AUDIO_1);
diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp
index b9d46d2c..c4f49e19 100644
--- a/src/audio/AudioManager.cpp
+++ b/src/audio/AudioManager.cpp
@@ -333,7 +333,7 @@ cAudioManager::Get3DProviderName(uint8 id) const
if (!m_bIsInitialised)
return nil;
#ifdef AUDIO_OAL
- id = clamp(id, 0, SampleManager.GetNum3DProvidersAvailable() - 1);
+ id = Clamp(id, 0, SampleManager.GetNum3DProvidersAvailable() - 1);
#else
// We don't want that either since it will crash the game, but skipping for now
if (id >= SampleManager.GetNum3DProvidersAvailable())
@@ -533,7 +533,7 @@ cAudioManager::ComputeDopplerEffectedFrequency(uint32 oldFreq, float position1,
if (dist != 0.0f) {
float speedOfSource = (dist / m_nTimeSpent) * speedMultiplier;
if (m_fSpeedOfSound > Abs(speedOfSource)) {
- speedOfSource = clamp2(speedOfSource, 0.0f, 1.5f);
+ speedOfSource = Clamp2(speedOfSource, 0.0f, 1.5f);
newFreq = (oldFreq * m_fSpeedOfSound) / (speedOfSource + m_fSpeedOfSound);
}
}
@@ -897,11 +897,11 @@ cAudioManager::ProcessActiveQueues()
sample.m_fSpeedMultiplier);
if (sample.m_nFrequency != m_asActiveSamples[j].m_nFrequency) {
- m_asActiveSamples[j].m_nFrequency = clamp2((int32)sample.m_nFrequency, (int32)m_asActiveSamples[j].m_nFrequency, 6000);
+ m_asActiveSamples[j].m_nFrequency = Clamp2((int32)sample.m_nFrequency, (int32)m_asActiveSamples[j].m_nFrequency, 6000);
SampleManager.SetChannelFrequency(j, m_asActiveSamples[j].m_nFrequency);
}
if (sample.m_nEmittingVolume != m_asActiveSamples[j].m_nEmittingVolume) {
- vol = clamp2((int8)sample.m_nEmittingVolume, (int8)m_asActiveSamples[j].m_nEmittingVolume, 10);
+ vol = Clamp2((int8)sample.m_nEmittingVolume, (int8)m_asActiveSamples[j].m_nEmittingVolume, 10);
if (field_4) {
emittingVol = 2 * Min(63, vol);
diff --git a/src/audio/MusicManager.cpp b/src/audio/MusicManager.cpp
index dad45371..9032a8e7 100644
--- a/src/audio/MusicManager.cpp
+++ b/src/audio/MusicManager.cpp
@@ -310,7 +310,16 @@ cMusicManager::ChangeMusicMode(uint8 mode)
switch (mode)
{
- case MUSICMODE_FRONTEND: m_nUpcomingMusicMode = MUSICMODE_FRONTEND; break;
+ case MUSICMODE_FRONTEND:
+ m_nUpcomingMusicMode = MUSICMODE_FRONTEND;
+
+#ifdef PAUSE_RADIO_IN_FRONTEND
+ // rewind those streams we weren't listening right now
+ for( uint32 i = STREAMED_SOUND_RADIO_HEAD; i < STREAMED_SOUND_CUTSCENE_BIKER; i++ )
+ m_aTracks[i].m_nPosition = GetTrackStartPos(i);
+#endif
+
+ break;
case MUSICMODE_GAME: m_nUpcomingMusicMode = MUSICMODE_GAME; break;
case MUSICMODE_CUTSCENE:
m_nUpcomingMusicMode = MUSICMODE_CUTSCENE;
@@ -414,6 +423,12 @@ cMusicManager::ServiceFrontEndMode()
{
static bool8 bRadioStatsRecorded = FALSE;
+#ifdef PAUSE_RADIO_IN_FRONTEND
+ // pause radio
+ for( uint32 i = STREAMED_SOUND_RADIO_HEAD; i < STREAMED_SOUND_CUTSCENE_BIKER; i++ )
+ m_aTracks[i].m_nLastPosCheckTimer = CTimer::GetTimeInMillisecondsPauseMode();
+#endif
+
if (m_bAnnouncementInProgress) {
SampleManager.StopStreamedFile();
if (SampleManager.IsStreamPlaying())
diff --git a/src/audio/oal/stream.cpp b/src/audio/oal/stream.cpp
index ab266681..7fc36acd 100644
--- a/src/audio/oal/stream.cpp
+++ b/src/audio/oal/stream.cpp
@@ -162,7 +162,7 @@ public:
else
StepIndex--;
- StepIndex = clamp(StepIndex, 0, 88);
+ StepIndex = Clamp(StepIndex, 0, 88);
int delta = step >> 3;
if (adpcm & 1) delta += step >> 2;
@@ -171,7 +171,7 @@ public:
if (adpcm & 8) delta = -delta;
int newSample = Sample + delta;
- Sample = clamp(newSample, -32768, 32767);
+ Sample = Clamp(newSample, -32768, 32767);
return Sample;
}
};
@@ -716,7 +716,7 @@ public:
static short quantize(double sample)
{
int a = int(sample + 0.5);
- return short(clamp(a, -32768, 32767));
+ return short(Clamp(a, -32768, 32767));
}
void Decode(void* _inbuf, int16* _outbuf, size_t size)
@@ -1448,10 +1448,10 @@ void CStream::SetVolume(uint32 nVol)
void CStream::SetPan(uint8 nPan)
{
- m_nPan = clamp((int8)nPan - 63, 0, 63);
+ m_nPan = Clamp((int8)nPan - 63, 0, 63);
SetPosition(0, (m_nPan - 63) / 64.0f, 0.0f, Sqrt(1.0f - SQR((m_nPan - 63) / 64.0f)));
- m_nPan = clamp((int8)nPan + 64, 64, 127);
+ m_nPan = Clamp((int8)nPan + 64, 64, 127);
SetPosition(1, (m_nPan - 63) / 64.0f, 0.0f, Sqrt(1.0f - SQR((m_nPan - 63) / 64.0f)));
m_nPan = nPan;
diff --git a/src/audio/sampman_miles.cpp b/src/audio/sampman_miles.cpp
index 5e2b348b..88eceecf 100644
--- a/src/audio/sampman_miles.cpp
+++ b/src/audio/sampman_miles.cpp
@@ -1750,7 +1750,7 @@ cSampleManager::UpdateReverb(void)
#undef CALCULATE_RATIO
#undef MIN_DIST
- fRatio = clamp(fRatio, 0.0f, 0.6f);
+ fRatio = Clamp(fRatio, 0.0f, 0.6f);
if ( fRatio == _fPrevEaxRatioDestination )
return FALSE;
diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp
index 3cd7a736..60d26b7d 100644
--- a/src/audio/sampman_oal.cpp
+++ b/src/audio/sampman_oal.cpp
@@ -430,7 +430,7 @@ int8 cSampleManager::SetCurrent3DProvider(uint8 nProvider)
{
int savedprovider = curprovider;
- nProvider = clamp(nProvider, 0, m_nNumberOfProviders - 1);
+ nProvider = Clamp(nProvider, 0, m_nNumberOfProviders - 1);
if ( set_new_provider(nProvider) )
return curprovider;
@@ -553,18 +553,32 @@ _FindMP3s(void)
bool8 bInitFirstEntry;
HANDLE hFind;
char path[MAX_PATH];
- char filepath[MAX_PATH*2];
int total_ms;
WIN32_FIND_DATA fd;
+ char filepath[MAX_PATH + sizeof(fd.cFileName)];
if (getcwd(_mp3DirectoryPath, MAX_PATH) == NULL) {
perror("getcwd: ");
return;
}
+
+ if (strlen(_mp3DirectoryPath) + 1 > MAX_PATH - 10) {
+ // This is not gonna end well
+ printf("MP3 folder path is too long, no place left for file names. MP3 finding aborted.\n");
+ return;
+ }
OutputDebugString("Finding MP3s...");
strcpy(path, _mp3DirectoryPath);
strcat(path, "\\MP3\\");
+
+#if !defined(_WIN32)
+ char *actualPath = casepath(path);
+ if (actualPath) {
+ strcpy(path, actualPath);
+ free(actualPath);
+ }
+#endif
strcpy(_mp3DirectoryPath, path);
OutputDebugString(_mp3DirectoryPath);
@@ -577,92 +591,32 @@ _FindMP3s(void)
{
return;
}
-
- strcpy(filepath, _mp3DirectoryPath);
- strcat(filepath, fd.cFileName);
-
- size_t filepathlen = strlen(filepath);
-
- if ( filepathlen <= 0)
- {
- FindClose(hFind);
- return;
- }
- if ( _ResolveLink(filepath, filepath) )
- {
- OutputDebugString("Resolving Link");
- OutputDebugString(filepath);
- bShortcut = TRUE;
- } else
- bShortcut = FALSE;
-
- if (aStream[0] && aStream[0]->Open(filepath))
- {
- total_ms = aStream[0]->GetLengthMS();
- aStream[0]->Close();
+ bShortcut = FALSE;
+ bInitFirstEntry = TRUE;
- OutputDebugString(fd.cFileName);
-
- _pMP3List = new tMP3Entry;
-
- if ( _pMP3List == NULL )
- {
- FindClose(hFind);
- return;
- }
-
- nNumMP3s = 1;
-
- strcpy(_pMP3List->aFilename, fd.cFileName);
-
- _pMP3List->nTrackLength = total_ms;
-
- _pMP3List->pNext = NULL;
-
- pList = _pMP3List;
-
- if ( bShortcut )
- {
- _pMP3List->pLinkPath = new char[MAX_PATH*2];
- strcpy(_pMP3List->pLinkPath, filepath);
- }
- else
- {
- _pMP3List->pLinkPath = NULL;
- }
+ do
+ {
+ strcpy(filepath, _mp3DirectoryPath);
+ strcat(filepath, fd.cFileName);
+
+ if (!strcmp(fd.cFileName, ".") || !strcmp(fd.cFileName, ".."))
+ continue;
- bInitFirstEntry = FALSE;
- }
- else
- {
- strcat(filepath, " - NOT A VALID MP3");
-
- OutputDebugString(filepath);
+ size_t filepathlen = strlen(filepath);
- bInitFirstEntry = TRUE;
- }
-
- while ( TRUE )
- {
- if ( !FindNextFile(hFind, &fd) )
- break;
-
if ( bInitFirstEntry )
{
- strcpy(filepath, _mp3DirectoryPath);
- strcat(filepath, fd.cFileName);
-
- size_t filepathlen = strlen(filepath);
-
- if ( filepathlen > 0 )
+ if (filepathlen > 0)
{
- if ( _ResolveLink(filepath, filepath) )
+ if (_ResolveLink(filepath, filepath))
{
OutputDebugString("Resolving Link");
OutputDebugString(filepath);
bShortcut = TRUE;
- } else {
+ }
+ else
+ {
bShortcut = FALSE;
if (filepathlen > MAX_PATH) {
continue;
@@ -674,29 +628,29 @@ _FindMP3s(void)
aStream[0]->Close();
OutputDebugString(fd.cFileName);
-
+
_pMP3List = new tMP3Entry;
-
- if ( _pMP3List == NULL)
+
+ if (_pMP3List == NULL)
break;
-
+
nNumMP3s = 1;
-
+
strcpy(_pMP3List->aFilename, fd.cFileName);
-
+
_pMP3List->nTrackLength = total_ms;
_pMP3List->pNext = NULL;
-
- if ( bShortcut )
+
+ if (bShortcut)
{
- _pMP3List->pLinkPath = new char [MAX_PATH*2];
+ _pMP3List->pLinkPath = new char[MAX_PATH + sizeof(fd.cFileName)];
strcpy(_pMP3List->pLinkPath, filepath);
}
else
{
_pMP3List->pLinkPath = NULL;
}
-
+
pList = _pMP3List;
bInitFirstEntry = FALSE;
@@ -707,14 +661,11 @@ _FindMP3s(void)
OutputDebugString(filepath);
}
}
+ else
+ break;
}
else
{
- strcpy(filepath, _mp3DirectoryPath);
- strcat(filepath, fd.cFileName);
-
- size_t filepathlen = strlen(filepath);
-
if ( filepathlen > 0 )
{
if ( _ResolveLink(filepath, filepath) )
@@ -722,7 +673,8 @@ _FindMP3s(void)
OutputDebugString("Resolving Link");
OutputDebugString(filepath);
bShortcut = TRUE;
- } else
+ }
+ else
bShortcut = FALSE;
if (aStream[0] && aStream[0]->Open(filepath))
@@ -747,7 +699,7 @@ _FindMP3s(void)
if ( bShortcut )
{
- e->pLinkPath = new char [MAX_PATH*2];
+ e->pLinkPath = new char [MAX_PATH + sizeof(fd.cFileName)];
strcpy(e->pLinkPath, filepath);
}
else
@@ -766,7 +718,7 @@ _FindMP3s(void)
}
}
}
- }
+ } while (FindNextFile(hFind, &fd));
FindClose(hFind);
}
@@ -1386,14 +1338,14 @@ cSampleManager::IsPedCommentLoaded(uint32 nComment)
{
ASSERT( nComment < TOTAL_AUDIO_SAMPLES );
- int8 slot;
-
for ( int32 i = 0; i < _TODOCONST(3); i++ )
{
- slot = nCurrentPedSlot - i - 1;
#ifdef FIX_BUGS
+ int8 slot = (int8)nCurrentPedSlot - i - 1;
if (slot < 0)
slot += ARRAY_SIZE(nPedSlotSfx);
+#else
+ uint8 slot = nCurrentPedSlot - i - 1;
#endif
if ( nComment == nPedSlotSfx[slot] )
return TRUE;
@@ -1406,14 +1358,14 @@ cSampleManager::IsPedCommentLoaded(uint32 nComment)
int32
cSampleManager::_GetPedCommentSlot(uint32 nComment)
{
- int8 slot;
-
for (int32 i = 0; i < _TODOCONST(3); i++)
{
- slot = nCurrentPedSlot - i - 1;
#ifdef FIX_BUGS
+ int8 slot = (int8)nCurrentPedSlot - i - 1;
if (slot < 0)
slot += ARRAY_SIZE(nPedSlotSfx);
+#else
+ uint8 slot = nCurrentPedSlot - i - 1;
#endif
if (nComment == nPedSlotSfx[slot])
return slot;
@@ -1537,7 +1489,7 @@ bool8 cSampleManager::UpdateReverb(void)
#undef CALCULATE_RATIO
#undef MIN_DIST
- fRatio = clamp(fRatio, 0.0f, 0.6f);
+ fRatio = Clamp(fRatio, 0.0f, 0.6f);
if ( fRatio == _fPrevEaxRatioDestination )
return FALSE;