summaryrefslogtreecommitdiff
path: root/src/audio/sampman_oal.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/audio/sampman_oal.cpp')
-rw-r--r--src/audio/sampman_oal.cpp240
1 files changed, 188 insertions, 52 deletions
diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp
index 817d68dd..5b05269b 100644
--- a/src/audio/sampman_oal.cpp
+++ b/src/audio/sampman_oal.cpp
@@ -92,7 +92,7 @@ OggOpusFile *fpSampleDataHandle;
#else
FILE *fpSampleDataHandle;
#endif
-bool8 bSampleBankLoaded [MAX_SFX_BANKS];
+bool8 bSampleBankLoaded [MAX_SFX_BANKS];
int32 nSampleBankDiscStartOffset [MAX_SFX_BANKS];
int32 nSampleBankSize [MAX_SFX_BANKS];
uintptr nSampleBankMemoryStartAddress[MAX_SFX_BANKS];
@@ -102,10 +102,11 @@ int32 nPedSlotSfx [MAX_PEDSFX];
int32 nPedSlotSfxAddr[MAX_PEDSFX];
uint8 nCurrentPedSlot;
-#ifdef FIX_BUGS
+uint32 nMissionSlotSfx[MISSION_AUDIO_SLOTS] = { UINT32_MAX, UINT32_MAX };
+uintptr nMissionSlotSfxStartAddress;
+
uint32 gPlayerTalkSfx = UINT32_MAX;
void *gPlayerTalkData = 0;
-#endif
CChannel aChannel[NUM_CHANNELS];
uint8 nChannelVolume[NUM_CHANNELS];
@@ -306,7 +307,7 @@ set_new_provider(int index)
static bool8
IsThisTrackAt16KHz(uint32 track)
{
- return track == STREAMED_SOUND_RADIO_KCHAT || track == STREAMED_SOUND_RADIO_VCPR || track == STREAMED_SOUND_RADIO_POLICE;
+ return false;// track == STREAMED_SOUND_RADIO_KCHAT || track == STREAMED_SOUND_RADIO_VCPR || track == STREAMED_SOUND_RADIO_POLICE;
}
cSampleManager::cSampleManager(void)
@@ -319,6 +320,80 @@ cSampleManager::~cSampleManager(void)
}
+int gBankStartOffset[67];
+
+void
+SetUpDebugBanksInfo()
+{
+ gBankStartOffset[3] = SFX_FE_BACK;
+ gBankStartOffset[4] = SFX_CAR_ACCEL_1;
+ gBankStartOffset[5] = SFX_CAR_ACCEL_2;
+ gBankStartOffset[9] = SFX_CAR_ACCEL_6;
+ gBankStartOffset[10] = SFX_CAR_ACCEL_7;
+ gBankStartOffset[1] = SFX_EMPTY;
+ gBankStartOffset[11] = SFX_CAR_ACCEL_8;
+ gBankStartOffset[7] = SFX_CAR_ACCEL_4;
+ gBankStartOffset[15] = SFX_CAR_ACCEL_12;
+ gBankStartOffset[13] = SFX_CAR_ACCEL_10;
+ gBankStartOffset[16] = SFX_CAR_CHAINSAW_IDLE;
+ gBankStartOffset[0] = SFX_AIR_BRAKES;
+ gBankStartOffset[17] = SFX_RC_IDLE;
+ gBankStartOffset[6] = SFX_CAR_ACCEL_3;
+ gBankStartOffset[19] = SFX_CAR_ACCEL_16;
+ gBankStartOffset[12] = SFX_CAR_ACCEL_9;
+ gBankStartOffset[2] = SFX_AMBULAN_VOICE_1_VAN_1;
+ gBankStartOffset[21] = SFX_CAR_ACCEL_18;
+ gBankStartOffset[22] = SFX_CAR_ACCEL_19;
+ gBankStartOffset[8] = SFX_CAR_ACCEL_5;
+ gBankStartOffset[23] = SFX_CAR_ACCEL_20;
+ gBankStartOffset[14] = SFX_CAR_ACCEL_11;
+ gBankStartOffset[20] = SFX_CAR_ACCEL_17;
+ gBankStartOffset[18] = SFX_CAR_RC_HELI;
+ gBankStartOffset[25] = SFX_CAR_AFTER_ACCEL_21;
+ gBankStartOffset[26] = SFX_CAR_FINGER_OFF_ACCEL_21;
+ gBankStartOffset[27] = SFX_CAR_ACCEL_22;
+ gBankStartOffset[28] = SFX_CAR_AFTER_ACCEL_22;
+ gBankStartOffset[29] = SFX_CAR_FINGER_OFF_ACCEL_22;
+ gBankStartOffset[24] = SFX_CAR_ACCEL_21;
+ gBankStartOffset[30] = SFX_HELI_APACHE_1;
+ gBankStartOffset[31] = SFX_HELI_UNUSED_1;
+ gBankStartOffset[32] = SFX_HELI_UNUSED_2;
+ gBankStartOffset[33] = SFX_HELI_UNUSED_3;
+ gBankStartOffset[34] = SFX_HELI_UNUSED_4;
+ gBankStartOffset[35] = SFX_SEAPLANE_LOW;
+ gBankStartOffset[37] = SFX_PLANE_UNUSED_2;
+ gBankStartOffset[38] = SFX_PLANE_UNUSED_3;
+ gBankStartOffset[39] = SFX_PLANE_UNUSED_4;
+ gBankStartOffset[40] = SFX_BUILDINGS_BANK_ALARM;
+ gBankStartOffset[41] = SFX_BUILDING_SNORE;
+ gBankStartOffset[36] = SFX_PLANE_UNUSED_1;
+ gBankStartOffset[43] = SFX_BUILDING_BAR_2;
+ gBankStartOffset[44] = SFX_BUILDING_BAR_3;
+ gBankStartOffset[45] = SFX_BUILDING_BAR_4;
+ gBankStartOffset[46] = SFX_BUILDING_MALIBU_1;
+ gBankStartOffset[47] = SFX_BUILDING_MALIBU_2;
+ gBankStartOffset[42] = SFX_BUILDING_BAR_1;
+ gBankStartOffset[49] = SFX_BUILDING_STRIP_1;
+ gBankStartOffset[50] = SFX_BUILDING_STRIP_2;
+ gBankStartOffset[51] = SFX_BUILDING_STRIP_3;
+ gBankStartOffset[52] = SFX_BUILDING_CHURCH;
+ gBankStartOffset[53] = SFX_BUILDING_FAN_1;
+ gBankStartOffset[48] = SFX_BUILDING_MALIBU_3;
+ gBankStartOffset[55] = SFX_BUILDING_INSECTS_1;
+ gBankStartOffset[56] = SFX_BUILDING_INSECTS_2;
+ gBankStartOffset[54] = SFX_BUILDING_FAN_2;
+ gBankStartOffset[57] = SFX_CLUB_1;
+ gBankStartOffset[58] = SFX_CLUB_2;
+ gBankStartOffset[59] = SFX_CLUB_3;
+ gBankStartOffset[60] = SFX_CLUB_4;
+ gBankStartOffset[61] = SFX_FOOTSTEP_GRASS_1;
+ gBankStartOffset[62] = SFX_FOOTSTEP_GRAVEL_1;
+ gBankStartOffset[63] = SFX_FOOTSTEP_WOOD_1;
+ gBankStartOffset[64] = SFX_FOOTSTEP_METAL_1;
+ gBankStartOffset[65] = SFX_FOOTSTEP_WATER_1;
+ gBankStartOffset[66] = SFX_FOOTSTEP_SAND_1;
+}
+
void cSampleManager::SetSpeakerConfig(int32 nConfig)
{
@@ -764,7 +839,7 @@ cSampleManager::Initialise(void)
{
if ( _bSampmanInitialised )
return TRUE;
-
+ SetUpDebugBanksInfo();
EFXInit();
for(int i = 0; i < MAX_STREAMS; i++)
@@ -925,11 +1000,21 @@ cSampleManager::Initialise(void)
for ( int32 i = 0; i < TOTAL_STREAMED_SOUNDS; i++ )
{
- if ( aStream[0] && (
-#ifdef PS2_AUDIO_PATHS
- aStream[0]->Open(PS2StreamedNameTable[i], IsThisTrackAt16KHz(i) ? 16000 : 32000) ||
-#endif
- aStream[0]->Open(StreamedNameTable[i], IsThisTrackAt16KHz(i) ? 16000 : 32000)) )
+ bool opened = false;
+ char filename[MAX_PATH];
+ sprintf(filename, "%s.VB", StreamedNameTable[i]);
+ if ( aStream[0] )
+ opened = aStream[0]->Open(filename, IsThisTrackAt16KHz(i) ? 16000 : 32000);
+
+ if ( !opened )
+ {
+ sprintf(filename, "%s.MP3", StreamedNameTable[i]);
+ if ( aStream[0] )
+ {
+ opened = aStream[0]->Open(filename, IsThisTrackAt16KHz(i) ? 16000 : 32000);
+ }
+ }
+ if ( opened )
{
uint32 tatalms = aStream[0]->GetLengthMS();
aStream[0]->Close();
@@ -969,7 +1054,9 @@ cSampleManager::Initialise(void)
nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = (uintptr)malloc(PED_BLOCKSIZE*MAX_PEDSFX);
ASSERT(nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] != 0);
-#ifdef FIX_BUGS
+ nMissionSlotSfxStartAddress = (uintptr)malloc(MISSION_AUDIO_BLOCKSIZE*MISSION_AUDIO_SLOTS);
+ ASSERT(nMissionSlotSfxStartAddress != 0);
+
// Find biggest player comment
uint32 nMaxPedSize = 0;
for (uint32 i = PLAYER_COMMENTS_START; i <= PLAYER_COMMENTS_END; i++)
@@ -977,7 +1064,6 @@ cSampleManager::Initialise(void)
gPlayerTalkData = malloc(nMaxPedSize);
ASSERT(gPlayerTalkData != 0);
-#endif
LoadSampleBank(SFX_BANK_0);
}
@@ -1139,13 +1225,20 @@ cSampleManager::Terminate(void)
nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = 0;
}
-#ifdef FIX_BUGS
+ if ( nMissionSlotSfxStartAddress != 0 )
+ {
+ free((void*)nMissionSlotSfxStartAddress);
+ nMissionSlotSfxStartAddress = 0;
+
+ for ( uint32 i = 0; i < MISSION_AUDIO_SLOTS; i++ )
+ nMissionSlotSfx[i] = UINT32_MAX;
+ }
+
if ( gPlayerTalkData != 0 )
{
free(gPlayerTalkData);
gPlayerTalkData = 0;
}
-#endif
_bSampmanInitialised = FALSE;
}
@@ -1271,32 +1364,50 @@ cSampleManager::IsSampleBankLoaded(uint8 nBank)
return bSampleBankLoaded[nBank];
}
-#ifdef FIX_BUGS
bool8
cSampleManager::IsMissionAudioLoaded(uint8 nSlot, uint32 nSample)
{
- ASSERT(nSlot == MISSION_AUDIO_PLAYER_COMMENT); // only MISSION_AUDIO_PLAYER_COMMENT is supported on PC
-
- return nSample == gPlayerTalkSfx;
+ ASSERT(nSlot != MISSION_AUDIO_POLRADIO_CRIME_OR_COLOR && nSlot != MISSION_AUDIO_POLRADIO_AREA_OR_CAR); // these are not used in LCS
+
+ switch (nSlot)
+ {
+ case MISSION_AUDIO_SLOT_1:
+ case MISSION_AUDIO_SLOT_2:
+ return nMissionSlotSfx[nSlot] == nSample;
+ case MISSION_AUDIO_PLAYER_COMMENT:
+ return nSample == gPlayerTalkSfx;
+ }
+ return FALSE;
}
bool8
cSampleManager::LoadMissionAudio(uint8 nSlot, uint32 nSample)
{
- ASSERT(nSlot == MISSION_AUDIO_PLAYER_COMMENT); // only MISSION_AUDIO_PLAYER_COMMENT is supported on PC
+ ASSERT(nSlot != MISSION_AUDIO_POLRADIO_CRIME_OR_COLOR && nSlot != MISSION_AUDIO_POLRADIO_AREA_OR_CAR); // these are not used in LCS
ASSERT(nSample < TOTAL_AUDIO_SAMPLES);
if (fseek(fpSampleDataHandle, m_aSamples[nSample].nOffset, SEEK_SET) != 0)
return FALSE;
- if (fread(gPlayerTalkData, 1, m_aSamples[nSample].nSize, fpSampleDataHandle) != m_aSamples[nSample].nSize)
- return FALSE;
+ switch (nSlot)
+ {
+ case MISSION_AUDIO_SLOT_1:
+ case MISSION_AUDIO_SLOT_2:
+ if (fread((void*)(nMissionSlotSfxStartAddress + nSlot*MISSION_AUDIO_BLOCKSIZE), 1, m_aSamples[nSample].nSize, fpSampleDataHandle) != m_aSamples[nSample].nSize)
+ return FALSE;
- gPlayerTalkSfx = nSample;
+ nMissionSlotSfx[nSlot] = nSample;
+ break;
+ case MISSION_AUDIO_PLAYER_COMMENT:
+ if (fread(gPlayerTalkData, 1, m_aSamples[nSample].nSize, fpSampleDataHandle) != m_aSamples[nSample].nSize)
+ return FALSE;
+
+ gPlayerTalkSfx = nSample;
+ break;
+ }
return TRUE;
}
-#endif
bool8
cSampleManager::IsPedCommentLoaded(uint32 nComment)
@@ -1532,7 +1643,6 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank)
addr = nSampleBankMemoryStartAddress[nBank] + m_aSamples[nSfx].nOffset - m_aSamples[BankStartOffset[nBank]].nOffset;
}
-#ifdef FIX_BUGS
else if ( nSfx >= PLAYER_COMMENTS_START && nSfx <= PLAYER_COMMENTS_END )
{
if ( !IsMissionAudioLoaded(MISSION_AUDIO_PLAYER_COMMENT, nSfx) )
@@ -1540,16 +1650,23 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank)
addr = (uintptr)gPlayerTalkData;
}
-#endif
else
{
+ for ( uint32 i = 0; i < MISSION_AUDIO_SLOTS; i++ ) {
+ if ( IsMissionAudioLoaded(i, nSfx) ) {
+ addr = nMissionSlotSfxStartAddress + i * MISSION_AUDIO_BLOCKSIZE;
+ goto MissionAudioFound;
+ }
+ }
+
if ( !IsPedCommentLoaded(nSfx) )
return FALSE;
int32 slot = _GetPedCommentSlot(nSfx);
addr = (nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BLOCKSIZE * slot);
}
-
+
+MissionAudioFound:
if ( GetChannelUsedFlag(nChannel) )
{
TRACE("Stopping channel %d - really!!!", nChannel);
@@ -1610,7 +1727,7 @@ cSampleManager::SetChannelVolume(uint32 nChannel, uint32 nVolume)
ASSERT( nChannel >= MAXCHANNELS );
ASSERT( nChannel < NUM_CHANNELS );
- if ( nChannel == CHANNEL_POLICE_RADIO )
+ if( nChannel >= CHANNEL_POLICE_RADIO )
{
uint32 vol = nVolume;
if ( vol > MAX_VOLUME ) vol = MAX_VOLUME;
@@ -1635,7 +1752,7 @@ cSampleManager::SetChannelPan(uint32 nChannel, uint32 nPan)
ASSERT( nChannel >= MAXCHANNELS );
ASSERT( nChannel < NUM_CHANNELS );
- if ( nChannel == CHANNEL_POLICE_RADIO )
+ if ( nChannel >= CHANNEL_POLICE_RADIO )
{
aChannel[nChannel].SetPan(nPan);
}
@@ -1691,7 +1808,9 @@ cSampleManager::StopChannel(uint32 nChannel)
void
cSampleManager::PreloadStreamedFile(uint32 nFile, uint8 nStream)
-{
+{
+ char filename[MAX_PATH];
+
ASSERT( nStream < MAX_STREAMS );
if ( nFile < TOTAL_STREAMED_SOUNDS )
@@ -1699,11 +1818,15 @@ cSampleManager::PreloadStreamedFile(uint32 nFile, uint8 nStream)
CStream *stream = aStream[nStream];
stream->Close();
-#ifdef PS2_AUDIO_PATHS
- if(!stream->Open(PS2StreamedNameTable[nFile], IsThisTrackAt16KHz(nFile) ? 16000 : 32000))
-#endif
- stream->Open(StreamedNameTable[nFile], IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
- if ( !stream->Setup() )
+ sprintf(filename, "%s.VB", StreamedNameTable[nFile]);
+ bool opened = stream->Open(filename, IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
+ if ( !opened )
+ {
+ sprintf(filename, "%s.MP3", StreamedNameTable[nFile]);
+ opened = stream->Open(filename, IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
+ }
+
+ if ( opened && !stream->Setup() )
{
stream->Close();
}
@@ -1763,12 +1886,18 @@ cSampleManager::StartStreamedFile(uint32 nFile, uint32 nPos, uint8 nStream)
if(!_GetMP3PosFromStreamPos(&position, &e) && !e) {
nFile = 0;
+ sprintf(filename, "%s.VB", StreamedNameTable[nFile]);
+
CStream *stream = aStream[nStream];
-#ifdef PS2_AUDIO_PATHS
- if(!stream->Open(PS2StreamedNameTable[nFile], IsThisTrackAt16KHz(nFile) ? 16000 : 32000))
-#endif
- stream->Open(StreamedNameTable[nFile], IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
- if ( stream->Setup() ) {
+ bool opened = stream->Open(filename, IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
+
+ if ( !opened )
+ {
+ sprintf(filename, "%s.MP3", StreamedNameTable[nFile]);
+ opened = stream->Open(filename, IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
+ }
+
+ if ( opened && stream->Setup() ) {
stream->SetLoopCount(nStreamLoopedFlag[nStream] ? 0 : 1);
nStreamLoopedFlag[nStream] = TRUE;
if (position != 0)
@@ -1819,14 +1948,18 @@ cSampleManager::StartStreamedFile(uint32 nFile, uint32 nPos, uint8 nStream)
{
nFile = 0;
_bIsMp3Active = FALSE;
+ sprintf(filename, "%s.VB", StreamedNameTable[nFile]);
- CStream *stream = aStream[nStream];
-#ifdef PS2_AUDIO_PATHS
- if(!stream->Open(PS2StreamedNameTable[nFile], IsThisTrackAt16KHz(nFile) ? 16000 : 32000))
-#endif
- stream->Open(StreamedNameTable[nFile], IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
+ CStream* stream = aStream[nStream];
+ bool opened = stream->Open(filename, IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
- if (stream->Setup()) {
+ if ( !opened )
+ {
+ sprintf(filename, "%s.MP3", StreamedNameTable[nFile]);
+ opened = stream->Open(filename, IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
+ }
+
+ if (opened && stream->Setup()) {
stream->SetLoopCount(nStreamLoopedFlag[nStream] ? 0 : 1);
nStreamLoopedFlag[nStream] = TRUE;
if (position != 0)
@@ -1867,16 +2000,19 @@ cSampleManager::StartStreamedFile(uint32 nFile, uint32 nPos, uint8 nStream)
position = 0;
nFile = 0;
}
- strcpy(filename, StreamedNameTable[nFile]);
-
+ sprintf(filename, "%s.VB", StreamedNameTable[nFile]);
+
CStream *stream = aStream[nStream];
+
+ bool opened = stream->Open(filename, IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
-#ifdef PS2_AUDIO_PATHS
- if(!stream->Open(PS2StreamedNameTable[nFile], IsThisTrackAt16KHz(nFile) ? 16000 : 32000))
-#endif
- stream->Open(StreamedNameTable[nFile], IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
+ if ( !opened )
+ {
+ sprintf(filename, "%s.MP3", StreamedNameTable[nFile]);
+ opened = stream->Open(filename, IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
+ }
- if ( stream->Setup() ) {
+ if ( opened && stream->Setup() ) {
stream->SetLoopCount(nStreamLoopedFlag[nStream] ? 0 : 1);
nStreamLoopedFlag[nStream] = TRUE;
if (position != 0)