Increase the number of audio channels to PS2 count and some small audio fixes

This commit is contained in:
Sergeanur 2021-05-23 16:14:30 +03:00
parent c9804510d1
commit 7a2dbd9112
9 changed files with 114 additions and 86 deletions

View File

@ -38,9 +38,9 @@
#include "ZoneCull.h" #include "ZoneCull.h"
#include "sampman.h" #include "sampman.h"
const int channels = ARRAY_SIZE(AudioManager.m_asActiveSamples); #ifndef GTA_PS2
const int policeChannel = channels + 1; #define CHANNEL_PLAYER_VEHICLE_ENGINE m_nActiveSamples
const int allChannels = channels + 2; #endif
uint32 gPornNextTime; uint32 gPornNextTime;
uint32 gSawMillNextTime; uint32 gSawMillNextTime;
@ -224,24 +224,26 @@ cAudioManager::ResetAudioLogicTimers(uint32 timer)
} }
} }
ClearMissionAudio(); ClearMissionAudio();
SampleManager.StopChannel(policeChannel); SampleManager.StopChannel(CHANNEL_POLICE_RADIO);
} }
void void
cAudioManager::ProcessReverb() const cAudioManager::ProcessReverb() const
{ {
if (SampleManager.UpdateReverb() && m_bDynamicAcousticModelingStatus) { if (SampleManager.UpdateReverb() && m_bDynamicAcousticModelingStatus) {
#ifndef GTA_PS2
for (uint32 i = 0; i < for (uint32 i = 0; i <
#ifdef FIX_BUGS #ifdef FIX_BUGS
channels NUM_CHANNELS_GENERIC
#else #else
28 NUM_CHANNELS_GENERIC+1
#endif #endif
; ;
i++) { i++) {
if (m_asActiveSamples[i].m_bReverbFlag) if (m_asActiveSamples[i].m_bReverbFlag)
SampleManager.SetChannelReverbFlag(i, TRUE); SampleManager.SetChannelReverbFlag(i, TRUE);
} }
#endif
} }
} }
@ -278,7 +280,7 @@ cAudioManager::ProcessSpecial()
CPlayerPed *playerPed = FindPlayerPed(); CPlayerPed *playerPed = FindPlayerPed();
if (playerPed) { if (playerPed) {
if(playerPed->EnteringCar() && !playerPed->bInVehicle) if(playerPed->EnteringCar() && !playerPed->bInVehicle)
SampleManager.StopChannel(m_nActiveSamples); SampleManager.StopChannel(CHANNEL_PLAYER_VEHICLE_ENGINE);
} }
} }
} }
@ -931,7 +933,7 @@ cAudioManager::ProcessVehicleEngine(cVehicleParams& params)
playerVeh = FindPlayerVehicle(); playerVeh = FindPlayerVehicle();
veh = params.m_pVehicle; veh = params.m_pVehicle;
if (playerVeh == veh && veh->GetStatus() == STATUS_WRECKED) { if (playerVeh == veh && veh->GetStatus() == STATUS_WRECKED) {
SampleManager.StopChannel(m_nActiveSamples); SampleManager.StopChannel(CHANNEL_PLAYER_VEHICLE_ENGINE);
return; return;
} }
if (veh->bEngineOn) { if (veh->bEngineOn) {
@ -1231,7 +1233,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CAutomobile *
else else
accelerateState = Pads[0].GetAccelerate(); accelerateState = Pads[0].GetAccelerate();
channelUsed = SampleManager.GetChannelUsedFlag(m_nActiveSamples); channelUsed = SampleManager.GetChannelUsedFlag(CHANNEL_PLAYER_VEHICLE_ENGINE);
transmission = params.m_pTransmission; transmission = params.m_pTransmission;
velocityChange = params.m_fVelocityChange; velocityChange = params.m_fVelocityChange;
relativeVelocityChange = 2.0f * velocityChange / transmission->fMaxVelocity; relativeVelocityChange = 2.0f * velocityChange / transmission->fMaxVelocity;
@ -1278,7 +1280,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CAutomobile *
if (accelerateState <= 0) { if (accelerateState <= 0) {
if (params.m_fVelocityChange < -0.001f) { if (params.m_fVelocityChange < -0.001f) {
if (channelUsed) { if (channelUsed) {
SampleManager.StopChannel(m_nActiveSamples); SampleManager.StopChannel(CHANNEL_PLAYER_VEHICLE_ENGINE);
bAccelSampleStopped = TRUE; bAccelSampleStopped = TRUE;
} }
if (automobile->m_nWheelsOnGround == 0 || automobile->bIsHandbrakeOn || lostTraction) if (automobile->m_nWheelsOnGround == 0 || automobile->bIsHandbrakeOn || lostTraction)
@ -1290,7 +1292,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CAutomobile *
automobile->m_fGasPedalAudio = gasPedalAudio; automobile->m_fGasPedalAudio = gasPedalAudio;
} else if (LastAccel > 0) { } else if (LastAccel > 0) {
if (channelUsed) { if (channelUsed) {
SampleManager.StopChannel(m_nActiveSamples); SampleManager.StopChannel(CHANNEL_PLAYER_VEHICLE_ENGINE);
bAccelSampleStopped = TRUE; bAccelSampleStopped = TRUE;
} }
nCruising = 0; nCruising = 0;
@ -1334,7 +1336,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CAutomobile *
if (engineSoundType == SFX_BANK_TRUCK) if (engineSoundType == SFX_BANK_TRUCK)
freq /= 2; freq /= 2;
if (channelUsed) { if (channelUsed) {
SampleManager.StopChannel(m_nActiveSamples); SampleManager.StopChannel(CHANNEL_PLAYER_VEHICLE_ENGINE);
bAccelSampleStopped = TRUE; bAccelSampleStopped = TRUE;
} }
AddPlayerCarSample(vol, freq, (engineSoundType - CAR_SFX_BANKS_OFFSET + SFX_CAR_REV_1), SFX_BANK_0, 2, TRUE); AddPlayerCarSample(vol, freq, (engineSoundType - CAR_SFX_BANKS_OFFSET + SFX_CAR_REV_1), SFX_BANK_0, 2, TRUE);
@ -1361,22 +1363,22 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CAutomobile *
} }
} }
if (!SampleManager.InitialiseChannel(m_nActiveSamples, 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;
SampleManager.SetChannelLoopCount(m_nActiveSamples, 1); SampleManager.SetChannelLoopCount(CHANNEL_PLAYER_VEHICLE_ENGINE, 1);
SampleManager.SetChannelLoopPoints(m_nActiveSamples, 0, -1); SampleManager.SetChannelLoopPoints(CHANNEL_PLAYER_VEHICLE_ENGINE, 0, -1);
} }
SampleManager.SetChannelEmittingVolume(m_nActiveSamples, 85); SampleManager.SetChannelEmittingVolume(CHANNEL_PLAYER_VEHICLE_ENGINE, 85);
SampleManager.SetChannel3DPosition(m_nActiveSamples, pos.x, pos.y, pos.z); SampleManager.SetChannel3DPosition(CHANNEL_PLAYER_VEHICLE_ENGINE, pos.x, pos.y, pos.z);
SampleManager.SetChannel3DDistances(m_nActiveSamples, 50.f, 12.5f); SampleManager.SetChannel3DDistances(CHANNEL_PLAYER_VEHICLE_ENGINE, 50.f, 12.5f);
freq = GearFreqAdj[CurrentPretendGear] + freqModifier + 22050; freq = GearFreqAdj[CurrentPretendGear] + freqModifier + 22050;
if (engineSoundType == SFX_BANK_TRUCK) if (engineSoundType == SFX_BANK_TRUCK)
freq /= 2; freq /= 2;
SampleManager.SetChannelFrequency(m_nActiveSamples, freq); SampleManager.SetChannelFrequency(CHANNEL_PLAYER_VEHICLE_ENGINE, freq);
if (!channelUsed) { if (!channelUsed) {
SampleManager.SetChannelReverbFlag(m_nActiveSamples, m_bDynamicAcousticModelingStatus != FALSE); SampleManager.SetChannelReverbFlag(CHANNEL_PLAYER_VEHICLE_ENGINE, m_bDynamicAcousticModelingStatus != FALSE);
SampleManager.StartChannel(m_nActiveSamples); SampleManager.StartChannel(CHANNEL_PLAYER_VEHICLE_ENGINE);
} }
} }
break; break;

