summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/audio/AudioLogic.cpp5
-rw-r--r--src/audio/AudioManager.cpp59
2 files changed, 32 insertions, 32 deletions
diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp
index a6768b0e..b902690f 100644
--- a/src/audio/AudioLogic.cpp
+++ b/src/audio/AudioLogic.cpp
@@ -1301,13 +1301,12 @@ cAudioManager::ProcessCarHeli(cVehicleParams& params)
if (hunterBool) {
m_sQueueSample.m_nSampleIndex = SFX_HELI_APACHE_4;
m_sQueueSample.m_nBankIndex = SFX_BANK_0;
- freq = 3000 * propellerSpeed + 30000;
+ m_sQueueSample.m_nFrequency = 3000 * propellerSpeed + 30000;
} else {
m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_STA;
m_sQueueSample.m_nBankIndex = SFX_BANK_0;
- freq = 3000 * propellerSpeed + 6000;
+ m_sQueueSample.m_nFrequency = 3000 * propellerSpeed + 6000;
}
- m_sQueueSample.m_nFrequency = freq;
m_sQueueSample.m_nCounter = 12;
m_sQueueSample.m_bIs2D = FALSE;
m_sQueueSample.m_nPriority = 1;
diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp
index 27385bf2..4a47c739 100644
--- a/src/audio/AudioManager.cpp
+++ b/src/audio/AudioManager.cpp
@@ -200,7 +200,7 @@ cAudioManager::DestroyEntity(int32 id)
for (uint32 i = 0; i < m_nAudioEntitiesCount; ++i) {
if (id == m_aAudioEntityOrderList[i]) {
if (i < NUM_AUDIOENTITIES - 1)
- memmove(&m_aAudioEntityOrderList[i], &m_aAudioEntityOrderList[i + 1], NUM_AUDIOENTITY_EVENTS * (m_nAudioEntitiesCount - (i + 1)));
+ memmove(&m_aAudioEntityOrderList[i], &m_aAudioEntityOrderList[i + 1], sizeof(uint32) * (m_nAudioEntitiesCount - (i + 1)));
m_aAudioEntityOrderList[--m_nAudioEntitiesCount] = NUM_AUDIOENTITIES;
return;
}
@@ -231,14 +231,17 @@ cAudioManager::GetEntityPointer(int32 id)
return NULL;
}
+static Const uint8 OneShotPriority[] = {
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 4, 2, 5, 5, 3, 5, 2, 2, 1, 1, 3, 1, 3, 3, 1, 1, 1, 1, 4, 4, 4, 3, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 6, 1, 1, 1, 1, 1, 1, 3, 4, 2, 0, 0, 6, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 1, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 3, 1, 1, 1, 9, 0, 0, 0, 1, 2, 2, 0, 0, 2, 3, 3, 3, 5, 1, 1,
+ 1, 1, 1, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 4, 7, 1, 4, 3, 4, 2, 2, 2, 3, 1, 2, 1, 3, 5, 3, 4, 6, 4, 6, 3, 0, 0, 0, 0, 0,
+ 0, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 3, 1, 1, 2, 1, 1, 0, 0, 0, 0, 0, 3, 3, 1, 0
+ };
+
void
cAudioManager::PlayOneShot(int32 index, uint16 sound, float vol)
{
- static const uint8 OneShotPriority[] = { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 4, 2, 5, 5, 3, 5, 2, 2, 1, 1, 3, 1, 3, 3, 1, 1, 1, 1, 4, 4, 4, 3, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 6, 1, 1, 1, 1, 1, 1, 3, 4, 2, 0, 0, 6, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 1, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 3, 1, 1, 1, 9, 0, 0, 0, 1, 2, 2, 0, 0, 2, 3, 3, 3, 5, 1, 1,
- 1, 1, 1, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 4, 7, 1, 4, 3, 4, 2, 2, 2, 3, 1, 2, 1, 3, 5, 3, 4, 6, 4, 6, 3, 0, 0, 0, 0, 0,
- 0, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 3, 1, 1, 2, 1, 1, 0, 0, 0, 0, 0, 3, 3, 1, 0 };
if (m_bIsInitialised) {
if (index >= 0 && index < NUM_AUDIOENTITIES) {
@@ -255,7 +258,7 @@ cAudioManager::PlayOneShot(int32 index, uint16 sound, float vol)
int32 i = 0;
while (TRUE) {
if (i >= entity.m_AudioEvents) {
- if (entity.m_AudioEvents < ARRAY_SIZE(entity.m_awAudioEvent)) {
+ if (entity.m_AudioEvents < NUM_AUDIOENTITY_EVENTS) {
entity.m_awAudioEvent[i] = sound;
entity.m_afVolume[i] = vol;
entity.m_AudioEvents++;
@@ -267,12 +270,12 @@ cAudioManager::PlayOneShot(int32 index, uint16 sound, float vol)
i++;
}
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_afVolume[i + 1], &entity.m_afVolume[i], (NUM_AUDIOENTITY_EVENTS - 1 - i) * NUM_AUDIOENTITY_EVENTS);
+ memmove(&entity.m_awAudioEvent[i + 1], &entity.m_awAudioEvent[i], (NUM_AUDIOENTITY_EVENTS - 1 - i) * sizeof(int16));
+ memmove(&entity.m_afVolume[i + 1], &entity.m_afVolume[i], (NUM_AUDIOENTITY_EVENTS - 1 - i) * sizeof(float));
}
entity.m_awAudioEvent[i] = sound;
entity.m_afVolume[i] = vol;
- if (entity.m_AudioEvents < ARRAY_SIZE(entity.m_awAudioEvent))
+ if (entity.m_AudioEvents < NUM_AUDIOENTITY_EVENTS)
entity.m_AudioEvents++;
}
}
@@ -483,17 +486,15 @@ cAudioManager::IsMP3RadioChannelAvailable()
void
cAudioManager::ReleaseDigitalHandle()
{
- if (m_bIsInitialised) {
+ if (m_bIsInitialised)
SampleManager.ReleaseDigitalHandle();
- }
}
void
cAudioManager::ReacquireDigitalHandle()
{
- if (m_bIsInitialised) {
+ if (m_bIsInitialised)
SampleManager.ReacquireDigitalHandle();
- }
}
#ifdef AUDIO_REFLECTIONS
@@ -619,10 +620,10 @@ Const static uint8 PanTable[64] = { 0, 3, 8, 12, 16, 19, 22, 24, 26, 28, 30, 3
int32
cAudioManager::ComputeFrontRearMix(float dist, CVector *vec)
{
- int32 index = vec->y / (dist / 64.f);
+ int32 index = vec->y / (dist / 64.0f);
index = Min(63, ABS(index));
- if (vec->y > 0.f)
+ if (vec->y > 0.0f)
return Max(0, 63 - (int8)PanTable[index]);
return Min(127, PanTable[index] + 63);
}
@@ -630,10 +631,10 @@ cAudioManager::ComputeFrontRearMix(float dist, CVector *vec)
int32
cAudioManager::ComputePan(float dist, CVector *vec)
{
- int32 index = vec->x / (dist / 64.f);
+ int32 index = vec->x / (dist / 64.0f);
index = Min(63, ABS(index));
- if (vec->x > 0.f)
+ if (vec->x > 0.0f)
return Max(20, 63 - (int8)PanTable[index]);
return Min(107, PanTable[index] + 63);
}
@@ -663,15 +664,15 @@ cAudioManager::RandomDisplacement(uint32 seed)
static bool8 bPos = TRUE;
static uint32 Adjustment = 0;
- if (!seed)
+ if (seed == 0)
return 0;
value = m_anRandomTable[(Adjustment + seed) % 5] % seed;
Adjustment += value;
- if (value % 2) {
+ if (value % 2)
bPos = !bPos;
- }
+
if (!bPos)
value = -value;
return value;
@@ -776,7 +777,7 @@ cAudioManager::AddReflectionsToRequestedQueue()
oldFreq = m_sQueueSample.m_nFrequency;
} else
#endif
- emittingVolume = (9 * m_sQueueSample.m_nVolume) / 16;
+ emittingVolume = (9 * m_sQueueSample.m_nVolume) >> 4;
m_sQueueSample.m_MaxDistance /= 2.0f;
uint32 halfOldFreq = oldFreq >> 1;
@@ -784,23 +785,23 @@ cAudioManager::AddReflectionsToRequestedQueue()
for (uint32 i = 0; i < ARRAY_SIZE(m_afReflectionsDistances); i++) {
#ifndef USE_TIME_SCALE_FOR_AUDIO
if ( CTimer::GetIsSlowMotionActive() )
- m_afReflectionsDistances[i] = (m_anRandomTable[i % 4] % 3) * 50.f / 8.f;
+ m_afReflectionsDistances[i] = (m_anRandomTable[i % 4] % 3) * 50.0f / 8.0f;
#endif
reflectionDistance = m_afReflectionsDistances[i];
- if (reflectionDistance > 0.0f && reflectionDistance < 100.f && reflectionDistance < m_sQueueSample.m_MaxDistance) {
+ if (reflectionDistance > 0.0f && reflectionDistance < 100.0f && reflectionDistance < m_sQueueSample.m_MaxDistance) {
#ifndef USE_TIME_SCALE_FOR_AUDIO
- m_sQueueSample.m_nReflectionDelay = CTimer::GetIsSlowMotionActive() ? (reflectionDistance * 600.f / 1029.f) : (reflectionDistance * 300.f / 1029.f);
+ m_sQueueSample.m_nReflectionDelay = CTimer::GetIsSlowMotionActive() ? (reflectionDistance * 600.0f / 1029.0f) : (reflectionDistance * 300.0f / 1029.0f);
#else
- m_sQueueSample.m_nReflectionDelay = reflectionDistance * 300.f / 1029.f;
+ m_sQueueSample.m_nReflectionDelay = reflectionDistance * 300.0f / 1029.0f;
#endif
if (m_sQueueSample.m_nReflectionDelay > 3) {
m_sQueueSample.m_fDistance = m_afReflectionsDistances[i];
SET_EMITTING_VOLUME(emittingVolume);
m_sQueueSample.m_nVolume = ComputeVolume(emittingVolume, m_sQueueSample.m_MaxDistance, m_sQueueSample.m_fDistance);
- if (m_sQueueSample.m_nVolume > emittingVolume / 16) {
- m_sQueueSample.m_nCounter = oldCounter + (i + 1) * 256;
+ if (m_sQueueSample.m_nVolume > emittingVolume >> 4) {
+ m_sQueueSample.m_nCounter = oldCounter + ((i + 1) << 8);
if (m_sQueueSample.m_nLoopCount > 0) {
#ifndef USE_TIME_SCALE_FOR_AUDIO
if ( CTimer::GetIsSlowMotionActive() ) {
@@ -808,7 +809,7 @@ cAudioManager::AddReflectionsToRequestedQueue()
} else
#endif
{
- noise = RandomDisplacement(m_sQueueSample.m_nFrequency / 32);
+ noise = RandomDisplacement(m_sQueueSample.m_nFrequency >> 5);
if (noise > 0)
m_sQueueSample.m_nFrequency -= noise;
else