summaryrefslogtreecommitdiffstats
path: root/src/audio/sampman_miles.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/audio/sampman_miles.cpp')
-rw-r--r--src/audio/sampman_miles.cpp229
1 files changed, 189 insertions, 40 deletions
diff --git a/src/audio/sampman_miles.cpp b/src/audio/sampman_miles.cpp
index e820864c..0ba6b544 100644
--- a/src/audio/sampman_miles.cpp
+++ b/src/audio/sampman_miles.cpp
@@ -73,7 +73,7 @@ char _aHDDPath[MAX_PATH];
bool8 _bSampmanInitialised = FALSE;
-
+#ifdef EXTERNAL_3D_SOUND
//
// Miscellaneous globals / defines
@@ -93,10 +93,11 @@ S32 usingEAX=0;
S32 usingEAX3=0;
HPROVIDER opened_provider=0;
H3DSAMPLE opened_samples[MAXCHANNELS] = {0};
+#endif
HSAMPLE opened_2dsamples[MAX2DCHANNELS] = {0};
HDIGDRIVER DIG;
+#ifdef EXTERNAL_3D_SOUND
S32 speaker_type=0;
-
U32 _maxSamples;
float _fPrevEaxRatioDestination;
bool8 _usingMilesFast2D;
@@ -263,6 +264,7 @@ set_new_provider(S32 index)
return FALSE;
}
+#endif
cSampleManager::cSampleManager(void) :
m_nNumberOfProviders(0)
@@ -275,6 +277,7 @@ cSampleManager::~cSampleManager(void)
}
+#ifdef EXTERNAL_3D_SOUND
void
cSampleManager::SetSpeakerConfig(int32 which)
{
@@ -353,6 +356,7 @@ cSampleManager::SetCurrent3DProvider(uint8 nProvider)
else
return curprovider;
}
+#endif
static bool8
_ResolveLink(char const *path, char *out)
@@ -823,9 +827,11 @@ cSampleManager::ReleaseDigitalHandle(void)
{
if ( DIG )
{
+#ifdef EXTERNAL_3D_SOUND
prevprovider = curprovider;
release_existing();
curprovider = -1;
+#endif
AIL_digital_handle_release(DIG);
}
}
@@ -836,8 +842,10 @@ cSampleManager::ReacquireDigitalHandle(void)
if ( DIG )
{
AIL_digital_handle_reacquire(DIG);
+#ifdef EXTERNAL_3D_SOUND
if ( prevprovider != -1 )
set_new_provider(prevprovider);
+#endif
}
}
@@ -866,7 +874,8 @@ cSampleManager::Initialise(void)
m_nMonoMode = 0;
}
-
+
+#ifdef EXTERNAL_3D_SOUND
// miles
TRACE("MILES");
{
@@ -887,6 +896,7 @@ cSampleManager::Initialise(void)
for ( int32 i = 0; i < MAXCHANNELS; i++ )
opened_samples[i] = NULL;
}
+#endif
// banks
TRACE("banks");
@@ -939,8 +949,10 @@ cSampleManager::Initialise(void)
Terminate();
return FALSE;
}
-
+
+#ifdef EXTERNAL_3D_SOUND
add_providers();
+#endif
if ( !InitialiseSampleBanks() )
{
@@ -992,11 +1004,20 @@ cSampleManager::Initialise(void)
if ( GetDriveType(m_szCDRomRootPath) == DRIVE_CDROM )
{
+ FILE *f;
+#ifdef PS2_AUDIO_PATHS
strcpy(filepath, m_szCDRomRootPath);
- strcat(filepath, StreamedNameTable[0]);
-
- FILE *f = fopen(filepath, "rb");
+ strcat(filepath, PS2StreamedNameTable[0]);
+ f = fopen(filepath, "rb");
+
+ if ( !f )
+#endif
+ {
+ strcpy(filepath, m_szCDRomRootPath);
+ strcat(filepath, StreamedNameTable[0]);
+ f = fopen(filepath, "rb");
+ }
if ( f )
{
fclose(f);
@@ -1005,11 +1026,20 @@ cSampleManager::Initialise(void)
for ( int32 i = 0; i < TOTAL_STREAMED_SOUNDS; i++ )
{
+#ifdef PS2_AUDIO_PATHS
strcpy(filepath, m_szCDRomRootPath);
- strcat(filepath, StreamedNameTable[i]);
-
+ strcat(filepath, PS2StreamedNameTable[i]);
+
mp3Stream[0] = AIL_open_stream(DIG, filepath, 0);
-
+ if ( !mp3Stream[0] )
+#endif
+ {
+ strcpy(filepath, m_szCDRomRootPath);
+ strcat(filepath, StreamedNameTable[i]);
+
+ mp3Stream[0] = AIL_open_stream(DIG, filepath, 0);
+ }
+
if ( mp3Stream[0] )
{
AIL_stream_ms_position(mp3Stream[0], &tatalms, NULL);
@@ -1078,7 +1108,14 @@ cSampleManager::Initialise(void)
strcpy(_aHDDPath, m_szCDRomRootPath);
rootpath[0] = '\0';
- FILE *f = fopen(StreamedNameTable[0], "rb");
+ FILE *f;
+
+#ifdef PS2_AUDIO_PATHS
+ f = fopen(PS2StreamedNameTable[0], "rb");
+ if (!f)
+#endif
+
+ f = fopen(StreamedNameTable[0], "rb");
if ( f )
{
@@ -1086,11 +1123,20 @@ cSampleManager::Initialise(void)
for ( int32 i = 0; i < TOTAL_STREAMED_SOUNDS; i++ )
{
+#ifdef PS2_AUDIO_PATHS
strcpy(filepath, rootpath);
- strcat(filepath, StreamedNameTable[i]);
-
+ strcat(filepath, PS2StreamedNameTable[i]);
+
mp3Stream[0] = AIL_open_stream(DIG, filepath, 0);
-
+ if ( !mp3Stream[0] )
+#endif
+ {
+ strcpy(filepath, rootpath);
+ strcat(filepath, StreamedNameTable[i]);
+
+ mp3Stream[0] = AIL_open_stream(DIG, filepath, 0);
+ }
+
if ( mp3Stream[0] )
{
AIL_stream_ms_position(mp3Stream[0], &tatalms, NULL);
@@ -1154,7 +1200,8 @@ cSampleManager::Initialise(void)
TRACE("providerset");
{
_bSampmanInitialised = TRUE;
-
+
+#ifdef EXTERNAL_3D_SOUND
U32 n = 0;
while ( n < m_nNumberOfProviders )
@@ -1172,6 +1219,7 @@ cSampleManager::Initialise(void)
Terminate();
return FALSE;
}
+#endif
}
TRACE("bank");
@@ -1211,7 +1259,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;
@@ -1222,7 +1270,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 )
@@ -1231,7 +1279,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
@@ -1266,8 +1314,10 @@ cSampleManager::Terminate(void)
opened_2dsamples[i] = NULL;
}
}
-
+
+#ifdef EXTERNAL_3D_SOUND
release_existing();
+#endif
_DeleteMP3Entries();
@@ -1299,9 +1349,11 @@ cSampleManager::CheckForAnAudioFileOnCD(void)
{
#if GTA_VERSION < GTA3_PC_STEAM && !defined(NO_CDCHECK)
char filepath[MAX_PATH];
+ FILE *f;
+#ifdef PS2_AUDIO_PATHS
#if GTA_VERSION >= GTA3_PC_11
- if (_bUseHDDAudio)
+ if(_bUseHDDAudio)
strcpy(filepath, _aHDDPath);
else
strcpy(filepath, m_szCDRomRootPath);
@@ -1309,10 +1361,25 @@ cSampleManager::CheckForAnAudioFileOnCD(void)
strcpy(filepath, m_szCDRomRootPath);
#endif // #if GTA_VERSION >= GTA3_PC_11
- strcat(filepath, StreamedNameTable[AudioManager.GetRandomNumber(1) % TOTAL_STREAMED_SOUNDS]);
-
- FILE *f = fopen(filepath, "rb");
+ strcat(filepath, PS2StreamedNameTable[AudioManager.m_anRandomTable[1] % TOTAL_STREAMED_SOUNDS]);
+
+ f = fopen(filepath, "rb");
+ if ( !f )
+#endif // PS2_AUDIO_PATHS
+ {
+#if GTA_VERSION >= GTA3_PC_11
+ if (_bUseHDDAudio)
+ strcpy(filepath, _aHDDPath);
+ else
+ strcpy(filepath, m_szCDRomRootPath);
+#else
+ strcpy(filepath, m_szCDRomRootPath);
+#endif // #if GTA_VERSION >= GTA3_PC_11
+
+ strcat(filepath, StreamedNameTable[AudioManager.m_anRandomTable[1] % TOTAL_STREAMED_SOUNDS]);
+ f = fopen(filepath, "rb");
+ }
if ( f )
{
fclose(f);
@@ -1360,6 +1427,7 @@ cSampleManager::UpdateEffectsVolume(void) //[Y], cSampleManager::UpdateSoundBuff
{
for ( int32 i = 0; i < MAXCHANNELS+MAX2DCHANNELS; i++ )
{
+#ifdef EXTERNAL_3D_SOUND
if ( i < MAXCHANNELS )
{
if ( opened_samples[i] && GetChannelUsedFlag(i) )
@@ -1372,6 +1440,7 @@ cSampleManager::UpdateEffectsVolume(void) //[Y], cSampleManager::UpdateSoundBuff
}
}
else
+#endif
{
if ( opened_2dsamples[i - MAXCHANNELS] )
{
@@ -1577,15 +1646,16 @@ cSampleManager::GetSampleLength(uint32 nSample)
bool8
cSampleManager::UpdateReverb(void)
{
+#ifdef EXTERNAL_3D_SOUND
if ( !usingEAX )
return FALSE;
- if ( AudioManager.GetFrameCounter() & 15 )
+ if ( AudioManager.m_FrameCounter & 15 )
return FALSE;
- float y = AudioManager.GetReflectionsDistance(REFLECTION_TOP) + AudioManager.GetReflectionsDistance(REFLECTION_BOTTOM);
- float x = AudioManager.GetReflectionsDistance(REFLECTION_LEFT) + AudioManager.GetReflectionsDistance(REFLECTION_RIGHT);
- float z = AudioManager.GetReflectionsDistance(REFLECTION_UP);
+ float y = AudioManager.m_afReflectionsDistances[REFLECTION_TOP] + AudioManager.m_afReflectionsDistances[REFLECTION_BOTTOM];
+ float x = AudioManager.m_afReflectionsDistances[REFLECTION_LEFT] + AudioManager.m_afReflectionsDistances[REFLECTION_RIGHT];
+ float z = AudioManager.m_afReflectionsDistances[REFLECTION_UP];
float normy = norm(y, 5.0f, 40.0f);
float normx = norm(x, 5.0f, 40.0f);
@@ -1649,11 +1719,14 @@ cSampleManager::UpdateReverb(void)
_fPrevEaxRatioDestination = fRatio;
return TRUE;
+#endif
+ return FALSE;
}
void
cSampleManager::SetChannelReverbFlag(uint32 nChannel, bool8 nReverbFlag)
{
+#ifdef EXTERNAL_3D_SOUND
bool8 b2d = FALSE;
switch ( nChannel )
@@ -1678,11 +1751,13 @@ cSampleManager::SetChannelReverbFlag(uint32 nChannel, bool8 nReverbFlag)
AIL_set_3D_sample_effects_level(opened_samples[nChannel], 0.0f);
}
}
+#endif
}
bool8
cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank)
{
+#ifdef EXTERNAL_3D_SOUND
bool8 b2d = FALSE;
switch ( nChannel )
@@ -1693,6 +1768,7 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank)
break;
}
}
+#endif
int32 addr;
@@ -1712,9 +1788,11 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank)
addr = nPedSlotSfxAddr[slot];
}
-
+
+#ifdef EXTERNAL_3D_SOUND
if ( b2d )
{
+#endif
if ( opened_2dsamples[nChannel - MAXCHANNELS] )
{
AIL_set_sample_address(opened_2dsamples[nChannel - MAXCHANNELS], (void *)addr, m_aSamples[nSfx].nSize);
@@ -1722,6 +1800,7 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank)
}
else
return FALSE;
+#ifdef EXTERNAL_3D_SOUND
}
else
{
@@ -1742,8 +1821,10 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank)
return TRUE;
}
+#endif
}
+#ifdef EXTERNAL_3D_SOUND
void
cSampleManager::SetChannelEmittingVolume(uint32 nChannel, uint32 nVolume)
{
@@ -1778,17 +1859,20 @@ cSampleManager::SetChannel3DDistances(uint32 nChannel, float fMax, float fMin)
if ( opened_samples[nChannel] )
AIL_set_3D_sample_distances(opened_samples[nChannel], fMax, fMin);
}
+#endif
void
cSampleManager::SetChannelVolume(uint32 nChannel, uint32 nVolume)
{
uint32 vol = nVolume;
if ( vol > MAX_VOLUME ) vol = MAX_VOLUME;
-
+
+#ifdef EXTERNAL_3D_SOUND
switch ( nChannel )
{
case CHANNEL_POLICE_RADIO:
{
+#endif
nChannelVolume[nChannel] = vol;
// increase the volume for JB.MP3 and S4_BDBD.MP3
@@ -1804,34 +1888,41 @@ cSampleManager::SetChannelVolume(uint32 nChannel, uint32 nVolume)
AIL_set_sample_volume(opened_2dsamples[nChannel - MAXCHANNELS],
m_nEffectsFadeVolume*vol*m_nEffectsVolume >> 14);
}
-
+
+#ifdef EXTERNAL_3D_SOUND
break;
}
}
+#endif
}
void
cSampleManager::SetChannelPan(uint32 nChannel, uint32 nPan)
{
+#ifdef EXTERNAL_3D_SOUND
switch ( nChannel )
{
case CHANNEL_POLICE_RADIO:
{
-#ifndef FIX_BUGS
+#endif
+#if !defined(FIX_BUGS) && defined(EXTERNAL_3D_SOUND)
if ( opened_samples[nChannel - MAXCHANNELS] ) // BUG
#else
if ( opened_2dsamples[nChannel - MAXCHANNELS] )
#endif
AIL_set_sample_pan(opened_2dsamples[nChannel - MAXCHANNELS], nPan);
+#ifdef EXTERNAL_3D_SOUND
break;
}
}
+#endif
}
void
cSampleManager::SetChannelFrequency(uint32 nChannel, uint32 nFreq)
{
+#ifdef EXTERNAL_3D_SOUND
bool8 b2d = FALSE;
switch ( nChannel )
@@ -1845,19 +1936,23 @@ cSampleManager::SetChannelFrequency(uint32 nChannel, uint32 nFreq)
if ( b2d )
{
+#endif
if ( opened_2dsamples[nChannel - MAXCHANNELS] )
AIL_set_sample_playback_rate(opened_2dsamples[nChannel - MAXCHANNELS], nFreq);
+#ifdef EXTERNAL_3D_SOUND
}
else
{
if ( opened_samples[nChannel] )
AIL_set_3D_sample_playback_rate(opened_samples[nChannel], nFreq);
}
+#endif
}
void
cSampleManager::SetChannelLoopPoints(uint32 nChannel, uint32 nLoopStart, int32 nLoopEnd)
{
+#ifdef EXTERNAL_3D_SOUND
bool8 b2d = FALSE;
switch ( nChannel )
@@ -1871,19 +1966,23 @@ cSampleManager::SetChannelLoopPoints(uint32 nChannel, uint32 nLoopStart, int32 n
if ( b2d )
{
+#endif
if ( opened_2dsamples[nChannel - MAXCHANNELS] )
AIL_set_sample_loop_block(opened_2dsamples[nChannel - MAXCHANNELS], nLoopStart, nLoopEnd);
+#ifdef EXTERNAL_3D_SOUND
}
else
{
if ( opened_samples[nChannel] )
AIL_set_3D_sample_loop_block(opened_samples[nChannel], nLoopStart, nLoopEnd);
}
+#endif
}
void
cSampleManager::SetChannelLoopCount(uint32 nChannel, uint32 nLoopCount)
{
+#ifdef EXTERNAL_3D_SOUND
bool8 b2d = FALSE;
switch ( nChannel )
@@ -1897,19 +1996,23 @@ cSampleManager::SetChannelLoopCount(uint32 nChannel, uint32 nLoopCount)
if ( b2d )
{
+#endif
if ( opened_2dsamples[nChannel - MAXCHANNELS] )
AIL_set_sample_loop_count(opened_2dsamples[nChannel - MAXCHANNELS], nLoopCount);
+#ifdef EXTERNAL_3D_SOUND
}
else
{
if ( opened_samples[nChannel] )
AIL_set_3D_sample_loop_count(opened_samples[nChannel], nLoopCount);
}
+#endif
}
bool8
cSampleManager::GetChannelUsedFlag(uint32 nChannel)
{
+#ifdef EXTERNAL_3D_SOUND
bool8 b2d = FALSE;
switch ( nChannel )
@@ -1923,10 +2026,12 @@ cSampleManager::GetChannelUsedFlag(uint32 nChannel)
if ( b2d )
{
+#endif
if ( opened_2dsamples[nChannel - MAXCHANNELS] )
return AIL_sample_status(opened_2dsamples[nChannel - MAXCHANNELS]) == SMP_PLAYING;
else
return FALSE;
+#ifdef EXTERNAL_3D_SOUND
}
else
{
@@ -1935,12 +2040,14 @@ cSampleManager::GetChannelUsedFlag(uint32 nChannel)
else
return FALSE;
}
+#endif
}
void
cSampleManager::StartChannel(uint32 nChannel)
{
+#ifdef EXTERNAL_3D_SOUND
bool8 b2d = FALSE;
switch ( nChannel )
@@ -1954,19 +2061,23 @@ cSampleManager::StartChannel(uint32 nChannel)
if ( b2d )
{
+#endif
if ( opened_2dsamples[nChannel - MAXCHANNELS] )
AIL_start_sample(opened_2dsamples[nChannel - MAXCHANNELS]);
+#ifdef EXTERNAL_3D_SOUND
}
else
{
if ( opened_samples[nChannel] )
AIL_start_3D_sample(opened_samples[nChannel]);
}
+#endif
}
void
cSampleManager::StopChannel(uint32 nChannel)
{
+#ifdef EXTERNAL_3D_SOUND
bool8 b2d = FALSE;
switch ( nChannel )
@@ -1980,8 +2091,10 @@ cSampleManager::StopChannel(uint32 nChannel)
if ( b2d )
{
+#endif
if ( opened_2dsamples[nChannel - MAXCHANNELS] )
AIL_end_sample(opened_2dsamples[nChannel - MAXCHANNELS]);
+#ifdef EXTERNAL_3D_SOUND
}
else
{
@@ -1991,6 +2104,7 @@ cSampleManager::StopChannel(uint32 nChannel)
AIL_end_3D_sample(opened_samples[nChannel]);
}
}
+#endif
}
void
@@ -2007,11 +2121,19 @@ cSampleManager::PreloadStreamedFile(uint8 nFile, uint8 nStream)
}
char filepath[MAX_PATH];
-
+#ifdef PS2_AUDIO_PATHS
strcpy(filepath, m_szCDRomRootPath);
- strcat(filepath, StreamedNameTable[nFile]);
-
+ strcat(filepath, PS2StreamedNameTable[nFile]);
+
mp3Stream[nStream] = AIL_open_stream(DIG, filepath, 0);
+ if ( !mp3Stream[nStream] )
+#endif
+ {
+ strcpy(filepath, m_szCDRomRootPath);
+ strcat(filepath, StreamedNameTable[nFile]);
+
+ mp3Stream[nStream] = AIL_open_stream(DIG, filepath, 0);
+ }
if ( mp3Stream[nStream] )
{
@@ -2073,10 +2195,19 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream)
// Try to continue from previous song, if already started
if(!_GetMP3PosFromStreamPos(&position, &e) && !e) {
nFile = 0;
+#ifdef PS2_AUDIO_PATHS
strcpy(filename, m_szCDRomRootPath);
- strcat(filename, StreamedNameTable[nFile]);
-
+ strcat(filename, PS2StreamedNameTable[nFile]);
+
mp3Stream[nStream] = AIL_open_stream(DIG, filename, 0);
+ if ( !mp3Stream[nStream] )
+#endif
+ {
+ strcpy(filename, m_szCDRomRootPath);
+ strcat(filename, StreamedNameTable[nFile]);
+
+ mp3Stream[nStream] = AIL_open_stream(DIG, filename, 0);
+ }
if ( mp3Stream[nStream] )
{
AIL_set_stream_loop_count(mp3Stream[nStream], 1);
@@ -2120,10 +2251,19 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream)
{
nFile = 0;
_bIsMp3Active = 0;
+#ifdef PS2_AUDIO_PATHS
strcpy(filename, m_szCDRomRootPath);
- strcat(filename, StreamedNameTable[nFile]);
-
+ strcat(filename, PS2StreamedNameTable[nFile]);
+
mp3Stream[nStream] = AIL_open_stream(DIG, filename, 0);
+ if ( !mp3Stream[nStream] )
+#endif
+ {
+ strcpy(filename, m_szCDRomRootPath);
+ strcat(filename, StreamedNameTable[nFile]);
+
+ mp3Stream[nStream] = AIL_open_stream(DIG, filename, 0);
+ }
if ( mp3Stream[nStream] )
{
AIL_set_stream_loop_count(mp3Stream[nStream], 1);
@@ -2161,10 +2301,19 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream)
position = 0;
nFile = 0;
}
+#ifdef PS2_AUDIO_PATHS
strcpy(filename, m_szCDRomRootPath);
- strcat(filename, StreamedNameTable[nFile]);
-
+ strcat(filename, PS2StreamedNameTable[nFile]);
+
mp3Stream[nStream] = AIL_open_stream(DIG, filename, 0);
+ if ( !mp3Stream[nStream] )
+#endif
+ {
+ strcpy(filename, m_szCDRomRootPath);
+ strcat(filename, StreamedNameTable[nFile]);
+
+ mp3Stream[nStream] = AIL_open_stream(DIG, filename, 0);
+ }
if ( mp3Stream[nStream] )
{
AIL_set_stream_loop_count(mp3Stream[nStream], 1);