View File

@ -13,10 +13,6 @@
cAudioManager AudioManager; cAudioManager AudioManager;
const int channels = ARRAY_SIZE(AudioManager.m_asActiveSamples);
const int policeChannel = channels + 1;
const int allChannels = channels + 2;
#define SPEED_OF_SOUND 343.f #define SPEED_OF_SOUND 343.f
#define TIME_SPENT 50 #define TIME_SPENT 50
@ -26,7 +22,7 @@ cAudioManager::cAudioManager()
m_bReverb = TRUE; m_bReverb = TRUE;
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_SOUNDS_SAMPLES_SLOTS; m_nActiveSamples = NUM_CHANNELS_GENERIC;
m_nActiveSampleQueue = 1; m_nActiveSampleQueue = 1;
ClearRequestedQueue(); ClearRequestedQueue();
m_nActiveSampleQueue = 0; m_nActiveSampleQueue = 0;
@ -267,7 +263,7 @@ cAudioManager::ResetTimers(uint32 time)
} }
ClearActiveSamples(); ClearActiveSamples();
ClearMissionAudio(); ClearMissionAudio();
SampleManager.StopChannel(policeChannel); SampleManager.StopChannel(CHANNEL_POLICE_RADIO);
SampleManager.SetEffectsFadeVolume(0); SampleManager.SetEffectsFadeVolume(0);
SampleManager.SetMusicFadeVolume(0); SampleManager.SetMusicFadeVolume(0);
MusicManager.ResetMusicAfterReload(); MusicManager.ResetMusicAfterReload();
@ -429,7 +425,7 @@ cAudioManager::ServiceSoundEffects()
{ {
m_bFifthFrameFlag = (m_FrameCounter++ % 5) == 0; m_bFifthFrameFlag = (m_FrameCounter++ % 5) == 0;
if (m_nUserPause && !m_nPreviousUserPause) { if (m_nUserPause && !m_nPreviousUserPause) {
for (int32 i = 0; i < allChannels; i++) for (int32 i = 0; i < NUM_CHANNELS; i++)
SampleManager.StopChannel(i); SampleManager.StopChannel(i);
ClearRequestedQueue(); ClearRequestedQueue();
@ -692,7 +688,12 @@ cAudioManager::UpdateReflections()
void void
cAudioManager::AddReleasingSounds() cAudioManager::AddReleasingSounds()
{ {
bool8 toProcess[44]; // why not 27? because PS2? // in case someone would want to increase it
#ifdef FIX_BUGS
bool8 toProcess[NUM_CHANNELS_GENERIC];
#else
bool8 toProcess[44];
#endif
int8 queue = m_nActiveSampleQueue == 0 ? 1 : 0; int8 queue = m_nActiveSampleQueue == 0 ? 1 : 0;

View File

@ -195,10 +195,10 @@ public:
int32 m_nTimer; int32 m_nTimer;
tSound m_sQueueSample; tSound m_sQueueSample;
uint8 m_nActiveSampleQueue; uint8 m_nActiveSampleQueue;
tSound m_asSamples[NUM_SOUNDS_SAMPLES_BANKS][NUM_SOUNDS_SAMPLES_SLOTS]; tSound m_asSamples[NUM_SOUNDS_SAMPLES_BANKS][NUM_CHANNELS_GENERIC];
uint8 m_abSampleQueueIndexTable[NUM_SOUNDS_SAMPLES_BANKS][NUM_SOUNDS_SAMPLES_SLOTS]; uint8 m_abSampleQueueIndexTable[NUM_SOUNDS_SAMPLES_BANKS][NUM_CHANNELS_GENERIC];
uint8 m_SampleRequestQueuesStatus[NUM_SOUNDS_SAMPLES_BANKS]; uint8 m_SampleRequestQueuesStatus[NUM_SOUNDS_SAMPLES_BANKS];
tSound m_asActiveSamples[NUM_SOUNDS_SAMPLES_SLOTS]; tSound m_asActiveSamples[NUM_CHANNELS_GENERIC];
tAudioEntity m_asAudioEntities[NUM_AUDIOENTITIES]; tAudioEntity m_asAudioEntities[NUM_AUDIOENTITIES];
int32 m_anAudioEntityIndices[NUM_AUDIOENTITIES]; int32 m_anAudioEntityIndices[NUM_AUDIOENTITIES];
int32 m_nAudioEntitiesTotal; int32 m_nAudioEntitiesTotal;
@ -498,7 +498,7 @@ public:
#endif #endif
}; };
#ifdef AUDIO_MSS #if defined(AUDIO_MSS) && !defined(PS2_AUDIO_CHANNELS)
static_assert(sizeof(cAudioManager) == 19220, "cAudioManager: error"); static_assert(sizeof(cAudioManager) == 19220, "cAudioManager: error");
#endif #endif

View File

@ -254,3 +254,25 @@ enum eAudioType
AUDIOTYPE_POLICERADIO, AUDIOTYPE_POLICERADIO,
TOTAL_AUDIO_TYPES, TOTAL_AUDIO_TYPES,
}; };
#ifdef GTA_PS2
enum
{
NUM_CHANNELS_GENERIC = 43,
CHANNEL_POLICE_RADIO = NUM_CHANNELS_GENERIC,
CHANNEL_MISSION_AUDIO,
CHANNEL_PLAYER_VEHICLE_ENGINE,
NUM_CHANNELS
};
#else
enum
{
#ifdef PS2_AUDIO_CHANNELS
NUM_CHANNELS_GENERIC = 43,
#else
NUM_CHANNELS_GENERIC = 27,
#endif
CHANNEL_POLICE_RADIO,
NUM_CHANNELS
};
#endif

View File

@ -10,9 +10,9 @@
extern bool IsFXSupported(); extern bool IsFXSupported();
ALuint alSources[MAXCHANNELS+MAX2DCHANNELS]; ALuint alSources[NUM_CHANNELS];
ALuint alFilters[MAXCHANNELS+MAX2DCHANNELS]; ALuint alFilters[NUM_CHANNELS];
ALuint alBuffers[MAXCHANNELS+MAX2DCHANNELS]; ALuint alBuffers[NUM_CHANNELS];
bool bChannelsCreated = false; bool bChannelsCreated = false;
int32 CChannel::channelsThatNeedService = 0; int32 CChannel::channelsThatNeedService = 0;
@ -22,10 +22,10 @@ uint8 tempStereoBuffer[PED_BLOCKSIZE * 2];
void void
CChannel::InitChannels() CChannel::InitChannels()
{ {
alGenSources(MAXCHANNELS+MAX2DCHANNELS, alSources); alGenSources(NUM_CHANNELS, alSources);
alGenBuffers(MAXCHANNELS+MAX2DCHANNELS, alBuffers); alGenBuffers(NUM_CHANNELS, alBuffers);
if (IsFXSupported()) if (IsFXSupported())
alGenFilters(MAXCHANNELS + MAX2DCHANNELS, alFilters); alGenFilters(NUM_CHANNELS, alFilters);
bChannelsCreated = true; bChannelsCreated = true;
} }
@ -34,13 +34,13 @@ CChannel::DestroyChannels()
{ {
if (bChannelsCreated) if (bChannelsCreated)
{ {
alDeleteSources(MAXCHANNELS + MAX2DCHANNELS, alSources); alDeleteSources(NUM_CHANNELS, alSources);
memset(alSources, 0, sizeof(alSources)); memset(alSources, 0, sizeof(alSources));
alDeleteBuffers(MAXCHANNELS + MAX2DCHANNELS, alBuffers); alDeleteBuffers(NUM_CHANNELS, alBuffers);
memset(alBuffers, 0, sizeof(alBuffers)); memset(alBuffers, 0, sizeof(alBuffers));
if (IsFXSupported()) if (IsFXSupported())
{ {
alDeleteFilters(MAXCHANNELS + MAX2DCHANNELS, alFilters); alDeleteFilters(NUM_CHANNELS, alFilters);
memset(alFilters, 0, sizeof(alFilters)); memset(alFilters, 0, sizeof(alFilters));
} }
bChannelsCreated = false; bChannelsCreated = false;

View File

@ -1,5 +1,6 @@
#pragma once #pragma once
#include "AudioSamples.h" #include "AudioSamples.h"
#include "audio_enums.h"
#define MAX_VOLUME 127 #define MAX_VOLUME 127
#define MAX_FREQ DIGITALRATE #define MAX_FREQ DIGITALRATE
@ -99,10 +100,9 @@ enum
#define MAXPROVIDERS 64 #define MAXPROVIDERS 64
#define MAXCHANNELS 28 #define MAXCHANNELS (NUM_CHANNELS_GENERIC+1)
#define MAXCHANNELS_SURROUND 24 #define MAXCHANNELS_SURROUND (MAXCHANNELS-4)
#define MAX2DCHANNELS 1 #define MAX2DCHANNELS 1
#define CHANNEL2D MAXCHANNELS
#define MAX_STREAMS 2 #define MAX_STREAMS 2
@ -110,7 +110,13 @@ enum
#define DIGITALBITS 16 #define DIGITALBITS 16
#define DIGITALCHANNELS 2 #define DIGITALCHANNELS 2
#define MAX_DIGITAL_MIXER_CHANNELS 32 #ifdef FIX_BUGS
#define MAX_DIGITAL_MIXER_CHANNELS (MAXCHANNELS+MAX_STREAMS*2+MAX2DCHANNELS)
#else
#define MAX_DIGITAL_MIXER_CHANNELS (MAXCHANNELS+MAX_STREAMS*2)
#endif
static_assert( NUM_CHANNELS == MAXCHANNELS + MAX2DCHANNELS, "The number of channels doesn't match with an enum" );
class cSampleManager class cSampleManager
{ {

View File

@ -1657,7 +1657,7 @@ cSampleManager::SetChannelReverbFlag(uint32 nChannel, bool8 nReverbFlag)
switch ( nChannel ) switch ( nChannel )
{ {
case CHANNEL2D: case CHANNEL_POLICE_RADIO:
{ {
b2d = TRUE; b2d = TRUE;
break; break;
@ -1686,7 +1686,7 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank)
switch ( nChannel ) switch ( nChannel )
{ {
case CHANNEL2D: case CHANNEL_POLICE_RADIO:
{ {
b2d = TRUE; b2d = TRUE;
break; break;
@ -1786,7 +1786,7 @@ cSampleManager::SetChannelVolume(uint32 nChannel, uint32 nVolume)
switch ( nChannel ) switch ( nChannel )
{ {
case CHANNEL2D: case CHANNEL_POLICE_RADIO:
{ {
nChannelVolume[nChannel] = vol; nChannelVolume[nChannel] = vol;
@ -1814,7 +1814,7 @@ cSampleManager::SetChannelPan(uint32 nChannel, uint32 nPan)
{ {
switch ( nChannel ) switch ( nChannel )
{ {
case CHANNEL2D: case CHANNEL_POLICE_RADIO:
{ {
#ifndef FIX_BUGS #ifndef FIX_BUGS
if ( opened_samples[nChannel - MAXCHANNELS] ) // BUG if ( opened_samples[nChannel - MAXCHANNELS] ) // BUG
@ -1835,7 +1835,7 @@ cSampleManager::SetChannelFrequency(uint32 nChannel, uint32 nFreq)
switch ( nChannel ) switch ( nChannel )
{ {
case CHANNEL2D: case CHANNEL_POLICE_RADIO:
{ {
b2d = TRUE; b2d = TRUE;
break; break;
@ -1861,7 +1861,7 @@ cSampleManager::SetChannelLoopPoints(uint32 nChannel, uint32 nLoopStart, int32 n
switch ( nChannel ) switch ( nChannel )
{ {
case CHANNEL2D: case CHANNEL_POLICE_RADIO:
{ {
b2d = TRUE; b2d = TRUE;
break; break;
@ -1887,7 +1887,7 @@ cSampleManager::SetChannelLoopCount(uint32 nChannel, uint32 nLoopCount)
switch ( nChannel ) switch ( nChannel )
{ {
case CHANNEL2D: case CHANNEL_POLICE_RADIO:
{ {
b2d = TRUE; b2d = TRUE;
break; break;
@ -1913,7 +1913,7 @@ cSampleManager::GetChannelUsedFlag(uint32 nChannel)
switch ( nChannel ) switch ( nChannel )
{ {
case CHANNEL2D: case CHANNEL_POLICE_RADIO:
{ {
b2d = TRUE; b2d = TRUE;
break; break;
@ -1944,7 +1944,7 @@ cSampleManager::StartChannel(uint32 nChannel)
switch ( nChannel ) switch ( nChannel )
{ {
case CHANNEL2D: case CHANNEL_POLICE_RADIO:
{ {
b2d = TRUE; b2d = TRUE;
break; break;
@ -1970,7 +1970,7 @@ cSampleManager::StopChannel(uint32 nChannel)
switch ( nChannel ) switch ( nChannel )
{ {
case CHANNEL2D: case CHANNEL_POLICE_RADIO:
{ {
b2d = TRUE; b2d = TRUE;
break; break;

View File

@ -94,8 +94,8 @@ int32 nPedSlotSfx [MAX_PEDSFX];
int32 nPedSlotSfxAddr[MAX_PEDSFX]; int32 nPedSlotSfxAddr[MAX_PEDSFX];
uint8 nCurrentPedSlot; uint8 nCurrentPedSlot;
CChannel aChannel[MAXCHANNELS+MAX2DCHANNELS]; CChannel aChannel[NUM_CHANNELS];
uint8 nChannelVolume[MAXCHANNELS+MAX2DCHANNELS]; uint8 nChannelVolume[NUM_CHANNELS];
uint32 nStreamLength[TOTAL_STREAMED_SOUNDS]; uint32 nStreamLength[TOTAL_STREAMED_SOUNDS];
ALuint ALStreamSources[MAX_STREAMS][2]; ALuint ALStreamSources[MAX_STREAMS][2];
@ -212,9 +212,8 @@ add_providers()
static void static void
release_existing() release_existing()
{ {
for ( int32 i = 0; i < MAXCHANNELS; i++ ) for ( int32 i = 0; i < NUM_CHANNELS; i++ )
aChannel[i].Term(); aChannel[i].Term();
aChannel[CHANNEL2D].Term();
if ( IsFXSupported() ) if ( IsFXSupported() )
{ {
@ -283,7 +282,7 @@ set_new_provider(int index)
_maxSamples = MAXCHANNELS; _maxSamples = MAXCHANNELS;
ALCint attr[] = {ALC_FREQUENCY,MAX_FREQ, ALCint attr[] = {ALC_FREQUENCY,MAX_FREQ,
ALC_MONO_SOURCES, MAX_STREAMS * 2 + MAXCHANNELS, ALC_MONO_SOURCES, MAX_DIGITAL_MIXER_CHANNELS,
0, 0,
}; };
@ -370,7 +369,8 @@ set_new_provider(int index)
for ( int32 i = 0; i < MAXCHANNELS; i++ ) for ( int32 i = 0; i < MAXCHANNELS; i++ )
aChannel[i].Init(i); aChannel[i].Init(i);
aChannel[CHANNEL2D].Init(CHANNEL2D, true); for ( int32 i = 0; i < MAX2DCHANNELS; i++ )
aChannel[MAXCHANNELS+i].Init(MAXCHANNELS+i, true);
if ( IsFXSupported() ) if ( IsFXSupported() )
{ {
@ -950,7 +950,7 @@ cSampleManager::Initialise(void)
} }
{ {
for ( int32 i = 0; i < MAXCHANNELS+MAX2DCHANNELS; i++ ) for ( int32 i = 0; i < NUM_CHANNELS; i++ )
nChannelVolume[i] = 0; nChannelVolume[i] = 0;
} }
@ -1153,7 +1153,7 @@ cSampleManager::UpdateEffectsVolume(void)
{ {
if ( _bSampmanInitialised ) if ( _bSampmanInitialised )
{ {
for ( int32 i = 0; i < MAXCHANNELS+MAX2DCHANNELS; i++ ) for ( int32 i = 0; i < NUM_CHANNELS; i++ )
{ {
if ( GetChannelUsedFlag(i) ) if ( GetChannelUsedFlag(i) )
{ {
@ -1461,7 +1461,7 @@ bool8 cSampleManager::UpdateReverb(void)
void void
cSampleManager::SetChannelReverbFlag(uint32 nChannel, bool8 nReverbFlag) cSampleManager::SetChannelReverbFlag(uint32 nChannel, bool8 nReverbFlag)
{ {
ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); ASSERT( nChannel < NUM_CHANNELS );
if ( usingEAX || _usingEFX ) if ( usingEAX || _usingEFX )
{ {
@ -1480,7 +1480,7 @@ cSampleManager::SetChannelReverbFlag(uint32 nChannel, bool8 nReverbFlag)
bool8 bool8
cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank) cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank)
{ {
ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); ASSERT( nChannel < NUM_CHANNELS );
uintptr addr; uintptr addr;
@ -1521,8 +1521,7 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank)
void void
cSampleManager::SetChannelEmittingVolume(uint32 nChannel, uint32 nVolume) cSampleManager::SetChannelEmittingVolume(uint32 nChannel, uint32 nVolume)
{ {
ASSERT( nChannel != CHANNEL2D ); ASSERT( nChannel < MAXCHANNELS );
ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS );
uint32 vol = nVolume; uint32 vol = nVolume;
if ( vol > MAX_VOLUME ) vol = MAX_VOLUME; if ( vol > MAX_VOLUME ) vol = MAX_VOLUME;
@ -1544,8 +1543,7 @@ cSampleManager::SetChannelEmittingVolume(uint32 nChannel, uint32 nVolume)
void void
cSampleManager::SetChannel3DPosition(uint32 nChannel, float fX, float fY, float fZ) cSampleManager::SetChannel3DPosition(uint32 nChannel, float fX, float fY, float fZ)
{ {
ASSERT( nChannel != CHANNEL2D ); ASSERT( nChannel < MAXCHANNELS );
ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS );
aChannel[nChannel].SetPosition(-fX, fY, fZ); aChannel[nChannel].SetPosition(-fX, fY, fZ);
} }
@ -1553,18 +1551,17 @@ cSampleManager::SetChannel3DPosition(uint32 nChannel, float fX, float fY, float
void void
cSampleManager::SetChannel3DDistances(uint32 nChannel, float fMax, float fMin) cSampleManager::SetChannel3DDistances(uint32 nChannel, float fMax, float fMin)
{ {
ASSERT( nChannel != CHANNEL2D ); ASSERT( nChannel < MAXCHANNELS );
ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS );
aChannel[nChannel].SetDistances(fMax, fMin); aChannel[nChannel].SetDistances(fMax, fMin);
} }
void void
cSampleManager::SetChannelVolume(uint32 nChannel, uint32 nVolume) cSampleManager::SetChannelVolume(uint32 nChannel, uint32 nVolume)
{ {
ASSERT( nChannel == CHANNEL2D ); ASSERT( nChannel >= MAXCHANNELS );
ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); ASSERT( nChannel < NUM_CHANNELS );
if ( nChannel == CHANNEL2D ) if ( nChannel == CHANNEL_POLICE_RADIO )
{ {
uint32 vol = nVolume; uint32 vol = nVolume;
if ( vol > MAX_VOLUME ) vol = MAX_VOLUME; if ( vol > MAX_VOLUME ) vol = MAX_VOLUME;
@ -1586,10 +1583,10 @@ cSampleManager::SetChannelVolume(uint32 nChannel, uint32 nVolume)
void void
cSampleManager::SetChannelPan(uint32 nChannel, uint32 nPan) cSampleManager::SetChannelPan(uint32 nChannel, uint32 nPan)
{ {
ASSERT(nChannel == CHANNEL2D); ASSERT( nChannel >= MAXCHANNELS );
ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); ASSERT( nChannel < NUM_CHANNELS );
if ( nChannel == CHANNEL2D ) if ( nChannel == CHANNEL_POLICE_RADIO )
{ {
aChannel[nChannel].SetPan(nPan); aChannel[nChannel].SetPan(nPan);
} }
@ -1598,7 +1595,7 @@ cSampleManager::SetChannelPan(uint32 nChannel, uint32 nPan)
void void
cSampleManager::SetChannelFrequency(uint32 nChannel, uint32 nFreq) cSampleManager::SetChannelFrequency(uint32 nChannel, uint32 nFreq)
{ {
ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); ASSERT( nChannel < NUM_CHANNELS );
aChannel[nChannel].SetCurrentFreq(nFreq); aChannel[nChannel].SetCurrentFreq(nFreq);
} }
@ -1606,7 +1603,7 @@ cSampleManager::SetChannelFrequency(uint32 nChannel, uint32 nFreq)
void void
cSampleManager::SetChannelLoopPoints(uint32 nChannel, uint32 nLoopStart, int32 nLoopEnd) cSampleManager::SetChannelLoopPoints(uint32 nChannel, uint32 nLoopStart, int32 nLoopEnd)
{ {
ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); ASSERT( nChannel < NUM_CHANNELS );
aChannel[nChannel].SetLoopPoints(nLoopStart / (DIGITALBITS / 8), nLoopEnd / (DIGITALBITS / 8)); aChannel[nChannel].SetLoopPoints(nLoopStart / (DIGITALBITS / 8), nLoopEnd / (DIGITALBITS / 8));
} }
@ -1614,7 +1611,7 @@ cSampleManager::SetChannelLoopPoints(uint32 nChannel, uint32 nLoopStart, int32 n
void void
cSampleManager::SetChannelLoopCount(uint32 nChannel, uint32 nLoopCount) cSampleManager::SetChannelLoopCount(uint32 nChannel, uint32 nLoopCount)
{ {
ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); ASSERT( nChannel < NUM_CHANNELS );
aChannel[nChannel].SetLoopCount(nLoopCount); aChannel[nChannel].SetLoopCount(nLoopCount);
} }
@ -1622,7 +1619,7 @@ cSampleManager::SetChannelLoopCount(uint32 nChannel, uint32 nLoopCount)
bool8 bool8
cSampleManager::GetChannelUsedFlag(uint32 nChannel) cSampleManager::GetChannelUsedFlag(uint32 nChannel)
{ {
ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); ASSERT( nChannel < NUM_CHANNELS );
return aChannel[nChannel].IsUsed(); return aChannel[nChannel].IsUsed();
} }
@ -1630,7 +1627,7 @@ cSampleManager::GetChannelUsedFlag(uint32 nChannel)
void void
cSampleManager::StartChannel(uint32 nChannel) cSampleManager::StartChannel(uint32 nChannel)
{ {
ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); ASSERT( nChannel < NUM_CHANNELS );
aChannel[nChannel].Start(); aChannel[nChannel].Start();
} }
@ -1638,7 +1635,7 @@ cSampleManager::StartChannel(uint32 nChannel)
void void
cSampleManager::StopChannel(uint32 nChannel) cSampleManager::StopChannel(uint32 nChannel)
{ {
ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); ASSERT( nChannel < NUM_CHANNELS );
aChannel[nChannel].Stop(); aChannel[nChannel].Stop();
} }
@ -1961,7 +1958,7 @@ cSampleManager::Service(void)
stream->Update(); stream->Update();
} }
int refCount = CChannel::channelsThatNeedService; int refCount = CChannel::channelsThatNeedService;
for ( int32 i = 0; refCount && i < MAXCHANNELS+MAX2DCHANNELS; i++ ) for ( int32 i = 0; refCount && i < NUM_CHANNELS; i++ )
{ {
if ( aChannel[i].Update() ) if ( aChannel[i].Update() )
refCount--; refCount--;

View File

@ -128,7 +128,6 @@ enum Config {
NUM_PED_COMMENTS_SLOTS = 20, NUM_PED_COMMENTS_SLOTS = 20,
NUM_SOUNDS_SAMPLES_BANKS = 2, NUM_SOUNDS_SAMPLES_BANKS = 2,
NUM_SOUNDS_SAMPLES_SLOTS = 27,
NUM_AUDIOENTITIES = 200, NUM_AUDIOENTITIES = 200,
NUM_AUDIO_REFLECTIONS = 5, NUM_AUDIO_REFLECTIONS = 5,
@ -395,6 +394,7 @@ enum Config {
// Audio // Audio
#define RADIO_SCROLL_TO_PREV_STATION #define RADIO_SCROLL_TO_PREV_STATION
#define AUDIO_CACHE #define AUDIO_CACHE
#define PS2_AUDIO_CHANNELS // increases the maximum number of audio channels to PS2 value of 44 (PC has 28 originally)
//#define PS2_AUDIO_PATHS // changes audio paths for cutscenes and radio to PS2 paths (needs vbdec on MSS builds) //#define PS2_AUDIO_PATHS // changes audio paths for cutscenes and radio to PS2 paths (needs vbdec on MSS builds)
//#define AUDIO_OAL_USE_SNDFILE // use libsndfile to decode WAVs instead of our internal decoder //#define AUDIO_OAL_USE_SNDFILE // use libsndfile to decode WAVs instead of our internal decoder
#define AUDIO_OAL_USE_MPG123 // use mpg123 to support mp3 files #define AUDIO_OAL_USE_MPG123 // use mpg123 to support mp3 files