diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/audio/AudioLogic.cpp | 12 | ||||
-rw-r--r-- | src/audio/AudioManager.cpp | 2 | ||||
-rw-r--r-- | src/audio/AudioManager.h | 4 | ||||
-rw-r--r-- | src/audio/MusicManager.cpp | 20 | ||||
-rw-r--r-- | src/audio/sampman_miles.cpp | 20 | ||||
-rw-r--r-- | src/audio/sampman_oal.cpp | 20 |
6 files changed, 37 insertions, 41 deletions
diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 0290dcee..83f55d33 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -3022,7 +3022,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams& params) m_sQueueSample.m_nSampleIndex = SFX_GLASS_CRACK; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = 68; - emittingVol = m_anRandomTable[1] % 30 + 80; //GetRandomNumberInRange(1, 80, 109) + emittingVol = m_anRandomTable[1] % 30 + 80; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_GLASS_CRACK); m_sQueueSample.m_nReleasingVolumeModificator = 5; m_sQueueSample.m_fSpeedMultiplier = 0.0f; @@ -3817,8 +3817,8 @@ uint8 gJumboVolOffsetPercentage; void DoJumboVolOffset() { - if (!(AudioManager.GetFrameCounter() % (AudioManager.GetRandomNumber(0) % 6 + 3))) - gJumboVolOffsetPercentage = AudioManager.GetRandomNumber(1) % 60; + if (!(AudioManager.m_FrameCounter % (AudioManager.m_anRandomTable[0] % 6 + 3))) + gJumboVolOffsetPercentage = AudioManager.m_anRandomTable[1] % 60; } void @@ -5191,7 +5191,7 @@ cAudioManager::SetupPedComments(cPedParams ¶ms, uint16 sound) switch(sound) { case SOUND_PED_HELI_PLAYER_FOUND: soundIntensity = 400.0f; - pedComment.m_nSampleIndex = GetRandomNumberInRange(m_sQueueSample.m_nEntityIndex % 4, SFX_POLICE_HELI_1, SFX_POLICE_HELI_20); + pedComment.m_nSampleIndex = m_anRandomTable[m_sQueueSample.m_nEntityIndex % 4] % 20 + SFX_POLICE_HELI_1; break; case SOUND_PED_VCPA_PLAYER_FOUND: soundIntensity = 400.0f; @@ -5203,11 +5203,11 @@ cAudioManager::SetupPedComments(cPedParams ¶ms, uint16 sound) break; case SOUND_INJURED_PED_MALE_OUCH: soundIntensity = 40.0f; - pedComment.m_nSampleIndex = GetRandomNumberInRange(m_sQueueSample.m_nEntityIndex % 4, SFX_GENERIC_MALE_GRUNT_1, SFX_GENERIC_MALE_GRUNT_41); + pedComment.m_nSampleIndex = m_anRandomTable[m_sQueueSample.m_nEntityIndex % 4] % 41 + SFX_GENERIC_MALE_GRUNT_1; break; case SOUND_INJURED_PED_FEMALE: soundIntensity = 40.0f; - pedComment.m_nSampleIndex = GetRandomNumberInRange(m_sQueueSample.m_nEntityIndex % 4, SFX_GENERIC_FEMALE_GRUNT_1, SFX_GENERIC_FEMALE_GRUNT_33); + pedComment.m_nSampleIndex = m_anRandomTable[m_sQueueSample.m_nEntityIndex % 4] % 33 + SFX_GENERIC_FEMALE_GRUNT_1; break; default: return; diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index b0b3f49d..e4f8a023 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -664,7 +664,7 @@ cAudioManager::AddReflectionsToRequestedQueue() for (uint32 i = 0; i < ARRAY_SIZE(m_afReflectionsDistances); i++) { if ( CTimer::GetIsSlowMotionActive() ) - m_afReflectionsDistances[i] = GetRandomNumberInRange(i % 4, 0, 2) * 100.f / 8.f; + m_afReflectionsDistances[i] = (m_anRandomTable[i % 4] % 3) * 100.f / 8.f; reflectionDistance = m_afReflectionsDistances[i]; if (reflectionDistance > 0.0f && reflectionDistance < 100.f && reflectionDistance < m_sQueueSample.m_fSoundIntensity) { diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index f68c53ad..cf1e4777 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -251,10 +251,6 @@ public: ~cAudioManager(); // getters - uint32 GetFrameCounter() const { return m_FrameCounter; } - float GetReflectionsDistance(int32 idx) const { return m_afReflectionsDistances[idx]; } - int32 GetRandomNumber(int32 idx) const { return m_anRandomTable[idx]; } - int32 GetRandomNumberInRange(int32 idx, int32 low, int32 high) const { return (m_anRandomTable[idx] % (high - low + 1)) + low; } bool8 IsMissionAudioSamplePlaying(uint8 slot); // { return m_sMissionAudio.m_nPlayStatus == 1; } bool8 ShouldDuckMissionAudio(uint8 slot); diff --git a/src/audio/MusicManager.cpp b/src/audio/MusicManager.cpp index e569f8c7..8f5fb5b8 100644 --- a/src/audio/MusicManager.cpp +++ b/src/audio/MusicManager.cpp @@ -132,23 +132,23 @@ cMusicManager::SetStartingTrackPositions(bool8 isNewGameTimer) if (IsInitialised()) { time_t timevalue = time(0); if (timevalue == -1) { - pos = AudioManager.GetRandomNumber(0); + pos = AudioManager.m_anRandomTable[0]; } else { tm* pTm = localtime(&timevalue); if (pTm->tm_sec == 0) - pTm->tm_sec = AudioManager.GetRandomNumber(0); + pTm->tm_sec = AudioManager.m_anRandomTable[0]; if (pTm->tm_min == 0) - pTm->tm_min = AudioManager.GetRandomNumber(1); + pTm->tm_min = AudioManager.m_anRandomTable[1]; if (pTm->tm_hour == 0) - pTm->tm_hour = AudioManager.GetRandomNumber(2); + pTm->tm_hour = AudioManager.m_anRandomTable[2]; if (pTm->tm_mday == 0) - pTm->tm_mday = AudioManager.GetRandomNumber(3); + pTm->tm_mday = AudioManager.m_anRandomTable[3]; if (pTm->tm_mon == 0) - pTm->tm_mon = AudioManager.GetRandomNumber(4); + pTm->tm_mon = AudioManager.m_anRandomTable[4]; if (pTm->tm_year == 0) - pTm->tm_year = AudioManager.GetRandomNumber(3); + pTm->tm_year = AudioManager.m_anRandomTable[3]; if (pTm->tm_wday == 0) - pTm->tm_wday = AudioManager.GetRandomNumber(2); + pTm->tm_wday = AudioManager.m_anRandomTable[2]; pos = pTm->tm_yday * pTm->tm_wday * pTm->tm_year @@ -165,7 +165,7 @@ cMusicManager::SetStartingTrackPositions(bool8 isNewGameTimer) if (i < STREAMED_SOUND_CITY_AMBIENT && isNewGameTimer) m_aTracks[i].m_nPosition = NewGameRadioTimers[i]; else if (i < STREAMED_SOUND_ANNOUNCE_BRIDGE_CLOSED) - m_aTracks[i].m_nPosition = (pos * AudioManager.GetRandomNumber(i % 5)) % m_aTracks[i].m_nLength; + m_aTracks[i].m_nPosition = (pos * AudioManager.m_anRandomTable[i % 5]) % m_aTracks[i].m_nLength; else m_aTracks[i].m_nPosition = 0; @@ -1171,7 +1171,7 @@ cMusicManager::GetCarTuning() if (UsesPoliceRadio(veh)) return STREAMED_SOUND_RADIO_POLICE; if (UsesTaxiRadio(veh)) return STREAMED_SOUND_RADIO_TAXI; if (veh->m_nRadioStation == USERTRACK && !SampleManager.IsMP3RadioChannelAvailable()) - veh->m_nRadioStation = AudioManager.GetRandomNumber(2) % USERTRACK; + veh->m_nRadioStation = AudioManager.m_anRandomTable[2] % USERTRACK; return veh->m_nRadioStation; } diff --git a/src/audio/sampman_miles.cpp b/src/audio/sampman_miles.cpp index b77584d0..f94768cb 100644 --- a/src/audio/sampman_miles.cpp +++ b/src/audio/sampman_miles.cpp @@ -1322,7 +1322,7 @@ cSampleManager::Initialise(void) int32 randval; if ( bUseRandomTable ) - randval = AudioManager.GetRandomNumber(1); + randval = AudioManager.m_anRandomTable[1]; else randval = localtm->tm_sec * localtm->tm_min; @@ -1333,7 +1333,7 @@ cSampleManager::Initialise(void) randmp3 = randmp3->pNext; if ( bUseRandomTable ) - _CurMP3Pos = AudioManager.GetRandomNumber(0) % randmp3->nTrackLength; + _CurMP3Pos = AudioManager.m_anRandomTable[0] % randmp3->nTrackLength; else { if ( localtm->tm_sec > 0 ) @@ -1342,7 +1342,7 @@ cSampleManager::Initialise(void) _CurMP3Pos = s*s*s*s*s*s*s*s % randmp3->nTrackLength; } else - _CurMP3Pos = AudioManager.GetRandomNumber(0) % randmp3->nTrackLength; + _CurMP3Pos = AudioManager.m_anRandomTable[0] % randmp3->nTrackLength; } } else @@ -1671,7 +1671,7 @@ cSampleManager::UpdateReverb(void) if ( !usingEAX ) return FALSE; - if ( AudioManager.GetFrameCounter() & 15 ) + if ( AudioManager.m_FrameCounter & 15 ) return FALSE; float fRatio = 0.0f; @@ -1679,13 +1679,13 @@ cSampleManager::UpdateReverb(void) #define MIN_DIST 0.5f #define CALCULATE_RATIO(value, maxDist, maxRatio) (value > MIN_DIST && value < maxDist ? value / maxDist * maxRatio : 0) - fRatio += CALCULATE_RATIO(AudioManager.GetReflectionsDistance(REFLECTION_CEIL_NORTH), 10.0f, 1/2.f); - fRatio += CALCULATE_RATIO(AudioManager.GetReflectionsDistance(REFLECTION_CEIL_SOUTH), 10.0f, 1/2.f); - fRatio += CALCULATE_RATIO(AudioManager.GetReflectionsDistance(REFLECTION_CEIL_WEST), 10.0f, 1/2.f); - fRatio += CALCULATE_RATIO(AudioManager.GetReflectionsDistance(REFLECTION_CEIL_EAST), 10.0f, 1/2.f); + fRatio += CALCULATE_RATIO(AudioManager.m_afReflectionsDistances[REFLECTION_CEIL_NORTH], 10.0f, 1/2.f); + fRatio += CALCULATE_RATIO(AudioManager.m_afReflectionsDistances[REFLECTION_CEIL_SOUTH], 10.0f, 1/2.f); + fRatio += CALCULATE_RATIO(AudioManager.m_afReflectionsDistances[REFLECTION_CEIL_WEST], 10.0f, 1/2.f); + fRatio += CALCULATE_RATIO(AudioManager.m_afReflectionsDistances[REFLECTION_CEIL_EAST], 10.0f, 1/2.f); - fRatio += CALCULATE_RATIO((AudioManager.GetReflectionsDistance(REFLECTION_NORTH) + AudioManager.GetReflectionsDistance(REFLECTION_SOUTH)) / 2.f, 4.0f, 1/3.f); - fRatio += CALCULATE_RATIO((AudioManager.GetReflectionsDistance(REFLECTION_WEST) + AudioManager.GetReflectionsDistance(REFLECTION_EAST)) / 2.f, 4.0f, 1/3.f); + fRatio += CALCULATE_RATIO((AudioManager.m_afReflectionsDistances[REFLECTION_NORTH] + AudioManager.m_afReflectionsDistances[REFLECTION_SOUTH]) / 2.f, 4.0f, 1/3.f); + fRatio += CALCULATE_RATIO((AudioManager.m_afReflectionsDistances[REFLECTION_WEST] + AudioManager.m_afReflectionsDistances[REFLECTION_EAST]) / 2.f, 4.0f, 1/3.f); #undef CALCULATE_RATIO #undef MIN_DIST diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp index 73f6900b..3441c202 100644 --- a/src/audio/sampman_oal.cpp +++ b/src/audio/sampman_oal.cpp @@ -1023,7 +1023,7 @@ cSampleManager::Initialise(void) int32 randval; if ( bUseRandomTable ) - randval = AudioManager.GetRandomNumber(1); + randval = AudioManager.m_anRandomTable[1]; else randval = localtm->tm_sec * localtm->tm_min; @@ -1034,7 +1034,7 @@ cSampleManager::Initialise(void) randmp3 = randmp3->pNext; if ( bUseRandomTable ) - _CurMP3Pos = AudioManager.GetRandomNumber(0) % randmp3->nTrackLength; + _CurMP3Pos = AudioManager.m_anRandomTable[0] % randmp3->nTrackLength; else { if ( localtm->tm_sec > 0 ) @@ -1043,7 +1043,7 @@ cSampleManager::Initialise(void) _CurMP3Pos = s*s*s*s*s*s*s*s % randmp3->nTrackLength; } else - _CurMP3Pos = AudioManager.GetRandomNumber(0) % randmp3->nTrackLength; + _CurMP3Pos = AudioManager.m_anRandomTable[0] % randmp3->nTrackLength; } } else @@ -1386,7 +1386,7 @@ bool8 cSampleManager::UpdateReverb(void) if ( !usingEAX && !_usingEFX ) return FALSE; - if ( AudioManager.GetFrameCounter() & 15 ) + if ( AudioManager.m_FrameCounter & 15 ) return FALSE; float fRatio = 0.0f; @@ -1394,13 +1394,13 @@ bool8 cSampleManager::UpdateReverb(void) #define MIN_DIST 0.5f #define CALCULATE_RATIO(value, maxDist, maxRatio) (value > MIN_DIST && value < maxDist ? value / maxDist * maxRatio : 0) - fRatio += CALCULATE_RATIO(AudioManager.GetReflectionsDistance(REFLECTION_CEIL_NORTH), 10.0f, 1/2.f); - fRatio += CALCULATE_RATIO(AudioManager.GetReflectionsDistance(REFLECTION_CEIL_SOUTH), 10.0f, 1/2.f); - fRatio += CALCULATE_RATIO(AudioManager.GetReflectionsDistance(REFLECTION_CEIL_WEST), 10.0f, 1/2.f); - fRatio += CALCULATE_RATIO(AudioManager.GetReflectionsDistance(REFLECTION_CEIL_EAST), 10.0f, 1/2.f); + fRatio += CALCULATE_RATIO(AudioManager.m_afReflectionsDistances[REFLECTION_CEIL_NORTH], 10.0f, 1/2.f); + fRatio += CALCULATE_RATIO(AudioManager.m_afReflectionsDistances[REFLECTION_CEIL_SOUTH], 10.0f, 1/2.f); + fRatio += CALCULATE_RATIO(AudioManager.m_afReflectionsDistances[REFLECTION_CEIL_WEST], 10.0f, 1/2.f); + fRatio += CALCULATE_RATIO(AudioManager.m_afReflectionsDistances[REFLECTION_CEIL_EAST], 10.0f, 1/2.f); - fRatio += CALCULATE_RATIO((AudioManager.GetReflectionsDistance(REFLECTION_NORTH) + AudioManager.GetReflectionsDistance(REFLECTION_SOUTH)) / 2.f, 4.0f, 1/3.f); - fRatio += CALCULATE_RATIO((AudioManager.GetReflectionsDistance(REFLECTION_WEST) + AudioManager.GetReflectionsDistance(REFLECTION_EAST)) / 2.f, 4.0f, 1/3.f); + fRatio += CALCULATE_RATIO((AudioManager.m_afReflectionsDistances[REFLECTION_NORTH] + AudioManager.m_afReflectionsDistances[REFLECTION_SOUTH]) / 2.f, 4.0f, 1/3.f); + fRatio += CALCULATE_RATIO((AudioManager.m_afReflectionsDistances[REFLECTION_WEST] + AudioManager.m_afReflectionsDistances[REFLECTION_EAST]) / 2.f, 4.0f, 1/3.f); #undef CALCULATE_RATIO #undef MIN_DIST |