From b3581bc0b4eb40cefe9261dae7a7ae70c16322d5 Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Fri, 1 Jan 2021 16:43:26 +0100 Subject: Overhaul and enable cache for openal build --- src/audio/sampman_oal.cpp | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'src/audio') diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp index eec5ca5f..7d6f429d 100644 --- a/src/audio/sampman_oal.cpp +++ b/src/audio/sampman_oal.cpp @@ -956,33 +956,37 @@ cSampleManager::Initialise(void) #ifdef AUDIO_CACHE FILE *cacheFile = fcaseopen("audio\\sound.cache", "rb"); if (cacheFile) { + debug("Loadind audio cache (If game crashes around here, then your cache is corrupted, remove audio/sound.cache)\n"); fread(nStreamLength, sizeof(uint32), TOTAL_STREAMED_SOUNDS, cacheFile); fclose(cacheFile); } else -#endif { - - for ( int32 i = 0; i < TOTAL_STREAMED_SOUNDS; i++ ) - { + debug("Cannot load audio cache\n"); +#endif + + for(int32 i = 0; i < TOTAL_STREAMED_SOUNDS; i++) { aStream[0] = new CStream(StreamedNameTable[i], ALStreamSources[0], ALStreamBuffers[0]); - - if ( aStream[0] && aStream[0]->IsOpened() ) - { + + if(aStream[0] && aStream[0]->IsOpened()) { uint32 tatalms = aStream[0]->GetLengthMS(); delete aStream[0]; aStream[0] = NULL; - + nStreamLength[i] = tatalms; - } - else + } else USERERROR("Can't open '%s'\n", StreamedNameTable[i]); } #ifdef AUDIO_CACHE cacheFile = fcaseopen("audio\\sound.cache", "wb"); - fwrite(nStreamLength, sizeof(uint32), TOTAL_STREAMED_SOUNDS, cacheFile); - fclose(cacheFile); -#endif + if(cacheFile) { + debug("Saving audio cache\n"); + fwrite(nStreamLength, sizeof(uint32), TOTAL_STREAMED_SOUNDS, cacheFile); + fclose(cacheFile); + } else { + debug("Cannot save audio cache\n"); + } } +#endif { if ( !InitialiseSampleBanks() ) -- cgit v1.2.3 From 941e70a70111beeb108fadb2af48db19c41e24eb Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sun, 3 Jan 2021 16:44:21 +0200 Subject: Sync miami things --- src/audio/AudioManager.cpp | 9 ++++++--- src/audio/AudioManager.h | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'src/audio') diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index 868f1b65..e1b5be1d 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -17,12 +17,15 @@ const int channels = ARRAY_SIZE(cAudioManager::m_asActiveSamples); const int policeChannel = channels + 1; const int allChannels = channels + 2; +#define SPEED_OF_SOUND 343.f +#define TIME_SPENT 50 + cAudioManager::cAudioManager() { m_bIsInitialised = false; - field_1 = 1; - m_fSpeedOfSound = 6.86f; - m_nTimeSpent = 50; + m_bReverb = true; + m_fSpeedOfSound = SPEED_OF_SOUND / TIME_SPENT; + m_nTimeSpent = TIME_SPENT; m_nActiveSamples = NUM_SOUNDS_SAMPLES_SLOTS; m_nActiveSampleQueue = 1; ClearRequestedQueue(); diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index 9fe2f4ef..2f86ee98 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -185,7 +185,7 @@ class cAudioManager { public: bool m_bIsInitialised; - uint8 field_1; // unused + bool m_bReverb; // unused bool m_bFifthFrameFlag; uint8 m_nActiveSamples; uint8 field_4; // unused -- cgit v1.2.3 From 150f5302b735331780815194fb7d397a477fcb19 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Mon, 4 Jan 2021 22:46:50 +0200 Subject: Handle stereo panning in OAL manually for streams --- src/audio/oal/stream.cpp | 213 +++++++++++++++++++++++++++++++++++----------- src/audio/oal/stream.h | 10 +-- src/audio/sampman_oal.cpp | 21 +++-- 3 files changed, 184 insertions(+), 60 deletions(-) (limited to 'src/audio') diff --git a/src/audio/oal/stream.cpp b/src/audio/oal/stream.cpp index 90e90dd8..f36985e5 100644 --- a/src/audio/oal/stream.cpp +++ b/src/audio/oal/stream.cpp @@ -19,6 +19,64 @@ #include "crossplatform.h" #endif +/* +As we ran onto an issue of having different volume levels for mono streams +and stereo streams we are now handling all the stereo panning ourselves. +Each stream now has two sources - one panned to the left and one to the right, +and uses two separate buffers to store data for each individual channel. +For that we also have to reshuffle all decoded PCM stereo data from LRLRLRLR to +LLLLRRRR (handled by CSortStereoBuffer). +*/ + +class CSortStereoBuffer +{ + uint16* PcmBuf; + size_t BufSize; +public: + CSortStereoBuffer() : PcmBuf(nil), BufSize(0) {} + ~CSortStereoBuffer() + { + if (PcmBuf) + free(PcmBuf); + } + + uint16* GetBuffer(size_t size) + { + if (size == 0) return nil; + if (!PcmBuf) + { + BufSize = size; + PcmBuf = (uint16*)malloc(BufSize); + } + else if (BufSize < size) + { + BufSize = size; + PcmBuf = (uint16*)realloc(PcmBuf, size); + } + return PcmBuf; + } + + void SortStereo(void* buf, size_t size) + { + uint16* InBuf = (uint16*)buf; + uint16* OutBuf = GetBuffer(size); + + if (!OutBuf) return; + + size_t rightStart = size / 4; + for (size_t i = 0; i < size / 4; i++) + { + OutBuf[i] = InBuf[i*2]; + OutBuf[i+rightStart] = InBuf[i*2+1]; + } + + memcpy(InBuf, OutBuf, size); + } + +}; + +CSortStereoBuffer SortStereoBuffer; + #ifndef AUDIO_OPUS class CSndFile : public IDecoder { @@ -81,7 +139,11 @@ public: uint32 Decode(void *buffer) { if ( !IsOpened() ) return 0; - return sf_read_short(m_pfSound, (short *)buffer, GetBufferSamples()) * GetSampleSize(); + + size_t size = sf_read_short(m_pfSound, (short*)buffer, GetBufferSamples()) * GetSampleSize(); + if (GetChannels()==2) + SortStereoBuffer.SortStereo(buffer, size); + return size; } }; @@ -101,6 +163,8 @@ public: m_pMH = mpg123_new(nil, nil); if ( m_pMH ) { + mpg123_param(m_pMH, MPG123_FLAGS, MPG123_FUZZY | MPG123_SEEKBUFFER | MPG123_GAPLESS, 0.0); + long rate = 0; int channels = 0; int encoding = 0; @@ -176,6 +240,8 @@ public: assert("We can't handle audio files more then 2 GB yet :shrug:" && (size < UINT32_MAX)); #endif if (err != MPG123_OK && err != MPG123_DONE) return 0; + if (GetChannels() == 2) + SortStereoBuffer.SortStereo(buffer, size); return (uint32)size; } }; @@ -267,6 +333,9 @@ public: if (size < 0) return 0; + if (GetChannels() == 2) + SortStereoBuffer.SortStereo(buffer, size * m_nChannels * GetSampleSize()); + return size * m_nChannels * GetSampleSize(); } }; @@ -286,8 +355,8 @@ void CStream::Terminate() #endif } -CStream::CStream(char *filename, ALuint &source, ALuint (&buffers)[NUM_STREAMBUFFERS]) : - m_alSource(source), +CStream::CStream(char *filename, ALuint *sources, ALuint (&buffers)[NUM_STREAMBUFFERS]) : + m_pAlSources(sources), m_alBuffers(buffers), m_pBuffer(nil), m_bPaused(false), @@ -368,7 +437,7 @@ void CStream::Delete() bool CStream::HasSource() { - return m_alSource != AL_NONE; + return (m_pAlSources[0] != AL_NONE) && (m_pAlSources[1] != AL_NONE); } bool CStream::IsOpened() @@ -382,9 +451,10 @@ bool CStream::IsPlaying() if ( !m_bPaused ) { - ALint sourceState; - alGetSourcei(m_alSource, AL_SOURCE_STATE, &sourceState); - if ( m_bActive || sourceState == AL_PLAYING ) + ALint sourceState[2]; + alGetSourcei(m_pAlSources[0], AL_SOURCE_STATE, &sourceState[0]); + alGetSourcei(m_pAlSources[1], AL_SOURCE_STATE, &sourceState[1]); + if ( m_bActive || sourceState[0] == AL_PLAYING || sourceState[1] == AL_PLAYING) return true; } @@ -395,9 +465,12 @@ void CStream::Pause() { if ( !HasSource() ) return; ALint sourceState = AL_PAUSED; - alGetSourcei(m_alSource, AL_SOURCE_STATE, &sourceState); + alGetSourcei(m_pAlSources[0], AL_SOURCE_STATE, &sourceState); if (sourceState != AL_PAUSED ) - alSourcePause(m_alSource); + alSourcePause(m_pAlSources[0]); + alGetSourcei(m_pAlSources[1], AL_SOURCE_STATE, &sourceState); + if (sourceState != AL_PAUSED) + alSourcePause(m_pAlSources[1]); } void CStream::SetPause(bool bPause) @@ -419,19 +492,21 @@ void CStream::SetPause(bool bPause) void CStream::SetPitch(float pitch) { if ( !HasSource() ) return; - alSourcef(m_alSource, AL_PITCH, pitch); + alSourcef(m_pAlSources[0], AL_PITCH, pitch); + alSourcef(m_pAlSources[1], AL_PITCH, pitch); } void CStream::SetGain(float gain) { if ( !HasSource() ) return; - alSourcef(m_alSource, AL_GAIN, gain); + alSourcef(m_pAlSources[0], AL_GAIN, gain); + alSourcef(m_pAlSources[1], AL_GAIN, gain); } -void CStream::SetPosition(float x, float y, float z) +void CStream::SetPosition(int i, float x, float y, float z) { if ( !HasSource() ) return; - alSource3f(m_alSource, AL_POSITION, x, y, z); + alSource3f(m_pAlSources[i], AL_POSITION, x, y, z); } void CStream::SetVolume(uint32 nVol) @@ -442,8 +517,13 @@ void CStream::SetVolume(uint32 nVol) void CStream::SetPan(uint8 nPan) { + m_nPan = clamp((int8)nPan - 63, 0, 63); + SetPosition(0, (m_nPan - 63) / 64.0f, 0.0f, Sqrt(1.0f - SQR((m_nPan - 63) / 64.0f))); + + m_nPan = clamp((int8)nPan + 64, 64, 127); + SetPosition(1, (m_nPan - 63) / 64.0f, 0.0f, Sqrt(1.0f - SQR((m_nPan - 63) / 64.0f))); + m_nPan = nPan; - SetPosition((nPan - 63)/64.0f, 0.0f, Sqrt(1.0f-SQR((nPan-63)/64.0f))); } void CStream::SetPosMS(uint32 nPos) @@ -460,10 +540,10 @@ uint32 CStream::GetPosMS() ALint offset; //alGetSourcei(m_alSource, AL_SAMPLE_OFFSET, &offset); - alGetSourcei(m_alSource, AL_BYTE_OFFSET, &offset); + alGetSourcei(m_pAlSources[0], AL_BYTE_OFFSET, &offset); return m_pSoundFile->Tell() - - m_pSoundFile->samples2ms(m_pSoundFile->GetBufferSamples() * (NUM_STREAMBUFFERS-1)) / m_pSoundFile->GetChannels() + - m_pSoundFile->samples2ms(m_pSoundFile->GetBufferSamples() * (NUM_STREAMBUFFERS/2-1)) / m_pSoundFile->GetChannels() + m_pSoundFile->samples2ms(offset/m_pSoundFile->GetSampleSize()) / m_pSoundFile->GetChannels(); } @@ -473,33 +553,41 @@ uint32 CStream::GetLengthMS() return m_pSoundFile->GetLength(); } -bool CStream::FillBuffer(ALuint alBuffer) +bool CStream::FillBuffer(ALuint *alBuffer) { if ( !HasSource() ) return false; if ( !IsOpened() ) return false; - if ( !(alBuffer != AL_NONE && alIsBuffer(alBuffer)) ) + if ( !(alBuffer[0] != AL_NONE && alIsBuffer(alBuffer[0])) ) + return false; + if ( !(alBuffer[1] != AL_NONE && alIsBuffer(alBuffer[1])) ) return false; uint32 size = m_pSoundFile->Decode(m_pBuffer); if( size == 0 ) return false; + + uint32 channelSize = size / m_pSoundFile->GetChannels(); - alBufferData(alBuffer, m_pSoundFile->GetChannels() == 1 ? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16, - m_pBuffer, size, m_pSoundFile->GetSampleRate()); - + alBufferData(alBuffer[0], AL_FORMAT_MONO16, m_pBuffer, channelSize, m_pSoundFile->GetSampleRate()); + // TODO: use just one buffer if we play mono + if (m_pSoundFile->GetChannels() == 1) + alBufferData(alBuffer[1], AL_FORMAT_MONO16, m_pBuffer, channelSize, m_pSoundFile->GetSampleRate()); + else + alBufferData(alBuffer[1], AL_FORMAT_MONO16, (uint8*)m_pBuffer + channelSize, channelSize, m_pSoundFile->GetSampleRate()); return true; } int32 CStream::FillBuffers() { int32 i = 0; - for ( i = 0; i < NUM_STREAMBUFFERS; i++ ) + for ( i = 0; i < NUM_STREAMBUFFERS/2; i++ ) { - if ( !FillBuffer(m_alBuffers[i]) ) + if ( !FillBuffer(&m_alBuffers[i*2]) ) break; - alSourceQueueBuffers(m_alSource, 1, &m_alBuffers[i]); + alSourceQueueBuffers(m_pAlSources[0], 1, &m_alBuffers[i*2]); + alSourceQueueBuffers(m_pAlSources[1], 1, &m_alBuffers[i*2+1]); } return i; @@ -508,13 +596,16 @@ int32 CStream::FillBuffers() void CStream::ClearBuffers() { if ( !HasSource() ) return; - - ALint buffersQueued; - alGetSourcei(m_alSource, AL_BUFFERS_QUEUED, &buffersQueued); + + ALint buffersQueued[2]; + alGetSourcei(m_pAlSources[0], AL_BUFFERS_QUEUED, &buffersQueued[0]); + alGetSourcei(m_pAlSources[1], AL_BUFFERS_QUEUED, &buffersQueued[1]); ALuint value; - while (buffersQueued--) - alSourceUnqueueBuffers(m_alSource, 1, &value); + while (buffersQueued[0]--) + alSourceUnqueueBuffers(m_pAlSources[0], 1, &value); + while (buffersQueued[1]--) + alSourceUnqueueBuffers(m_pAlSources[1], 1, &value); } bool CStream::Setup() @@ -522,7 +613,6 @@ bool CStream::Setup() if ( IsOpened() ) { m_pSoundFile->Seek(0); - alSourcei(m_alSource, AL_SOURCE_RELATIVE, AL_TRUE); //SetPosition(0.0f, 0.0f, 0.0f); SetPitch(1.0f); //SetPan(m_nPan); @@ -538,17 +628,29 @@ void CStream::SetPlay(bool state) if ( state ) { ALint sourceState = AL_PLAYING; - alGetSourcei(m_alSource, AL_SOURCE_STATE, &sourceState); + alGetSourcei(m_pAlSources[0], AL_SOURCE_STATE, &sourceState); if (sourceState != AL_PLAYING ) - alSourcePlay(m_alSource); + alSourcePlay(m_pAlSources[0]); + + sourceState = AL_PLAYING; + alGetSourcei(m_pAlSources[1], AL_SOURCE_STATE, &sourceState); + if (sourceState != AL_PLAYING) + alSourcePlay(m_pAlSources[1]); + m_bActive = true; } else { ALint sourceState = AL_STOPPED; - alGetSourcei(m_alSource, AL_SOURCE_STATE, &sourceState); - if (sourceState != AL_STOPPED ) - alSourceStop(m_alSource); + alGetSourcei(m_pAlSources[0], AL_SOURCE_STATE, &sourceState); + if (sourceState != AL_STOPPED) + alSourceStop(m_pAlSources[0]); + + sourceState = AL_STOPPED; + alGetSourcei(m_pAlSources[1], AL_SOURCE_STATE, &sourceState); + if (sourceState != AL_STOPPED) + alSourceStop(m_pAlSources[1]); + m_bActive = false; } } @@ -579,35 +681,48 @@ void CStream::Update() if ( !m_bPaused ) { - ALint sourceState; - ALint buffersProcessed = 0; + ALint sourceState[2]; + ALint buffersProcessed[2] = { 0, 0 }; - alGetSourcei(m_alSource, AL_SOURCE_STATE, &sourceState); - alGetSourcei(m_alSource, AL_BUFFERS_PROCESSED, &buffersProcessed); + // Relying a lot on left buffer states in here + + //alSourcef(m_pAlSources[0], AL_ROLLOFF_FACTOR, 0.0f); + alGetSourcei(m_pAlSources[0], AL_SOURCE_STATE, &sourceState[0]); + alGetSourcei(m_pAlSources[0], AL_BUFFERS_PROCESSED, &buffersProcessed[0]); + //alSourcef(m_pAlSources[1], AL_ROLLOFF_FACTOR, 0.0f); + alGetSourcei(m_pAlSources[1], AL_SOURCE_STATE, &sourceState[1]); + alGetSourcei(m_pAlSources[1], AL_BUFFERS_PROCESSED, &buffersProcessed[1]); ALint looping = AL_FALSE; - alGetSourcei(m_alSource, AL_LOOPING, &looping); + alGetSourcei(m_pAlSources[0], AL_LOOPING, &looping); if ( looping == AL_TRUE ) { TRACE("stream set looping"); - alSourcei(m_alSource, AL_LOOPING, AL_TRUE); + alSourcei(m_pAlSources[0], AL_LOOPING, AL_TRUE); + alSourcei(m_pAlSources[1], AL_LOOPING, AL_TRUE); } + + assert(buffersProcessed[0] == buffersProcessed[1]); - while( buffersProcessed-- ) + while( buffersProcessed[0]-- ) { - ALuint buffer; + ALuint buffer[2]; - alSourceUnqueueBuffers(m_alSource, 1, &buffer); + alSourceUnqueueBuffers(m_pAlSources[0], 1, &buffer[0]); + alSourceUnqueueBuffers(m_pAlSources[1], 1, &buffer[1]); - if ( m_bActive && FillBuffer(buffer) ) - alSourceQueueBuffers(m_alSource, 1, &buffer); + if (m_bActive && FillBuffer(buffer)) + { + alSourceQueueBuffers(m_pAlSources[0], 1, &buffer[0]); + alSourceQueueBuffers(m_pAlSources[1], 1, &buffer[1]); + } } - if ( sourceState != AL_PLAYING ) + if ( sourceState[0] != AL_PLAYING ) { - alGetSourcei(m_alSource, AL_BUFFERS_PROCESSED, &buffersProcessed); - SetPlay(buffersProcessed!=0); + alGetSourcei(m_pAlSources[0], AL_BUFFERS_PROCESSED, &buffersProcessed[0]); + SetPlay(buffersProcessed[0]!=0); } } } diff --git a/src/audio/oal/stream.h b/src/audio/oal/stream.h index 2476abcc..326ce6a1 100644 --- a/src/audio/oal/stream.h +++ b/src/audio/oal/stream.h @@ -3,7 +3,7 @@ #ifdef AUDIO_OAL #include -#define NUM_STREAMBUFFERS 4 +#define NUM_STREAMBUFFERS 8 class IDecoder { @@ -57,7 +57,7 @@ public: class CStream { char m_aFilename[128]; - ALuint &m_alSource; + ALuint *m_pAlSources; ALuint (&m_alBuffers)[NUM_STREAMBUFFERS]; bool m_bPaused; @@ -73,20 +73,20 @@ class CStream IDecoder *m_pSoundFile; bool HasSource(); - void SetPosition(float x, float y, float z); + void SetPosition(int i, float x, float y, float z); void SetPitch(float pitch); void SetGain(float gain); void Pause(); void SetPlay(bool state); - bool FillBuffer(ALuint alBuffer); + bool FillBuffer(ALuint *alBuffer); int32 FillBuffers(); void ClearBuffers(); public: static void Initialise(); static void Terminate(); - CStream(char *filename, ALuint &source, ALuint (&buffers)[NUM_STREAMBUFFERS]); + CStream(char *filename, ALuint *sources, ALuint (&buffers)[NUM_STREAMBUFFERS]); ~CStream(); void Delete(); diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp index 7d6f429d..5579644c 100644 --- a/src/audio/sampman_oal.cpp +++ b/src/audio/sampman_oal.cpp @@ -102,7 +102,7 @@ CChannel aChannel[MAXCHANNELS+MAX2DCHANNELS]; uint8 nChannelVolume[MAXCHANNELS+MAX2DCHANNELS]; uint32 nStreamLength[TOTAL_STREAMED_SOUNDS]; -ALuint ALStreamSources[MAX_STREAMS]; +ALuint ALStreamSources[MAX_STREAMS][2]; ALuint ALStreamBuffers[MAX_STREAMS][NUM_STREAMBUFFERS]; struct tMP3Entry @@ -245,9 +245,9 @@ release_existing() if (stream) stream->ProviderTerm(); - alDeleteSources(1, &ALStreamSources[i]); alDeleteBuffers(NUM_STREAMBUFFERS, ALStreamBuffers[i]); } + alDeleteSources(MAX_STREAMS*2, ALStreamSources[0]); CChannel::DestroyChannels(); @@ -287,7 +287,10 @@ set_new_provider(int index) //TODO: _maxSamples = MAXCHANNELS; - ALCint attr[] = {ALC_FREQUENCY,MAX_FREQ,0}; + ALCint attr[] = {ALC_FREQUENCY,MAX_FREQ, + ALC_MONO_SOURCES, MAX_STREAMS * 2 + MAXCHANNELS, + 0, + }; ALDevice = alcOpenDevice(providers[index].id); ASSERT(ALDevice != NULL); @@ -319,11 +322,17 @@ set_new_provider(int index) alGenAuxiliaryEffectSlots(1, &ALEffectSlot); alGenEffects(1, &ALEffect); } - + + alGenSources(MAX_STREAMS*2, ALStreamSources[0]); for ( int32 i = 0; i < MAX_STREAMS; i++ ) { - alGenSources(1, &ALStreamSources[i]); - alGenBuffers(NUM_STREAMBUFFERS, ALStreamBuffers[i]); + alGenBuffers(NUM_STREAMBUFFERS, ALStreamBuffers[i]); + alSourcei(ALStreamSources[i][0], AL_SOURCE_RELATIVE, AL_TRUE); + alSource3f(ALStreamSources[i][0], AL_POSITION, 0.0f, 0.0f, 0.0f); + alSourcef(ALStreamSources[i][0], AL_GAIN, 1.0f); + alSourcei(ALStreamSources[i][1], AL_SOURCE_RELATIVE, AL_TRUE); + alSource3f(ALStreamSources[i][1], AL_POSITION, 0.0f, 0.0f, 0.0f); + alSourcef(ALStreamSources[i][1], AL_GAIN, 1.0f); CStream *stream = aStream[i]; if (stream) -- cgit v1.2.3 From 63e9f6d826b950b959ce112fd3be7bf170b76c8c Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Tue, 5 Jan 2021 00:32:03 +0200 Subject: Audio fixes --- src/audio/AudioLogic.cpp | 148 +++++++++++++++++++++++------------------------ src/audio/oal/stream.cpp | 2 +- 2 files changed, 75 insertions(+), 75 deletions(-) (limited to 'src/audio') diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 94ca67de..6c5d2ad0 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -3038,81 +3038,81 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) switch (sound) { case SOUND_STEP_START: case SOUND_STEP_END: - if (!params.m_pPed->bIsLooking) { - emittingVol = m_anRandomTable[3] % 15 + 45; - if (FindPlayerPed() != m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_pEntity) - emittingVol /= 2; - maxDist = 400.f; - switch (params.m_pPed->m_nSurfaceTouched) { - case SURFACE_GRASS: - sampleIndex = m_anRandomTable[1] % 5 + SFX_FOOTSTEP_GRASS_1; - break; - case SURFACE_GRAVEL: - case SURFACE_MUD_DRY: - sampleIndex = m_anRandomTable[4] % 5 + SFX_FOOTSTEP_GRAVEL_1; - break; - case SURFACE_CAR: - case SURFACE_GARAGE_DOOR: - case SURFACE_CAR_PANEL: - case SURFACE_THICK_METAL_PLATE: - case SURFACE_SCAFFOLD_POLE: - case SURFACE_LAMP_POST: - case SURFACE_FIRE_HYDRANT: - case SURFACE_GIRDER: - case SURFACE_METAL_CHAIN_FENCE: - case SURFACE_CONTAINER: - case SURFACE_NEWS_VENDOR: - sampleIndex = m_anRandomTable[0] % 5 + SFX_FOOTSTEP_METAL_1; - break; - case SURFACE_SAND: - sampleIndex = (m_anRandomTable[4] & 3) + SFX_FOOTSTEP_SAND_1; - break; - case SURFACE_WATER: - sampleIndex = (m_anRandomTable[3] & 3) + SFX_FOOTSTEP_WATER_1; - break; - case SURFACE_WOOD_CRATES: - case SURFACE_WOOD_BENCH: - case SURFACE_WOOD_SOLID: - sampleIndex = m_anRandomTable[2] % 5 + SFX_FOOTSTEP_WOOD_1; - break; - case SURFACE_HEDGE: - sampleIndex = m_anRandomTable[2] % 5 + SFX_COL_VEG_1; - break; - default: - sampleIndex = m_anRandomTable[2] % 5 + SFX_FOOTSTEP_CONCRETE_1; - break; - } - m_sQueueSample.m_nSampleIndex = sampleIndex; - m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_nCounter = m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_awAudioEvent[i] - 28; - m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 17); - switch (params.m_pPed->m_nMoveState) { - case PEDMOVE_WALK: - emittingVol /= 4; - m_sQueueSample.m_nFrequency = 9 * m_sQueueSample.m_nFrequency / 10; - break; - case PEDMOVE_RUN: - emittingVol /= 2; - m_sQueueSample.m_nFrequency = 11 * m_sQueueSample.m_nFrequency / 10; - break; - case PEDMOVE_SPRINT: - m_sQueueSample.m_nFrequency = 12 * m_sQueueSample.m_nFrequency / 10; - break; - default: - break; - } - m_sQueueSample.m_nReleasingVolumeModificator = 5; - m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_fSoundIntensity = 20.0f; - m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_nLoopStart = 0; - m_sQueueSample.m_nLoopEnd = -1; - m_sQueueSample.m_nEmittingVolume = emittingVol; - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_bReleasingSoundFlag = true; - m_sQueueSample.m_bRequireReflection = true; + if (!params.m_pPed->bIsInTheAir) + continue; + emittingVol = m_anRandomTable[3] % 15 + 45; + if (FindPlayerPed() != m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_pEntity) + emittingVol /= 2; + maxDist = 400.f; + switch (params.m_pPed->m_nSurfaceTouched) { + case SURFACE_GRASS: + sampleIndex = m_anRandomTable[1] % 5 + SFX_FOOTSTEP_GRASS_1; + break; + case SURFACE_GRAVEL: + case SURFACE_MUD_DRY: + sampleIndex = m_anRandomTable[4] % 5 + SFX_FOOTSTEP_GRAVEL_1; + break; + case SURFACE_CAR: + case SURFACE_GARAGE_DOOR: + case SURFACE_CAR_PANEL: + case SURFACE_THICK_METAL_PLATE: + case SURFACE_SCAFFOLD_POLE: + case SURFACE_LAMP_POST: + case SURFACE_FIRE_HYDRANT: + case SURFACE_GIRDER: + case SURFACE_METAL_CHAIN_FENCE: + case SURFACE_CONTAINER: + case SURFACE_NEWS_VENDOR: + sampleIndex = m_anRandomTable[0] % 5 + SFX_FOOTSTEP_METAL_1; + break; + case SURFACE_SAND: + sampleIndex = (m_anRandomTable[4] & 3) + SFX_FOOTSTEP_SAND_1; + break; + case SURFACE_WATER: + sampleIndex = (m_anRandomTable[3] & 3) + SFX_FOOTSTEP_WATER_1; + break; + case SURFACE_WOOD_CRATES: + case SURFACE_WOOD_BENCH: + case SURFACE_WOOD_SOLID: + sampleIndex = m_anRandomTable[2] % 5 + SFX_FOOTSTEP_WOOD_1; + break; + case SURFACE_HEDGE: + sampleIndex = m_anRandomTable[2] % 5 + SFX_COL_VEG_1; + break; + default: + sampleIndex = m_anRandomTable[2] % 5 + SFX_FOOTSTEP_CONCRETE_1; + break; } + m_sQueueSample.m_nSampleIndex = sampleIndex; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_nCounter = m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_awAudioEvent[i] - SOUND_STEP_START + 1; + m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 17); + switch (params.m_pPed->m_nMoveState) { + case PEDMOVE_WALK: + emittingVol /= 4; + m_sQueueSample.m_nFrequency = 9 * m_sQueueSample.m_nFrequency / 10; + break; + case PEDMOVE_RUN: + emittingVol /= 2; + m_sQueueSample.m_nFrequency = 11 * m_sQueueSample.m_nFrequency / 10; + break; + case PEDMOVE_SPRINT: + m_sQueueSample.m_nFrequency = 12 * m_sQueueSample.m_nFrequency / 10; + break; + default: + break; + } + m_sQueueSample.m_nReleasingVolumeModificator = 5; + m_sQueueSample.m_fSpeedMultiplier = 0.0f; + m_sQueueSample.m_fSoundIntensity = 20.0f; + m_sQueueSample.m_nLoopCount = 1; + m_sQueueSample.m_nLoopStart = 0; + m_sQueueSample.m_nLoopEnd = -1; + m_sQueueSample.m_nEmittingVolume = emittingVol; + m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bReleasingSoundFlag = true; + m_sQueueSample.m_bRequireReflection = true; break; case SOUND_FALL_LAND: case SOUND_FALL_COLLAPSE: diff --git a/src/audio/oal/stream.cpp b/src/audio/oal/stream.cpp index f36985e5..cf5fe831 100644 --- a/src/audio/oal/stream.cpp +++ b/src/audio/oal/stream.cpp @@ -466,7 +466,7 @@ void CStream::Pause() if ( !HasSource() ) return; ALint sourceState = AL_PAUSED; alGetSourcei(m_pAlSources[0], AL_SOURCE_STATE, &sourceState); - if (sourceState != AL_PAUSED ) + if (sourceState != AL_PAUSED) alSourcePause(m_pAlSources[0]); alGetSourcei(m_pAlSources[1], AL_SOURCE_STATE, &sourceState); if (sourceState != AL_PAUSED) -- cgit v1.2.3 From 042e21115e249f7e62c54e182c4ea59549d34127 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Tue, 5 Jan 2021 00:50:51 +0200 Subject: More audio fix --- src/audio/AudioLogic.cpp | 50 ++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'src/audio') diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 6c5d2ad0..976bbaec 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -3038,7 +3038,7 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) switch (sound) { case SOUND_STEP_START: case SOUND_STEP_END: - if (!params.m_pPed->bIsInTheAir) + if (params.m_pPed->bIsInTheAir) continue; emittingVol = m_anRandomTable[3] % 15 + 45; if (FindPlayerPed() != m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_pEntity) @@ -3116,31 +3116,31 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) break; case SOUND_FALL_LAND: case SOUND_FALL_COLLAPSE: - if (!ped->bIsLooking) { - maxDist = SQR(30); - emittingVol = m_anRandomTable[3] % 20 + 80; - if (ped->m_nSurfaceTouched == SURFACE_WATER) { - m_sQueueSample.m_nSampleIndex = (m_anRandomTable[3] & 3) + SFX_FOOTSTEP_WATER_1; - } else if (sound == SOUND_FALL_LAND) { - m_sQueueSample.m_nSampleIndex = SFX_BODY_LAND; - } else { - m_sQueueSample.m_nSampleIndex = SFX_BODY_LAND_AND_FALL; - } - m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_nCounter = 1; - m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 17); - m_sQueueSample.m_nReleasingVolumeModificator = 2; - m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_fSoundIntensity = 30.0f; - m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_nLoopStart = 0; - m_sQueueSample.m_nLoopEnd = -1; - m_sQueueSample.m_nEmittingVolume = emittingVol; - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_bReleasingSoundFlag = true; - m_sQueueSample.m_bRequireReflection = true; + if (ped->bIsInTheAir) + continue; + maxDist = SQR(30); + emittingVol = m_anRandomTable[3] % 20 + 80; + if (ped->m_nSurfaceTouched == SURFACE_WATER) { + m_sQueueSample.m_nSampleIndex = (m_anRandomTable[3] & 3) + SFX_FOOTSTEP_WATER_1; + } else if (sound == SOUND_FALL_LAND) { + m_sQueueSample.m_nSampleIndex = SFX_BODY_LAND; + } else { + m_sQueueSample.m_nSampleIndex = SFX_BODY_LAND_AND_FALL; } + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_nCounter = 1; + m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 17); + m_sQueueSample.m_nReleasingVolumeModificator = 2; + m_sQueueSample.m_fSpeedMultiplier = 0.0f; + m_sQueueSample.m_fSoundIntensity = 30.0f; + m_sQueueSample.m_nLoopCount = 1; + m_sQueueSample.m_nLoopStart = 0; + m_sQueueSample.m_nLoopEnd = -1; + m_sQueueSample.m_nEmittingVolume = emittingVol; + m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bReleasingSoundFlag = true; + m_sQueueSample.m_bRequireReflection = true; break; case SOUND_FIGHT_PUNCH_33: m_sQueueSample.m_nSampleIndex = SFX_FIGHT_1; -- cgit v1.2.3 From fd4c2172f5469161106edbb196b79b8896300402 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Tue, 5 Jan 2021 21:06:17 +0200 Subject: Add support of PS2 audio streams to OpenAL --- src/audio/oal/stream.cpp | 242 +++++++++++++++++++++++++++++++++++++++++++++- src/audio/oal/stream.h | 2 +- src/audio/sampman_oal.cpp | 22 +++-- 3 files changed, 255 insertions(+), 11 deletions(-) (limited to 'src/audio') diff --git a/src/audio/oal/stream.cpp b/src/audio/oal/stream.cpp index cf5fe831..1f8f4c1a 100644 --- a/src/audio/oal/stream.cpp +++ b/src/audio/oal/stream.cpp @@ -147,6 +147,12 @@ public: } }; +#ifdef _WIN32 +// fuzzy seek eliminates stutter when playing ADF but spams errors a lot (nothing breaks though) +#define MP3_USE_FUZZY_SEEK +#endif // _WIN32 + + class CMP3File : public IDecoder { mpg123_handle *m_pMH; @@ -163,8 +169,9 @@ public: m_pMH = mpg123_new(nil, nil); if ( m_pMH ) { +#ifdef MP3_USE_FUZZY_SEEK mpg123_param(m_pMH, MPG123_FLAGS, MPG123_FUZZY | MPG123_SEEKBUFFER | MPG123_GAPLESS, 0.0); - +#endif long rate = 0; int channels = 0; int encoding = 0; @@ -245,6 +252,233 @@ public: return (uint32)size; } }; + +#define VAG_LINE_SIZE (0x10) +#define VAG_SAMPLES_IN_LINE (28) + +class CVagDecoder +{ + const double f[5][2] = { { 0.0, 0.0 }, + { 60.0 / 64.0, 0.0 }, + { 115.0 / 64.0, -52.0 / 64.0 }, + { 98.0 / 64.0, -55.0 / 64.0 }, + { 122.0 / 64.0, -60.0 / 64.0 } }; + + double s_1; + double s_2; +public: + CVagDecoder() + { + ResetState(); + } + + void ResetState() + { + s_1 = s_2 = 0.0; + } + + static short quantize(double sample) + { + int a = int(sample + 0.5); + return short(clamp(int(sample + 0.5), -32768, 32767)); + } + + void Decode(void* _inbuf, int16* _outbuf, size_t size) + { + uint8* inbuf = (uint8*)_inbuf; + int16* outbuf = _outbuf; + size &= ~(VAG_LINE_SIZE - 1); + + while (size > 0) { + double samples[VAG_SAMPLES_IN_LINE]; + + int predict_nr, shift_factor, flags; + predict_nr = *(inbuf++); + shift_factor = predict_nr & 0xf; + predict_nr >>= 4; + flags = *(inbuf++); + if (flags == 7) // TODO: ignore? + break; + for (int i = 0; i < VAG_SAMPLES_IN_LINE; i += 2) { + int d = *(inbuf++); + int16 s = int16((d & 0xf) << 12); + samples[i] = (double)(s >> shift_factor); + s = int16((d & 0xf0) << 8); + samples[i + 1] = (double)(s >> shift_factor); + } + + for (int i = 0; i < VAG_SAMPLES_IN_LINE; i++) { + samples[i] = samples[i] + s_1 * f[predict_nr][0] + s_2 * f[predict_nr][1]; + s_2 = s_1; + s_1 = samples[i]; + *(outbuf++) = quantize(samples[i] + 0.5); + } + size -= VAG_LINE_SIZE; + } + } +}; + +#define VB_BLOCK_SIZE (0x2000) +#define NUM_VAG_LINES_IN_BLOCK (VB_BLOCK_SIZE / VAG_LINE_SIZE) +#define NUM_VAG_SAMPLES_IN_BLOCK (NUM_VAG_LINES_IN_BLOCK * VAG_SAMPLES_IN_LINE) + +class CVbFile : public IDecoder +{ + FILE* pFile; + size_t m_FileSize; + size_t m_nNumberOfBlocks; + CVagDecoder* decoders; + + uint32 m_nSampleRate; + uint8 m_nChannels; + bool m_bBlockRead; + uint16 m_LineInBlock; + size_t m_CurrentBlock; + + uint8** ppTempBuffers; + + void ReadBlock(int32 block = -1) + { + // just read next block if -1 + if (block != -1) + fseek(pFile, block * m_nChannels * VB_BLOCK_SIZE, SEEK_SET); + + for (int i = 0; i < m_nChannels; i++) + fread(ppTempBuffers[i], VB_BLOCK_SIZE, 1, pFile); + m_bBlockRead = true; + } + +public: + CVbFile(const char* path, uint32 nSampleRate = 32000, uint8 nChannels = 2) : m_nSampleRate(nSampleRate), m_nChannels(nChannels) + { + pFile = fopen(path, "rb"); + if (pFile) { + fseek(pFile, 0, SEEK_END); + m_FileSize = ftell(pFile); + fseek(pFile, 0, SEEK_SET); + m_nNumberOfBlocks = m_FileSize / (nChannels * VB_BLOCK_SIZE); + decoders = new CVagDecoder[nChannels]; + m_CurrentBlock = 0; + m_LineInBlock = 0; + m_bBlockRead = false; + ppTempBuffers = new uint8 * [nChannels]; + for (uint8 i = 0; i < nChannels; i++) + ppTempBuffers[i] = new uint8[VB_BLOCK_SIZE]; + } + } + + ~CVbFile() + { + if (pFile) + { + fclose(pFile); + delete decoders; + for (int i = 0; i < m_nChannels; i++) + delete ppTempBuffers[i]; + delete ppTempBuffers; + } + } + + bool IsOpened() + { + return pFile != nil; + } + + uint32 GetSampleSize() + { + return sizeof(uint16); + } + + uint32 GetSampleCount() + { + if (!IsOpened()) return 0; + return m_nNumberOfBlocks * NUM_VAG_LINES_IN_BLOCK * VAG_SAMPLES_IN_LINE; + } + + uint32 GetSampleRate() + { + return m_nSampleRate; + } + + uint32 GetChannels() + { + return m_nChannels; + } + + void Seek(uint32 milliseconds) + { + if (!IsOpened()) return; + uint32 samples = ms2samples(milliseconds); + int32 block = samples / NUM_VAG_SAMPLES_IN_BLOCK; + if (block > m_nNumberOfBlocks) + { + samples = 0; + block = 0; + } + if (block != m_CurrentBlock) + ReadBlock(block); + + uint32 remainingSamples = samples - block * NUM_VAG_SAMPLES_IN_BLOCK; + uint32 newLine = remainingSamples / VAG_SAMPLES_IN_LINE / VAG_LINE_SIZE; + + if (m_CurrentBlock != block || m_LineInBlock != newLine) + { + m_CurrentBlock = block; + m_LineInBlock = newLine; + for (int i = 0; i < GetChannels(); i++) + decoders[i].ResetState(); + } + + } + + uint32 Tell() + { + if (!IsOpened()) return 0; + uint32 pos = (m_CurrentBlock * NUM_VAG_LINES_IN_BLOCK + m_LineInBlock) * VAG_SAMPLES_IN_LINE; + return samples2ms(pos); + } + + uint32 Decode(void* buffer) + { + if (!IsOpened()) return 0; + + if (!m_bBlockRead) + ReadBlock(m_CurrentBlock); + + if (m_CurrentBlock == m_nNumberOfBlocks) return 0; + int size = 0; + + int numberOfRequiredLines = GetBufferSamples() / GetChannels() / VAG_SAMPLES_IN_LINE; + int numberOfRemainingLines = (m_nNumberOfBlocks - m_CurrentBlock) * NUM_VAG_LINES_IN_BLOCK - m_LineInBlock; + int bufSizePerChannel = Min(numberOfRequiredLines, numberOfRemainingLines) * VAG_SAMPLES_IN_LINE * GetSampleSize(); + + if (numberOfRequiredLines > numberOfRemainingLines) + numberOfRemainingLines = numberOfRemainingLines; + + int16* buffers[2] = { (int16*)buffer, &((int16*)buffer)[bufSizePerChannel / GetSampleSize()] }; + + while (size < bufSizePerChannel) + { + for (int i = 0; i < GetChannels(); i++) + { + decoders[i].Decode(ppTempBuffers[i] + m_LineInBlock * VAG_LINE_SIZE, buffers[i], VAG_LINE_SIZE); + buffers[i] += VAG_SAMPLES_IN_LINE; + } + size += VAG_SAMPLES_IN_LINE * GetSampleSize(); + m_LineInBlock++; + if (m_LineInBlock >= NUM_VAG_LINES_IN_BLOCK) + { + m_CurrentBlock++; + if (m_CurrentBlock >= m_nNumberOfBlocks) + break; + m_LineInBlock = 0; + ReadBlock(); + } + } + + return bufSizePerChannel * GetChannels(); + } +}; #else class COpusFile : public IDecoder { @@ -341,6 +575,8 @@ public: }; #endif +#ifdef MP3_USE_FUZZY_SEEK +#endif void CStream::Initialise() { #ifndef AUDIO_OPUS @@ -355,7 +591,7 @@ void CStream::Terminate() #endif } -CStream::CStream(char *filename, ALuint *sources, ALuint (&buffers)[NUM_STREAMBUFFERS]) : +CStream::CStream(char *filename, ALuint *sources, ALuint (&buffers)[NUM_STREAMBUFFERS], uint32 overrideSampleRate) : m_pAlSources(sources), m_alBuffers(buffers), m_pBuffer(nil), @@ -388,6 +624,8 @@ CStream::CStream(char *filename, ALuint *sources, ALuint (&buffers)[NUM_STREAMBU m_pSoundFile = new CMP3File(m_aFilename); else if (!strcasecmp(&m_aFilename[strlen(m_aFilename) - strlen(".wav")], ".wav")) m_pSoundFile = new CSndFile(m_aFilename); + else if (!strcasecmp(&m_aFilename[strlen(m_aFilename) - strlen(".vb")], ".VB")) + m_pSoundFile = new CVbFile(m_aFilename, overrideSampleRate); #else if (!strcasecmp(&m_aFilename[strlen(m_aFilename) - strlen(".opus")], ".opus")) m_pSoundFile = new COpusFile(m_aFilename); diff --git a/src/audio/oal/stream.h b/src/audio/oal/stream.h index 326ce6a1..bcbc5e54 100644 --- a/src/audio/oal/stream.h +++ b/src/audio/oal/stream.h @@ -86,7 +86,7 @@ public: static void Initialise(); static void Terminate(); - CStream(char *filename, ALuint *sources, ALuint (&buffers)[NUM_STREAMBUFFERS]); + CStream(char *filename, ALuint *sources, ALuint (&buffers)[NUM_STREAMBUFFERS], uint32 overrideSampleRate = 32000); ~CStream(); void Delete(); diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp index 5579644c..07d943e3 100644 --- a/src/audio/sampman_oal.cpp +++ b/src/audio/sampman_oal.cpp @@ -393,6 +393,12 @@ set_new_provider(int index) return false; } +static bool +IsThisTrackAt16KHz(uint32 track) +{ + return track == STREAMED_SOUND_RADIO_CHAT; +} + cSampleManager::cSampleManager(void) { ; @@ -974,7 +980,7 @@ cSampleManager::Initialise(void) #endif for(int32 i = 0; i < TOTAL_STREAMED_SOUNDS; i++) { - aStream[0] = new CStream(StreamedNameTable[i], ALStreamSources[0], ALStreamBuffers[0]); + aStream[0] = new CStream(StreamedNameTable[i], ALStreamSources[0], ALStreamBuffers[0], IsThisTrackAt16KHz(i) ? 16000 : 32000); if(aStream[0] && aStream[0]->IsOpened()) { uint32 tatalms = aStream[0]->GetLengthMS(); @@ -1661,7 +1667,7 @@ cSampleManager::PreloadStreamedFile(uint8 nFile, uint8 nStream) strcpy(filename, StreamedNameTable[nFile]); - CStream *stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream]); + CStream *stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000); ASSERT(stream != NULL); aStream[nStream] = stream; @@ -1736,7 +1742,7 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) nFile = 0; strcat(filename, StreamedNameTable[nFile]); - CStream* stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream]); + CStream* stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000); ASSERT(stream != NULL); aStream[nStream] = stream; @@ -1760,12 +1766,12 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) } if (mp3->pLinkPath != NULL) - aStream[nStream] = new CStream(mp3->pLinkPath, ALStreamSources[nStream], ALStreamBuffers[nStream]); + aStream[nStream] = new CStream(mp3->pLinkPath, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000); else { strcpy(filename, _mp3DirectoryPath); strcat(filename, mp3->aFilename); - aStream[nStream] = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream]); + aStream[nStream] = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000); } if (aStream[nStream]->IsOpened()) { @@ -1792,7 +1798,7 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) { nFile = 0; strcat(filename, StreamedNameTable[nFile]); - CStream* stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream]); + CStream* stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000); ASSERT(stream != NULL); aStream[nStream] = stream; @@ -1816,7 +1822,7 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) } if (e->pLinkPath != NULL) - aStream[nStream] = new CStream(e->pLinkPath, ALStreamSources[nStream], ALStreamBuffers[nStream]); + aStream[nStream] = new CStream(e->pLinkPath, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000); else { strcpy(filename, _mp3DirectoryPath); strcat(filename, e->aFilename); @@ -1849,7 +1855,7 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) strcpy(filename, StreamedNameTable[nFile]); - CStream *stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream]); + CStream *stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000); ASSERT(stream != NULL); aStream[nStream] = stream; -- cgit v1.2.3 From d94e8e8fafadf3a41b8d9c531f01383ecdb5f65f Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Tue, 5 Jan 2021 21:31:49 +0200 Subject: duh --- src/audio/oal/stream.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/audio') diff --git a/src/audio/oal/stream.cpp b/src/audio/oal/stream.cpp index 1f8f4c1a..9beb27a0 100644 --- a/src/audio/oal/stream.cpp +++ b/src/audio/oal/stream.cpp @@ -575,8 +575,6 @@ public: }; #endif -#ifdef MP3_USE_FUZZY_SEEK -#endif void CStream::Initialise() { #ifndef AUDIO_OPUS -- cgit v1.2.3 From 493f6cb57851c147c340ceab9937df43582e53c3 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Wed, 6 Jan 2021 15:46:59 +0200 Subject: Implementing our own WAV decoder to replace SndFile --- src/audio/oal/stream.cpp | 357 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 329 insertions(+), 28 deletions(-) (limited to 'src/audio') diff --git a/src/audio/oal/stream.cpp b/src/audio/oal/stream.cpp index 9beb27a0..0a5be049 100644 --- a/src/audio/oal/stream.cpp +++ b/src/audio/oal/stream.cpp @@ -8,10 +8,14 @@ #include #else #ifdef _WIN32 +#ifdef AUDIO_OAL_USE_SNDFILE #pragma comment( lib, "libsndfile-1.lib" ) +#endif #pragma comment( lib, "libmpg123-0.lib" ) #endif +#ifdef AUDIO_OAL_USE_SNDFILE #include +#endif #include #endif @@ -78,6 +82,290 @@ public: CSortStereoBuffer SortStereoBuffer; #ifndef AUDIO_OPUS +class CImaADPCMDecoder +{ + const uint16 StepTable[89] = { + 7, 8, 9, 10, 11, 12, 13, 14, + 16, 17, 19, 21, 23, 25, 28, 31, + 34, 37, 41, 45, 50, 55, 60, 66, + 73, 80, 88, 97, 107, 118, 130, 143, + 157, 173, 190, 209, 230, 253, 279, 307, + 337, 371, 408, 449, 494, 544, 598, 658, + 724, 796, 876, 963, 1060, 1166, 1282, 1411, + 1552, 1707, 1878, 2066, 2272, 2499, 2749, 3024, + 3327, 3660, 4026, 4428, 4871, 5358, 5894, 6484, + 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899, + 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, + 32767 + }; + + int16 Sample, StepIndex; + +public: + CImaADPCMDecoder() + { + Init(0, 0); + } + + void Init(int16 _Sample, int16 _StepIndex) + { + Sample = _Sample; + StepIndex = _StepIndex; + } + + void Decode(uint8 *inbuf, int16 *_outbuf, size_t size) + { + int16* outbuf = _outbuf; + for (size_t i = 0; i < size; i++) + { + *(outbuf++) = DecodeSample(inbuf[i] & 0xF); + *(outbuf++) = DecodeSample(inbuf[i] >> 4); + } + } + + int16 DecodeSample(uint8 adpcm) + { + uint16 step = StepTable[StepIndex]; + + if (adpcm & 4) + StepIndex += ((adpcm & 3) + 1) * 2; + else + StepIndex--; + + StepIndex = clamp(StepIndex, 0, 88); + + int delta = step >> 3; + if (adpcm & 1) delta += step >> 2; + if (adpcm & 2) delta += step >> 1; + if (adpcm & 4) delta += step; + if (adpcm & 8) delta = -delta; + + int newSample = Sample + delta; + Sample = clamp(newSample, -32768, 32767); + return Sample; + } +}; + +class CWavFile : public IDecoder +{ + enum + { + WAVEFMT_PCM = 1, + WAVEFMT_IMA_ADPCM = 0x11, + WAVEFMT_XBOX_ADPCM = 0x69, + }; + + struct tDataHeader + { + uint32 ID; + uint32 Size; + }; + + struct tFormatHeader + { + uint16 AudioFormat; + uint16 NumChannels; + uint32 SampleRate; + uint32 ByteRate; + uint16 BlockAlign; + uint16 BitsPerSample; + uint16 extra[2]; // adpcm only + + tFormatHeader() { memset(this, 0, sizeof(*this)); } + }; + + FILE* pFile; + bool bIsOpen; + tFormatHeader FormatHeader; + + uint32 DataStartOffset; + uint32 SampleCount; + uint32 SamplesPerBlock; + + // ADPCM things + uint8 *AdpcmBlock; + int16 **buffers; + CImaADPCMDecoder* decoders; + + void Close() + { + if (pFile) { + fclose(pFile); + pFile = nil; + } + if (AdpcmBlock) delete AdpcmBlock; + if (buffers) delete buffers; + if (decoders) delete decoders; + } + +public: + CWavFile(const char* path) : bIsOpen(false), DataStartOffset(0), SampleCount(0), SamplesPerBlock(0), AdpcmBlock(nil), buffers(nil), decoders(nil) + { + pFile = fopen(path, "rb"); + if (!pFile) return; + +#define CLOSE_ON_ERROR(op)\ + if (op) { \ + Close(); \ + return; \ + } + + tDataHeader DataHeader; + + CLOSE_ON_ERROR(fread(&DataHeader, sizeof(DataHeader), 1, pFile) == 0); + CLOSE_ON_ERROR(DataHeader.ID != 'FFIR'); + + int WAVE; + CLOSE_ON_ERROR(fread(&WAVE, 4, 1, pFile) == 0); + CLOSE_ON_ERROR(WAVE != 'EVAW') + CLOSE_ON_ERROR(fread(&DataHeader, sizeof(DataHeader), 1, pFile) == 0); + CLOSE_ON_ERROR(DataHeader.ID != ' tmf'); + + CLOSE_ON_ERROR(fread(&FormatHeader, Min(DataHeader.Size, sizeof(tFormatHeader)), 1, pFile) == 0); + CLOSE_ON_ERROR(DataHeader.Size > sizeof(tFormatHeader)); + + switch (FormatHeader.AudioFormat) + { + case WAVEFMT_XBOX_ADPCM: + FormatHeader.AudioFormat = WAVEFMT_IMA_ADPCM; + case WAVEFMT_IMA_ADPCM: + SamplesPerBlock = (FormatHeader.BlockAlign / FormatHeader.NumChannels - 4) * 2 + 1; + AdpcmBlock = new uint8[FormatHeader.BlockAlign]; + buffers = new int16*[FormatHeader.NumChannels]; + decoders = new CImaADPCMDecoder[FormatHeader.NumChannels]; + break; + case WAVEFMT_PCM: + SamplesPerBlock = 1; + if (FormatHeader.BitsPerSample != 16) + { + debug("Unsupported PCM (%d bits), only signed 16-bit is supported (%s)\n", FormatHeader.BitsPerSample, path); + return; + } + break; + default: + debug("Unsupported wav format 0x%x (%s)\n", FormatHeader.AudioFormat, path); + return; + } + + while (true) { + CLOSE_ON_ERROR(fread(&DataHeader, sizeof(DataHeader), 1, pFile) == 0); + if (DataHeader.ID == 'atad') + break; + fseek(pFile, DataHeader.Size, SEEK_CUR); + } + + DataStartOffset = ftell(pFile); + SampleCount = DataHeader.Size / FormatHeader.BlockAlign * SamplesPerBlock; + + bIsOpen = true; +#undef CLOSE_ON_ERROR + } + + ~CWavFile() + { + Close(); + } + + bool IsOpened() + { + return bIsOpen; + } + + uint32 GetSampleSize() + { + return sizeof(uint16); + } + + uint32 GetSampleCount() + { + return SampleCount; + } + + uint32 GetSampleRate() + { + return FormatHeader.SampleRate; + } + + uint32 GetChannels() + { + return FormatHeader.NumChannels; + } + + void Seek(uint32 milliseconds) + { + if (!IsOpened()) return; + fseek(pFile, DataStartOffset + ms2samples(milliseconds) / SamplesPerBlock * FormatHeader.BlockAlign, SEEK_SET); + } + + uint32 Tell() + { + if (!IsOpened()) return 0; + return samples2ms((ftell(pFile) - DataStartOffset) / FormatHeader.BlockAlign * SamplesPerBlock); + } + +#define SAMPLES_IN_LINE (8) + + uint32 Decode(void* buffer) + { + if (!IsOpened()) return 0; + + if (FormatHeader.AudioFormat == WAVEFMT_PCM) + { + uint32 size = fread(buffer, 1, GetBufferSize(), pFile); + if (FormatHeader.NumChannels == 2) + SortStereoBuffer.SortStereo(buffer, size); + return size; + } + else if (FormatHeader.AudioFormat == WAVEFMT_IMA_ADPCM) + { + uint32 MaxSamples = GetBufferSamples() / FormatHeader.NumChannels; + uint32 CurSample = (ftell(pFile) - DataStartOffset) / FormatHeader.BlockAlign * SamplesPerBlock; + + MaxSamples = Min(MaxSamples, SampleCount - CurSample); + MaxSamples = MaxSamples / SamplesPerBlock * SamplesPerBlock; + uint32 OutBufSizePerChannel = MaxSamples * GetSampleSize(); + uint32 OutBufSize = OutBufSizePerChannel * FormatHeader.NumChannels; + int16** buffers = new int16*[FormatHeader.NumChannels]; + CImaADPCMDecoder* decoders = new CImaADPCMDecoder[FormatHeader.NumChannels]; + for (uint32 i = 0; i < FormatHeader.NumChannels; i++) + buffers[i] = (int16*)((int8*)buffer + OutBufSizePerChannel * i); + + uint32 samplesRead = 0; + while (samplesRead < MaxSamples) + { + uint8* AdpcmBuf = AdpcmBlock; + if (fread(AdpcmBlock, 1, FormatHeader.BlockAlign, pFile) == 0) + return 0; + + for (uint32 i = 0; i < FormatHeader.NumChannels; i++) + { + int16 Sample = *(int16*)AdpcmBuf; + AdpcmBuf += sizeof(int16); + int16 Step = *(int16*)AdpcmBuf; + AdpcmBuf += sizeof(int16); + decoders[i].Init(Sample, Step); + *(buffers[i]) = Sample; + buffers[i]++; + } + samplesRead++; + for (uint32 s = 1; s < SamplesPerBlock; s += SAMPLES_IN_LINE) + { + for (uint32 i = 0; i < FormatHeader.NumChannels; i++) + { + decoders[i].Decode(AdpcmBuf, buffers[i], SAMPLES_IN_LINE / 2); + AdpcmBuf += SAMPLES_IN_LINE / 2; + buffers[i] += SAMPLES_IN_LINE; + } + samplesRead += SAMPLES_IN_LINE; + } + } + return OutBufSize; + } + return 0; + } +}; + +#ifdef AUDIO_OAL_USE_SNDFILE class CSndFile : public IDecoder { SNDFILE *m_pfSound; @@ -146,6 +434,7 @@ public: return size; } }; +#endif #ifdef _WIN32 // fuzzy seek eliminates stutter when playing ADF but spams errors a lot (nothing breaks though) @@ -280,7 +569,7 @@ public: static short quantize(double sample) { int a = int(sample + 0.5); - return short(clamp(int(sample + 0.5), -32768, 32767)); + return short(clamp(a, -32768, 32767)); } void Decode(void* _inbuf, int16* _outbuf, size_t size) @@ -336,6 +625,7 @@ class CVbFile : public IDecoder size_t m_CurrentBlock; uint8** ppTempBuffers; + int16** buffers; void ReadBlock(int32 block = -1) { @@ -349,22 +639,24 @@ class CVbFile : public IDecoder } public: - CVbFile(const char* path, uint32 nSampleRate = 32000, uint8 nChannels = 2) : m_nSampleRate(nSampleRate), m_nChannels(nChannels) + CVbFile(const char* path, uint32 nSampleRate = 32000, uint8 nChannels = 2) : m_nSampleRate(nSampleRate), m_nChannels(nChannels), decoders(nil), ppTempBuffers(nil), buffers(nil), + m_FileSize(0), m_nNumberOfBlocks(0), m_bBlockRead(false), m_LineInBlock(0), m_CurrentBlock(0) { pFile = fopen(path, "rb"); - if (pFile) { - fseek(pFile, 0, SEEK_END); - m_FileSize = ftell(pFile); - fseek(pFile, 0, SEEK_SET); - m_nNumberOfBlocks = m_FileSize / (nChannels * VB_BLOCK_SIZE); - decoders = new CVagDecoder[nChannels]; - m_CurrentBlock = 0; - m_LineInBlock = 0; - m_bBlockRead = false; - ppTempBuffers = new uint8 * [nChannels]; - for (uint8 i = 0; i < nChannels; i++) - ppTempBuffers[i] = new uint8[VB_BLOCK_SIZE]; - } + if (!pFile) return; + + fseek(pFile, 0, SEEK_END); + m_FileSize = ftell(pFile); + fseek(pFile, 0, SEEK_SET); + m_nNumberOfBlocks = m_FileSize / (nChannels * VB_BLOCK_SIZE); + decoders = new CVagDecoder[nChannels]; + m_CurrentBlock = 0; + m_LineInBlock = 0; + m_bBlockRead = false; + ppTempBuffers = new uint8*[nChannels]; + buffers = new int16*[nChannels]; + for (uint8 i = 0; i < nChannels; i++) + ppTempBuffers[i] = new uint8[VB_BLOCK_SIZE]; } ~CVbFile() @@ -376,6 +668,7 @@ public: for (int i = 0; i < m_nChannels; i++) delete ppTempBuffers[i]; delete ppTempBuffers; + delete buffers; } } @@ -409,14 +702,14 @@ public: { if (!IsOpened()) return; uint32 samples = ms2samples(milliseconds); - int32 block = samples / NUM_VAG_SAMPLES_IN_BLOCK; + uint32 block = samples / NUM_VAG_SAMPLES_IN_BLOCK; if (block > m_nNumberOfBlocks) { samples = 0; block = 0; } if (block != m_CurrentBlock) - ReadBlock(block); + m_bBlockRead = false; uint32 remainingSamples = samples - block * NUM_VAG_SAMPLES_IN_BLOCK; uint32 newLine = remainingSamples / VAG_SAMPLES_IN_LINE / VAG_LINE_SIZE; @@ -425,7 +718,7 @@ public: { m_CurrentBlock = block; m_LineInBlock = newLine; - for (int i = 0; i < GetChannels(); i++) + for (uint32 i = 0; i < GetChannels(); i++) decoders[i].ResetState(); } @@ -448,18 +741,19 @@ public: if (m_CurrentBlock == m_nNumberOfBlocks) return 0; int size = 0; - int numberOfRequiredLines = GetBufferSamples() / GetChannels() / VAG_SAMPLES_IN_LINE; + int numberOfRequiredLines = GetBufferSamples() / m_nChannels / VAG_SAMPLES_IN_LINE; int numberOfRemainingLines = (m_nNumberOfBlocks - m_CurrentBlock) * NUM_VAG_LINES_IN_BLOCK - m_LineInBlock; int bufSizePerChannel = Min(numberOfRequiredLines, numberOfRemainingLines) * VAG_SAMPLES_IN_LINE * GetSampleSize(); if (numberOfRequiredLines > numberOfRemainingLines) numberOfRemainingLines = numberOfRemainingLines; - int16* buffers[2] = { (int16*)buffer, &((int16*)buffer)[bufSizePerChannel / GetSampleSize()] }; + for (uint32 i = 0; i < m_nChannels; i++) + buffers[i] = (int16*)((int8*)buffer + bufSizePerChannel * i); while (size < bufSizePerChannel) { - for (int i = 0; i < GetChannels(); i++) + for (uint32 i = 0; i < m_nChannels; i++) { decoders[i].Decode(ppTempBuffers[i] + m_LineInBlock * VAG_LINE_SIZE, buffers[i], VAG_LINE_SIZE); buffers[i] += VAG_SAMPLES_IN_LINE; @@ -476,7 +770,7 @@ public: } } - return bufSizePerChannel * GetChannels(); + return bufSizePerChannel * m_nChannels; } }; #else @@ -621,7 +915,11 @@ CStream::CStream(char *filename, ALuint *sources, ALuint (&buffers)[NUM_STREAMBU if (!strcasecmp(&m_aFilename[strlen(m_aFilename) - strlen(".mp3")], ".mp3")) m_pSoundFile = new CMP3File(m_aFilename); else if (!strcasecmp(&m_aFilename[strlen(m_aFilename) - strlen(".wav")], ".wav")) +#ifdef AUDIO_OAL_USE_SNDFILE m_pSoundFile = new CSndFile(m_aFilename); +#else + m_pSoundFile = new CWavFile(m_aFilename); +#endif else if (!strcasecmp(&m_aFilename[strlen(m_aFilename) - strlen(".vb")], ".VB")) m_pSoundFile = new CVbFile(m_aFilename, overrideSampleRate); #else @@ -922,12 +1220,15 @@ void CStream::Update() // Relying a lot on left buffer states in here - //alSourcef(m_pAlSources[0], AL_ROLLOFF_FACTOR, 0.0f); - alGetSourcei(m_pAlSources[0], AL_SOURCE_STATE, &sourceState[0]); - alGetSourcei(m_pAlSources[0], AL_BUFFERS_PROCESSED, &buffersProcessed[0]); - //alSourcef(m_pAlSources[1], AL_ROLLOFF_FACTOR, 0.0f); - alGetSourcei(m_pAlSources[1], AL_SOURCE_STATE, &sourceState[1]); - alGetSourcei(m_pAlSources[1], AL_BUFFERS_PROCESSED, &buffersProcessed[1]); + do + { + //alSourcef(m_pAlSources[0], AL_ROLLOFF_FACTOR, 0.0f); + alGetSourcei(m_pAlSources[0], AL_SOURCE_STATE, &sourceState[0]); + alGetSourcei(m_pAlSources[0], AL_BUFFERS_PROCESSED, &buffersProcessed[0]); + //alSourcef(m_pAlSources[1], AL_ROLLOFF_FACTOR, 0.0f); + alGetSourcei(m_pAlSources[1], AL_SOURCE_STATE, &sourceState[1]); + alGetSourcei(m_pAlSources[1], AL_BUFFERS_PROCESSED, &buffersProcessed[1]); + } while (buffersProcessed[0] != buffersProcessed[1]); ALint looping = AL_FALSE; alGetSourcei(m_pAlSources[0], AL_LOOPING, &looping); -- cgit v1.2.3 From 145bd243e8fc0a25e18288cb9d012320aef8b43e Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Wed, 6 Jan 2021 17:56:23 +0100 Subject: Small fixes for new wav decoder --- src/audio/oal/stream.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/audio') diff --git a/src/audio/oal/stream.cpp b/src/audio/oal/stream.cpp index 0a5be049..2b1d37c2 100644 --- a/src/audio/oal/stream.cpp +++ b/src/audio/oal/stream.cpp @@ -193,9 +193,9 @@ class CWavFile : public IDecoder fclose(pFile); pFile = nil; } - if (AdpcmBlock) delete AdpcmBlock; - if (buffers) delete buffers; - if (decoders) delete decoders; + if (AdpcmBlock) delete[] AdpcmBlock; + if (buffers) delete[] buffers; + if (decoders) delete[] decoders; } public: -- cgit v1.2.3 From 36996af82b9f4b8d9d20335f8141347a51304e02 Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Wed, 6 Jan 2021 18:14:44 +0100 Subject: Fixes for CVbFile --- src/audio/oal/stream.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/audio') diff --git a/src/audio/oal/stream.cpp b/src/audio/oal/stream.cpp index 2b1d37c2..c084f2a9 100644 --- a/src/audio/oal/stream.cpp +++ b/src/audio/oal/stream.cpp @@ -664,11 +664,11 @@ public: if (pFile) { fclose(pFile); - delete decoders; + delete[] decoders; for (int i = 0; i < m_nChannels; i++) - delete ppTempBuffers[i]; - delete ppTempBuffers; - delete buffers; + delete[] ppTempBuffers[i]; + delete[] ppTempBuffers; + delete[] buffers; } } -- cgit v1.2.3 From 02a28996f4028b49d70dfa573f9faf0578ed7244 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Wed, 6 Jan 2021 20:22:09 +0200 Subject: Cleanup and fixes for new decoders --- src/audio/oal/stream.cpp | 267 ++++++++++++++++++++++++++--------------------- 1 file changed, 149 insertions(+), 118 deletions(-) (limited to 'src/audio') diff --git a/src/audio/oal/stream.cpp b/src/audio/oal/stream.cpp index c084f2a9..f9c02821 100644 --- a/src/audio/oal/stream.cpp +++ b/src/audio/oal/stream.cpp @@ -174,35 +174,45 @@ class CWavFile : public IDecoder tFormatHeader() { memset(this, 0, sizeof(*this)); } }; - FILE* pFile; - bool bIsOpen; - tFormatHeader FormatHeader; + FILE *m_pFile; + bool m_bIsOpen; - uint32 DataStartOffset; - uint32 SampleCount; - uint32 SamplesPerBlock; + tFormatHeader m_FormatHeader; + + uint32 m_DataStartOffset; // TODO: 64 bit? + uint32 m_nSampleCount; + uint32 m_nSamplesPerBlock; // ADPCM things - uint8 *AdpcmBlock; - int16 **buffers; - CImaADPCMDecoder* decoders; + uint8 *m_pAdpcmBuffer; + int16 **m_ppPcmBuffers; + CImaADPCMDecoder *m_pAdpcmDecoders; void Close() { - if (pFile) { - fclose(pFile); - pFile = nil; + if (m_pFile) { + fclose(m_pFile); + m_pFile = nil; } - if (AdpcmBlock) delete[] AdpcmBlock; - if (buffers) delete[] buffers; - if (decoders) delete[] decoders; + delete[] m_pAdpcmBuffer; + delete[] m_ppPcmBuffers; + delete[] m_pAdpcmDecoders; + } + + uint32 GetCurrentSample() const + { + // TODO: 64 bit? + uint32 FilePos = ftell(m_pFile); + if (FilePos <= m_DataStartOffset) + return 0; + return (FilePos - m_DataStartOffset) / m_FormatHeader.BlockAlign * m_nSamplesPerBlock; } public: - CWavFile(const char* path) : bIsOpen(false), DataStartOffset(0), SampleCount(0), SamplesPerBlock(0), AdpcmBlock(nil), buffers(nil), decoders(nil) + CWavFile(const char* path) : m_bIsOpen(false), m_DataStartOffset(0), m_nSampleCount(0), m_nSamplesPerBlock(0), m_pAdpcmBuffer(nil), m_ppPcmBuffers(nil), m_pAdpcmDecoders(nil) { - pFile = fopen(path, "rb"); - if (!pFile) return; + m_pFile = fopen(path, "rb"); + if (!m_pFile) return; #define CLOSE_ON_ERROR(op)\ if (op) { \ @@ -212,52 +222,58 @@ public: tDataHeader DataHeader; - CLOSE_ON_ERROR(fread(&DataHeader, sizeof(DataHeader), 1, pFile) == 0); + CLOSE_ON_ERROR(fread(&DataHeader, sizeof(DataHeader), 1, m_pFile) == 0); CLOSE_ON_ERROR(DataHeader.ID != 'FFIR'); + // TODO? validate filesizes + int WAVE; - CLOSE_ON_ERROR(fread(&WAVE, 4, 1, pFile) == 0); + CLOSE_ON_ERROR(fread(&WAVE, 4, 1, m_pFile) == 0); CLOSE_ON_ERROR(WAVE != 'EVAW') - CLOSE_ON_ERROR(fread(&DataHeader, sizeof(DataHeader), 1, pFile) == 0); + CLOSE_ON_ERROR(fread(&DataHeader, sizeof(DataHeader), 1, m_pFile) == 0); CLOSE_ON_ERROR(DataHeader.ID != ' tmf'); - CLOSE_ON_ERROR(fread(&FormatHeader, Min(DataHeader.Size, sizeof(tFormatHeader)), 1, pFile) == 0); + CLOSE_ON_ERROR(fread(&m_FormatHeader, Min(DataHeader.Size, sizeof(tFormatHeader)), 1, m_pFile) == 0); CLOSE_ON_ERROR(DataHeader.Size > sizeof(tFormatHeader)); - switch (FormatHeader.AudioFormat) + switch (m_FormatHeader.AudioFormat) { case WAVEFMT_XBOX_ADPCM: - FormatHeader.AudioFormat = WAVEFMT_IMA_ADPCM; + m_FormatHeader.AudioFormat = WAVEFMT_IMA_ADPCM; case WAVEFMT_IMA_ADPCM: - SamplesPerBlock = (FormatHeader.BlockAlign / FormatHeader.NumChannels - 4) * 2 + 1; - AdpcmBlock = new uint8[FormatHeader.BlockAlign]; - buffers = new int16*[FormatHeader.NumChannels]; - decoders = new CImaADPCMDecoder[FormatHeader.NumChannels]; + m_nSamplesPerBlock = (m_FormatHeader.BlockAlign / m_FormatHeader.NumChannels - 4) * 2 + 1; + m_pAdpcmBuffer = new uint8[m_FormatHeader.BlockAlign]; + m_ppPcmBuffers = new int16*[m_FormatHeader.NumChannels]; + m_pAdpcmDecoders = new CImaADPCMDecoder[m_FormatHeader.NumChannels]; break; case WAVEFMT_PCM: - SamplesPerBlock = 1; - if (FormatHeader.BitsPerSample != 16) + m_nSamplesPerBlock = 1; + if (m_FormatHeader.BitsPerSample != 16) { - debug("Unsupported PCM (%d bits), only signed 16-bit is supported (%s)\n", FormatHeader.BitsPerSample, path); + debug("Unsupported PCM (%d bits), only signed 16-bit is supported (%s)\n", m_FormatHeader.BitsPerSample, path); + Close(); return; } break; default: - debug("Unsupported wav format 0x%x (%s)\n", FormatHeader.AudioFormat, path); + debug("Unsupported wav format 0x%x (%s)\n", m_FormatHeader.AudioFormat, path); + Close(); return; } while (true) { - CLOSE_ON_ERROR(fread(&DataHeader, sizeof(DataHeader), 1, pFile) == 0); + CLOSE_ON_ERROR(fread(&DataHeader, sizeof(DataHeader), 1, m_pFile) == 0); if (DataHeader.ID == 'atad') break; - fseek(pFile, DataHeader.Size, SEEK_CUR); + fseek(m_pFile, DataHeader.Size, SEEK_CUR); + // TODO? validate data size + // maybe check if there no extreme custom headers that might break this } - DataStartOffset = ftell(pFile); - SampleCount = DataHeader.Size / FormatHeader.BlockAlign * SamplesPerBlock; + m_DataStartOffset = ftell(m_pFile); + m_nSampleCount = DataHeader.Size / m_FormatHeader.BlockAlign * m_nSamplesPerBlock; - bIsOpen = true; + m_bIsOpen = true; #undef CLOSE_ON_ERROR } @@ -268,7 +284,7 @@ public: bool IsOpened() { - return bIsOpen; + return m_bIsOpen; } uint32 GetSampleSize() @@ -278,29 +294,29 @@ public: uint32 GetSampleCount() { - return SampleCount; + return m_nSampleCount; } uint32 GetSampleRate() { - return FormatHeader.SampleRate; + return m_FormatHeader.SampleRate; } uint32 GetChannels() { - return FormatHeader.NumChannels; + return m_FormatHeader.NumChannels; } void Seek(uint32 milliseconds) { if (!IsOpened()) return; - fseek(pFile, DataStartOffset + ms2samples(milliseconds) / SamplesPerBlock * FormatHeader.BlockAlign, SEEK_SET); + fseek(m_pFile, m_DataStartOffset + ms2samples(milliseconds) / m_nSamplesPerBlock * m_FormatHeader.BlockAlign, SEEK_SET); } uint32 Tell() { if (!IsOpened()) return 0; - return samples2ms((ftell(pFile) - DataStartOffset) / FormatHeader.BlockAlign * SamplesPerBlock); + return samples2ms(GetCurrentSample()); } #define SAMPLES_IN_LINE (8) @@ -309,52 +325,61 @@ public: { if (!IsOpened()) return 0; - if (FormatHeader.AudioFormat == WAVEFMT_PCM) + if (m_FormatHeader.AudioFormat == WAVEFMT_PCM) { - uint32 size = fread(buffer, 1, GetBufferSize(), pFile); - if (FormatHeader.NumChannels == 2) + // just read the file and sort the samples + uint32 size = fread(buffer, 1, GetBufferSize(), m_pFile); + if (m_FormatHeader.NumChannels == 2) SortStereoBuffer.SortStereo(buffer, size); return size; } - else if (FormatHeader.AudioFormat == WAVEFMT_IMA_ADPCM) + else if (m_FormatHeader.AudioFormat == WAVEFMT_IMA_ADPCM) { - uint32 MaxSamples = GetBufferSamples() / FormatHeader.NumChannels; - uint32 CurSample = (ftell(pFile) - DataStartOffset) / FormatHeader.BlockAlign * SamplesPerBlock; - - MaxSamples = Min(MaxSamples, SampleCount - CurSample); - MaxSamples = MaxSamples / SamplesPerBlock * SamplesPerBlock; - uint32 OutBufSizePerChannel = MaxSamples * GetSampleSize(); - uint32 OutBufSize = OutBufSizePerChannel * FormatHeader.NumChannels; - int16** buffers = new int16*[FormatHeader.NumChannels]; - CImaADPCMDecoder* decoders = new CImaADPCMDecoder[FormatHeader.NumChannels]; - for (uint32 i = 0; i < FormatHeader.NumChannels; i++) - buffers[i] = (int16*)((int8*)buffer + OutBufSizePerChannel * i); + // trim the buffer size if we're at the end of our file + uint32 nMaxSamples = GetBufferSamples() / m_FormatHeader.NumChannels; + uint32 nSamplesLeft = m_nSampleCount - GetCurrentSample(); + nMaxSamples = Min(nMaxSamples, nSamplesLeft); + + // align sample count to our block + nMaxSamples = nMaxSamples / m_nSamplesPerBlock * m_nSamplesPerBlock; + + // count the size of output buffer + uint32 OutBufSizePerChannel = nMaxSamples * GetSampleSize(); + uint32 OutBufSize = OutBufSizePerChannel * m_FormatHeader.NumChannels; + + // calculate the pointers to individual channel buffers + for (uint32 i = 0; i < m_FormatHeader.NumChannels; i++) + m_ppPcmBuffers[i] = (int16*)((int8*)buffer + OutBufSizePerChannel * i); uint32 samplesRead = 0; - while (samplesRead < MaxSamples) + while (samplesRead < nMaxSamples) { - uint8* AdpcmBuf = AdpcmBlock; - if (fread(AdpcmBlock, 1, FormatHeader.BlockAlign, pFile) == 0) + // read the file + uint8 *pAdpcmBuf = m_pAdpcmBuffer; + if (fread(m_pAdpcmBuffer, 1, m_FormatHeader.BlockAlign, m_pFile) == 0) return 0; - for (uint32 i = 0; i < FormatHeader.NumChannels; i++) + // get the first sample in adpcm block and initialise the decoder(s) + for (uint32 i = 0; i < m_FormatHeader.NumChannels; i++) { - int16 Sample = *(int16*)AdpcmBuf; - AdpcmBuf += sizeof(int16); - int16 Step = *(int16*)AdpcmBuf; - AdpcmBuf += sizeof(int16); - decoders[i].Init(Sample, Step); - *(buffers[i]) = Sample; - buffers[i]++; + int16 Sample = *(int16*)pAdpcmBuf; + pAdpcmBuf += sizeof(int16); + int16 Step = *(int16*)pAdpcmBuf; + pAdpcmBuf += sizeof(int16); + m_pAdpcmDecoders[i].Init(Sample, Step); + *(m_ppPcmBuffers[i]) = Sample; + m_ppPcmBuffers[i]++; } samplesRead++; - for (uint32 s = 1; s < SamplesPerBlock; s += SAMPLES_IN_LINE) + + // decode the rest of the block + for (uint32 s = 1; s < m_nSamplesPerBlock; s += SAMPLES_IN_LINE) { - for (uint32 i = 0; i < FormatHeader.NumChannels; i++) + for (uint32 i = 0; i < m_FormatHeader.NumChannels; i++) { - decoders[i].Decode(AdpcmBuf, buffers[i], SAMPLES_IN_LINE / 2); - AdpcmBuf += SAMPLES_IN_LINE / 2; - buffers[i] += SAMPLES_IN_LINE; + m_pAdpcmDecoders[i].Decode(pAdpcmBuf, m_ppPcmBuffers[i], SAMPLES_IN_LINE / 2); + pAdpcmBuf += SAMPLES_IN_LINE / 2; + m_ppPcmBuffers[i] += SAMPLES_IN_LINE; } samplesRead += SAMPLES_IN_LINE; } @@ -613,68 +638,68 @@ public: class CVbFile : public IDecoder { - FILE* pFile; - size_t m_FileSize; - size_t m_nNumberOfBlocks; - CVagDecoder* decoders; + FILE *m_pFile; + CVagDecoder *m_pVagDecoders; - uint32 m_nSampleRate; - uint8 m_nChannels; - bool m_bBlockRead; - uint16 m_LineInBlock; - size_t m_CurrentBlock; + size_t m_FileSize; + size_t m_nNumberOfBlocks; - uint8** ppTempBuffers; - int16** buffers; + uint32 m_nSampleRate; + uint8 m_nChannels; + bool m_bBlockRead; + uint16 m_LineInBlock; + size_t m_CurrentBlock; + + uint8 **m_ppVagBuffers; // buffers that cache actual ADPCM file data + int16 **m_ppPcmBuffers; void ReadBlock(int32 block = -1) { // just read next block if -1 if (block != -1) - fseek(pFile, block * m_nChannels * VB_BLOCK_SIZE, SEEK_SET); + fseek(m_pFile, block * m_nChannels * VB_BLOCK_SIZE, SEEK_SET); for (int i = 0; i < m_nChannels; i++) - fread(ppTempBuffers[i], VB_BLOCK_SIZE, 1, pFile); + fread(m_ppVagBuffers[i], VB_BLOCK_SIZE, 1, m_pFile); m_bBlockRead = true; } public: - CVbFile(const char* path, uint32 nSampleRate = 32000, uint8 nChannels = 2) : m_nSampleRate(nSampleRate), m_nChannels(nChannels), decoders(nil), ppTempBuffers(nil), buffers(nil), + CVbFile(const char* path, uint32 nSampleRate = 32000, uint8 nChannels = 2) : m_nSampleRate(nSampleRate), m_nChannels(nChannels), m_pVagDecoders(nil), m_ppVagBuffers(nil), m_ppPcmBuffers(nil), m_FileSize(0), m_nNumberOfBlocks(0), m_bBlockRead(false), m_LineInBlock(0), m_CurrentBlock(0) { - pFile = fopen(path, "rb"); - if (!pFile) return; + m_pFile = fopen(path, "rb"); + if (!m_pFile) return; + + fseek(m_pFile, 0, SEEK_END); + m_FileSize = ftell(m_pFile); + fseek(m_pFile, 0, SEEK_SET); - fseek(pFile, 0, SEEK_END); - m_FileSize = ftell(pFile); - fseek(pFile, 0, SEEK_SET); m_nNumberOfBlocks = m_FileSize / (nChannels * VB_BLOCK_SIZE); - decoders = new CVagDecoder[nChannels]; - m_CurrentBlock = 0; - m_LineInBlock = 0; - m_bBlockRead = false; - ppTempBuffers = new uint8*[nChannels]; - buffers = new int16*[nChannels]; + m_pVagDecoders = new CVagDecoder[nChannels]; + m_ppVagBuffers = new uint8*[nChannels]; + m_ppPcmBuffers = new int16*[nChannels]; for (uint8 i = 0; i < nChannels; i++) - ppTempBuffers[i] = new uint8[VB_BLOCK_SIZE]; + m_ppVagBuffers[i] = new uint8[VB_BLOCK_SIZE]; } ~CVbFile() { - if (pFile) + if (m_pFile) { - fclose(pFile); - delete[] decoders; + fclose(m_pFile); + + delete[] m_pVagDecoders; for (int i = 0; i < m_nChannels; i++) - delete[] ppTempBuffers[i]; - delete[] ppTempBuffers; - delete[] buffers; + delete[] m_ppVagBuffers[i]; + delete[] m_ppVagBuffers; + delete[] m_ppPcmBuffers; } } bool IsOpened() { - return pFile != nil; + return m_pFile != nil; } uint32 GetSampleSize() @@ -702,6 +727,8 @@ public: { if (!IsOpened()) return; uint32 samples = ms2samples(milliseconds); + + // find the block of our sample uint32 block = samples / NUM_VAG_SAMPLES_IN_BLOCK; if (block > m_nNumberOfBlocks) { @@ -711,6 +738,7 @@ public: if (block != m_CurrentBlock) m_bBlockRead = false; + // find a line of our sample within our block uint32 remainingSamples = samples - block * NUM_VAG_SAMPLES_IN_BLOCK; uint32 newLine = remainingSamples / VAG_SAMPLES_IN_LINE / VAG_LINE_SIZE; @@ -719,7 +747,7 @@ public: m_CurrentBlock = block; m_LineInBlock = newLine; for (uint32 i = 0; i < GetChannels(); i++) - decoders[i].ResetState(); + m_pVagDecoders[i].ResetState(); } } @@ -735,35 +763,38 @@ public: { if (!IsOpened()) return 0; + if (m_CurrentBlock >= m_nNumberOfBlocks) return 0; + + // cache current ADPCM block if (!m_bBlockRead) ReadBlock(m_CurrentBlock); - if (m_CurrentBlock == m_nNumberOfBlocks) return 0; - int size = 0; - + // trim the buffer size if we're at the end of our file int numberOfRequiredLines = GetBufferSamples() / m_nChannels / VAG_SAMPLES_IN_LINE; int numberOfRemainingLines = (m_nNumberOfBlocks - m_CurrentBlock) * NUM_VAG_LINES_IN_BLOCK - m_LineInBlock; int bufSizePerChannel = Min(numberOfRequiredLines, numberOfRemainingLines) * VAG_SAMPLES_IN_LINE * GetSampleSize(); - if (numberOfRequiredLines > numberOfRemainingLines) - numberOfRemainingLines = numberOfRemainingLines; - + // calculate the pointers to individual channel buffers for (uint32 i = 0; i < m_nChannels; i++) - buffers[i] = (int16*)((int8*)buffer + bufSizePerChannel * i); + m_ppPcmBuffers[i] = (int16*)((int8*)buffer + bufSizePerChannel * i); + int size = 0; while (size < bufSizePerChannel) { + // decode the VAG lines for (uint32 i = 0; i < m_nChannels; i++) { - decoders[i].Decode(ppTempBuffers[i] + m_LineInBlock * VAG_LINE_SIZE, buffers[i], VAG_LINE_SIZE); - buffers[i] += VAG_SAMPLES_IN_LINE; + m_pVagDecoders[i].Decode(m_ppVagBuffers[i] + m_LineInBlock * VAG_LINE_SIZE, m_ppPcmBuffers[i], VAG_LINE_SIZE); + m_ppPcmBuffers[i] += VAG_SAMPLES_IN_LINE; } size += VAG_SAMPLES_IN_LINE * GetSampleSize(); m_LineInBlock++; + + // block is over, read the next block if (m_LineInBlock >= NUM_VAG_LINES_IN_BLOCK) { m_CurrentBlock++; - if (m_CurrentBlock >= m_nNumberOfBlocks) + if (m_CurrentBlock >= m_nNumberOfBlocks) // end of file break; m_LineInBlock = 0; ReadBlock(); -- cgit v1.2.3 From ef13866af6e08797030865a33a1d5ba260a833bf Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Thu, 7 Jan 2021 22:01:44 +0200 Subject: Make opus available alongside other formats --- src/audio/oal/stream.cpp | 34 ++++++++++++++++++---------------- src/audio/sampman.h | 6 ++++-- src/audio/sampman_oal.cpp | 12 ++++++------ 3 files changed, 28 insertions(+), 24 deletions(-) (limited to 'src/audio') diff --git a/src/audio/oal/stream.cpp b/src/audio/oal/stream.cpp index f9c02821..8c7b3232 100644 --- a/src/audio/oal/stream.cpp +++ b/src/audio/oal/stream.cpp @@ -4,20 +4,23 @@ #include "stream.h" #include "sampman.h" -#ifdef AUDIO_OPUS -#include -#else #ifdef _WIN32 #ifdef AUDIO_OAL_USE_SNDFILE #pragma comment( lib, "libsndfile-1.lib" ) #endif +#ifdef AUDIO_OAL_USE_MPG123 #pragma comment( lib, "libmpg123-0.lib" ) #endif +#endif #ifdef AUDIO_OAL_USE_SNDFILE #include #endif +#ifdef AUDIO_OAL_USE_MPG123 #include #endif +#ifdef AUDIO_OAL_USE_OPUS +#include +#endif #ifndef _WIN32 #include "crossplatform.h" @@ -81,7 +84,6 @@ public: CSortStereoBuffer SortStereoBuffer; -#ifndef AUDIO_OPUS class CImaADPCMDecoder { const uint16 StepTable[89] = { @@ -461,11 +463,9 @@ public: }; #endif -#ifdef _WIN32 +#ifdef AUDIO_OAL_USE_MPG123 // fuzzy seek eliminates stutter when playing ADF but spams errors a lot (nothing breaks though) #define MP3_USE_FUZZY_SEEK -#endif // _WIN32 - class CMP3File : public IDecoder { @@ -567,6 +567,7 @@ public: } }; +#endif #define VAG_LINE_SIZE (0x10) #define VAG_SAMPLES_IN_LINE (28) @@ -804,7 +805,7 @@ public: return bufSizePerChannel * m_nChannels; } }; -#else +#ifdef AUDIO_OAL_USE_OPUS class COpusFile : public IDecoder { OggOpusFile *m_FileH; @@ -902,14 +903,14 @@ public: void CStream::Initialise() { -#ifndef AUDIO_OPUS +#ifdef AUDIO_OAL_USE_MPG123 mpg123_init(); #endif } void CStream::Terminate() { -#ifndef AUDIO_OPUS +#ifdef AUDIO_OAL_USE_MPG123 mpg123_exit(); #endif } @@ -942,19 +943,20 @@ CStream::CStream(char *filename, ALuint *sources, ALuint (&buffers)[NUM_STREAMBU DEV("Stream %s\n", m_aFilename); -#ifndef AUDIO_OPUS - if (!strcasecmp(&m_aFilename[strlen(m_aFilename) - strlen(".mp3")], ".mp3")) - m_pSoundFile = new CMP3File(m_aFilename); - else if (!strcasecmp(&m_aFilename[strlen(m_aFilename) - strlen(".wav")], ".wav")) + if (!strcasecmp(&m_aFilename[strlen(m_aFilename) - strlen(".wav")], ".wav")) #ifdef AUDIO_OAL_USE_SNDFILE m_pSoundFile = new CSndFile(m_aFilename); #else m_pSoundFile = new CWavFile(m_aFilename); +#endif +#ifdef AUDIO_OAL_USE_MPG123 + else if (!strcasecmp(&m_aFilename[strlen(m_aFilename) - strlen(".mp3")], ".mp3")) + m_pSoundFile = new CMP3File(m_aFilename); #endif else if (!strcasecmp(&m_aFilename[strlen(m_aFilename) - strlen(".vb")], ".VB")) m_pSoundFile = new CVbFile(m_aFilename, overrideSampleRate); -#else - if (!strcasecmp(&m_aFilename[strlen(m_aFilename) - strlen(".opus")], ".opus")) +#ifdef AUDIO_OAL_USE_OPUS + else if (!strcasecmp(&m_aFilename[strlen(m_aFilename) - strlen(".opus")], ".opus")) m_pSoundFile = new COpusFile(m_aFilename); #endif else diff --git a/src/audio/sampman.h b/src/audio/sampman.h index 2284d385..72c3eb7f 100644 --- a/src/audio/sampman.h +++ b/src/audio/sampman.h @@ -218,7 +218,7 @@ extern uint32 BankStartOffset[MAX_SFX_BANKS]; extern int defaultProvider; #endif -#ifdef AUDIO_OPUS +#if defined(OPUS_AUDIO_PATHS) static char StreamedNameTable[][25] = { "AUDIO\\HEAD.OPUS", "AUDIO\\CLASS.OPUS", "AUDIO\\KJAH.OPUS", "AUDIO\\RISE.OPUS", "AUDIO\\LIPS.OPUS", "AUDIO\\GAME.OPUS", "AUDIO\\MSX.OPUS", "AUDIO\\FLASH.OPUS", "AUDIO\\CHAT.OPUS", "AUDIO\\HEAD.OPUS", "AUDIO\\POLICE.OPUS", "AUDIO\\CITY.OPUS", @@ -254,9 +254,9 @@ static char StreamedNameTable[][25] = { "AUDIO\\door_2.OPUS", "AUDIO\\door_3.OPUS", "AUDIO\\door_4.OPUS", "AUDIO\\door_5.OPUS", "AUDIO\\door_6.OPUS", "AUDIO\\t3_a.OPUS", "AUDIO\\t3_b.OPUS", "AUDIO\\t3_c.OPUS", "AUDIO\\k1_b.OPUS", "AUDIO\\cat1.OPUS"}; #else +#if defined(PS2_AUDIO_PATHS) static char StreamedNameTable[][25]= { -#ifdef PS2_AUDIO "AUDIO\\MUSIC\\HEAD.VB", "AUDIO\\MUSIC\\CLASS.VB", "AUDIO\\MUSIC\\KJAH.VB", @@ -353,6 +353,8 @@ static char StreamedNameTable[][25]= "AUDIO\\MUSIC\\MISCOM.VB", "AUDIO\\MUSIC\\END.VB", #else +static char StreamedNameTable[][25] = +{ "AUDIO\\HEAD.WAV", "AUDIO\\CLASS.WAV", "AUDIO\\KJAH.WAV", diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp index 07d943e3..bb7f0aac 100644 --- a/src/audio/sampman_oal.cpp +++ b/src/audio/sampman_oal.cpp @@ -30,7 +30,7 @@ #include "MusicManager.h" #include "Frontend.h" #include "Timer.h" -#ifdef AUDIO_OPUS +#ifdef AUDIO_OAL_USE_OPUS #include #endif @@ -83,7 +83,7 @@ char SampleBankDescFilename[] = "audio/sfx.SDT"; char SampleBankDataFilename[] = "audio/sfx.RAW"; FILE *fpSampleDescHandle; -#ifdef AUDIO_OPUS +#ifdef OPUS_SFX OggOpusFile *fpSampleDataHandle; #else FILE *fpSampleDataHandle; @@ -1218,7 +1218,7 @@ cSampleManager::LoadSampleBank(uint8 nBank) return false; } -#ifdef AUDIO_OPUS +#ifdef OPUS_SFX int samplesRead = 0; int samplesSize = nSampleBankSize[nBank] / 2; op_pcm_seek(fpSampleDataHandle, 0); @@ -1331,7 +1331,7 @@ cSampleManager::LoadPedComment(uint32 nComment) } } -#ifdef AUDIO_OPUS +#ifdef OPUS_SFX int samplesRead = 0; int samplesSize = m_aSamples[nComment].nSize / 2; op_pcm_seek(fpSampleDataHandle, m_aSamples[nComment].nOffset / 2); @@ -1978,7 +1978,7 @@ cSampleManager::InitialiseSampleBanks(void) fpSampleDescHandle = fcaseopen(SampleBankDescFilename, "rb"); if ( fpSampleDescHandle == NULL ) return false; -#ifndef AUDIO_OPUS +#ifndef OPUS_SFX fpSampleDataHandle = fcaseopen(SampleBankDataFilename, "rb"); if ( fpSampleDataHandle == NULL ) { @@ -1996,7 +1996,7 @@ cSampleManager::InitialiseSampleBanks(void) fpSampleDataHandle = op_open_file(SampleBankDataFilename, &e); #endif fread(m_aSamples, sizeof(tSample), TOTAL_AUDIO_SAMPLES, fpSampleDescHandle); -#ifdef AUDIO_OPUS +#ifdef OPUS_SFX int32 _nSampleDataEndOffset = m_aSamples[TOTAL_AUDIO_SAMPLES - 1].nOffset + m_aSamples[TOTAL_AUDIO_SAMPLES - 1].nSize; #endif fclose(fpSampleDescHandle); -- cgit v1.2.3 From d8a04c9e43f493362dd522f67929c850b8e45f49 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Thu, 7 Jan 2021 22:15:30 +0200 Subject: Add MPG123_QUIET to mp3 files --- src/audio/oal/stream.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/audio') diff --git a/src/audio/oal/stream.cpp b/src/audio/oal/stream.cpp index 8c7b3232..ccb17577 100644 --- a/src/audio/oal/stream.cpp +++ b/src/audio/oal/stream.cpp @@ -484,7 +484,7 @@ public: if ( m_pMH ) { #ifdef MP3_USE_FUZZY_SEEK - mpg123_param(m_pMH, MPG123_FLAGS, MPG123_FUZZY | MPG123_SEEKBUFFER | MPG123_GAPLESS, 0.0); + mpg123_param(m_pMH, MPG123_FLAGS, MPG123_FUZZY | MPG123_SEEKBUFFER | MPG123_GAPLESS | MPG123_QUIET, 0.0); #endif long rate = 0; int channels = 0; -- cgit v1.2.3 From 8eed6ae1794989eb15fe95d867c44c196080c4dd Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Fri, 8 Jan 2021 21:50:59 +0200 Subject: Use original names --- src/audio/AudioLogic.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/audio') diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 976bbaec..777fdfe4 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -5788,7 +5788,7 @@ cAudioManager::GetCasualMaleOldTalkSfx(int16 sound) uint32 cAudioManager::GetSpecialCharacterTalkSfx(int32 modelIndex, int32 sound) { - char *modelName = CModelInfo::GetModelInfo(modelIndex)->GetName(); + char *modelName = CModelInfo::GetModelInfo(modelIndex)->GetModelName(); if (!CGeneral::faststricmp(modelName, "eight") || !CGeneral::faststricmp(modelName, "eight2")) { return GetEightTalkSfx(sound); } -- cgit v1.2.3 From 8a157eee0a106ed30e785e8da203a6413d562452 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Mon, 11 Jan 2021 01:01:15 +0100 Subject: audio: only use #pragma comment(lib, xxx.lib) on MSVC --- src/audio/oal/stream.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/audio') diff --git a/src/audio/oal/stream.cpp b/src/audio/oal/stream.cpp index ccb17577..74ed86f4 100644 --- a/src/audio/oal/stream.cpp +++ b/src/audio/oal/stream.cpp @@ -4,7 +4,7 @@ #include "stream.h" #include "sampman.h" -#ifdef _WIN32 +#if defined _MSC_VER && !defined RE3_NO_AUTOLINK #ifdef AUDIO_OAL_USE_SNDFILE #pragma comment( lib, "libsndfile-1.lib" ) #endif -- cgit v1.2.3 From 5a47379bf5f011a65c1d0f88a0cb5f2130feb9db Mon Sep 17 00:00:00 2001 From: erorcun Date: Sat, 16 Jan 2021 16:44:59 +0300 Subject: Includes overhaul, fix some compiler warnings --- src/audio/PoliceRadio.cpp | 1 + src/audio/PoliceRadio.h | 2 +- src/audio/sampman.h | 1 - src/audio/sampman_miles.cpp | 6 ++---- src/audio/sampman_oal.cpp | 33 ++++++++++++++------------------- 5 files changed, 18 insertions(+), 25 deletions(-) (limited to 'src/audio') diff --git a/src/audio/PoliceRadio.cpp b/src/audio/PoliceRadio.cpp index 37421904..94143746 100644 --- a/src/audio/PoliceRadio.cpp +++ b/src/audio/PoliceRadio.cpp @@ -13,6 +13,7 @@ #include "World.h" #include "Zones.h" #include "sampman.h" +#include "Wanted.h" const int channels = ARRAY_SIZE(cAudioManager::m_asActiveSamples); const int policeChannel = channels + 1; diff --git a/src/audio/PoliceRadio.h b/src/audio/PoliceRadio.h index c01f21ce..368708b6 100644 --- a/src/audio/PoliceRadio.h +++ b/src/audio/PoliceRadio.h @@ -1,6 +1,6 @@ #pragma once -#include "Wanted.h" +#include "Crime.h" struct cAMCrime { int32 type; diff --git a/src/audio/sampman.h b/src/audio/sampman.h index 72c3eb7f..a5f6c7e2 100644 --- a/src/audio/sampman.h +++ b/src/audio/sampman.h @@ -1,5 +1,4 @@ #pragma once -#include "common.h" #include "AudioSamples.h" #define MAX_VOLUME 127 diff --git a/src/audio/sampman_miles.cpp b/src/audio/sampman_miles.cpp index db38da64..82886c66 100644 --- a/src/audio/sampman_miles.cpp +++ b/src/audio/sampman_miles.cpp @@ -1,8 +1,5 @@ -#include "common.h" - #ifdef AUDIO_MSS -#include -#include +#include #include #include @@ -11,6 +8,7 @@ #include "eax-util.h" #include "mss.h" +#include "common.h" #include "sampman.h" #include "AudioManager.h" #include "MusicManager.h" diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp index bb7f0aac..798ea287 100644 --- a/src/audio/sampman_oal.cpp +++ b/src/audio/sampman_oal.cpp @@ -1,17 +1,11 @@ //#define JUICY_OAL #ifdef AUDIO_OAL -#include "sampman.h" - #include #include "eax.h" #include "eax-util.h" -#define WITHWINDOWS -#include "common.h" -#include "crossplatform.h" - #ifdef _WIN32 #include #include @@ -19,8 +13,22 @@ #include #include #include + +#pragma comment(lib, "OpenAL32.lib") + +// for user MP3s +#include +#include +#include +#else +#define _getcwd getcwd #endif +#include "common.h" +#include "crossplatform.h" + +#include "sampman.h" + #include "oal/oal_utils.h" #include "oal/aldlist.h" #include "oal/channel.h" @@ -38,19 +46,6 @@ //TODO: max channels //TODO: loop count -#ifdef _WIN32 -#pragma comment( lib, "OpenAL32.lib" ) -#endif - -// for user MP3s -#ifdef _WIN32 -#include -#include -#include -#else -#define _getcwd getcwd -#endif - cSampleManager SampleManager; bool _bSampmanInitialised = false; -- cgit v1.2.3 From ac0f759b274368b9424222a392d9f28b73980eb0 Mon Sep 17 00:00:00 2001 From: withmorten Date: Tue, 19 Jan 2021 13:35:48 +0100 Subject: make building with Codewarrior 7 possible --- src/audio/AudioLogic.cpp | 4 ++-- src/audio/AudioManager.cpp | 4 ++-- src/audio/AudioManager.h | 2 +- src/audio/PoliceRadio.cpp | 2 +- src/audio/sampman_miles.cpp | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/audio') diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 777fdfe4..eab14ce6 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -1,4 +1,4 @@ -#include "common.h" +#include "common.h" #include "AudioManager.h" #include "audio_enums.h" @@ -38,7 +38,7 @@ #include "ZoneCull.h" #include "sampman.h" -const int channels = ARRAY_SIZE(cAudioManager::m_asActiveSamples); +const int channels = ARRAY_SIZE(AudioManager.m_asActiveSamples); const int policeChannel = channels + 1; const int allChannels = channels + 2; diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index e1b5be1d..f61350fb 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -13,7 +13,7 @@ cAudioManager AudioManager; -const int channels = ARRAY_SIZE(cAudioManager::m_asActiveSamples); +const int channels = ARRAY_SIZE(AudioManager.m_asActiveSamples); const int policeChannel = channels + 1; const int allChannels = channels + 2; @@ -948,7 +948,7 @@ cAudioManager::ClearActiveSamples() m_asActiveSamples[i].m_nCalculatedVolume = 0; m_asActiveSamples[i].m_nReleasingVolumeDivider = 0; m_asActiveSamples[i].m_nVolumeChange = -1; - m_asActiveSamples[i].m_vecPos = {0.0f, 0.0f, 0.0f}; + m_asActiveSamples[i].m_vecPos = CVector(0.0f, 0.0f, 0.0f); m_asActiveSamples[i].m_bReverbFlag = false; m_asActiveSamples[i].m_nLoopsRemaining = 0; m_asActiveSamples[i].m_bRequireReflection = false; diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index 2f86ee98..57ed0fb7 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -499,7 +499,7 @@ public: }; #ifdef AUDIO_MSS -static_assert(sizeof(cAudioManager) == 19220, "cAudioManager: error"); +re3_static_assert(sizeof(cAudioManager) == 19220, "cAudioManager: error"); #endif extern cAudioManager AudioManager; diff --git a/src/audio/PoliceRadio.cpp b/src/audio/PoliceRadio.cpp index 94143746..7021b5be 100644 --- a/src/audio/PoliceRadio.cpp +++ b/src/audio/PoliceRadio.cpp @@ -15,7 +15,7 @@ #include "sampman.h" #include "Wanted.h" -const int channels = ARRAY_SIZE(cAudioManager::m_asActiveSamples); +const int channels = ARRAY_SIZE(AudioManager.m_asActiveSamples); const int policeChannel = channels + 1; struct tPoliceRadioZone { diff --git a/src/audio/sampman_miles.cpp b/src/audio/sampman_miles.cpp index 82886c66..eccc9114 100644 --- a/src/audio/sampman_miles.cpp +++ b/src/audio/sampman_miles.cpp @@ -1,4 +1,4 @@ -#ifdef AUDIO_MSS +#if defined(AUDIO_MSS) || defined (__MWERKS__) #include #include -- cgit v1.2.3 From 034df61f3c2757b28c082101fd0f38054263c0ed Mon Sep 17 00:00:00 2001 From: withmorten Date: Thu, 21 Jan 2021 03:40:56 +0100 Subject: codewarrior: finishing touches --- src/audio/AudioManager.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/audio') diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index 57ed0fb7..2f86ee98 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -499,7 +499,7 @@ public: }; #ifdef AUDIO_MSS -re3_static_assert(sizeof(cAudioManager) == 19220, "cAudioManager: error"); +static_assert(sizeof(cAudioManager) == 19220, "cAudioManager: error"); #endif extern cAudioManager AudioManager; -- cgit v1.2.3 From 497e0b801ff30cf836887b625752c1643b533a7e Mon Sep 17 00:00:00 2001 From: withmorten Date: Fri, 22 Jan 2021 00:19:44 +0100 Subject: m_nWantedLevel -> GetWantedLevel() --- src/audio/PoliceRadio.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/audio') diff --git a/src/audio/PoliceRadio.cpp b/src/audio/PoliceRadio.cpp index 7021b5be..785dbf8f 100644 --- a/src/audio/PoliceRadio.cpp +++ b/src/audio/PoliceRadio.cpp @@ -161,7 +161,7 @@ cAudioManager::ServicePoliceRadio() if(CReplay::IsPlayingBack() || !FindPlayerPed() || !FindPlayerPed()->m_pWanted) return; #endif - wantedLevel = FindPlayerPed()->m_pWanted->m_nWantedLevel; + wantedLevel = FindPlayerPed()->m_pWanted->GetWantedLevel(); if(!crimeReport) { if(wantedLevel != 0) { if(nLastSeen != 0) { @@ -679,7 +679,7 @@ void cAudioManager::ReportCrime(eCrimeType type, const CVector &pos) { int32 lastCrime = ARRAY_SIZE(m_sPoliceRadioQueue.crimes); - if (m_bIsInitialised && MusicManager.m_nMusicMode != MUSICMODE_CUTSCENE && FindPlayerPed()->m_pWanted->m_nWantedLevel > 0 && + if (m_bIsInitialised && MusicManager.m_nMusicMode != MUSICMODE_CUTSCENE && FindPlayerPed()->m_pWanted->GetWantedLevel() > 0 && (type > CRIME_NONE || type < NUM_CRIME_TYPES) && m_FrameCounter >= gMinTimeToNextReport[type]) { for (int32 i = 0; i < ARRAY_SIZE(m_sPoliceRadioQueue.crimes); i++) { if (m_sPoliceRadioQueue.crimes[i].type) { -- cgit v1.2.3 From 3b4e79f073a5b4c19723d913ddd4aa9a17abfce3 Mon Sep 17 00:00:00 2001 From: withmorten Date: Fri, 22 Jan 2021 21:10:49 +0100 Subject: small fix regarding codewarrior and AUDIO_MSS --- src/audio/sampman_miles.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/audio') diff --git a/src/audio/sampman_miles.cpp b/src/audio/sampman_miles.cpp index eccc9114..11e2b0ff 100644 --- a/src/audio/sampman_miles.cpp +++ b/src/audio/sampman_miles.cpp @@ -1,4 +1,6 @@ -#if defined(AUDIO_MSS) || defined (__MWERKS__) +#include "common.h" + +#ifdef AUDIO_MSS #include #include @@ -8,7 +10,6 @@ #include "eax-util.h" #include "mss.h" -#include "common.h" #include "sampman.h" #include "AudioManager.h" #include "MusicManager.h" -- cgit v1.2.3 From 4afa7b86aefdb98eab039e76bdaf0c6f75c67cfa Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sun, 31 Jan 2021 23:44:30 +0200 Subject: Add radio off text --- src/audio/MusicManager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/audio') diff --git a/src/audio/MusicManager.cpp b/src/audio/MusicManager.cpp index 54c1b0bc..ad304985 100644 --- a/src/audio/MusicManager.cpp +++ b/src/audio/MusicManager.cpp @@ -163,13 +163,13 @@ cMusicManager::DisplayRadioStationName() case CHATTERBOX: string = TheText.Get("FEA_FM8"); break; case USERTRACK: string = TheText.Get("FEA_FM9"); break; #ifdef RADIO_OFF_TEXT - case RADIO_OFF: case POLICE_RADIO: string = TheText.Get("FEM_OFF"); break; + case RADIO_OFF: case POLICE_RADIO: string = TheText.Get("FEA_FMN"); break; #endif default: return; }; #ifdef RADIO_OFF_TEXT - if(pRetune == USERTRACK && !SampleManager.IsMP3RadioChannelAvailable()) { string = TheText.Get("FEM_OFF"); } + if(pRetune == USERTRACK && !SampleManager.IsMP3RadioChannelAvailable()) { string = TheText.Get("FEA_FMN"); } #else if(pRetune > CHATTERBOX && !SampleManager.IsMP3RadioChannelAvailable()) { return; } #endif -- cgit v1.2.3 From 1667ffdd8f7fcde03d283db32694f0dd27086299 Mon Sep 17 00:00:00 2001 From: erorcun Date: Wed, 3 Feb 2021 14:08:28 +0300 Subject: MusicManager fixes --- src/audio/AudioLogic.cpp | 2 +- src/audio/MusicManager.cpp | 281 ++++++++++++++++++++++++-------------------- src/audio/MusicManager.h | 10 +- src/audio/audio_enums.h | 5 +- src/audio/sampman_miles.cpp | 10 +- src/audio/sampman_oal.cpp | 10 +- src/audio/soundlist.h | 2 +- 7 files changed, 172 insertions(+), 148 deletions(-) (limited to 'src/audio') diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index eab14ce6..ec364c27 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -7927,7 +7927,7 @@ cAudioManager::ProcessFrontEnd() frontendBank = true; stereo = true; break; - case SOUND_FRONTEND_NO_RADIO: + case SOUND_FRONTEND_RADIO_TURN_OFF: case SOUND_FRONTEND_RADIO_CHANGE: m_sQueueSample.m_nSampleIndex = SFX_RADIO_CLICK; break; diff --git a/src/audio/MusicManager.cpp b/src/audio/MusicManager.cpp index ad304985..3e1a7384 100644 --- a/src/audio/MusicManager.cpp +++ b/src/audio/MusicManager.cpp @@ -15,6 +15,9 @@ #include "World.h" #include "sampman.h" +#if !defined FIX_BUGS && (defined RADIO_SCROLL_TO_PREV_STATION || defined RADIO_OFF_TEXT) +static_assert(false, "RADIO_SCROLL_TO_PREV_STATION and RADIO_OFF_TEXT won't work correctly without FIX_BUGS"); +#endif cMusicManager MusicManager; int32 gNumRetunePresses; @@ -26,8 +29,8 @@ cMusicManager::cMusicManager() m_bIsInitialised = false; m_bDisabled = false; m_nMusicMode = MUSICMODE_DISABLED; - m_nCurrentStreamedSound = NO_TRACK; - m_nPreviousStreamedSound = NO_TRACK; + m_nNextTrack = NO_TRACK; + m_nPlayingTrack = NO_TRACK; m_bFrontendTrackFinished = false; m_bPlayInFrontend = false; m_bSetNextStation = false; @@ -35,7 +38,7 @@ cMusicManager::cMusicManager() m_bPreviousPlayerInCar = false; m_bPlayerInCar = false; m_bAnnouncementInProgress = false; - m_bDontServiceAmbienceTrack = false; + m_bVerifyAmbienceTrackStartedToPlay = false; bHasStarted = false; } @@ -83,16 +86,15 @@ cMusicManager::DisplayRadioStationName() if(m_bPlayerInCar && !m_bPreviousPlayerInCar) pCurrentStation = nil; +#ifdef FIX_BUGS + const int curRadio = GetCarTuning(); +#else + const int curRadio = m_nNextTrack; +#endif + #ifdef RADIO_SCROLL_TO_PREV_STATION if(gNumRetunePresses < 0) { - gStreamedSound = m_nCurrentStreamedSound; - - if(gStreamedSound == STREAMED_SOUND_CITY_AMBIENT || - gStreamedSound == STREAMED_SOUND_WATER_AMBIENT) { - gStreamedSound = POLICE_RADIO; // which means OFF - - } else if(gStreamedSound > STREAMED_SOUND_RADIO_MP3_PLAYER) - return; + gStreamedSound = curRadio; gRetuneCounter = gNumRetunePresses; pRetune = gStreamedSound; @@ -100,7 +102,7 @@ cMusicManager::DisplayRadioStationName() while(gRetuneCounter < 0) { if(pRetune == HEAD_RADIO) { pRetune = RADIO_OFF; - } else if(pRetune == RADIO_OFF || pRetune == POLICE_RADIO) { + } else if(pRetune == RADIO_OFF || pRetune == NUM_RADIOS) { pRetune = SampleManager.IsMP3RadioChannelAvailable() ? USERTRACK : USERTRACK - 1; } else pRetune--; @@ -110,31 +112,38 @@ cMusicManager::DisplayRadioStationName() } else #endif if(SampleManager.IsMP3RadioChannelAvailable()) { - gStreamedSound = m_nCurrentStreamedSound; + gStreamedSound = curRadio; if(gStreamedSound == STREAMED_SOUND_CITY_AMBIENT || - gStreamedSound == STREAMED_SOUND_WATER_AMBIENT) { - gStreamedSound = POLICE_RADIO; // which means OFF + gStreamedSound == STREAMED_SOUND_WATER_AMBIENT) { // which means OFF + gStreamedSound = NUM_RADIOS; } else if(gStreamedSound > STREAMED_SOUND_RADIO_MP3_PLAYER) return; pRetune = gNumRetunePresses + gStreamedSound; - if(pRetune == POLICE_RADIO) { +#ifdef FIX_BUGS + while(pRetune > NUM_RADIOS) + pRetune -= (NUM_RADIOS + 1); +#endif + if(pRetune == NUM_RADIOS) { pRetune = RADIO_OFF; - } else if(pRetune > POLICE_RADIO) { - pRetune = pRetune - RADIO_OFF; } +#ifndef FIX_BUGS + else if(pRetune > NUM_RADIOS) { + pRetune = pRetune - (NUM_RADIOS + 1); + } +#endif } else { - gStreamedSound = m_nCurrentStreamedSound; + gStreamedSound = curRadio; pRetune = gNumRetunePresses + gStreamedSound; if(pRetune >= USERTRACK) { gRetuneCounter = gNumRetunePresses; - pRetune = m_nCurrentStreamedSound; + pRetune = curRadio; if(gStreamedSound == STREAMED_SOUND_WATER_AMBIENT) - pRetune = RADIO_OFF; + pRetune = STREAMED_SOUND_CITY_AMBIENT; // which is RADIO_OFF while(gRetuneCounter) { if(pRetune == RADIO_OFF) { @@ -149,7 +158,7 @@ cMusicManager::DisplayRadioStationName() } } - wchar *string = nil; + wchar *string; switch(pRetune) { case HEAD_RADIO: string = TheText.Get("FEA_FM0"); break; @@ -161,22 +170,27 @@ cMusicManager::DisplayRadioStationName() case MSX_FM: string = TheText.Get("FEA_FM6"); break; case FLASHBACK: string = TheText.Get("FEA_FM7"); break; case CHATTERBOX: string = TheText.Get("FEA_FM8"); break; - case USERTRACK: string = TheText.Get("FEA_FM9"); break; + case USERTRACK: + if (!SampleManager.IsMP3RadioChannelAvailable()) + return; + string = TheText.Get("FEA_FM9"); break; #ifdef RADIO_OFF_TEXT - case RADIO_OFF: case POLICE_RADIO: string = TheText.Get("FEA_FMN"); break; + case RADIO_OFF: { + extern wchar WideErrorString[]; + + string = TheText.Get("FEA_FMN"); + if(string == WideErrorString) { + pCurrentStation = nil; + return; + } + break; + } #endif default: return; }; -#ifdef RADIO_OFF_TEXT - if(pRetune == USERTRACK && !SampleManager.IsMP3RadioChannelAvailable()) { string = TheText.Get("FEA_FMN"); } -#else - if(pRetune > CHATTERBOX && !SampleManager.IsMP3RadioChannelAvailable()) { return; } -#endif - - if(string && pCurrentStation != string || - m_nCurrentStreamedSound == STREAMED_SOUND_RADIO_MP3_PLAYER && - m_nPreviousStreamedSound != STREAMED_SOUND_RADIO_MP3_PLAYER) { + if(pCurrentStation != string || + m_nNextTrack == STREAMED_SOUND_RADIO_MP3_PLAYER && m_nPlayingTrack != STREAMED_SOUND_RADIO_MP3_PLAYER) { pCurrentStation = string; cDisplay = 60; } else { @@ -257,7 +271,7 @@ cMusicManager::Initialise() m_bDoTrackService = false; m_bIgnoreTimeDelay = false; m_bRadioSetByScript = false; - m_nRadioStation = HEAD_RADIO; + m_nRadioStationScript = HEAD_RADIO; m_nRadioPosition = -1; m_nRadioInCar = NO_TRACK; gNumRetunePresses = 0; @@ -274,8 +288,8 @@ cMusicManager::Terminate() if (SampleManager.IsStreamPlaying(0)) { SampleManager.StopStreamedFile(0); - m_nCurrentStreamedSound = NO_TRACK; - m_nPreviousStreamedSound = NO_TRACK; + m_nNextTrack = NO_TRACK; + m_nPlayingTrack = NO_TRACK; } m_bIsInitialised = false; } @@ -303,14 +317,14 @@ cMusicManager::ChangeMusicMode(uint8 mode) case MUSICMODE_CUTSCENE: case MUSICMODE_DISABLED: if (SampleManager.IsStreamPlaying(0)) { - if (m_nCurrentStreamedSound < TOTAL_STREAMED_SOUNDS) { - m_aTracks[m_nCurrentStreamedSound].m_nPosition = SampleManager.GetStreamedFilePosition(0); - m_aTracks[m_nCurrentStreamedSound].m_nLastPosCheckTimer = CTimer::GetTimeInMillisecondsPauseMode(); + if (m_nNextTrack < TOTAL_STREAMED_SOUNDS) { + m_aTracks[m_nNextTrack].m_nPosition = SampleManager.GetStreamedFilePosition(0); + m_aTracks[m_nNextTrack].m_nLastPosCheckTimer = CTimer::GetTimeInMillisecondsPauseMode(); } SampleManager.StopStreamedFile(0); } - m_nCurrentStreamedSound = NO_TRACK; - m_nPreviousStreamedSound = NO_TRACK; + m_nNextTrack = NO_TRACK; + m_nPlayingTrack = NO_TRACK; m_bFrontendTrackFinished = false; m_bPlayInFrontend = false; m_bSetNextStation = false; @@ -320,7 +334,7 @@ cMusicManager::ChangeMusicMode(uint8 mode) m_nTimer = m_nLastTrackServiceTime = CTimer::GetTimeInMillisecondsPauseMode(); m_bDoTrackService = false; m_bIgnoreTimeDelay = true; - m_bDontServiceAmbienceTrack = false; + m_bVerifyAmbienceTrackStartedToPlay = false; m_nMusicMode = mode2; break; default: return; @@ -370,7 +384,7 @@ cMusicManager::SetRadioChannelByScript(uint8 station, int32 pos) { if (m_bIsInitialised && station < RADIO_OFF) { m_bRadioSetByScript = true; - m_nRadioStation = station; + m_nRadioStationScript = station; m_nRadioPosition = pos == -1 ? -1 : pos % m_aTracks[station].m_nLength; } } @@ -380,7 +394,7 @@ void cMusicManager::ResetMusicAfterReload() { m_bRadioSetByScript = false; - m_nRadioStation = 0; + m_nRadioStationScript = 0; m_nRadioPosition = -1; m_nAnnouncement = NO_TRACK; m_bAnnouncementInProgress = false; @@ -419,7 +433,7 @@ cMusicManager::Service() m_nLastTrackServiceTime = m_nTimer; } else m_bDoTrackService = false; - if (m_nCurrentStreamedSound == NO_TRACK && SampleManager.IsStreamPlaying(0)) + if (m_nNextTrack == NO_TRACK && SampleManager.IsStreamPlaying(0)) SampleManager.StopStreamedFile(0); else switch (m_nMusicMode) { case MUSICMODE_FRONTEND: ServiceFrontEndMode(); break; @@ -430,10 +444,10 @@ cMusicManager::Service() void cMusicManager::ServiceFrontEndMode() { - if (m_nCurrentStreamedSound < TOTAL_STREAMED_SOUNDS) { + if (m_nNextTrack < TOTAL_STREAMED_SOUNDS) { if (m_bFrontendTrackFinished) { if (!SampleManager.IsStreamPlaying(0)) { - switch (m_nCurrentStreamedSound) + switch (m_nNextTrack) { case STREAMED_SOUND_MISSION_COMPLETED: if (!AudioManager.m_nUserPause) @@ -445,15 +459,15 @@ cMusicManager::ServiceFrontEndMode() default: break; } - m_nCurrentStreamedSound = NO_TRACK; - m_nPreviousStreamedSound = NO_TRACK; + m_nNextTrack = NO_TRACK; + m_nPlayingTrack = NO_TRACK; } } else if (bHasStarted) { if (!SampleManager.IsStreamPlaying(0)) - SampleManager.StartStreamedFile(m_nCurrentStreamedSound, 0, 0); + SampleManager.StartStreamedFile(m_nNextTrack, 0, 0); } else { SampleManager.SetStreamedVolumeAndPan(0, 63, 0, 0); - if (!SampleManager.StartStreamedFile(m_nCurrentStreamedSound, m_nCurrentStreamedSound < STREAMED_SOUND_RADIO_POLICE ? GetTrackStartPos(m_nCurrentStreamedSound) : 0, 0)) + if (!SampleManager.StartStreamedFile(m_nNextTrack, m_nNextTrack < NUM_RADIOS ? GetTrackStartPos(m_nNextTrack) : 0, 0)) return; SampleManager.SetStreamedVolumeAndPan(100, 63, 0, 0); if (m_bPlayInFrontend) bHasStarted = true; @@ -473,7 +487,7 @@ cMusicManager::ServiceGameMode() m_bPreviousPlayerInCar = m_bPlayerInCar; m_bPlayerInCar = PlayerInCar(); - m_nPreviousStreamedSound = m_nCurrentStreamedSound; + m_nPlayingTrack = m_nNextTrack; if (m_bPlayerInCar) { if (FindPlayerPed() != nil && !FindPlayerPed()->DyingOrDead() @@ -485,10 +499,13 @@ cMusicManager::ServiceGameMode() gRetuneCounter = 30; gNumRetunePresses++; AudioManager.PlayOneShot(AudioManager.m_nFrontEndEntity, SOUND_FRONTEND_RADIO_CHANGE, 1.0f); + // This needs loop, and this is not the right place. Now done elsewhere. +#ifndef FIX_BUGS if (SampleManager.IsMP3RadioChannelAvailable()) { if (gNumRetunePresses > RADIO_OFF) gNumRetunePresses -= RADIO_OFF; } +#endif } #ifdef RADIO_SCROLL_TO_PREV_STATION else if(CPad::GetPad(0)->GetMouseWheelDownJustDown() || CPad::GetPad(0)->GetMouseWheelUpJustDown()) { @@ -511,8 +528,8 @@ cMusicManager::ServiceGameMode() m_bPreviousPlayerInCar = false; if (!m_bPlayerInCar) { if (m_bPreviousPlayerInCar) { - if (m_nCurrentStreamedSound != STREAMED_SOUND_RADIO_POLICE) - m_nRadioInCar = m_nCurrentStreamedSound; + if (m_nNextTrack != STREAMED_SOUND_RADIO_POLICE) + m_nRadioInCar = m_nNextTrack; } ServiceAmbience(); return; @@ -520,22 +537,22 @@ cMusicManager::ServiceGameMode() if (m_bPreviousPlayerInCar) { if (m_nAnnouncement < TOTAL_STREAMED_SOUNDS - && (m_nCurrentStreamedSound < STREAMED_SOUND_CITY_AMBIENT || m_bAnnouncementInProgress) + && (m_nNextTrack < RADIO_OFF || m_bAnnouncementInProgress) && ServiceAnnouncement()) { if (m_bAnnouncementInProgress) { m_bSetNextStation = false; return; } - m_nPreviousStreamedSound = m_nCurrentStreamedSound; - m_nCurrentStreamedSound = GetCarTuning(); + m_nPlayingTrack = m_nNextTrack; + m_nNextTrack = GetCarTuning(); } if (SampleManager.IsMP3RadioChannelAvailable() - && m_nCurrentStreamedSound != STREAMED_SOUND_RADIO_MP3_PLAYER + && m_nNextTrack != STREAMED_SOUND_RADIO_MP3_PLAYER && ControlsManager.GetIsKeyboardKeyJustDown(rsF9)) { - m_nPreviousStreamedSound = m_nCurrentStreamedSound; - m_nCurrentStreamedSound = STREAMED_SOUND_RADIO_MP3_PLAYER; + m_nPlayingTrack = m_nNextTrack; + m_nNextTrack = STREAMED_SOUND_RADIO_MP3_PLAYER; if (FindPlayerVehicle() != nil) FindPlayerVehicle()->m_nRadioStation = STREAMED_SOUND_RADIO_MP3_PLAYER; AudioManager.PlayOneShot(AudioManager.m_nFrontEndEntity, SOUND_FRONTEND_RADIO_CHANGE, 1.0f); @@ -563,22 +580,22 @@ cMusicManager::ServiceGameMode() AudioManager.DoPoliceRadioCrackle(); if (m_bSetNextStation) { m_bSetNextStation = false; - m_nPreviousStreamedSound = m_nCurrentStreamedSound; - m_nCurrentStreamedSound = GetNextCarTuning(); - if (m_nCurrentStreamedSound == STREAMED_SOUND_CITY_AMBIENT || m_nCurrentStreamedSound == STREAMED_SOUND_WATER_AMBIENT) + m_nPlayingTrack = m_nNextTrack; + m_nNextTrack = GetNextCarTuning(); + if (m_nNextTrack == STREAMED_SOUND_CITY_AMBIENT || m_nNextTrack == STREAMED_SOUND_WATER_AMBIENT) bRadioOff = true; - if (m_nPreviousStreamedSound == STREAMED_SOUND_CITY_AMBIENT || m_nPreviousStreamedSound == STREAMED_SOUND_WATER_AMBIENT) + if (m_nPlayingTrack == STREAMED_SOUND_CITY_AMBIENT || m_nPlayingTrack == STREAMED_SOUND_WATER_AMBIENT) AudioManager.PlayOneShot(AudioManager.m_nFrontEndEntity, SOUND_FRONTEND_RADIO_CHANGE, 0.0f); } - if (m_nCurrentStreamedSound < STREAMED_SOUND_CITY_AMBIENT) { + if (m_nNextTrack < RADIO_OFF) { if (ChangeRadioChannel()) { ServiceTrack(); } else { m_bPlayerInCar = false; if (FindPlayerVehicle()) - FindPlayerVehicle()->m_nRadioStation = m_nCurrentStreamedSound; - m_nCurrentStreamedSound = NO_TRACK; + FindPlayerVehicle()->m_nRadioStation = m_nNextTrack; + m_nNextTrack = NO_TRACK; } if (CTimer::GetIsSlowMotionActive()) { if (TheCamera.pTargetEntity != nil) { @@ -631,56 +648,56 @@ cMusicManager::ServiceGameMode() return; } if (bRadioOff) { - m_nCurrentStreamedSound = m_nPreviousStreamedSound; + m_nNextTrack = m_nPlayingTrack; if (FindPlayerVehicle() != nil) FindPlayerVehicle()->m_nRadioStation = RADIO_OFF; - AudioManager.PlayOneShot(AudioManager.m_nFrontEndEntity, SOUND_FRONTEND_NO_RADIO, 0.0f); + AudioManager.PlayOneShot(AudioManager.m_nFrontEndEntity, SOUND_FRONTEND_RADIO_TURN_OFF, 0.0f); } ServiceAmbience(); return; } if (m_bRadioSetByScript) { if (UsesPoliceRadio(FindPlayerVehicle())) { - m_nCurrentStreamedSound = STREAMED_SOUND_RADIO_POLICE; + m_nNextTrack = STREAMED_SOUND_RADIO_POLICE; } else { - m_nCurrentStreamedSound = m_nRadioStation; - if (FindPlayerVehicle()->m_nRadioStation == m_nCurrentStreamedSound) { - m_nPreviousStreamedSound = NO_TRACK; + m_nNextTrack = m_nRadioStationScript; + if (FindPlayerVehicle()->m_nRadioStation == m_nNextTrack) { + m_nPlayingTrack = NO_TRACK; SampleManager.SetStreamedVolumeAndPan(0, 63, 0, 0); SampleManager.StopStreamedFile(0); } if (m_nRadioPosition != -1) { - m_aTracks[m_nCurrentStreamedSound].m_nPosition = m_nRadioPosition; - m_aTracks[m_nCurrentStreamedSound].m_nLastPosCheckTimer = CTimer::GetTimeInMillisecondsPauseMode(); + m_aTracks[m_nNextTrack].m_nPosition = m_nRadioPosition; + m_aTracks[m_nNextTrack].m_nLastPosCheckTimer = CTimer::GetTimeInMillisecondsPauseMode(); } } } else { - m_nCurrentStreamedSound = GetCarTuning(); + m_nNextTrack = GetCarTuning(); } - if (m_nCurrentStreamedSound >= RADIO_OFF) { + if (m_nNextTrack >= RADIO_OFF) { ServiceAmbience(); return; } if (ChangeRadioChannel()) { if (m_bRadioSetByScript) { m_bRadioSetByScript = false; - FindPlayerVehicle()->m_nRadioStation = m_nCurrentStreamedSound; + FindPlayerVehicle()->m_nRadioStation = m_nNextTrack; } } else { m_bPlayerInCar = false; - m_nCurrentStreamedSound = NO_TRACK; + m_nNextTrack = NO_TRACK; } } void cMusicManager::StopFrontEndTrack() { - if (IsInitialised() && !m_bDisabled && m_nMusicMode == MUSICMODE_FRONTEND && m_nCurrentStreamedSound != NO_TRACK) { - m_aTracks[m_nCurrentStreamedSound].m_nPosition = SampleManager.GetStreamedFilePosition(0); - m_aTracks[m_nCurrentStreamedSound].m_nLastPosCheckTimer = CTimer::GetTimeInMillisecondsPauseMode(); + if (IsInitialised() && !m_bDisabled && m_nMusicMode == MUSICMODE_FRONTEND && m_nNextTrack != NO_TRACK) { + m_aTracks[m_nNextTrack].m_nPosition = SampleManager.GetStreamedFilePosition(0); + m_aTracks[m_nNextTrack].m_nLastPosCheckTimer = CTimer::GetTimeInMillisecondsPauseMode(); SampleManager.StopStreamedFile(0); - m_nPreviousStreamedSound = NO_TRACK; - m_nCurrentStreamedSound = NO_TRACK; + m_nPlayingTrack = NO_TRACK; + m_nNextTrack = NO_TRACK; } } @@ -696,30 +713,30 @@ cMusicManager::PlayFrontEndTrack(uint8 track, uint8 bPlayInFrontend) { if (IsInitialised() && !m_bDisabled && track < TOTAL_STREAMED_SOUNDS) { if (m_nMusicMode == MUSICMODE_GAME) { - if (m_nCurrentStreamedSound != NO_TRACK) { + if (m_nNextTrack != NO_TRACK) { if (m_bAnnouncementInProgress) { m_nAnnouncement = NO_TRACK; m_bAnnouncementInProgress = false; } - m_aTracks[m_nCurrentStreamedSound].m_nPosition = SampleManager.GetStreamedFilePosition(0); - m_aTracks[m_nCurrentStreamedSound].m_nLastPosCheckTimer = CTimer::GetTimeInMillisecondsPauseMode(); + m_aTracks[m_nNextTrack].m_nPosition = SampleManager.GetStreamedFilePosition(0); + m_aTracks[m_nNextTrack].m_nLastPosCheckTimer = CTimer::GetTimeInMillisecondsPauseMode(); } SampleManager.StopStreamedFile(0); } else if (m_nMusicMode == MUSICMODE_FRONTEND) { - if (m_nCurrentStreamedSound != NO_TRACK) { - m_aTracks[m_nCurrentStreamedSound].m_nPosition = SampleManager.GetStreamedFilePosition(0); - m_aTracks[m_nCurrentStreamedSound].m_nLastPosCheckTimer = CTimer::GetTimeInMillisecondsPauseMode(); + if (m_nNextTrack != NO_TRACK) { + m_aTracks[m_nNextTrack].m_nPosition = SampleManager.GetStreamedFilePosition(0); + m_aTracks[m_nNextTrack].m_nLastPosCheckTimer = CTimer::GetTimeInMillisecondsPauseMode(); } SampleManager.StopStreamedFile(0); } - m_nPreviousStreamedSound = m_nCurrentStreamedSound; - m_nCurrentStreamedSound = track; + m_nPlayingTrack = m_nNextTrack; + m_nNextTrack = track; m_bPlayInFrontend = !!bPlayInFrontend; m_bFrontendTrackFinished = false; m_bDoTrackService = true; bHasStarted = false; - if (m_nCurrentStreamedSound < STREAMED_SOUND_RADIO_POLICE) { + if (m_nNextTrack < NUM_RADIOS) { gRetuneCounter = 0; gNumRetunePresses = 0; } @@ -735,7 +752,7 @@ cMusicManager::PreloadCutSceneMusic(uint8 track) SampleManager.StopStreamedFile(0); SampleManager.PreloadStreamedFile(track, 0); SampleManager.SetStreamedVolumeAndPan(MAX_VOLUME, 63, 1, 0); - m_nCurrentStreamedSound = track; + m_nNextTrack = track; } } @@ -751,7 +768,7 @@ cMusicManager::StopCutSceneMusic(void) { if (IsInitialised() && !m_bDisabled && m_nMusicMode == MUSICMODE_CUTSCENE) { SampleManager.StopStreamedFile(0); - m_nCurrentStreamedSound = NO_TRACK; + m_nNextTrack = NO_TRACK; } } @@ -795,45 +812,45 @@ cMusicManager::ServiceAmbience() m_nAnnouncement = NO_TRACK; m_bAnnouncementInProgress = false; } - if (m_nCurrentStreamedSound < STREAMED_SOUND_CITY_AMBIENT) { + if (m_nNextTrack < RADIO_OFF) { if (SampleManager.IsStreamPlaying(0)) { - m_aTracks[m_nCurrentStreamedSound].m_nPosition = SampleManager.GetStreamedFilePosition(0); - m_aTracks[m_nCurrentStreamedSound].m_nLastPosCheckTimer = CTimer::GetTimeInMillisecondsPauseMode(); + m_aTracks[m_nNextTrack].m_nPosition = SampleManager.GetStreamedFilePosition(0); + m_aTracks[m_nNextTrack].m_nLastPosCheckTimer = CTimer::GetTimeInMillisecondsPauseMode(); SampleManager.StopStreamedFile(0); - m_nCurrentStreamedSound = NO_TRACK; + m_nNextTrack = NO_TRACK; return; } - m_nCurrentStreamedSound = STREAMED_SOUND_CITY_AMBIENT; + m_nNextTrack = RADIO_OFF; } if (CWorld::Players[CWorld::PlayerInFocus].m_WBState != WBSTATE_PLAYING && !SampleManager.IsStreamPlaying(0)) { - m_nCurrentStreamedSound = NO_TRACK; + m_nNextTrack = NO_TRACK; return; } - m_nPreviousStreamedSound = m_nCurrentStreamedSound; - m_nCurrentStreamedSound = TheCamera.DistanceToWater <= 45.0f ? STREAMED_SOUND_WATER_AMBIENT : STREAMED_SOUND_CITY_AMBIENT; + m_nPlayingTrack = m_nNextTrack; + m_nNextTrack = TheCamera.DistanceToWater <= 45.0f ? STREAMED_SOUND_WATER_AMBIENT : STREAMED_SOUND_CITY_AMBIENT; - if (m_nCurrentStreamedSound == m_nPreviousStreamedSound) { + if (m_nNextTrack == m_nPlayingTrack) { ComputeAmbienceVol(false, volume); SampleManager.SetStreamedVolumeAndPan(volume, 63, 1, 0); - if (m_bDontServiceAmbienceTrack) { + if (m_bVerifyAmbienceTrackStartedToPlay) { if (SampleManager.IsStreamPlaying(0)) - m_bDontServiceAmbienceTrack = false; + m_bVerifyAmbienceTrackStartedToPlay = false; } else ServiceTrack(); } else { - if (m_nPreviousStreamedSound < TOTAL_STREAMED_SOUNDS) { - m_aTracks[m_nPreviousStreamedSound].m_nPosition = SampleManager.GetStreamedFilePosition(0); - m_aTracks[m_nPreviousStreamedSound].m_nLastPosCheckTimer = CTimer::GetTimeInMillisecondsPauseMode(); + if (m_nPlayingTrack < TOTAL_STREAMED_SOUNDS) { + m_aTracks[m_nPlayingTrack].m_nPosition = SampleManager.GetStreamedFilePosition(0); + m_aTracks[m_nPlayingTrack].m_nLastPosCheckTimer = CTimer::GetTimeInMillisecondsPauseMode(); SampleManager.StopStreamedFile(0); } - uint32 pos = GetTrackStartPos(m_nCurrentStreamedSound); + uint32 pos = GetTrackStartPos(m_nNextTrack); SampleManager.SetStreamedVolumeAndPan(0, 63, 1, 0); - if (SampleManager.StartStreamedFile(m_nCurrentStreamedSound, pos, 0)) { + if (SampleManager.StartStreamedFile(m_nNextTrack, pos, 0)) { ComputeAmbienceVol(true, volume); SampleManager.SetStreamedVolumeAndPan(volume, 63, 1, 0); - m_bDontServiceAmbienceTrack = true; + m_bVerifyAmbienceTrackStartedToPlay = true; } else - m_nCurrentStreamedSound = NO_TRACK; + m_nNextTrack = NO_TRACK; } } @@ -862,7 +879,7 @@ cMusicManager::ServiceTrack() { if (m_bDoTrackService) { if (!SampleManager.IsStreamPlaying(0)) - SampleManager.StartStreamedFile(m_nCurrentStreamedSound, 0, 0); + SampleManager.StartStreamedFile(m_nNextTrack, 0, 0); } } @@ -882,9 +899,9 @@ cMusicManager::ServiceAnnouncement() cCheck = 0; int pos = SampleManager.GetStreamedFilePosition(0); if (SampleManager.IsStreamPlaying(0)) { - if (m_nCurrentStreamedSound != NO_TRACK) { - m_aTracks[m_nCurrentStreamedSound].m_nPosition = pos; - m_aTracks[m_nCurrentStreamedSound].m_nLastPosCheckTimer = CTimer::GetTimeInMillisecondsPauseMode(); + if (m_nNextTrack != NO_TRACK) { + m_aTracks[m_nNextTrack].m_nPosition = pos; + m_aTracks[m_nNextTrack].m_nLastPosCheckTimer = CTimer::GetTimeInMillisecondsPauseMode(); SampleManager.StopStreamedFile(0); } } @@ -893,8 +910,8 @@ cMusicManager::ServiceAnnouncement() if (SampleManager.StartStreamedFile(m_nAnnouncement, 0, 0)) { SampleManager.SetStreamedVolumeAndPan(AudioManager.ShouldDuckMissionAudio() ? 25 : 100, 63, 0, 0); m_bAnnouncementInProgress = true; - m_nPreviousStreamedSound = m_nCurrentStreamedSound; - m_nCurrentStreamedSound = m_nAnnouncement; + m_nPlayingTrack = m_nNextTrack; + m_nNextTrack = m_nAnnouncement; return true; } @@ -929,7 +946,7 @@ cMusicManager::GetNextCarTuning() while (gNumRetunePresses < 0) { if(veh->m_nRadioStation == HEAD_RADIO) { veh->m_nRadioStation = RADIO_OFF; - } else if(veh->m_nRadioStation == RADIO_OFF || veh->m_nRadioStation == POLICE_RADIO) { + } else if(veh->m_nRadioStation == RADIO_OFF || veh->m_nRadioStation == NUM_RADIOS) { veh->m_nRadioStation = SampleManager.IsMP3RadioChannelAvailable() ? USERTRACK : USERTRACK - 1; } else veh->m_nRadioStation--; @@ -940,12 +957,18 @@ cMusicManager::GetNextCarTuning() #endif if (SampleManager.IsMP3RadioChannelAvailable()) { if (veh->m_nRadioStation == RADIO_OFF) - veh->m_nRadioStation = POLICE_RADIO; + veh->m_nRadioStation = NUM_RADIOS; veh->m_nRadioStation += gNumRetunePresses; - if (veh->m_nRadioStation == POLICE_RADIO) +#ifdef FIX_BUGS + while (veh->m_nRadioStation > NUM_RADIOS) + veh->m_nRadioStation -= (NUM_RADIOS + 1); +#endif + if (veh->m_nRadioStation == NUM_RADIOS) veh->m_nRadioStation = RADIO_OFF; - else if (veh->m_nRadioStation > POLICE_RADIO) - veh->m_nRadioStation -= RADIO_OFF; +#ifndef FIX_BUGS + else if (veh->m_nRadioStation > NUM_RADIOS) + veh->m_nRadioStation -= (NUM_RADIOS + 1); +#endif } else if (gNumRetunePresses + veh->m_nRadioStation >= USERTRACK) { while (gNumRetunePresses) { if (veh->m_nRadioStation == RADIO_OFF) @@ -967,16 +990,16 @@ cMusicManager::GetNextCarTuning() bool cMusicManager::ChangeRadioChannel() { - if (m_nCurrentStreamedSound != m_nPreviousStreamedSound) { - if (m_nPreviousStreamedSound < TOTAL_STREAMED_SOUNDS) { - m_aTracks[m_nPreviousStreamedSound].m_nPosition = SampleManager.GetStreamedFilePosition(0); - m_aTracks[m_nPreviousStreamedSound].m_nLastPosCheckTimer = CTimer::GetTimeInMillisecondsPauseMode(); + if (m_nNextTrack != m_nPlayingTrack) { + if (m_nPlayingTrack < TOTAL_STREAMED_SOUNDS) { + m_aTracks[m_nPlayingTrack].m_nPosition = SampleManager.GetStreamedFilePosition(0); + m_aTracks[m_nPlayingTrack].m_nLastPosCheckTimer = CTimer::GetTimeInMillisecondsPauseMode(); SampleManager.SetStreamedVolumeAndPan(0, 63, 0, 0); SampleManager.StopStreamedFile(0); } if (SampleManager.IsStreamPlaying(0)) return false; - if (!SampleManager.StartStreamedFile(m_nCurrentStreamedSound, GetTrackStartPos(m_nCurrentStreamedSound), 0)) + if (!SampleManager.StartStreamedFile(m_nNextTrack, GetTrackStartPos(m_nNextTrack), 0)) return false; SampleManager.SetStreamedVolumeAndPan(AudioManager.ShouldDuckMissionAudio() ? 25 : 100, 63, 0, 0); } diff --git a/src/audio/MusicManager.h b/src/audio/MusicManager.h index e8b94da6..5d277f0e 100644 --- a/src/audio/MusicManager.h +++ b/src/audio/MusicManager.h @@ -18,8 +18,8 @@ public: bool m_bIsInitialised; bool m_bDisabled; uint8 m_nMusicMode; - uint8 m_nCurrentStreamedSound; - uint8 m_nPreviousStreamedSound; + uint8 m_nNextTrack; + uint8 m_nPlayingTrack; bool m_bFrontendTrackFinished; bool m_bPlayInFrontend; bool m_bSetNextStation; @@ -34,9 +34,9 @@ public: uint32 m_nTimer; bool m_bDoTrackService; bool m_bIgnoreTimeDelay; - bool m_bDontServiceAmbienceTrack; + bool m_bVerifyAmbienceTrackStartedToPlay; bool m_bRadioSetByScript; - uint8 m_nRadioStation; + uint8 m_nRadioStationScript; int32 m_nRadioPosition; uint8 m_nRadioInCar; @@ -44,7 +44,7 @@ public: cMusicManager(); bool IsInitialised() { return m_bIsInitialised; } uint32 GetMusicMode() { return m_nMusicMode; } - uint8 GetCurrentTrack() { return m_nCurrentStreamedSound; } + uint8 GetNextTrack() { return m_nNextTrack; } bool Initialise(); void Terminate(); diff --git a/src/audio/audio_enums.h b/src/audio/audio_enums.h index 8c6d35aa..027042cb 100644 --- a/src/audio/audio_enums.h +++ b/src/audio/audio_enums.h @@ -12,8 +12,9 @@ enum eRadioStation FLASHBACK, CHATTERBOX, USERTRACK, - POLICE_RADIO, - RADIO_OFF, + POLICE_RADIO = 10, + NUM_RADIOS = 10, + RADIO_OFF = 11, }; enum eMusicMode diff --git a/src/audio/sampman_miles.cpp b/src/audio/sampman_miles.cpp index 11e2b0ff..9b601d52 100644 --- a/src/audio/sampman_miles.cpp +++ b/src/audio/sampman_miles.cpp @@ -1514,7 +1514,7 @@ cSampleManager::LoadPedComment(uint32 nComment) case MUSICMODE_FRONTEND: { - if ( MusicManager.GetCurrentTrack() == STREAMED_SOUND_GAME_COMPLETED ) + if ( MusicManager.GetNextTrack() == STREAMED_SOUND_GAME_COMPLETED ) return false; break; @@ -1753,8 +1753,8 @@ cSampleManager::SetChannelEmittingVolume(uint32 nChannel, uint32 nVolume) // increase the volume for JB.MP3 and S4_BDBD.MP3 if ( MusicManager.GetMusicMode() == MUSICMODE_CUTSCENE - && MusicManager.GetCurrentTrack() != STREAMED_SOUND_NEWS_INTRO - && MusicManager.GetCurrentTrack() != STREAMED_SOUND_CUTSCENE_SAL4_BDBD ) + && MusicManager.GetNextTrack() != STREAMED_SOUND_NEWS_INTRO + && MusicManager.GetNextTrack() != STREAMED_SOUND_CUTSCENE_SAL4_BDBD ) { nChannelVolume[nChannel] >>= 2; } @@ -1792,8 +1792,8 @@ cSampleManager::SetChannelVolume(uint32 nChannel, uint32 nVolume) // increase the volume for JB.MP3 and S4_BDBD.MP3 if ( MusicManager.GetMusicMode() == MUSICMODE_CUTSCENE - && MusicManager.GetCurrentTrack() != STREAMED_SOUND_NEWS_INTRO - && MusicManager.GetCurrentTrack() != STREAMED_SOUND_CUTSCENE_SAL4_BDBD ) + && MusicManager.GetNextTrack() != STREAMED_SOUND_NEWS_INTRO + && MusicManager.GetNextTrack() != STREAMED_SOUND_CUTSCENE_SAL4_BDBD ) { nChannelVolume[nChannel] >>= 2; } diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp index 798ea287..7b82a4e2 100644 --- a/src/audio/sampman_oal.cpp +++ b/src/audio/sampman_oal.cpp @@ -1318,7 +1318,7 @@ cSampleManager::LoadPedComment(uint32 nComment) case MUSICMODE_FRONTEND: { - if ( MusicManager.GetCurrentTrack() == STREAMED_SOUND_GAME_COMPLETED ) + if ( MusicManager.GetNextTrack() == STREAMED_SOUND_GAME_COMPLETED ) return false; break; @@ -1533,8 +1533,8 @@ cSampleManager::SetChannelEmittingVolume(uint32 nChannel, uint32 nVolume) // reduce channel volume when JB.MP3 or S4_BDBD.MP3 playing if ( MusicManager.GetMusicMode() == MUSICMODE_CUTSCENE - && MusicManager.GetCurrentTrack() != STREAMED_SOUND_NEWS_INTRO - && MusicManager.GetCurrentTrack() != STREAMED_SOUND_CUTSCENE_SAL4_BDBD ) + && MusicManager.GetNextTrack() != STREAMED_SOUND_NEWS_INTRO + && MusicManager.GetNextTrack() != STREAMED_SOUND_CUTSCENE_SAL4_BDBD ) { nChannelVolume[nChannel] = vol / 4; } @@ -1575,8 +1575,8 @@ cSampleManager::SetChannelVolume(uint32 nChannel, uint32 nVolume) // reduce the volume for JB.MP3 and S4_BDBD.MP3 if ( MusicManager.GetMusicMode() == MUSICMODE_CUTSCENE - && MusicManager.GetCurrentTrack() != STREAMED_SOUND_NEWS_INTRO - && MusicManager.GetCurrentTrack() != STREAMED_SOUND_CUTSCENE_SAL4_BDBD ) + && MusicManager.GetNextTrack() != STREAMED_SOUND_NEWS_INTRO + && MusicManager.GetNextTrack() != STREAMED_SOUND_CUTSCENE_SAL4_BDBD ) { nChannelVolume[nChannel] = vol / 4; } diff --git a/src/audio/soundlist.h b/src/audio/soundlist.h index 7c3b30a7..4bbc3dde 100644 --- a/src/audio/soundlist.h +++ b/src/audio/soundlist.h @@ -160,7 +160,7 @@ enum eSound SOUND_FRONTEND_MONO, SOUND_FRONTEND_AUDIO_TEST, SOUND_FRONTEND_FAIL, - SOUND_FRONTEND_NO_RADIO, + SOUND_FRONTEND_RADIO_TURN_OFF, SOUND_FRONTEND_RADIO_CHANGE, SOUND_HUD, SOUND_AMMUNATION_WELCOME_1, -- cgit v1.2.3 From 7ff899bd22f20c53d067529140aeb466612e8bbc Mon Sep 17 00:00:00 2001 From: erorcun Date: Tue, 2 Feb 2021 16:39:08 +0300 Subject: OAL Loops, fixes --- src/audio/oal/channel.cpp | 56 +++++++++++++++++++++++++++++++-- src/audio/oal/channel.h | 6 +++- src/audio/oal/stream.cpp | 79 +++++++++++++++++++++++++++++------------------ src/audio/oal/stream.h | 3 ++ src/audio/sampman_oal.cpp | 58 ++++++++++++++++------------------ 5 files changed, 136 insertions(+), 66 deletions(-) (limited to 'src/audio') diff --git a/src/audio/oal/channel.cpp b/src/audio/oal/channel.cpp index 673a4aed..d1fd0aea 100644 --- a/src/audio/oal/channel.cpp +++ b/src/audio/oal/channel.cpp @@ -15,6 +15,8 @@ ALuint alFilters[MAXCHANNELS+MAX2DCHANNELS]; ALuint alBuffers[MAXCHANNELS+MAX2DCHANNELS]; bool bChannelsCreated = false; +int32 CChannel::channelsThatNeedService = 0; + void CChannel::InitChannels() { @@ -59,7 +61,9 @@ void CChannel::SetDefault() Position[0] = 0.0f; Position[1] = 0.0f; Position[2] = 0.0f; Distances[0] = 0.0f; Distances[1] = FLT_MAX; - LoopCount = 1; + + LoopCount = 1; + LastProcessedOffset = UINT32_MAX; LoopPoints[0] = 0; LoopPoints[1] = -1; Frequency = MAX_FREQ; @@ -67,6 +71,10 @@ void CChannel::SetDefault() void CChannel::Reset() { + // Here is safe because ctor don't call this + if (LoopCount > 1) + channelsThatNeedService--; + ClearBuffer(); SetDefault(); } @@ -165,10 +173,51 @@ void CChannel::SetCurrentFreq(uint32 freq) SetPitch(ALfloat(freq) / Frequency); } -void CChannel::SetLoopCount(int32 loopCount) // fake. TODO: +void CChannel::SetLoopCount(int32 count) { if ( !HasSource() ) return; - alSourcei(alSources[id], AL_LOOPING, loopCount == 1 ? AL_FALSE : AL_TRUE); + + // 0: loop indefinitely, 1: play one time, 2: play two times etc... + // only > 1 needs manual processing + + if (LoopCount > 1 && count < 2) + channelsThatNeedService--; + else if (LoopCount < 2 && count > 1) + channelsThatNeedService++; + + alSourcei(alSources[id], AL_LOOPING, count == 1 ? AL_FALSE : AL_TRUE); + LoopCount = count; +} + +bool CChannel::Update() +{ + if (!HasSource()) return false; + if (LoopCount < 2) return false; + + ALint state; + alGetSourcei(alSources[id], AL_SOURCE_STATE, &state); + if (state == AL_STOPPED) { + debug("Looping channels(%d in this case) shouldn't report AL_STOPPED, but nvm\n", id); + SetLoopCount(1); + return true; + } + + assert(channelsThatNeedService > 0 && "Ref counting is broken"); + + ALint offset; + alGetSourcei(alSources[id], AL_SAMPLE_OFFSET, &offset); + + // Rewound + if (offset < LastProcessedOffset) { + LoopCount--; + if (LoopCount == 1) { + // Playing last tune... + channelsThatNeedService--; + alSourcei(alSources[id], AL_LOOPING, AL_FALSE); + } + } + LastProcessedOffset = offset; + return true; } void CChannel::SetLoopPoints(ALint start, ALint end) @@ -200,6 +249,7 @@ void CChannel::SetPan(int32 pan) void CChannel::ClearBuffer() { if ( !HasSource() ) return; + alSourcei(alSources[id], AL_LOOPING, AL_FALSE); alSourcei(alSources[id], AL_BUFFER, AL_NONE); Data = nil; DataSize = 0; diff --git a/src/audio/oal/channel.h b/src/audio/oal/channel.h index 81817a32..b081be25 100644 --- a/src/audio/oal/channel.h +++ b/src/audio/oal/channel.h @@ -19,7 +19,10 @@ class CChannel float Distances[2]; int32 LoopCount; ALint LoopPoints[2]; + ALint LastProcessedOffset; public: + static int32 channelsThatNeedService; + static void InitChannels(); static void DestroyChannels(); @@ -37,7 +40,7 @@ public: void SetVolume(int32 vol); void SetSampleData(void *_data, size_t _DataSize, int32 freq); void SetCurrentFreq(uint32 freq); - void SetLoopCount(int32 loopCount); // fake + void SetLoopCount(int32 count); void SetLoopPoints(ALint start, ALint end); void SetPosition(float x, float y, float z); void SetDistances(float max, float min); @@ -45,6 +48,7 @@ public: void ClearBuffer(); void SetReverbMix(ALuint slot, float mix); void UpdateReverb(ALuint slot); + bool Update(); }; #endif \ No newline at end of file diff --git a/src/audio/oal/stream.cpp b/src/audio/oal/stream.cpp index 74ed86f4..61cd243d 100644 --- a/src/audio/oal/stream.cpp +++ b/src/audio/oal/stream.cpp @@ -492,6 +492,7 @@ public: m_bOpened = mpg123_open(m_pMH, path) == MPG123_OK && mpg123_getformat(m_pMH, &rate, &channels, &encoding) == MPG123_OK; + m_nRate = rate; m_nChannels = channels; @@ -925,7 +926,8 @@ CStream::CStream(char *filename, ALuint *sources, ALuint (&buffers)[NUM_STREAMBU m_bReset(false), m_nVolume(0), m_nPan(0), - m_nPosBeforeReset(0) + m_nPosBeforeReset(0), + m_nLoopCount(1) { // Be case-insensitive on linux (from https://github.com/OneSadCookie/fcaseopen/) @@ -1021,7 +1023,7 @@ bool CStream::IsPlaying() ALint sourceState[2]; alGetSourcei(m_pAlSources[0], AL_SOURCE_STATE, &sourceState[0]); alGetSourcei(m_pAlSources[1], AL_SOURCE_STATE, &sourceState[1]); - if ( m_bActive || sourceState[0] == AL_PLAYING || sourceState[1] == AL_PLAYING) + if (sourceState[0] == AL_PLAYING || sourceState[1] == AL_PLAYING) return true; } @@ -1179,6 +1181,8 @@ bool CStream::Setup() { if ( IsOpened() ) { + alSourcei(m_pAlSources[0], AL_LOOPING, AL_FALSE); + alSourcei(m_pAlSources[1], AL_LOOPING, AL_FALSE); m_pSoundFile->Seek(0); //SetPosition(0.0f, 0.0f, 0.0f); SetPitch(1.0f); @@ -1189,6 +1193,13 @@ bool CStream::Setup() return IsOpened(); } +void CStream::SetLoopCount(int32 count) +{ + if ( !HasSource() ) return; + + m_nLoopCount = count; +} + void CStream::SetPlay(bool state) { if ( !HasSource() ) return; @@ -1248,7 +1259,7 @@ void CStream::Update() if ( !m_bPaused ) { - ALint sourceState[2]; + ALint totalBuffers[2] = { 0, 0 }; ALint buffersProcessed[2] = { 0, 0 }; // Relying a lot on left buffer states in here @@ -1256,44 +1267,51 @@ void CStream::Update() do { //alSourcef(m_pAlSources[0], AL_ROLLOFF_FACTOR, 0.0f); - alGetSourcei(m_pAlSources[0], AL_SOURCE_STATE, &sourceState[0]); + alGetSourcei(m_pAlSources[0], AL_BUFFERS_QUEUED, &totalBuffers[0]); alGetSourcei(m_pAlSources[0], AL_BUFFERS_PROCESSED, &buffersProcessed[0]); //alSourcef(m_pAlSources[1], AL_ROLLOFF_FACTOR, 0.0f); - alGetSourcei(m_pAlSources[1], AL_SOURCE_STATE, &sourceState[1]); + alGetSourcei(m_pAlSources[1], AL_BUFFERS_QUEUED, &totalBuffers[1]); alGetSourcei(m_pAlSources[1], AL_BUFFERS_PROCESSED, &buffersProcessed[1]); } while (buffersProcessed[0] != buffersProcessed[1]); - ALint looping = AL_FALSE; - alGetSourcei(m_pAlSources[0], AL_LOOPING, &looping); - - if ( looping == AL_TRUE ) + assert(buffersProcessed[0] == buffersProcessed[1]); + + // Correcting OpenAL concepts here: + // AL_BUFFERS_QUEUED = Number of *all* buffers in queue, including processed, processing and pending + // AL_BUFFERS_PROCESSED = Index of the buffer being processing right now. Buffers coming after that(have greater index) are pending buffers. + // which means: totalBuffers[0] - buffersProcessed[0] = pending buffers + + bool buffersRefilled = false; + + // We should wait queue to be cleared to loop track, because position calculation relies on queue. + if (m_nLoopCount != 1 && m_bActive && totalBuffers[0] == 0) { - TRACE("stream set looping"); - alSourcei(m_pAlSources[0], AL_LOOPING, AL_TRUE); - alSourcei(m_pAlSources[1], AL_LOOPING, AL_TRUE); + Setup(); + buffersRefilled = FillBuffers() != 0; + if (m_nLoopCount != 0) + m_nLoopCount--; } - - assert(buffersProcessed[0] == buffersProcessed[1]); - - while( buffersProcessed[0]-- ) + else { - ALuint buffer[2]; - - alSourceUnqueueBuffers(m_pAlSources[0], 1, &buffer[0]); - alSourceUnqueueBuffers(m_pAlSources[1], 1, &buffer[1]); - - if (m_bActive && FillBuffer(buffer)) + while( buffersProcessed[0]-- ) { - alSourceQueueBuffers(m_pAlSources[0], 1, &buffer[0]); - alSourceQueueBuffers(m_pAlSources[1], 1, &buffer[1]); + ALuint buffer[2]; + + alSourceUnqueueBuffers(m_pAlSources[0], 1, &buffer[0]); + alSourceUnqueueBuffers(m_pAlSources[1], 1, &buffer[1]); + + if (m_bActive && FillBuffer(buffer)) + { + buffersRefilled = true; + alSourceQueueBuffers(m_pAlSources[0], 1, &buffer[0]); + alSourceQueueBuffers(m_pAlSources[1], 1, &buffer[1]); + } } } - - if ( sourceState[0] != AL_PLAYING ) - { - alGetSourcei(m_pAlSources[0], AL_BUFFERS_PROCESSED, &buffersProcessed[0]); - SetPlay(buffersProcessed[0]!=0); - } + + // Two reasons: 1-Source may be starved to audio and stopped itself, 2- We're already waiting it to starve and die for looping track! + if (m_bActive && (buffersRefilled || (totalBuffers[1] - buffersProcessed[1] != 0))) + SetPlay(true); } } @@ -1305,6 +1323,7 @@ void CStream::ProviderInit() { SetPan(m_nPan); SetVolume(m_nVolume); + SetLoopCount(m_nLoopCount); SetPosMS(m_nPosBeforeReset); if (m_bActive) FillBuffers(); diff --git a/src/audio/oal/stream.h b/src/audio/oal/stream.h index bcbc5e54..b3e96809 100644 --- a/src/audio/oal/stream.h +++ b/src/audio/oal/stream.h @@ -69,6 +69,7 @@ class CStream uint32 m_nVolume; uint8 m_nPan; uint32 m_nPosBeforeReset; + int32 m_nLoopCount; IDecoder *m_pSoundFile; @@ -103,6 +104,8 @@ public: void Start(); void Stop(); void Update(void); + void SetLoopCount(int32); + void ProviderInit(); void ProviderTerm(); diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp index 7b82a4e2..9365c7dd 100644 --- a/src/audio/sampman_oal.cpp +++ b/src/audio/sampman_oal.cpp @@ -44,7 +44,6 @@ //TODO: fix eax3 reverb //TODO: max channels -//TODO: loop count cSampleManager SampleManager; bool _bSampmanInitialised = false; @@ -117,7 +116,6 @@ char _mp3DirectoryPath[MAX_PATH]; CStream *aStream[MAX_STREAMS]; uint8 nStreamPan [MAX_STREAMS]; uint8 nStreamVolume[MAX_STREAMS]; -uint8 nStreamLoopedFlag[MAX_STREAMS]; uint32 _CurMP3Index; int32 _CurMP3Pos; bool _bIsMp3Active; @@ -1666,7 +1664,7 @@ cSampleManager::PreloadStreamedFile(uint8 nFile, uint8 nStream) ASSERT(stream != NULL); aStream[nStream] = stream; - if ( !stream->IsOpened() ) + if ( !stream->Setup() ) { delete stream; aStream[nStream] = NULL; @@ -1696,7 +1694,7 @@ cSampleManager::StartPreloadedStreamedFile(uint8 nStream) if ( stream ) { - if ( stream->Setup() ) + if ( stream->IsOpened() ) { stream->Start(); } @@ -1742,13 +1740,11 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) aStream[nStream] = stream; - if (stream->IsOpened()) { - if (stream->Setup()) { - if (position != 0) - stream->SetPosMS(position); + if (stream->Setup()) { + if (position != 0) + stream->SetPosMS(position); - stream->Start(); - } + stream->Start(); return true; } else { @@ -1769,10 +1765,8 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) aStream[nStream] = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000); } - if (aStream[nStream]->IsOpened()) { - if (aStream[nStream]->Setup()) { - aStream[nStream]->Start(); - } + if (aStream[nStream]->Setup()) { + aStream[nStream]->Start(); return true; } else { @@ -1798,13 +1792,11 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) aStream[nStream] = stream; - if (stream->IsOpened()) { - if (stream->Setup()) { - if (position != 0) - stream->SetPosMS(position); + if (stream->Setup()) { + if (position != 0) + stream->SetPosMS(position); - stream->Start(); - } + stream->Start(); return true; } else { @@ -1825,13 +1817,11 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) aStream[nStream] = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream]); } - if (aStream[nStream]->IsOpened()) { - if (aStream[nStream]->Setup()) { - if (position != 0) - aStream[nStream]->SetPosMS(position); + if (aStream[nStream]->Setup()) { + if (position != 0) + aStream[nStream]->SetPosMS(position); - aStream[nStream]->Start(); - } + aStream[nStream]->Start(); _bIsMp3Active = true; return true; @@ -1855,13 +1845,11 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) aStream[nStream] = stream; - if ( stream->IsOpened() ) { - if ( stream->Setup() ) { - if (position != 0) - stream->SetPosMS(position); + if ( stream->Setup() ) { + if (position != 0) + stream->SetPosMS(position); - stream->Start(); - } + stream->Start(); return true; } else { @@ -1963,6 +1951,12 @@ cSampleManager::Service(void) if ( stream ) stream->Update(); } + int refCount = CChannel::channelsThatNeedService; + for ( int32 i = 0; refCount && i < MAXCHANNELS+MAX2DCHANNELS; i++ ) + { + if ( aChannel[i].Update() ) + refCount--; + } } bool -- cgit v1.2.3 From c002dd6cbaf642f24b33fbc2be3fff765024ee09 Mon Sep 17 00:00:00 2001 From: erorcun Date: Wed, 3 Feb 2021 23:12:55 +0300 Subject: MP3 player fixes --- src/audio/sampman_oal.cpp | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'src/audio') diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp index 9365c7dd..d9adef5b 100644 --- a/src/audio/sampman_oal.cpp +++ b/src/audio/sampman_oal.cpp @@ -14,8 +14,6 @@ #include #include -#pragma comment(lib, "OpenAL32.lib") - // for user MP3s #include #include @@ -24,6 +22,10 @@ #define _getcwd getcwd #endif +#if defined _MSC_VER && !defined CMAKE_NO_AUTOLINK +#pragma comment( lib, "OpenAL32.lib" ) +#endif + #include "common.h" #include "crossplatform.h" @@ -1872,6 +1874,9 @@ cSampleManager::StopStreamedFile(uint8 nStream) { delete stream; aStream[nStream] = NULL; + + if ( nStream == 0 ) + _bIsMp3Active = false; } } @@ -1884,7 +1889,21 @@ cSampleManager::GetStreamedFilePosition(uint8 nStream) if ( stream ) { - return stream->GetPosMS(); + if ( _bIsMp3Active ) + { + tMP3Entry *mp3 = _GetMP3EntryByIndex(_CurMP3Index); + + if ( mp3 != NULL ) + { + return stream->GetPosMS() + mp3->nTrackStreamPos; + } + else + return 0; + } + else + { + return stream->GetPosMS(); + } } return 0; -- cgit v1.2.3 From be550853033e631e85f122bc459533643c230bac Mon Sep 17 00:00:00 2001 From: erorcun Date: Sun, 14 Feb 2021 18:07:21 +0300 Subject: Try to fix streams stop after a while --- src/audio/oal/stream.cpp | 11 ++++++++--- src/audio/oal/stream.h | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'src/audio') diff --git a/src/audio/oal/stream.cpp b/src/audio/oal/stream.cpp index 61cd243d..44cc1c93 100644 --- a/src/audio/oal/stream.cpp +++ b/src/audio/oal/stream.cpp @@ -1095,6 +1095,7 @@ void CStream::SetPan(uint8 nPan) m_nPan = nPan; } +// Should only be called if source is stopped void CStream::SetPosMS(uint32 nPos) { if ( !IsOpened() ) return; @@ -1177,12 +1178,16 @@ void CStream::ClearBuffers() alSourceUnqueueBuffers(m_pAlSources[1], 1, &value); } -bool CStream::Setup() +bool CStream::Setup(bool imSureQueueIsEmpty) { if ( IsOpened() ) { alSourcei(m_pAlSources[0], AL_LOOPING, AL_FALSE); alSourcei(m_pAlSources[1], AL_LOOPING, AL_FALSE); + if (!imSureQueueIsEmpty) { + SetPlay(false); + ClearBuffers(); + } m_pSoundFile->Seek(0); //SetPosition(0.0f, 0.0f, 0.0f); SetPitch(1.0f); @@ -1286,7 +1291,7 @@ void CStream::Update() // We should wait queue to be cleared to loop track, because position calculation relies on queue. if (m_nLoopCount != 1 && m_bActive && totalBuffers[0] == 0) { - Setup(); + Setup(true); buffersRefilled = FillBuffers() != 0; if (m_nLoopCount != 0) m_nLoopCount--; @@ -1319,7 +1324,7 @@ void CStream::ProviderInit() { if ( m_bReset ) { - if ( Setup() ) + if ( Setup(true) ) { SetPan(m_nPan); SetVolume(m_nVolume); diff --git a/src/audio/oal/stream.h b/src/audio/oal/stream.h index b3e96809..9a2a2fbe 100644 --- a/src/audio/oal/stream.h +++ b/src/audio/oal/stream.h @@ -100,7 +100,7 @@ public: uint32 GetPosMS(); uint32 GetLengthMS(); - bool Setup(); + bool Setup(bool imSureQueueIsEmpty = false); void Start(); void Stop(); void Update(void); -- cgit v1.2.3 From 139c6bfcf3dd2e2f8e26d987b6da6db51645f210 Mon Sep 17 00:00:00 2001 From: erorcun Date: Fri, 19 Feb 2021 14:30:41 +0300 Subject: Fix MP3 player --- src/audio/sampman_miles.cpp | 184 +++++++++++++++++++++----------------------- src/audio/sampman_oal.cpp | 176 ++++++++++++++++++++---------------------- 2 files changed, 170 insertions(+), 190 deletions(-) (limited to 'src/audio') diff --git a/src/audio/sampman_miles.cpp b/src/audio/sampman_miles.cpp index 9b601d52..351c4958 100644 --- a/src/audio/sampman_miles.cpp +++ b/src/audio/sampman_miles.cpp @@ -2046,141 +2046,131 @@ cSampleManager::StartPreloadedStreamedFile(uint8 nStream) bool cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) { + int i = 0; uint32 position = nPos; char filename[MAX_PATH]; - if ( m_bInitialised && nFile < TOTAL_STREAMED_SOUNDS ) + if ( !m_bInitialised || nFile >= TOTAL_STREAMED_SOUNDS ) + return false; + + if ( mp3Stream[nStream] ) { - if ( mp3Stream[nStream] ) - { - AIL_pause_stream(mp3Stream[nStream], 1); - AIL_close_stream(mp3Stream[nStream]); - } - - if ( nFile == STREAMED_SOUND_RADIO_MP3_PLAYER ) + AIL_pause_stream(mp3Stream[nStream], 1); + AIL_close_stream(mp3Stream[nStream]); + } + if ( nFile == STREAMED_SOUND_RADIO_MP3_PLAYER ) + { + do { - uint32 i = 0; - do { - if(i != 0 || _bIsMp3Active) { - if(++_CurMP3Index >= nNumMP3s) _CurMP3Index = 0; - - _CurMP3Pos = 0; - - tMP3Entry *mp3 = _GetMP3EntryByIndex(_CurMP3Index); - - if(mp3) { - mp3 = _pMP3List; - if(mp3 == NULL) { - _bIsMp3Active = false; - nFile = 0; - 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); - AIL_set_stream_ms_position( - mp3Stream[nStream], position); - AIL_pause_stream(mp3Stream[nStream], - 0); - return true; - } + // Just switched to MP3 player + if ( !_bIsMp3Active && i == 0 ) + { + if ( nPos > nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] ) + position = 0; + tMP3Entry *e = _pMP3List; - return false; - } + // Try to continue from previous song, if already started + if(!_GetMP3PosFromStreamPos(&position, &e) && !e) { + nFile = 0; + 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); + AIL_set_stream_ms_position(mp3Stream[nStream], position); + AIL_pause_stream(mp3Stream[nStream], 0); + return true; } + return false; - if(mp3->pLinkPath != NULL) - mp3Stream[nStream] = - AIL_open_stream(DIG, mp3->pLinkPath, 0); + } else { + if ( e->pLinkPath != NULL ) + mp3Stream[nStream] = AIL_open_stream(DIG, e->pLinkPath, 0); else { strcpy(filename, _mp3DirectoryPath); - strcat(filename, mp3->aFilename); - - mp3Stream[nStream] = - AIL_open_stream(DIG, filename, 0); + strcat(filename, e->aFilename); + + mp3Stream[nStream] = AIL_open_stream(DIG, filename, 0); } - - if(mp3Stream[nStream]) { + + if ( mp3Stream[nStream] ) { AIL_set_stream_loop_count(mp3Stream[nStream], 1); - AIL_set_stream_ms_position(mp3Stream[nStream], 0); + AIL_set_stream_ms_position(mp3Stream[nStream], position); AIL_pause_stream(mp3Stream[nStream], 0); + + _bIsMp3Active = true; + return true; } - - _bIsMp3Active = false; - continue; + // fall through, start playing from another song } - if ( nPos > nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] ) - position = 0; - - tMP3Entry *e; - if ( !_GetMP3PosFromStreamPos(&position, &e) ) + } else { + if(++_CurMP3Index >= nNumMP3s) _CurMP3Index = 0; + + _CurMP3Pos = 0; + + tMP3Entry *mp3 = _GetMP3EntryByIndex(_CurMP3Index); + if ( !mp3 ) { - if ( e == NULL ) + mp3 = _pMP3List; + if ( !_pMP3List ) { nFile = 0; + _bIsMp3Active = 0; 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); - AIL_set_stream_ms_position( - mp3Stream[nStream], position); + + mp3Stream[nStream] = AIL_open_stream(DIG, filename, 0); + if ( mp3Stream[nStream] ) + { + AIL_set_stream_loop_count(mp3Stream[nStream], 1); + AIL_set_stream_ms_position(mp3Stream[nStream], position); AIL_pause_stream(mp3Stream[nStream], 0); return true; } - return false; } } - - if ( e->pLinkPath != NULL ) - mp3Stream[nStream] = AIL_open_stream(DIG, e->pLinkPath, 0); - else - { + if(mp3->pLinkPath != NULL) + mp3Stream[nStream] = AIL_open_stream(DIG, mp3->pLinkPath, 0); + else { strcpy(filename, _mp3DirectoryPath); - strcat(filename, e->aFilename); - - mp3Stream[nStream] = AIL_open_stream(DIG, filename, 0); + strcat(filename, mp3->aFilename); + + mp3Stream[nStream] = + AIL_open_stream(DIG, filename, 0); } - - if ( mp3Stream[nStream] ) - { + + if(mp3Stream[nStream]) { AIL_set_stream_loop_count(mp3Stream[nStream], 1); - AIL_set_stream_ms_position(mp3Stream[nStream], position); + AIL_set_stream_ms_position(mp3Stream[nStream], 0); AIL_pause_stream(mp3Stream[nStream], 0); - +#ifdef FIX_BUGS _bIsMp3Active = true; - +#endif return true; } - - _bIsMp3Active = false; - } while(++i < nNumMP3s); - - position = 0; - nFile = 0; - } - - 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); - AIL_set_stream_ms_position(mp3Stream[nStream], position); - AIL_pause_stream(mp3Stream[nStream], 0); - return true; + } + _bIsMp3Active = 0; } + while ( ++i < nNumMP3s ); + position = 0; + nFile = 0; } + 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); + AIL_set_stream_ms_position(mp3Stream[nStream], position); + AIL_pause_stream(mp3Stream[nStream], 0); + return true; + } return false; } diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp index d9adef5b..3d4b8dbd 100644 --- a/src/audio/sampman_oal.cpp +++ b/src/audio/sampman_oal.cpp @@ -730,8 +730,6 @@ _FindMP3s(void) delete aStream[0]; aStream[0] = NULL; - OutputDebugString(fd.cFileName); - pList->pNext = new tMP3Entry; tMP3Entry *e = pList->pNext; @@ -1706,91 +1704,91 @@ cSampleManager::StartPreloadedStreamedFile(uint8 nStream) bool cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) { + int i = 0; uint32 position = nPos; - char filename[256]; - - ASSERT( nStream < MAX_STREAMS ); - - if ( nFile < TOTAL_STREAMED_SOUNDS ) - { - if ( aStream[nStream] ) - { - delete aStream[nStream]; - aStream[nStream] = NULL; - } - - if ( nFile == STREAMED_SOUND_RADIO_MP3_PLAYER ) - { - uint32 i = 0; - do { - if(i != 0 || _bIsMp3Active) { - if(++_CurMP3Index >= nNumMP3s) _CurMP3Index = 0; - - _CurMP3Pos = 0; - - tMP3Entry *mp3 = _GetMP3EntryByIndex(_CurMP3Index); + char filename[MAX_PATH]; - if(mp3) { - mp3 = _pMP3List; - if(mp3 == NULL) { - _bIsMp3Active = false; - nFile = 0; - strcat(filename, StreamedNameTable[nFile]); + if ( nFile >= TOTAL_STREAMED_SOUNDS ) + return false; - CStream* stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000); - ASSERT(stream != NULL); + if ( aStream[nStream] ) + { + delete aStream[nStream]; + aStream[nStream] = NULL; + } + if ( nFile == STREAMED_SOUND_RADIO_MP3_PLAYER ) + { + do + { + // Switched to MP3 player just now + if ( !_bIsMp3Active && i == 0 ) + { + if ( nPos > nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] ) + position = 0; + tMP3Entry *e = _pMP3List; - aStream[nStream] = stream; + // Try to continue from previous song, if already started + if(!_GetMP3PosFromStreamPos(&position, &e) && !e) { + nFile = 0; + strcpy(filename, StreamedNameTable[nFile]); + + CStream* stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000); - if (stream->Setup()) { - if (position != 0) - stream->SetPosMS(position); + aStream[nStream] = stream; - stream->Start(); + if (stream->Setup()) { + if (position != 0) + stream->SetPosMS(position); - return true; - } else { - delete stream; - aStream[nStream] = NULL; - } + stream->Start(); - return false; - } + return true; + } else { + delete stream; + aStream[nStream] = NULL; } + return false; - if (mp3->pLinkPath != NULL) - aStream[nStream] = new CStream(mp3->pLinkPath, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000); + } else { + if ( e->pLinkPath != NULL ) + aStream[nStream] = new CStream(e->pLinkPath, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000); else { strcpy(filename, _mp3DirectoryPath); - strcat(filename, mp3->aFilename); - - aStream[nStream] = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000); + strcat(filename, e->aFilename); + + aStream[nStream] = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream]); } - + if (aStream[nStream]->Setup()) { + if (position != 0) + aStream[nStream]->SetPosMS(position); + aStream[nStream]->Start(); + _bIsMp3Active = true; return true; } else { delete aStream[nStream]; aStream[nStream] = NULL; } - - _bIsMp3Active = false; - continue; + // fall through, start playing from another song } - if ( nPos > nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] ) - position = 0; - - tMP3Entry *e; - if ( !_GetMP3PosFromStreamPos(&position, &e) ) + } else { + if(++_CurMP3Index >= nNumMP3s) _CurMP3Index = 0; + + _CurMP3Pos = 0; + + tMP3Entry *mp3 = _GetMP3EntryByIndex(_CurMP3Index); + if ( !mp3 ) { - if ( e == NULL ) + mp3 = _pMP3List; + if ( !_pMP3List ) { nFile = 0; - strcat(filename, StreamedNameTable[nFile]); + _bIsMp3Active = 0; + strcpy(filename, StreamedNameTable[nFile]); + CStream* stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000); - ASSERT(stream != NULL); aStream[nStream] = stream; @@ -1805,61 +1803,53 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) delete stream; aStream[nStream] = NULL; } - return false; } } - - if (e->pLinkPath != NULL) - aStream[nStream] = new CStream(e->pLinkPath, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000); + if(mp3->pLinkPath != NULL) + aStream[nStream] = new CStream(mp3->pLinkPath, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000); else { strcpy(filename, _mp3DirectoryPath); - strcat(filename, e->aFilename); + strcat(filename, mp3->aFilename); aStream[nStream] = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream]); } if (aStream[nStream]->Setup()) { - if (position != 0) - aStream[nStream]->SetPosMS(position); - aStream[nStream]->Start(); - +#ifdef FIX_BUGS _bIsMp3Active = true; +#endif return true; } else { delete aStream[nStream]; aStream[nStream] = NULL; } - - _bIsMp3Active = false; - } while(++i < nNumMP3s); - - position = 0; - nFile = 0; + } + _bIsMp3Active = 0; } + while ( ++i < nNumMP3s ); + position = 0; + nFile = 0; + } + strcpy(filename, StreamedNameTable[nFile]); + + CStream *stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000); - strcpy(filename, StreamedNameTable[nFile]); - - CStream *stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000); - ASSERT(stream != NULL); + aStream[nStream] = stream; + + if ( stream->Setup() ) { + if (position != 0) + stream->SetPosMS(position); - aStream[nStream] = stream; + stream->Start(); - if ( stream->Setup() ) { - if (position != 0) - stream->SetPosMS(position); - - stream->Start(); - - return true; - } else { - delete stream; - aStream[nStream] = NULL; - } + return true; + } else { + delete stream; + aStream[nStream] = NULL; } - return false; } -- cgit v1.2.3 From 59c9ae29cf12477576b0872a342bcbe5979b8281 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Fri, 26 Feb 2021 10:56:26 +0200 Subject: PoliceRadio -> PolRadio (original name) --- src/audio/PolRadio.cpp | 780 ++++++++++++++++++++++++++++++++++++++++++++++ src/audio/PolRadio.h | 46 +++ src/audio/PoliceRadio.cpp | 780 ---------------------------------------------- src/audio/PoliceRadio.h | 46 --- 4 files changed, 826 insertions(+), 826 deletions(-) create mode 100644 src/audio/PolRadio.cpp create mode 100644 src/audio/PolRadio.h delete mode 100644 src/audio/PoliceRadio.cpp delete mode 100644 src/audio/PoliceRadio.h (limited to 'src/audio') diff --git a/src/audio/PolRadio.cpp b/src/audio/PolRadio.cpp new file mode 100644 index 00000000..785dbf8f --- /dev/null +++ b/src/audio/PolRadio.cpp @@ -0,0 +1,780 @@ +#include "common.h" + +#include "DMAudio.h" + +#include "AudioManager.h" + +#include "AudioSamples.h" +#include "MusicManager.h" +#include "PlayerPed.h" +#include "PoliceRadio.h" +#include "Replay.h" +#include "Vehicle.h" +#include "World.h" +#include "Zones.h" +#include "sampman.h" +#include "Wanted.h" + +const int channels = ARRAY_SIZE(AudioManager.m_asActiveSamples); +const int policeChannel = channels + 1; + +struct tPoliceRadioZone { + char m_aName[8]; + uint32 m_nSampleIndex; + int32 field_12; +}; + +tPoliceRadioZone ZoneSfx[NUMAUDIOZONES]; +char SubZo2Label[8]; +char SubZo3Label[8]; + +int32 g_nMissionAudioSfx = TOTAL_AUDIO_SAMPLES; +int8 g_nMissionAudioPlayingStatus = 2; +uint8 gSpecialSuspectLastSeenReport; +uint32 gMinTimeToNextReport[NUM_CRIME_TYPES]; + +void +cAudioManager::InitialisePoliceRadioZones() +{ + for (int32 i = 0; i < NUMAUDIOZONES; i++) + memset(ZoneSfx[i].m_aName, 0, 8); + +#define SETZONESFX(i, name, sample) \ + strcpy(ZoneSfx[i].m_aName, name); \ + ZoneSfx[i].m_nSampleIndex = sample; + + SETZONESFX(0, "HOSPI_2", SFX_POLICE_RADIO_ROCKFORD); + SETZONESFX(1, "CONSTRU", SFX_POLICE_RADIO_FORT_STAUNTON); + SETZONESFX(2, "STADIUM", SFX_POLICE_RADIO_ASPATRIA); + SETZONESFX(3, "YAKUSA", SFX_POLICE_RADIO_TORRINGTON); + SETZONESFX(4, "SHOPING", SFX_POLICE_RADIO_BEDFORD_POINT); + SETZONESFX(5, "COM_EAS", SFX_POLICE_RADIO_NEWPORT); + SETZONESFX(6, "PARK", SFX_POLICE_RADIO_BELLEVILLE_PARK); + SETZONESFX(7, "UNIVERS", SFX_POLICE_RADIO_LIBERTY_CAMPUS); + SETZONESFX(8, "BIG_DAM", SFX_POLICE_RADIO_COCHRANE_DAM); + SETZONESFX(9, "SUB_IND", SFX_POLICE_RADIO_PIKE_CREEK); + SETZONESFX(10, "SWANKS", SFX_POLICE_RADIO_CEDAR_GROVE); + SETZONESFX(11, "PROJECT", SFX_POLICE_RADIO_WICHITA_GARDENS); + SETZONESFX(12, "AIRPORT", SFX_POLICE_RADIO_FRANCIS_INTERNATIONAL_AIRPORT); + SETZONESFX(13, "PORT_W", SFX_POLICE_RADIO_CALLAHAN_POINT); + SETZONESFX(14, "PORT_S", SFX_POLICE_RADIO_ATLANTIC_QUAYS); + SETZONESFX(15, "PORT_E", SFX_POLICE_RADIO_PORTLAND_HARBOUR); + SETZONESFX(16, "PORT_I", SFX_POLICE_RADIO_TRENTON); + SETZONESFX(17, "CHINA", SFX_POLICE_RADIO_CHINATOWN); + SETZONESFX(18, "REDLIGH", SFX_POLICE_RADIO_RED_LIGHT_DISTRICT); + SETZONESFX(19, "TOWERS", SFX_POLICE_RADIO_HEPBURN_HEIGHTS); + SETZONESFX(20, "LITTLEI", SFX_POLICE_RADIO_SAINT_MARKS); + SETZONESFX(21, "HARWOOD", SFX_POLICE_RADIO_HARWOOD); + SETZONESFX(22, "EASTBAY", SFX_POLICE_RADIO_PORTLAND_BEACH); + SETZONESFX(23, "S_VIEW", SFX_POLICE_RADIO_PORTLAND_STRAIGHTS); + SETZONESFX(24, "CITYZON", SFX_POLICE_RADIO_LIBERTY_CITY); + SETZONESFX(25, "IND_ZON", SFX_POLICE_RADIO_PORTLAND); + SETZONESFX(26, "COM_ZON", SFX_POLICE_RADIO_STAUNTON_ISLAND); + SETZONESFX(27, "SUB_ZON", SFX_POLICE_RADIO_SHORESIDE_VALE); + SETZONESFX(28, "SUB_ZO2", SFX_POLICE_RADIO_SHORESIDE_VALE); + SETZONESFX(29, "SUB_ZO3", SFX_POLICE_RADIO_SHORESIDE_VALE); + SETZONESFX(30, "A", SFX_POLICE_RADIO_ROCKFORD); + SETZONESFX(31, "A", SFX_POLICE_RADIO_ROCKFORD); + SETZONESFX(32, "A", SFX_POLICE_RADIO_ROCKFORD); + SETZONESFX(33, "A", SFX_POLICE_RADIO_ROCKFORD); + SETZONESFX(34, "A", SFX_POLICE_RADIO_ROCKFORD); + +#undef SETZONESFX + + strcpy(SubZo2Label, "SUB_ZO2"); + strcpy(SubZo3Label, "SUB_ZO3"); +} + +void +cAudioManager::InitialisePoliceRadio() +{ + m_sPoliceRadioQueue.policeChannelTimer = 0; + m_sPoliceRadioQueue.policeChannelTimerSeconds = 0; + m_sPoliceRadioQueue.policeChannelCounterSeconds = 0; + for (int32 i = 0; i < ARRAY_SIZE(m_sPoliceRadioQueue.crimes); i++) + m_sPoliceRadioQueue.crimes[i].type = CRIME_NONE; + + SampleManager.SetChannelReverbFlag(policeChannel, false); + gSpecialSuspectLastSeenReport = false; + for (int32 i = 0; i < ARRAY_SIZE(gMinTimeToNextReport); i++) + gMinTimeToNextReport[i] = m_FrameCounter; +} + +void +cAudioManager::ResetPoliceRadio() +{ + if (!m_bIsInitialised) return; + if (SampleManager.GetChannelUsedFlag(policeChannel)) SampleManager.StopChannel(policeChannel); + InitialisePoliceRadio(); +} + +void +cAudioManager::SetMissionScriptPoliceAudio(int32 sfx) const +{ + if (!m_bIsInitialised) return; + if (g_nMissionAudioPlayingStatus != 1) { + g_nMissionAudioPlayingStatus = 0; + g_nMissionAudioSfx = sfx; + } +} + +int8 +cAudioManager::GetMissionScriptPoliceAudioPlayingStatus() const +{ + return g_nMissionAudioPlayingStatus; +} + +void +cAudioManager::DoPoliceRadioCrackle() +{ + m_sQueueSample.m_nEntityIndex = m_nPoliceChannelEntity; + m_sQueueSample.m_nCounter = 0; + m_sQueueSample.m_nSampleIndex = SFX_POLICE_RADIO_CRACKLE; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_bIs2D = true; + m_sQueueSample.m_nReleasingVolumeModificator = 10; + m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_POLICE_RADIO_CRACKLE); + m_sQueueSample.m_nVolume = m_anRandomTable[2] % 20 + 15; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = m_sQueueSample.m_nVolume; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(SFX_POLICE_RADIO_CRACKLE); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(SFX_POLICE_RADIO_CRACKLE); + m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_bReverbFlag = false; + m_sQueueSample.m_nOffset = 63; + m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_bRequireReflection = false; + AddSampleToRequestedQueue(); +} + +void +cAudioManager::ServicePoliceRadio() +{ + int32 wantedLevel = 0; // uninitialized variable + static uint32 nLastSeen = 300; + + if(!m_bIsInitialised) return; + + if(m_nUserPause == 0) { + bool crimeReport = SetupCrimeReport(); +#ifdef FIX_BUGS // Crash at 0x5fe6ef + if(CReplay::IsPlayingBack() || !FindPlayerPed() || !FindPlayerPed()->m_pWanted) + return; +#endif + wantedLevel = FindPlayerPed()->m_pWanted->GetWantedLevel(); + if(!crimeReport) { + if(wantedLevel != 0) { + if(nLastSeen != 0) { + --nLastSeen; + } else { + nLastSeen = m_anRandomTable[1] % 1000 + 2000; + SetupSuspectLastSeenReport(); + } + } + } + } + ServicePoliceRadioChannel(wantedLevel); +} + +void +cAudioManager::ServicePoliceRadioChannel(uint8 wantedLevel) +{ + bool processed = false; + uint32 sample; + int32 freq; + + static int cWait = 0; + static bool bChannelOpen = false; + static uint8 bMissionAudioPhysicalPlayingStatus = 0; + static int32 PoliceChannelFreq = 5500; + + if (!m_bIsInitialised) return; + + if (m_nUserPause != 0) { + if (SampleManager.GetChannelUsedFlag(policeChannel)) SampleManager.StopChannel(policeChannel); + if (g_nMissionAudioSfx != TOTAL_AUDIO_SAMPLES && bMissionAudioPhysicalPlayingStatus == 1 && + SampleManager.IsStreamPlaying(1)) { + SampleManager.PauseStream(1, 1); + } + } else { + if (m_nPreviousUserPause && g_nMissionAudioSfx != TOTAL_AUDIO_SAMPLES && + bMissionAudioPhysicalPlayingStatus == 1) { + SampleManager.PauseStream(0, 1); + } + if (m_sPoliceRadioQueue.policeChannelTimer == 0) bChannelOpen = false; + if (cWait) { + --cWait; + return; + } + if (g_nMissionAudioSfx != TOTAL_AUDIO_SAMPLES && !bChannelOpen) { + if (g_nMissionAudioPlayingStatus) { + if (g_nMissionAudioPlayingStatus == 1 && !bMissionAudioPhysicalPlayingStatus && + SampleManager.IsStreamPlaying(1)) { + bMissionAudioPhysicalPlayingStatus = 1; + } + if (bMissionAudioPhysicalPlayingStatus == 1) { + if (SampleManager.IsStreamPlaying(1)) { + DoPoliceRadioCrackle(); + } else { + bMissionAudioPhysicalPlayingStatus = 2; + g_nMissionAudioPlayingStatus = 2; + g_nMissionAudioSfx = TOTAL_AUDIO_SAMPLES; + cWait = 30; + } + return; + } + } else if (!SampleManager.GetChannelUsedFlag(policeChannel)) { + SampleManager.PreloadStreamedFile(g_nMissionAudioSfx, 1); + SampleManager.SetStreamedVolumeAndPan(MAX_VOLUME, 63, 1, 1); + SampleManager.StartPreloadedStreamedFile(1); + g_nMissionAudioPlayingStatus = 1; + bMissionAudioPhysicalPlayingStatus = 0; + return; + } + } + if (bChannelOpen) DoPoliceRadioCrackle(); + if ((g_nMissionAudioSfx == TOTAL_AUDIO_SAMPLES || g_nMissionAudioPlayingStatus != 1) && + !SampleManager.GetChannelUsedFlag(policeChannel) && m_sPoliceRadioQueue.policeChannelTimer) { + if (m_sPoliceRadioQueue.policeChannelTimer) { + sample = m_sPoliceRadioQueue.crimesSamples[m_sPoliceRadioQueue.policeChannelCounterSeconds]; + m_sPoliceRadioQueue.policeChannelTimer--; + m_sPoliceRadioQueue.policeChannelCounterSeconds = (m_sPoliceRadioQueue.policeChannelCounterSeconds + 1) % 60; + } else { + sample = TOTAL_AUDIO_SAMPLES; + } + if (wantedLevel == 0) { + if (gSpecialSuspectLastSeenReport) { + gSpecialSuspectLastSeenReport = 0; + } else if (((sample >= SFX_POLICE_RADIO_MESSAGE_NOISE_1) && (sample <= SFX_POLICE_RADIO_MESSAGE_NOISE_3)) || sample == TOTAL_AUDIO_SAMPLES) { + bChannelOpen = false; + processed = true; + } + } + if (sample == TOTAL_AUDIO_SAMPLES) { + if (!processed) cWait = 30; + } else { + SampleManager.InitialiseChannel(policeChannel, sample, 0); + switch (sample) { + case SFX_POLICE_RADIO_MESSAGE_NOISE_1: + case SFX_POLICE_RADIO_MESSAGE_NOISE_2: + case SFX_POLICE_RADIO_MESSAGE_NOISE_3: + freq = m_anRandomTable[4] % 2000 + 10025; + bChannelOpen = bChannelOpen == false; + break; + default: freq = SampleManager.GetSampleBaseFrequency(sample); break; + } + PoliceChannelFreq = freq; + SampleManager.SetChannelFrequency(policeChannel, freq); + SampleManager.SetChannelVolume(policeChannel, 100); + SampleManager.SetChannelPan(policeChannel, 63); + SampleManager.SetChannelLoopCount(policeChannel, 1); + SampleManager.SetChannelLoopPoints(policeChannel, 0, -1); + SampleManager.StartChannel(policeChannel); + } + if (processed) ResetPoliceRadio(); + } + } +} + +bool +cAudioManager::SetupCrimeReport() +{ + int16 audioZoneId; + CZone *zone; + float rangeX; + float rangeY; + float halfX; + float halfY; + float quarterX; + float quarterY; + int i; + int32 sampleIndex; + bool processed = false; + + if (MusicManager.m_nMusicMode == MUSICMODE_CUTSCENE) return false; + + if (60 - m_sPoliceRadioQueue.policeChannelTimer <= 9) { + AgeCrimes(); + return true; + } + + for (i = 0; i < ARRAY_SIZE(m_sPoliceRadioQueue.crimes); i++) { + if (m_sPoliceRadioQueue.crimes[i].type != CRIME_NONE) + break; + } + + if (i == ARRAY_SIZE(m_sPoliceRadioQueue.crimes)) return false; + audioZoneId = CTheZones::FindAudioZone(&m_sPoliceRadioQueue.crimes[i].position); + if (audioZoneId >= 0 && audioZoneId < NUMAUDIOZONES) { + zone = CTheZones::GetAudioZone(audioZoneId); + for (int j = 0; j < NUMAUDIOZONES; j++) { + if (strcmp(zone->name, ZoneSfx[j].m_aName) == 0) { + sampleIndex = ZoneSfx[j].m_nSampleIndex; + m_sPoliceRadioQueue.Add(m_anRandomTable[4] % 3 + SFX_POLICE_RADIO_MESSAGE_NOISE_1); + m_sPoliceRadioQueue.Add(m_anRandomTable[0] % 3 + SFX_WEVE_GOT); + m_sPoliceRadioQueue.Add(m_anRandomTable[1] % 2 + SFX_A_10_1); + switch (m_sPoliceRadioQueue.crimes[i].type) { + case CRIME_PED_BURNED: m_sPoliceRadioQueue.crimes[i].type = CRIME_HIT_PED; break; + case CRIME_COP_BURNED: m_sPoliceRadioQueue.crimes[i].type = CRIME_HIT_COP; break; + case CRIME_VEHICLE_BURNED: m_sPoliceRadioQueue.crimes[i].type = CRIME_STEAL_CAR; break; + case CRIME_DESTROYED_CESSNA: m_sPoliceRadioQueue.crimes[i].type = CRIME_SHOOT_HELI; break; + default: break; + } + m_sPoliceRadioQueue.Add(m_sPoliceRadioQueue.crimes[i].type + SFX_CRIME_1 - 1); + m_sPoliceRadioQueue.Add(SFX_IN); + if (sampleIndex == SFX_POLICE_RADIO_SHORESIDE_VALE && + (strcmp(zone->name, SubZo2Label) == 0 || strcmp(zone->name, SubZo3Label) == 0)) { + m_sPoliceRadioQueue.Add(SFX_NORTH); + m_sPoliceRadioQueue.Add(SFX_EAST); + } else { + rangeX = zone->maxx - zone->minx; + rangeY = zone->maxy - zone->miny; + halfX = 0.5f * rangeX + zone->minx; + halfY = 0.5f * rangeY + zone->miny; + quarterX = 0.25f * rangeX; + quarterY = 0.25f * rangeY; + + if (m_sPoliceRadioQueue.crimes[i].position.y > halfY + quarterY) { + m_sPoliceRadioQueue.Add(SFX_NORTH); + processed = true; + } else if (m_sPoliceRadioQueue.crimes[i].position.y < halfY - quarterY) { + m_sPoliceRadioQueue.Add(SFX_SOUTH); + processed = true; + } + + if (m_sPoliceRadioQueue.crimes[i].position.x > halfX + quarterX) + m_sPoliceRadioQueue.Add(SFX_EAST); + else if (m_sPoliceRadioQueue.crimes[i].position.x < halfX - quarterX) + m_sPoliceRadioQueue.Add(SFX_WEST); + else if (!processed) + m_sPoliceRadioQueue.Add(SFX_CENTRAL); + + m_sPoliceRadioQueue.Add(sampleIndex); + m_sPoliceRadioQueue.Add(m_anRandomTable[2] % 3 + SFX_POLICE_RADIO_MESSAGE_NOISE_1); + m_sPoliceRadioQueue.Add(TOTAL_AUDIO_SAMPLES); + } + break; + } + } + } + m_sPoliceRadioQueue.crimes[i].type = CRIME_NONE; + AgeCrimes(); + return true; +} + +void +cAudioManager::SetupSuspectLastSeenReport() +{ + CVehicle *veh; + uint8 color1; + int32 main_color; + int32 sample; + + int32 color_pre_modifier; + int32 color_post_modifier; + + const int32 gCarColourTable[][3] = { + {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_BLACK, TOTAL_AUDIO_SAMPLES}, + {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_WHITE, TOTAL_AUDIO_SAMPLES}, + {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_BLUE, TOTAL_AUDIO_SAMPLES}, + {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_RED, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_DARK, SFX_POLICE_RADIO_BLUE, TOTAL_AUDIO_SAMPLES}, + {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_PURPLE, TOTAL_AUDIO_SAMPLES}, + {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_YELLOW, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_BRIGHT, SFX_POLICE_RADIO_BLUE, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_LIGHT, SFX_POLICE_RADIO_BLUE, SFX_POLICE_RADIO_GREY}, +#ifdef FIX_BUGS + {SFX_POLICE_RADIO_LIGHT, SFX_POLICE_RADIO_RED, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_DARK, SFX_POLICE_RADIO_RED, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_DARK, SFX_POLICE_RADIO_RED, TOTAL_AUDIO_SAMPLES}, +#else + {SFX_POLICE_RADIO_LIGHT, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, +#endif + {SFX_POLICE_RADIO_DARK, SFX_POLICE_RADIO_RED, TOTAL_AUDIO_SAMPLES}, + {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_RED, TOTAL_AUDIO_SAMPLES}, + {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_RED, TOTAL_AUDIO_SAMPLES}, + {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_RED, TOTAL_AUDIO_SAMPLES}, + {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_RED, TOTAL_AUDIO_SAMPLES}, + {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_RED, TOTAL_AUDIO_SAMPLES}, + {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_RED, TOTAL_AUDIO_SAMPLES}, +#ifdef FIX_BUGS + {SFX_POLICE_RADIO_LIGHT, SFX_POLICE_RADIO_RED, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_DARK, SFX_POLICE_RADIO_ORANGE, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_DARK, SFX_POLICE_RADIO_ORANGE, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_DARK, SFX_POLICE_RADIO_ORANGE, TOTAL_AUDIO_SAMPLES}, +#else + {SFX_POLICE_RADIO_LIGHT, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, +#endif + {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_ORANGE, TOTAL_AUDIO_SAMPLES}, + {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_ORANGE, TOTAL_AUDIO_SAMPLES}, + {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_ORANGE, TOTAL_AUDIO_SAMPLES}, + {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_ORANGE, TOTAL_AUDIO_SAMPLES}, + {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_ORANGE, TOTAL_AUDIO_SAMPLES}, + {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_ORANGE, TOTAL_AUDIO_SAMPLES}, +#ifdef FIX_BUGS + {SFX_POLICE_RADIO_LIGHT, SFX_POLICE_RADIO_ORANGE, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_DARK, SFX_POLICE_RADIO_YELLOW, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_DARK, SFX_POLICE_RADIO_YELLOW, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_DARK, SFX_POLICE_RADIO_YELLOW, TOTAL_AUDIO_SAMPLES}, +#else + {SFX_POLICE_RADIO_LIGHT, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, +#endif + {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_YELLOW, TOTAL_AUDIO_SAMPLES}, + {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_YELLOW, TOTAL_AUDIO_SAMPLES}, + {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_YELLOW, TOTAL_AUDIO_SAMPLES}, + {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_YELLOW, TOTAL_AUDIO_SAMPLES}, + {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_YELLOW, TOTAL_AUDIO_SAMPLES}, + {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_YELLOW, TOTAL_AUDIO_SAMPLES}, +#ifdef FIX_BUGS + {SFX_POLICE_RADIO_LIGHT, SFX_POLICE_RADIO_YELLOW, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_DARK, SFX_POLICE_RADIO_GREEN, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_DARK, SFX_POLICE_RADIO_GREEN, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_DARK, SFX_POLICE_RADIO_GREEN, TOTAL_AUDIO_SAMPLES}, +#else + {SFX_POLICE_RADIO_LIGHT, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, +#endif + {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_GREEN, TOTAL_AUDIO_SAMPLES}, + {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_GREEN, TOTAL_AUDIO_SAMPLES}, + {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_GREEN, TOTAL_AUDIO_SAMPLES}, + {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_GREEN, TOTAL_AUDIO_SAMPLES}, + {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_GREEN, TOTAL_AUDIO_SAMPLES}, + {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_GREEN, TOTAL_AUDIO_SAMPLES}, +#ifdef FIX_BUGS + {SFX_POLICE_RADIO_LIGHT, SFX_POLICE_RADIO_GREEN, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_DARK, SFX_POLICE_RADIO_BLUE, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_DARK, SFX_POLICE_RADIO_BLUE, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_DARK, SFX_POLICE_RADIO_BLUE, TOTAL_AUDIO_SAMPLES}, +#else + {SFX_POLICE_RADIO_LIGHT, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, +#endif + {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_BLUE, TOTAL_AUDIO_SAMPLES}, + {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_BLUE, TOTAL_AUDIO_SAMPLES}, + {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_BLUE, TOTAL_AUDIO_SAMPLES}, + {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_BLUE, TOTAL_AUDIO_SAMPLES}, + {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_BLUE, TOTAL_AUDIO_SAMPLES}, + {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_BLUE, TOTAL_AUDIO_SAMPLES}, +#ifdef FIX_BUGS + {SFX_POLICE_RADIO_LIGHT, SFX_POLICE_RADIO_BLUE, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_DARK, SFX_POLICE_RADIO_PURPLE, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_DARK, SFX_POLICE_RADIO_PURPLE, SFX_POLICE_RADIO_BLUE}, + {SFX_POLICE_RADIO_DARK, SFX_POLICE_RADIO_PURPLE, TOTAL_AUDIO_SAMPLES}, +#else + {SFX_POLICE_RADIO_LIGHT, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, +#endif + {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_PURPLE, TOTAL_AUDIO_SAMPLES}, + {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_PURPLE, TOTAL_AUDIO_SAMPLES}, +#ifdef FIX_BUGS + {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_PURPLE, SFX_POLICE_RADIO_GREY}, +#else + {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_PURPLE, TOTAL_AUDIO_SAMPLES}, +#endif + {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_PURPLE, TOTAL_AUDIO_SAMPLES}, + {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_PURPLE, TOTAL_AUDIO_SAMPLES}, + {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_PURPLE, TOTAL_AUDIO_SAMPLES}, +#ifdef FIX_BUGS + {SFX_POLICE_RADIO_LIGHT, SFX_POLICE_RADIO_PURPLE, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_DARK, SFX_POLICE_RADIO_SILVER, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_DARK, SFX_POLICE_RADIO_SILVER, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_DARK, SFX_POLICE_RADIO_SILVER, TOTAL_AUDIO_SAMPLES}, +#else + {SFX_POLICE_RADIO_LIGHT, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, +#endif + {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_SILVER, TOTAL_AUDIO_SAMPLES}, + {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_SILVER, TOTAL_AUDIO_SAMPLES}, + {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_SILVER, TOTAL_AUDIO_SAMPLES}, + {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_SILVER, TOTAL_AUDIO_SAMPLES}, + {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_SILVER, TOTAL_AUDIO_SAMPLES}, +#ifdef FIX_BUGS + {SFX_POLICE_RADIO_LIGHT, SFX_POLICE_RADIO_SILVER, TOTAL_AUDIO_SAMPLES}, +#else + {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_SILVER, TOTAL_AUDIO_SAMPLES}, +#endif + {SFX_POLICE_RADIO_LIGHT, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_LIGHT, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_LIGHT, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_LIGHT, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_LIGHT, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_LIGHT, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_LIGHT, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_LIGHT, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_LIGHT, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_LIGHT, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_LIGHT, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, + {SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES} + }; + + if (MusicManager.m_nMusicMode != MUSICMODE_CUTSCENE) { + veh = FindPlayerVehicle(); + if (veh != nil) { + if (60 - m_sPoliceRadioQueue.policeChannelTimer > 9) { + color1 = veh->m_currentColour1; + if (color1 >= ARRAY_SIZE(gCarColourTable)) { + debug("\n *** UNKNOWN CAR COLOUR %d *** ", color1); + } else { + main_color = gCarColourTable[color1][1]; + color_pre_modifier = gCarColourTable[color1][0]; + color_post_modifier = gCarColourTable[color1][2]; + switch (veh->GetModelIndex()) { +#ifdef FIX_BUGS + case MI_COLUMB: + main_color = SFX_POLICE_RADIO_BLUE; + color_pre_modifier = color_post_modifier = TOTAL_AUDIO_SAMPLES; +#endif + case MI_LANDSTAL: + case MI_BLISTA: sample = SFX_POLICE_RADIO_CRUISER; break; +#ifdef FIX_BUGS + case MI_YARDIE: + color_pre_modifier = TOTAL_AUDIO_SAMPLES; + main_color = SFX_POLICE_RADIO_RED; + color_post_modifier = SFX_POLICE_RADIO_YELLOW; + sample = SFX_POLICE_RADIO_CONVERTIBLE; break; + case MI_DIABLOS: + main_color = SFX_POLICE_RADIO_BLACK; +#endif + case MI_IDAHO: + case MI_STALLION: sample = SFX_POLICE_RADIO_CONVERTIBLE; break; +#ifdef FIX_BUGS + case MI_YAKUZA: + color_pre_modifier = TOTAL_AUDIO_SAMPLES; + main_color = SFX_POLICE_RADIO_SILVER; + color_post_modifier = SFX_POLICE_RADIO_RED; +#endif + case MI_STINGER: + case MI_INFERNUS: + case MI_CHEETAH: + case MI_BANSHEE: sample = SFX_POLICE_RADIO_SPORTS_CAR; break; +#ifdef FIX_BUGS + case MI_MAFIA: + color_pre_modifier = color_post_modifier = TOTAL_AUDIO_SAMPLES; + main_color = SFX_POLICE_RADIO_GREY; + case MI_KURUMA: +#endif + case MI_PEREN: + case MI_SENTINEL: + case MI_FBICAR: sample = SFX_POLICE_RADIO_SALOON; break; + case MI_PATRIOT: + case MI_BOBCAT: sample = SFX_POLICE_RADIO_PICKUP; break; + case MI_FIRETRUCK: sample = SFX_POLICE_RADIO_FIRE_TRUCK; break; +#ifdef FIX_BUGS + case MI_LINERUN: + case MI_FLATBED: +#endif + case MI_TRASH: + case MI_BARRACKS: sample = SFX_POLICE_RADIO_TRUCK; break; + case MI_STRETCH: sample = SFX_POLICE_RADIO_LIMO; break; +#ifdef FIX_BUGS + case MI_CORPSE: +#endif + case MI_MANANA: + case MI_ESPERANT: sample = SFX_POLICE_RADIO_2_DOOR; break; +#ifdef FIX_BUGS + case MI_HOODS: + color_pre_modifier = TOTAL_AUDIO_SAMPLES; + main_color = SFX_POLICE_RADIO_BLUE; + color_post_modifier = SFX_POLICE_RADIO_GREEN; + case MI_BELLYUP: + case MI_YANKEE: + case MI_TOYZ: + case MI_MRWONGS: + case MI_PANLANT: +#endif + case MI_PONY: + case MI_MULE: + case MI_MOONBEAM: + case MI_ENFORCER: + case MI_SECURICA: + case MI_RUMPO: sample = SFX_POLICE_RADIO_VAN; break; + case MI_AMBULAN: sample = SFX_POLICE_RADIO_AMBULANCE; break; + case MI_TAXI: + case MI_CABBIE: + case MI_BORGNINE: sample = SFX_POLICE_RADIO_TAXI; break; + case MI_MRWHOOP: + sample = SFX_POLICE_RADIO_ICE_CREAM_VAN; + break; + case MI_BFINJECT: sample = SFX_POLICE_RADIO_BUGGY; break; + case MI_POLICE: sample = SFX_POLICE_RADIO_POLICE_CAR; break; +#ifdef FIX_BUGS + case MI_SPEEDER: + case MI_REEFER: + case MI_GHOST: +#endif + case MI_PREDATOR: sample = SFX_POLICE_RADIO_BOAT; break; + case MI_BUS: + case MI_COACH: sample = SFX_POLICE_RADIO_BUS; break; + case MI_RHINO: + sample = SFX_POLICE_RADIO_TANK; + main_color = TOTAL_AUDIO_SAMPLES; + color_post_modifier = TOTAL_AUDIO_SAMPLES; + break; + case MI_TRAIN: + sample = SFX_POLICE_RADIO_SUBWAY_CAR; + main_color = TOTAL_AUDIO_SAMPLES; + color_post_modifier = TOTAL_AUDIO_SAMPLES; + + break; + default: + debug("\n *** UNKNOWN CAR MODEL INDEX %d *** ", veh->GetModelIndex()); + return; + } + m_sPoliceRadioQueue.Add(m_anRandomTable[4] % 3 + SFX_POLICE_RADIO_MESSAGE_NOISE_1); + m_sPoliceRadioQueue.Add(SFX_POLICE_RADIO_SUSPECT); + if (m_anRandomTable[3] % 2) + m_sPoliceRadioQueue.Add(SFX_POLICE_RADIO_LAST_SEEN); +#ifdef FIX_BUGS + if (main_color == SFX_POLICE_RADIO_ORANGE && color_pre_modifier == TOTAL_AUDIO_SAMPLES) +#else + if (main_color == SFX_POLICE_RADIO_ORANGE) +#endif + m_sPoliceRadioQueue.Add(SFX_POLICE_RADIO_IN_AN); + else + m_sPoliceRadioQueue.Add(SFX_POLICE_RADIO_IN_A); + if (color_pre_modifier != TOTAL_AUDIO_SAMPLES) + m_sPoliceRadioQueue.Add(color_pre_modifier); + if (main_color != TOTAL_AUDIO_SAMPLES) + m_sPoliceRadioQueue.Add(main_color); + if (color_post_modifier != TOTAL_AUDIO_SAMPLES) + m_sPoliceRadioQueue.Add(color_post_modifier); + m_sPoliceRadioQueue.Add(sample); + m_sPoliceRadioQueue.Add(m_anRandomTable[0] % 3 + SFX_POLICE_RADIO_MESSAGE_NOISE_1); + m_sPoliceRadioQueue.Add(TOTAL_AUDIO_SAMPLES); + } + } + } else if (60 - m_sPoliceRadioQueue.policeChannelTimer > 4) { + m_sPoliceRadioQueue.Add(SFX_POLICE_RADIO_MESSAGE_NOISE_1); + m_sPoliceRadioQueue.Add(SFX_POLICE_RADIO_SUSPECT); + m_sPoliceRadioQueue.Add(SFX_POLICE_RADIO_ON_FOOT); + m_sPoliceRadioQueue.Add(m_anRandomTable[0] % 3 + SFX_POLICE_RADIO_MESSAGE_NOISE_1); + m_sPoliceRadioQueue.Add(TOTAL_AUDIO_SAMPLES); + } + } +} + + + +void +cAudioManager::ReportCrime(eCrimeType type, const CVector &pos) +{ + int32 lastCrime = ARRAY_SIZE(m_sPoliceRadioQueue.crimes); + if (m_bIsInitialised && MusicManager.m_nMusicMode != MUSICMODE_CUTSCENE && FindPlayerPed()->m_pWanted->GetWantedLevel() > 0 && + (type > CRIME_NONE || type < NUM_CRIME_TYPES) && m_FrameCounter >= gMinTimeToNextReport[type]) { + for (int32 i = 0; i < ARRAY_SIZE(m_sPoliceRadioQueue.crimes); i++) { + if (m_sPoliceRadioQueue.crimes[i].type) { + if (m_sPoliceRadioQueue.crimes[i].type == type) { + m_sPoliceRadioQueue.crimes[i].position = pos; + m_sPoliceRadioQueue.crimes[i].timer = 0; + return; + } + } else { + lastCrime = i; + } + } + + if (lastCrime < ARRAY_SIZE(m_sPoliceRadioQueue.crimes)) { + m_sPoliceRadioQueue.crimes[lastCrime].type = type; + m_sPoliceRadioQueue.crimes[lastCrime].position = pos; + m_sPoliceRadioQueue.crimes[lastCrime].timer = 0; + gMinTimeToNextReport[type] = m_FrameCounter + 500; + } + } +} + +void +cAudioManager::PlaySuspectLastSeen(float x, float y, float z) +{ + int16 audioZone; + CZone *zone; + float rangeX; + float rangeY; + float halfX; + float halfY; + float quarterX; + float quarterY; + int32 sample; + bool processed = false; + CVector vec = CVector(x, y, z); + + if (!m_bIsInitialised) return; + + if (MusicManager.m_nMusicMode != MUSICMODE_CUTSCENE && 60 - m_sPoliceRadioQueue.policeChannelTimer > 9) { + audioZone = CTheZones::FindAudioZone(&vec); + if (audioZone >= 0 && audioZone < NUMAUDIOZONES) { + zone = CTheZones::GetAudioZone(audioZone); + for (int i = 0; i < NUMAUDIOZONES; i++) { + if (strcmp(zone->name, ZoneSfx[i].m_aName) == 0) { + sample = ZoneSfx[i].m_nSampleIndex; + m_sPoliceRadioQueue.Add(m_anRandomTable[4] % 3 + SFX_POLICE_RADIO_MESSAGE_NOISE_1); + m_sPoliceRadioQueue.Add(SFX_POLICE_RADIO_SUSPECT); + m_sPoliceRadioQueue.Add(SFX_POLICE_RADIO_LAST_SEEN); + m_sPoliceRadioQueue.Add(SFX_IN); + if (sample == SFX_POLICE_RADIO_SHORESIDE_VALE && + (strcmp(zone->name, SubZo2Label) == 0 || + strcmp(zone->name, SubZo3Label) == 0)) { + m_sPoliceRadioQueue.Add(SFX_NORTH); + m_sPoliceRadioQueue.Add(SFX_EAST); + } else { + rangeX = zone->maxx - zone->minx; + rangeY = zone->maxy - zone->miny; + halfX = 0.5f * rangeX + zone->minx; + halfY = 0.5f * rangeY + zone->miny; + quarterX = 0.25f * rangeX; + quarterY = 0.25f * rangeY; + + if (vec.y > halfY + quarterY) { + m_sPoliceRadioQueue.Add(SFX_NORTH); + processed = true; + } else if (vec.y < halfY - quarterY) { + m_sPoliceRadioQueue.Add(SFX_SOUTH); + processed = true; + } + + if (vec.x > halfX + quarterX) + m_sPoliceRadioQueue.Add(SFX_EAST); + else if (vec.x < halfX - quarterX) + m_sPoliceRadioQueue.Add(SFX_WEST); + else if (!processed) + m_sPoliceRadioQueue.Add(SFX_CENTRAL); + } + m_sPoliceRadioQueue.Add(sample); + m_sPoliceRadioQueue.Add(m_anRandomTable[2] % 3 + SFX_POLICE_RADIO_MESSAGE_NOISE_1); + m_sPoliceRadioQueue.Add(TOTAL_AUDIO_SAMPLES); + gSpecialSuspectLastSeenReport = true; + break; + } + } + } + } +} + +void +cAudioManager::AgeCrimes() +{ + for (uint8 i = 0; i < ARRAY_SIZE(m_sPoliceRadioQueue.crimes); i++) { + if (m_sPoliceRadioQueue.crimes[i].type != CRIME_NONE) { + if (++m_sPoliceRadioQueue.crimes[i].timer > 1500) m_sPoliceRadioQueue.crimes[i].type = CRIME_NONE; + } + } +} diff --git a/src/audio/PolRadio.h b/src/audio/PolRadio.h new file mode 100644 index 00000000..368708b6 --- /dev/null +++ b/src/audio/PolRadio.h @@ -0,0 +1,46 @@ +#pragma once + +#include "Crime.h" + +struct cAMCrime { + int32 type; + CVector position; + uint16 timer; + + cAMCrime() + { + type = CRIME_NONE; + position = CVector(0.0f, 0.0f, 0.0f); + timer = 0; + } +}; + +VALIDATE_SIZE(cAMCrime, 20); + +class cPoliceRadioQueue +{ +public: + int32 crimesSamples[60]; + uint8 policeChannelTimer; + uint8 policeChannelTimerSeconds; + uint8 policeChannelCounterSeconds; + cAMCrime crimes[10]; + + cPoliceRadioQueue() + { + policeChannelTimerSeconds = 0; + policeChannelCounterSeconds = 0; + policeChannelTimer = 0; + } + + void Add(uint32 sample) + { + if (policeChannelTimer != 60) { + crimesSamples[policeChannelTimerSeconds] = sample; + policeChannelTimer++; + policeChannelTimerSeconds = (policeChannelTimerSeconds + 1) % 60; + } + } +}; + +VALIDATE_SIZE(cPoliceRadioQueue, 444); diff --git a/src/audio/PoliceRadio.cpp b/src/audio/PoliceRadio.cpp deleted file mode 100644 index 785dbf8f..00000000 --- a/src/audio/PoliceRadio.cpp +++ /dev/null @@ -1,780 +0,0 @@ -#include "common.h" - -#include "DMAudio.h" - -#include "AudioManager.h" - -#include "AudioSamples.h" -#include "MusicManager.h" -#include "PlayerPed.h" -#include "PoliceRadio.h" -#include "Replay.h" -#include "Vehicle.h" -#include "World.h" -#include "Zones.h" -#include "sampman.h" -#include "Wanted.h" - -const int channels = ARRAY_SIZE(AudioManager.m_asActiveSamples); -const int policeChannel = channels + 1; - -struct tPoliceRadioZone { - char m_aName[8]; - uint32 m_nSampleIndex; - int32 field_12; -}; - -tPoliceRadioZone ZoneSfx[NUMAUDIOZONES]; -char SubZo2Label[8]; -char SubZo3Label[8]; - -int32 g_nMissionAudioSfx = TOTAL_AUDIO_SAMPLES; -int8 g_nMissionAudioPlayingStatus = 2; -uint8 gSpecialSuspectLastSeenReport; -uint32 gMinTimeToNextReport[NUM_CRIME_TYPES]; - -void -cAudioManager::InitialisePoliceRadioZones() -{ - for (int32 i = 0; i < NUMAUDIOZONES; i++) - memset(ZoneSfx[i].m_aName, 0, 8); - -#define SETZONESFX(i, name, sample) \ - strcpy(ZoneSfx[i].m_aName, name); \ - ZoneSfx[i].m_nSampleIndex = sample; - - SETZONESFX(0, "HOSPI_2", SFX_POLICE_RADIO_ROCKFORD); - SETZONESFX(1, "CONSTRU", SFX_POLICE_RADIO_FORT_STAUNTON); - SETZONESFX(2, "STADIUM", SFX_POLICE_RADIO_ASPATRIA); - SETZONESFX(3, "YAKUSA", SFX_POLICE_RADIO_TORRINGTON); - SETZONESFX(4, "SHOPING", SFX_POLICE_RADIO_BEDFORD_POINT); - SETZONESFX(5, "COM_EAS", SFX_POLICE_RADIO_NEWPORT); - SETZONESFX(6, "PARK", SFX_POLICE_RADIO_BELLEVILLE_PARK); - SETZONESFX(7, "UNIVERS", SFX_POLICE_RADIO_LIBERTY_CAMPUS); - SETZONESFX(8, "BIG_DAM", SFX_POLICE_RADIO_COCHRANE_DAM); - SETZONESFX(9, "SUB_IND", SFX_POLICE_RADIO_PIKE_CREEK); - SETZONESFX(10, "SWANKS", SFX_POLICE_RADIO_CEDAR_GROVE); - SETZONESFX(11, "PROJECT", SFX_POLICE_RADIO_WICHITA_GARDENS); - SETZONESFX(12, "AIRPORT", SFX_POLICE_RADIO_FRANCIS_INTERNATIONAL_AIRPORT); - SETZONESFX(13, "PORT_W", SFX_POLICE_RADIO_CALLAHAN_POINT); - SETZONESFX(14, "PORT_S", SFX_POLICE_RADIO_ATLANTIC_QUAYS); - SETZONESFX(15, "PORT_E", SFX_POLICE_RADIO_PORTLAND_HARBOUR); - SETZONESFX(16, "PORT_I", SFX_POLICE_RADIO_TRENTON); - SETZONESFX(17, "CHINA", SFX_POLICE_RADIO_CHINATOWN); - SETZONESFX(18, "REDLIGH", SFX_POLICE_RADIO_RED_LIGHT_DISTRICT); - SETZONESFX(19, "TOWERS", SFX_POLICE_RADIO_HEPBURN_HEIGHTS); - SETZONESFX(20, "LITTLEI", SFX_POLICE_RADIO_SAINT_MARKS); - SETZONESFX(21, "HARWOOD", SFX_POLICE_RADIO_HARWOOD); - SETZONESFX(22, "EASTBAY", SFX_POLICE_RADIO_PORTLAND_BEACH); - SETZONESFX(23, "S_VIEW", SFX_POLICE_RADIO_PORTLAND_STRAIGHTS); - SETZONESFX(24, "CITYZON", SFX_POLICE_RADIO_LIBERTY_CITY); - SETZONESFX(25, "IND_ZON", SFX_POLICE_RADIO_PORTLAND); - SETZONESFX(26, "COM_ZON", SFX_POLICE_RADIO_STAUNTON_ISLAND); - SETZONESFX(27, "SUB_ZON", SFX_POLICE_RADIO_SHORESIDE_VALE); - SETZONESFX(28, "SUB_ZO2", SFX_POLICE_RADIO_SHORESIDE_VALE); - SETZONESFX(29, "SUB_ZO3", SFX_POLICE_RADIO_SHORESIDE_VALE); - SETZONESFX(30, "A", SFX_POLICE_RADIO_ROCKFORD); - SETZONESFX(31, "A", SFX_POLICE_RADIO_ROCKFORD); - SETZONESFX(32, "A", SFX_POLICE_RADIO_ROCKFORD); - SETZONESFX(33, "A", SFX_POLICE_RADIO_ROCKFORD); - SETZONESFX(34, "A", SFX_POLICE_RADIO_ROCKFORD); - -#undef SETZONESFX - - strcpy(SubZo2Label, "SUB_ZO2"); - strcpy(SubZo3Label, "SUB_ZO3"); -} - -void -cAudioManager::InitialisePoliceRadio() -{ - m_sPoliceRadioQueue.policeChannelTimer = 0; - m_sPoliceRadioQueue.policeChannelTimerSeconds = 0; - m_sPoliceRadioQueue.policeChannelCounterSeconds = 0; - for (int32 i = 0; i < ARRAY_SIZE(m_sPoliceRadioQueue.crimes); i++) - m_sPoliceRadioQueue.crimes[i].type = CRIME_NONE; - - SampleManager.SetChannelReverbFlag(policeChannel, false); - gSpecialSuspectLastSeenReport = false; - for (int32 i = 0; i < ARRAY_SIZE(gMinTimeToNextReport); i++) - gMinTimeToNextReport[i] = m_FrameCounter; -} - -void -cAudioManager::ResetPoliceRadio() -{ - if (!m_bIsInitialised) return; - if (SampleManager.GetChannelUsedFlag(policeChannel)) SampleManager.StopChannel(policeChannel); - InitialisePoliceRadio(); -} - -void -cAudioManager::SetMissionScriptPoliceAudio(int32 sfx) const -{ - if (!m_bIsInitialised) return; - if (g_nMissionAudioPlayingStatus != 1) { - g_nMissionAudioPlayingStatus = 0; - g_nMissionAudioSfx = sfx; - } -} - -int8 -cAudioManager::GetMissionScriptPoliceAudioPlayingStatus() const -{ - return g_nMissionAudioPlayingStatus; -} - -void -cAudioManager::DoPoliceRadioCrackle() -{ - m_sQueueSample.m_nEntityIndex = m_nPoliceChannelEntity; - m_sQueueSample.m_nCounter = 0; - m_sQueueSample.m_nSampleIndex = SFX_POLICE_RADIO_CRACKLE; - m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = true; - m_sQueueSample.m_nReleasingVolumeModificator = 10; - m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_POLICE_RADIO_CRACKLE); - m_sQueueSample.m_nVolume = m_anRandomTable[2] % 20 + 15; - m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = m_sQueueSample.m_nVolume; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(SFX_POLICE_RADIO_CRACKLE); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(SFX_POLICE_RADIO_CRACKLE); - m_sQueueSample.m_bReleasingSoundFlag = false; - m_sQueueSample.m_bReverbFlag = false; - m_sQueueSample.m_nOffset = 63; - m_sQueueSample.m_nReleasingVolumeDivider = 3; - m_sQueueSample.m_bRequireReflection = false; - AddSampleToRequestedQueue(); -} - -void -cAudioManager::ServicePoliceRadio() -{ - int32 wantedLevel = 0; // uninitialized variable - static uint32 nLastSeen = 300; - - if(!m_bIsInitialised) return; - - if(m_nUserPause == 0) { - bool crimeReport = SetupCrimeReport(); -#ifdef FIX_BUGS // Crash at 0x5fe6ef - if(CReplay::IsPlayingBack() || !FindPlayerPed() || !FindPlayerPed()->m_pWanted) - return; -#endif - wantedLevel = FindPlayerPed()->m_pWanted->GetWantedLevel(); - if(!crimeReport) { - if(wantedLevel != 0) { - if(nLastSeen != 0) { - --nLastSeen; - } else { - nLastSeen = m_anRandomTable[1] % 1000 + 2000; - SetupSuspectLastSeenReport(); - } - } - } - } - ServicePoliceRadioChannel(wantedLevel); -} - -void -cAudioManager::ServicePoliceRadioChannel(uint8 wantedLevel) -{ - bool processed = false; - uint32 sample; - int32 freq; - - static int cWait = 0; - static bool bChannelOpen = false; - static uint8 bMissionAudioPhysicalPlayingStatus = 0; - static int32 PoliceChannelFreq = 5500; - - if (!m_bIsInitialised) return; - - if (m_nUserPause != 0) { - if (SampleManager.GetChannelUsedFlag(policeChannel)) SampleManager.StopChannel(policeChannel); - if (g_nMissionAudioSfx != TOTAL_AUDIO_SAMPLES && bMissionAudioPhysicalPlayingStatus == 1 && - SampleManager.IsStreamPlaying(1)) { - SampleManager.PauseStream(1, 1); - } - } else { - if (m_nPreviousUserPause && g_nMissionAudioSfx != TOTAL_AUDIO_SAMPLES && - bMissionAudioPhysicalPlayingStatus == 1) { - SampleManager.PauseStream(0, 1); - } - if (m_sPoliceRadioQueue.policeChannelTimer == 0) bChannelOpen = false; - if (cWait) { - --cWait; - return; - } - if (g_nMissionAudioSfx != TOTAL_AUDIO_SAMPLES && !bChannelOpen) { - if (g_nMissionAudioPlayingStatus) { - if (g_nMissionAudioPlayingStatus == 1 && !bMissionAudioPhysicalPlayingStatus && - SampleManager.IsStreamPlaying(1)) { - bMissionAudioPhysicalPlayingStatus = 1; - } - if (bMissionAudioPhysicalPlayingStatus == 1) { - if (SampleManager.IsStreamPlaying(1)) { - DoPoliceRadioCrackle(); - } else { - bMissionAudioPhysicalPlayingStatus = 2; - g_nMissionAudioPlayingStatus = 2; - g_nMissionAudioSfx = TOTAL_AUDIO_SAMPLES; - cWait = 30; - } - return; - } - } else if (!SampleManager.GetChannelUsedFlag(policeChannel)) { - SampleManager.PreloadStreamedFile(g_nMissionAudioSfx, 1); - SampleManager.SetStreamedVolumeAndPan(MAX_VOLUME, 63, 1, 1); - SampleManager.StartPreloadedStreamedFile(1); - g_nMissionAudioPlayingStatus = 1; - bMissionAudioPhysicalPlayingStatus = 0; - return; - } - } - if (bChannelOpen) DoPoliceRadioCrackle(); - if ((g_nMissionAudioSfx == TOTAL_AUDIO_SAMPLES || g_nMissionAudioPlayingStatus != 1) && - !SampleManager.GetChannelUsedFlag(policeChannel) && m_sPoliceRadioQueue.policeChannelTimer) { - if (m_sPoliceRadioQueue.policeChannelTimer) { - sample = m_sPoliceRadioQueue.crimesSamples[m_sPoliceRadioQueue.policeChannelCounterSeconds]; - m_sPoliceRadioQueue.policeChannelTimer--; - m_sPoliceRadioQueue.policeChannelCounterSeconds = (m_sPoliceRadioQueue.policeChannelCounterSeconds + 1) % 60; - } else { - sample = TOTAL_AUDIO_SAMPLES; - } - if (wantedLevel == 0) { - if (gSpecialSuspectLastSeenReport) { - gSpecialSuspectLastSeenReport = 0; - } else if (((sample >= SFX_POLICE_RADIO_MESSAGE_NOISE_1) && (sample <= SFX_POLICE_RADIO_MESSAGE_NOISE_3)) || sample == TOTAL_AUDIO_SAMPLES) { - bChannelOpen = false; - processed = true; - } - } - if (sample == TOTAL_AUDIO_SAMPLES) { - if (!processed) cWait = 30; - } else { - SampleManager.InitialiseChannel(policeChannel, sample, 0); - switch (sample) { - case SFX_POLICE_RADIO_MESSAGE_NOISE_1: - case SFX_POLICE_RADIO_MESSAGE_NOISE_2: - case SFX_POLICE_RADIO_MESSAGE_NOISE_3: - freq = m_anRandomTable[4] % 2000 + 10025; - bChannelOpen = bChannelOpen == false; - break; - default: freq = SampleManager.GetSampleBaseFrequency(sample); break; - } - PoliceChannelFreq = freq; - SampleManager.SetChannelFrequency(policeChannel, freq); - SampleManager.SetChannelVolume(policeChannel, 100); - SampleManager.SetChannelPan(policeChannel, 63); - SampleManager.SetChannelLoopCount(policeChannel, 1); - SampleManager.SetChannelLoopPoints(policeChannel, 0, -1); - SampleManager.StartChannel(policeChannel); - } - if (processed) ResetPoliceRadio(); - } - } -} - -bool -cAudioManager::SetupCrimeReport() -{ - int16 audioZoneId; - CZone *zone; - float rangeX; - float rangeY; - float halfX; - float halfY; - float quarterX; - float quarterY; - int i; - int32 sampleIndex; - bool processed = false; - - if (MusicManager.m_nMusicMode == MUSICMODE_CUTSCENE) return false; - - if (60 - m_sPoliceRadioQueue.policeChannelTimer <= 9) { - AgeCrimes(); - return true; - } - - for (i = 0; i < ARRAY_SIZE(m_sPoliceRadioQueue.crimes); i++) { - if (m_sPoliceRadioQueue.crimes[i].type != CRIME_NONE) - break; - } - - if (i == ARRAY_SIZE(m_sPoliceRadioQueue.crimes)) return false; - audioZoneId = CTheZones::FindAudioZone(&m_sPoliceRadioQueue.crimes[i].position); - if (audioZoneId >= 0 && audioZoneId < NUMAUDIOZONES) { - zone = CTheZones::GetAudioZone(audioZoneId); - for (int j = 0; j < NUMAUDIOZONES; j++) { - if (strcmp(zone->name, ZoneSfx[j].m_aName) == 0) { - sampleIndex = ZoneSfx[j].m_nSampleIndex; - m_sPoliceRadioQueue.Add(m_anRandomTable[4] % 3 + SFX_POLICE_RADIO_MESSAGE_NOISE_1); - m_sPoliceRadioQueue.Add(m_anRandomTable[0] % 3 + SFX_WEVE_GOT); - m_sPoliceRadioQueue.Add(m_anRandomTable[1] % 2 + SFX_A_10_1); - switch (m_sPoliceRadioQueue.crimes[i].type) { - case CRIME_PED_BURNED: m_sPoliceRadioQueue.crimes[i].type = CRIME_HIT_PED; break; - case CRIME_COP_BURNED: m_sPoliceRadioQueue.crimes[i].type = CRIME_HIT_COP; break; - case CRIME_VEHICLE_BURNED: m_sPoliceRadioQueue.crimes[i].type = CRIME_STEAL_CAR; break; - case CRIME_DESTROYED_CESSNA: m_sPoliceRadioQueue.crimes[i].type = CRIME_SHOOT_HELI; break; - default: break; - } - m_sPoliceRadioQueue.Add(m_sPoliceRadioQueue.crimes[i].type + SFX_CRIME_1 - 1); - m_sPoliceRadioQueue.Add(SFX_IN); - if (sampleIndex == SFX_POLICE_RADIO_SHORESIDE_VALE && - (strcmp(zone->name, SubZo2Label) == 0 || strcmp(zone->name, SubZo3Label) == 0)) { - m_sPoliceRadioQueue.Add(SFX_NORTH); - m_sPoliceRadioQueue.Add(SFX_EAST); - } else { - rangeX = zone->maxx - zone->minx; - rangeY = zone->maxy - zone->miny; - halfX = 0.5f * rangeX + zone->minx; - halfY = 0.5f * rangeY + zone->miny; - quarterX = 0.25f * rangeX; - quarterY = 0.25f * rangeY; - - if (m_sPoliceRadioQueue.crimes[i].position.y > halfY + quarterY) { - m_sPoliceRadioQueue.Add(SFX_NORTH); - processed = true; - } else if (m_sPoliceRadioQueue.crimes[i].position.y < halfY - quarterY) { - m_sPoliceRadioQueue.Add(SFX_SOUTH); - processed = true; - } - - if (m_sPoliceRadioQueue.crimes[i].position.x > halfX + quarterX) - m_sPoliceRadioQueue.Add(SFX_EAST); - else if (m_sPoliceRadioQueue.crimes[i].position.x < halfX - quarterX) - m_sPoliceRadioQueue.Add(SFX_WEST); - else if (!processed) - m_sPoliceRadioQueue.Add(SFX_CENTRAL); - - m_sPoliceRadioQueue.Add(sampleIndex); - m_sPoliceRadioQueue.Add(m_anRandomTable[2] % 3 + SFX_POLICE_RADIO_MESSAGE_NOISE_1); - m_sPoliceRadioQueue.Add(TOTAL_AUDIO_SAMPLES); - } - break; - } - } - } - m_sPoliceRadioQueue.crimes[i].type = CRIME_NONE; - AgeCrimes(); - return true; -} - -void -cAudioManager::SetupSuspectLastSeenReport() -{ - CVehicle *veh; - uint8 color1; - int32 main_color; - int32 sample; - - int32 color_pre_modifier; - int32 color_post_modifier; - - const int32 gCarColourTable[][3] = { - {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_BLACK, TOTAL_AUDIO_SAMPLES}, - {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_WHITE, TOTAL_AUDIO_SAMPLES}, - {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_BLUE, TOTAL_AUDIO_SAMPLES}, - {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_RED, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_DARK, SFX_POLICE_RADIO_BLUE, TOTAL_AUDIO_SAMPLES}, - {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_PURPLE, TOTAL_AUDIO_SAMPLES}, - {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_YELLOW, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_BRIGHT, SFX_POLICE_RADIO_BLUE, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_LIGHT, SFX_POLICE_RADIO_BLUE, SFX_POLICE_RADIO_GREY}, -#ifdef FIX_BUGS - {SFX_POLICE_RADIO_LIGHT, SFX_POLICE_RADIO_RED, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_DARK, SFX_POLICE_RADIO_RED, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_DARK, SFX_POLICE_RADIO_RED, TOTAL_AUDIO_SAMPLES}, -#else - {SFX_POLICE_RADIO_LIGHT, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, -#endif - {SFX_POLICE_RADIO_DARK, SFX_POLICE_RADIO_RED, TOTAL_AUDIO_SAMPLES}, - {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_RED, TOTAL_AUDIO_SAMPLES}, - {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_RED, TOTAL_AUDIO_SAMPLES}, - {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_RED, TOTAL_AUDIO_SAMPLES}, - {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_RED, TOTAL_AUDIO_SAMPLES}, - {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_RED, TOTAL_AUDIO_SAMPLES}, - {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_RED, TOTAL_AUDIO_SAMPLES}, -#ifdef FIX_BUGS - {SFX_POLICE_RADIO_LIGHT, SFX_POLICE_RADIO_RED, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_DARK, SFX_POLICE_RADIO_ORANGE, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_DARK, SFX_POLICE_RADIO_ORANGE, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_DARK, SFX_POLICE_RADIO_ORANGE, TOTAL_AUDIO_SAMPLES}, -#else - {SFX_POLICE_RADIO_LIGHT, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, -#endif - {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_ORANGE, TOTAL_AUDIO_SAMPLES}, - {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_ORANGE, TOTAL_AUDIO_SAMPLES}, - {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_ORANGE, TOTAL_AUDIO_SAMPLES}, - {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_ORANGE, TOTAL_AUDIO_SAMPLES}, - {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_ORANGE, TOTAL_AUDIO_SAMPLES}, - {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_ORANGE, TOTAL_AUDIO_SAMPLES}, -#ifdef FIX_BUGS - {SFX_POLICE_RADIO_LIGHT, SFX_POLICE_RADIO_ORANGE, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_DARK, SFX_POLICE_RADIO_YELLOW, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_DARK, SFX_POLICE_RADIO_YELLOW, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_DARK, SFX_POLICE_RADIO_YELLOW, TOTAL_AUDIO_SAMPLES}, -#else - {SFX_POLICE_RADIO_LIGHT, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, -#endif - {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_YELLOW, TOTAL_AUDIO_SAMPLES}, - {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_YELLOW, TOTAL_AUDIO_SAMPLES}, - {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_YELLOW, TOTAL_AUDIO_SAMPLES}, - {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_YELLOW, TOTAL_AUDIO_SAMPLES}, - {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_YELLOW, TOTAL_AUDIO_SAMPLES}, - {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_YELLOW, TOTAL_AUDIO_SAMPLES}, -#ifdef FIX_BUGS - {SFX_POLICE_RADIO_LIGHT, SFX_POLICE_RADIO_YELLOW, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_DARK, SFX_POLICE_RADIO_GREEN, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_DARK, SFX_POLICE_RADIO_GREEN, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_DARK, SFX_POLICE_RADIO_GREEN, TOTAL_AUDIO_SAMPLES}, -#else - {SFX_POLICE_RADIO_LIGHT, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, -#endif - {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_GREEN, TOTAL_AUDIO_SAMPLES}, - {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_GREEN, TOTAL_AUDIO_SAMPLES}, - {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_GREEN, TOTAL_AUDIO_SAMPLES}, - {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_GREEN, TOTAL_AUDIO_SAMPLES}, - {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_GREEN, TOTAL_AUDIO_SAMPLES}, - {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_GREEN, TOTAL_AUDIO_SAMPLES}, -#ifdef FIX_BUGS - {SFX_POLICE_RADIO_LIGHT, SFX_POLICE_RADIO_GREEN, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_DARK, SFX_POLICE_RADIO_BLUE, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_DARK, SFX_POLICE_RADIO_BLUE, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_DARK, SFX_POLICE_RADIO_BLUE, TOTAL_AUDIO_SAMPLES}, -#else - {SFX_POLICE_RADIO_LIGHT, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, -#endif - {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_BLUE, TOTAL_AUDIO_SAMPLES}, - {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_BLUE, TOTAL_AUDIO_SAMPLES}, - {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_BLUE, TOTAL_AUDIO_SAMPLES}, - {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_BLUE, TOTAL_AUDIO_SAMPLES}, - {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_BLUE, TOTAL_AUDIO_SAMPLES}, - {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_BLUE, TOTAL_AUDIO_SAMPLES}, -#ifdef FIX_BUGS - {SFX_POLICE_RADIO_LIGHT, SFX_POLICE_RADIO_BLUE, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_DARK, SFX_POLICE_RADIO_PURPLE, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_DARK, SFX_POLICE_RADIO_PURPLE, SFX_POLICE_RADIO_BLUE}, - {SFX_POLICE_RADIO_DARK, SFX_POLICE_RADIO_PURPLE, TOTAL_AUDIO_SAMPLES}, -#else - {SFX_POLICE_RADIO_LIGHT, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, -#endif - {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_PURPLE, TOTAL_AUDIO_SAMPLES}, - {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_PURPLE, TOTAL_AUDIO_SAMPLES}, -#ifdef FIX_BUGS - {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_PURPLE, SFX_POLICE_RADIO_GREY}, -#else - {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_PURPLE, TOTAL_AUDIO_SAMPLES}, -#endif - {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_PURPLE, TOTAL_AUDIO_SAMPLES}, - {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_PURPLE, TOTAL_AUDIO_SAMPLES}, - {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_PURPLE, TOTAL_AUDIO_SAMPLES}, -#ifdef FIX_BUGS - {SFX_POLICE_RADIO_LIGHT, SFX_POLICE_RADIO_PURPLE, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_DARK, SFX_POLICE_RADIO_SILVER, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_DARK, SFX_POLICE_RADIO_SILVER, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_DARK, SFX_POLICE_RADIO_SILVER, TOTAL_AUDIO_SAMPLES}, -#else - {SFX_POLICE_RADIO_LIGHT, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, -#endif - {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_SILVER, TOTAL_AUDIO_SAMPLES}, - {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_SILVER, TOTAL_AUDIO_SAMPLES}, - {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_SILVER, TOTAL_AUDIO_SAMPLES}, - {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_SILVER, TOTAL_AUDIO_SAMPLES}, - {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_SILVER, TOTAL_AUDIO_SAMPLES}, -#ifdef FIX_BUGS - {SFX_POLICE_RADIO_LIGHT, SFX_POLICE_RADIO_SILVER, TOTAL_AUDIO_SAMPLES}, -#else - {TOTAL_AUDIO_SAMPLES, SFX_POLICE_RADIO_SILVER, TOTAL_AUDIO_SAMPLES}, -#endif - {SFX_POLICE_RADIO_LIGHT, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_LIGHT, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_LIGHT, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_LIGHT, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_LIGHT, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_LIGHT, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_LIGHT, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_LIGHT, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_LIGHT, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_LIGHT, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_LIGHT, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES}, - {SFX_POLICE_RADIO_DARK, TOTAL_AUDIO_SAMPLES, TOTAL_AUDIO_SAMPLES} - }; - - if (MusicManager.m_nMusicMode != MUSICMODE_CUTSCENE) { - veh = FindPlayerVehicle(); - if (veh != nil) { - if (60 - m_sPoliceRadioQueue.policeChannelTimer > 9) { - color1 = veh->m_currentColour1; - if (color1 >= ARRAY_SIZE(gCarColourTable)) { - debug("\n *** UNKNOWN CAR COLOUR %d *** ", color1); - } else { - main_color = gCarColourTable[color1][1]; - color_pre_modifier = gCarColourTable[color1][0]; - color_post_modifier = gCarColourTable[color1][2]; - switch (veh->GetModelIndex()) { -#ifdef FIX_BUGS - case MI_COLUMB: - main_color = SFX_POLICE_RADIO_BLUE; - color_pre_modifier = color_post_modifier = TOTAL_AUDIO_SAMPLES; -#endif - case MI_LANDSTAL: - case MI_BLISTA: sample = SFX_POLICE_RADIO_CRUISER; break; -#ifdef FIX_BUGS - case MI_YARDIE: - color_pre_modifier = TOTAL_AUDIO_SAMPLES; - main_color = SFX_POLICE_RADIO_RED; - color_post_modifier = SFX_POLICE_RADIO_YELLOW; - sample = SFX_POLICE_RADIO_CONVERTIBLE; break; - case MI_DIABLOS: - main_color = SFX_POLICE_RADIO_BLACK; -#endif - case MI_IDAHO: - case MI_STALLION: sample = SFX_POLICE_RADIO_CONVERTIBLE; break; -#ifdef FIX_BUGS - case MI_YAKUZA: - color_pre_modifier = TOTAL_AUDIO_SAMPLES; - main_color = SFX_POLICE_RADIO_SILVER; - color_post_modifier = SFX_POLICE_RADIO_RED; -#endif - case MI_STINGER: - case MI_INFERNUS: - case MI_CHEETAH: - case MI_BANSHEE: sample = SFX_POLICE_RADIO_SPORTS_CAR; break; -#ifdef FIX_BUGS - case MI_MAFIA: - color_pre_modifier = color_post_modifier = TOTAL_AUDIO_SAMPLES; - main_color = SFX_POLICE_RADIO_GREY; - case MI_KURUMA: -#endif - case MI_PEREN: - case MI_SENTINEL: - case MI_FBICAR: sample = SFX_POLICE_RADIO_SALOON; break; - case MI_PATRIOT: - case MI_BOBCAT: sample = SFX_POLICE_RADIO_PICKUP; break; - case MI_FIRETRUCK: sample = SFX_POLICE_RADIO_FIRE_TRUCK; break; -#ifdef FIX_BUGS - case MI_LINERUN: - case MI_FLATBED: -#endif - case MI_TRASH: - case MI_BARRACKS: sample = SFX_POLICE_RADIO_TRUCK; break; - case MI_STRETCH: sample = SFX_POLICE_RADIO_LIMO; break; -#ifdef FIX_BUGS - case MI_CORPSE: -#endif - case MI_MANANA: - case MI_ESPERANT: sample = SFX_POLICE_RADIO_2_DOOR; break; -#ifdef FIX_BUGS - case MI_HOODS: - color_pre_modifier = TOTAL_AUDIO_SAMPLES; - main_color = SFX_POLICE_RADIO_BLUE; - color_post_modifier = SFX_POLICE_RADIO_GREEN; - case MI_BELLYUP: - case MI_YANKEE: - case MI_TOYZ: - case MI_MRWONGS: - case MI_PANLANT: -#endif - case MI_PONY: - case MI_MULE: - case MI_MOONBEAM: - case MI_ENFORCER: - case MI_SECURICA: - case MI_RUMPO: sample = SFX_POLICE_RADIO_VAN; break; - case MI_AMBULAN: sample = SFX_POLICE_RADIO_AMBULANCE; break; - case MI_TAXI: - case MI_CABBIE: - case MI_BORGNINE: sample = SFX_POLICE_RADIO_TAXI; break; - case MI_MRWHOOP: - sample = SFX_POLICE_RADIO_ICE_CREAM_VAN; - break; - case MI_BFINJECT: sample = SFX_POLICE_RADIO_BUGGY; break; - case MI_POLICE: sample = SFX_POLICE_RADIO_POLICE_CAR; break; -#ifdef FIX_BUGS - case MI_SPEEDER: - case MI_REEFER: - case MI_GHOST: -#endif - case MI_PREDATOR: sample = SFX_POLICE_RADIO_BOAT; break; - case MI_BUS: - case MI_COACH: sample = SFX_POLICE_RADIO_BUS; break; - case MI_RHINO: - sample = SFX_POLICE_RADIO_TANK; - main_color = TOTAL_AUDIO_SAMPLES; - color_post_modifier = TOTAL_AUDIO_SAMPLES; - break; - case MI_TRAIN: - sample = SFX_POLICE_RADIO_SUBWAY_CAR; - main_color = TOTAL_AUDIO_SAMPLES; - color_post_modifier = TOTAL_AUDIO_SAMPLES; - - break; - default: - debug("\n *** UNKNOWN CAR MODEL INDEX %d *** ", veh->GetModelIndex()); - return; - } - m_sPoliceRadioQueue.Add(m_anRandomTable[4] % 3 + SFX_POLICE_RADIO_MESSAGE_NOISE_1); - m_sPoliceRadioQueue.Add(SFX_POLICE_RADIO_SUSPECT); - if (m_anRandomTable[3] % 2) - m_sPoliceRadioQueue.Add(SFX_POLICE_RADIO_LAST_SEEN); -#ifdef FIX_BUGS - if (main_color == SFX_POLICE_RADIO_ORANGE && color_pre_modifier == TOTAL_AUDIO_SAMPLES) -#else - if (main_color == SFX_POLICE_RADIO_ORANGE) -#endif - m_sPoliceRadioQueue.Add(SFX_POLICE_RADIO_IN_AN); - else - m_sPoliceRadioQueue.Add(SFX_POLICE_RADIO_IN_A); - if (color_pre_modifier != TOTAL_AUDIO_SAMPLES) - m_sPoliceRadioQueue.Add(color_pre_modifier); - if (main_color != TOTAL_AUDIO_SAMPLES) - m_sPoliceRadioQueue.Add(main_color); - if (color_post_modifier != TOTAL_AUDIO_SAMPLES) - m_sPoliceRadioQueue.Add(color_post_modifier); - m_sPoliceRadioQueue.Add(sample); - m_sPoliceRadioQueue.Add(m_anRandomTable[0] % 3 + SFX_POLICE_RADIO_MESSAGE_NOISE_1); - m_sPoliceRadioQueue.Add(TOTAL_AUDIO_SAMPLES); - } - } - } else if (60 - m_sPoliceRadioQueue.policeChannelTimer > 4) { - m_sPoliceRadioQueue.Add(SFX_POLICE_RADIO_MESSAGE_NOISE_1); - m_sPoliceRadioQueue.Add(SFX_POLICE_RADIO_SUSPECT); - m_sPoliceRadioQueue.Add(SFX_POLICE_RADIO_ON_FOOT); - m_sPoliceRadioQueue.Add(m_anRandomTable[0] % 3 + SFX_POLICE_RADIO_MESSAGE_NOISE_1); - m_sPoliceRadioQueue.Add(TOTAL_AUDIO_SAMPLES); - } - } -} - - - -void -cAudioManager::ReportCrime(eCrimeType type, const CVector &pos) -{ - int32 lastCrime = ARRAY_SIZE(m_sPoliceRadioQueue.crimes); - if (m_bIsInitialised && MusicManager.m_nMusicMode != MUSICMODE_CUTSCENE && FindPlayerPed()->m_pWanted->GetWantedLevel() > 0 && - (type > CRIME_NONE || type < NUM_CRIME_TYPES) && m_FrameCounter >= gMinTimeToNextReport[type]) { - for (int32 i = 0; i < ARRAY_SIZE(m_sPoliceRadioQueue.crimes); i++) { - if (m_sPoliceRadioQueue.crimes[i].type) { - if (m_sPoliceRadioQueue.crimes[i].type == type) { - m_sPoliceRadioQueue.crimes[i].position = pos; - m_sPoliceRadioQueue.crimes[i].timer = 0; - return; - } - } else { - lastCrime = i; - } - } - - if (lastCrime < ARRAY_SIZE(m_sPoliceRadioQueue.crimes)) { - m_sPoliceRadioQueue.crimes[lastCrime].type = type; - m_sPoliceRadioQueue.crimes[lastCrime].position = pos; - m_sPoliceRadioQueue.crimes[lastCrime].timer = 0; - gMinTimeToNextReport[type] = m_FrameCounter + 500; - } - } -} - -void -cAudioManager::PlaySuspectLastSeen(float x, float y, float z) -{ - int16 audioZone; - CZone *zone; - float rangeX; - float rangeY; - float halfX; - float halfY; - float quarterX; - float quarterY; - int32 sample; - bool processed = false; - CVector vec = CVector(x, y, z); - - if (!m_bIsInitialised) return; - - if (MusicManager.m_nMusicMode != MUSICMODE_CUTSCENE && 60 - m_sPoliceRadioQueue.policeChannelTimer > 9) { - audioZone = CTheZones::FindAudioZone(&vec); - if (audioZone >= 0 && audioZone < NUMAUDIOZONES) { - zone = CTheZones::GetAudioZone(audioZone); - for (int i = 0; i < NUMAUDIOZONES; i++) { - if (strcmp(zone->name, ZoneSfx[i].m_aName) == 0) { - sample = ZoneSfx[i].m_nSampleIndex; - m_sPoliceRadioQueue.Add(m_anRandomTable[4] % 3 + SFX_POLICE_RADIO_MESSAGE_NOISE_1); - m_sPoliceRadioQueue.Add(SFX_POLICE_RADIO_SUSPECT); - m_sPoliceRadioQueue.Add(SFX_POLICE_RADIO_LAST_SEEN); - m_sPoliceRadioQueue.Add(SFX_IN); - if (sample == SFX_POLICE_RADIO_SHORESIDE_VALE && - (strcmp(zone->name, SubZo2Label) == 0 || - strcmp(zone->name, SubZo3Label) == 0)) { - m_sPoliceRadioQueue.Add(SFX_NORTH); - m_sPoliceRadioQueue.Add(SFX_EAST); - } else { - rangeX = zone->maxx - zone->minx; - rangeY = zone->maxy - zone->miny; - halfX = 0.5f * rangeX + zone->minx; - halfY = 0.5f * rangeY + zone->miny; - quarterX = 0.25f * rangeX; - quarterY = 0.25f * rangeY; - - if (vec.y > halfY + quarterY) { - m_sPoliceRadioQueue.Add(SFX_NORTH); - processed = true; - } else if (vec.y < halfY - quarterY) { - m_sPoliceRadioQueue.Add(SFX_SOUTH); - processed = true; - } - - if (vec.x > halfX + quarterX) - m_sPoliceRadioQueue.Add(SFX_EAST); - else if (vec.x < halfX - quarterX) - m_sPoliceRadioQueue.Add(SFX_WEST); - else if (!processed) - m_sPoliceRadioQueue.Add(SFX_CENTRAL); - } - m_sPoliceRadioQueue.Add(sample); - m_sPoliceRadioQueue.Add(m_anRandomTable[2] % 3 + SFX_POLICE_RADIO_MESSAGE_NOISE_1); - m_sPoliceRadioQueue.Add(TOTAL_AUDIO_SAMPLES); - gSpecialSuspectLastSeenReport = true; - break; - } - } - } - } -} - -void -cAudioManager::AgeCrimes() -{ - for (uint8 i = 0; i < ARRAY_SIZE(m_sPoliceRadioQueue.crimes); i++) { - if (m_sPoliceRadioQueue.crimes[i].type != CRIME_NONE) { - if (++m_sPoliceRadioQueue.crimes[i].timer > 1500) m_sPoliceRadioQueue.crimes[i].type = CRIME_NONE; - } - } -} diff --git a/src/audio/PoliceRadio.h b/src/audio/PoliceRadio.h deleted file mode 100644 index 368708b6..00000000 --- a/src/audio/PoliceRadio.h +++ /dev/null @@ -1,46 +0,0 @@ -#pragma once - -#include "Crime.h" - -struct cAMCrime { - int32 type; - CVector position; - uint16 timer; - - cAMCrime() - { - type = CRIME_NONE; - position = CVector(0.0f, 0.0f, 0.0f); - timer = 0; - } -}; - -VALIDATE_SIZE(cAMCrime, 20); - -class cPoliceRadioQueue -{ -public: - int32 crimesSamples[60]; - uint8 policeChannelTimer; - uint8 policeChannelTimerSeconds; - uint8 policeChannelCounterSeconds; - cAMCrime crimes[10]; - - cPoliceRadioQueue() - { - policeChannelTimerSeconds = 0; - policeChannelCounterSeconds = 0; - policeChannelTimer = 0; - } - - void Add(uint32 sample) - { - if (policeChannelTimer != 60) { - crimesSamples[policeChannelTimerSeconds] = sample; - policeChannelTimer++; - policeChannelTimerSeconds = (policeChannelTimerSeconds + 1) % 60; - } - } -}; - -VALIDATE_SIZE(cPoliceRadioQueue, 444); -- cgit v1.2.3 From 5bdbb5f802d8a6b5fdf9d23d1879b95c899a3df4 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Fri, 26 Feb 2021 11:05:37 +0200 Subject: Uhh, right --- src/audio/AudioManager.h | 2 +- src/audio/PolRadio.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/audio') diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index 2f86ee98..57fbc818 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -2,7 +2,7 @@ #include "audio_enums.h" #include "AudioCollision.h" -#include "PoliceRadio.h" +#include "PolRadio.h" class tSound { diff --git a/src/audio/PolRadio.cpp b/src/audio/PolRadio.cpp index 785dbf8f..cb12a2fe 100644 --- a/src/audio/PolRadio.cpp +++ b/src/audio/PolRadio.cpp @@ -7,7 +7,7 @@ #include "AudioSamples.h" #include "MusicManager.h" #include "PlayerPed.h" -#include "PoliceRadio.h" +#include "PolRadio.h" #include "Replay.h" #include "Vehicle.h" #include "World.h" -- cgit v1.2.3 From 4a9d890ae9e54a3f4c6b7420ee140fbfecb8a435 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Mon, 17 May 2021 17:45:56 +0300 Subject: Fix quiet police scanner on OpenAL --- src/audio/oal/channel.cpp | 19 ++++++++++++++++++- src/audio/oal/channel.h | 1 + 2 files changed, 19 insertions(+), 1 deletion(-) (limited to 'src/audio') diff --git a/src/audio/oal/channel.cpp b/src/audio/oal/channel.cpp index d1fd0aea..1bb4c4a8 100644 --- a/src/audio/oal/channel.cpp +++ b/src/audio/oal/channel.cpp @@ -17,6 +17,8 @@ bool bChannelsCreated = false; int32 CChannel::channelsThatNeedService = 0; +uint8 tempStereoBuffer[PED_BLOCKSIZE * 2]; + void CChannel::InitChannels() { @@ -50,6 +52,7 @@ CChannel::CChannel() { Data = nil; DataSize = 0; + bIs2D = false; SetDefault(); } @@ -90,6 +93,7 @@ void CChannel::Init(uint32 _id, bool Is2D) if ( Is2D ) { + bIs2D = true; alSource3f(alSources[id], AL_POSITION, 0.0f, 0.0f, 0.0f); alSourcef(alSources[id], AL_GAIN, 1.0f); } @@ -113,7 +117,20 @@ void CChannel::Start() if ( !HasSource() ) return; if ( !Data ) return; - alBufferData(alBuffers[id], AL_FORMAT_MONO16, Data, DataSize, Frequency); + if ( bIs2D ) + { + // convert mono data to stereo + int16 *monoData = (int16*)Data; + int16 *stereoData = (int16*)tempStereoBuffer; + for (size_t i = 0; i < DataSize / 2; i++) + { + *(stereoData++) = *monoData; + *(stereoData++) = *(monoData++); + } + alBufferData(alBuffers[id], AL_FORMAT_STEREO16, tempStereoBuffer, DataSize * 2, Frequency); + } + else + alBufferData(alBuffers[id], AL_FORMAT_MONO16, Data, DataSize, Frequency); if ( LoopPoints[0] != 0 && LoopPoints[0] != -1 ) alBufferiv(alBuffers[id], AL_LOOP_POINTS_SOFT, LoopPoints); alSourcei(alSources[id], AL_BUFFER, alBuffers[id]); diff --git a/src/audio/oal/channel.h b/src/audio/oal/channel.h index b081be25..872646c8 100644 --- a/src/audio/oal/channel.h +++ b/src/audio/oal/channel.h @@ -20,6 +20,7 @@ class CChannel int32 LoopCount; ALint LoopPoints[2]; ALint LastProcessedOffset; + bool bIs2D; public: static int32 channelsThatNeedService; -- cgit v1.2.3 From 786e101acff29e07503a4d3c294b613d4a2714b3 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 22 May 2021 12:11:50 +0300 Subject: Use bool8 in audio code --- src/audio/AudioCollision.cpp | 26 +- src/audio/AudioLogic.cpp | 1144 +++++++++++++++++++++--------------------- src/audio/AudioManager.cpp | 98 ++-- src/audio/AudioManager.h | 104 ++-- src/audio/DMAudio.cpp | 20 +- src/audio/DMAudio.h | 16 +- src/audio/MusicManager.cpp | 204 ++++---- src/audio/MusicManager.h | 42 +- src/audio/PolRadio.cpp | 56 +-- src/audio/sampman.h | 44 +- src/audio/sampman_miles.cpp | 282 +++++------ src/audio/sampman_null.cpp | 56 +-- src/audio/sampman_oal.cpp | 208 ++++---- 13 files changed, 1150 insertions(+), 1150 deletions(-) (limited to 'src/audio') diff --git a/src/audio/AudioCollision.cpp b/src/audio/AudioCollision.cpp index 6ce7bbac..0f96cec4 100644 --- a/src/audio/AudioCollision.cpp +++ b/src/audio/AudioCollision.cpp @@ -166,7 +166,7 @@ cAudioManager::SetUpLoopingCollisionSound(const cAudioCollision &col, uint8 coun m_sQueueSample.m_nCounter = counter; m_sQueueSample.m_vecPos = col.m_vecPosition; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nReleasingVolumeModificator = 7; m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nEmittingVolume = emittingVol; @@ -176,10 +176,10 @@ cAudioManager::SetUpLoopingCollisionSound(const cAudioCollision &col, uint8 coun SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 4.0f; m_sQueueSample.m_fSoundIntensity = CollisionSoundIntensity; - m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 5; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); } } @@ -307,7 +307,7 @@ cAudioManager::SetUpOneShotCollisionSound(const cAudioCollision &col) if(counter >= 255) counter = 28; m_sQueueSample.m_vecPos = col.m_vecPosition; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nReleasingVolumeModificator = 11; m_sQueueSample.m_nLoopCount = 1; m_sQueueSample.m_nEmittingVolume = emittingVol; @@ -315,9 +315,9 @@ cAudioManager::SetUpOneShotCollisionSound(const cAudioCollision &col) m_sQueueSample.m_nLoopEnd = -1; m_sQueueSample.m_fSpeedMultiplier = 4.0f; m_sQueueSample.m_fSoundIntensity = CollisionSoundIntensity; - m_sQueueSample.m_bReleasingSoundFlag = true; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReleasingSoundFlag = TRUE; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); } } @@ -328,13 +328,13 @@ void cAudioManager::ServiceCollisions() { int i, j; - bool abRepeatedCollision1[NUMAUDIOCOLLISIONS]; - bool abRepeatedCollision2[NUMAUDIOCOLLISIONS]; + bool8 abRepeatedCollision1[NUMAUDIOCOLLISIONS]; + bool8 abRepeatedCollision2[NUMAUDIOCOLLISIONS]; m_sQueueSample.m_nEntityIndex = m_nCollisionEntity; for (int i = 0; i < NUMAUDIOCOLLISIONS; i++) - abRepeatedCollision1[i] = abRepeatedCollision2[i] = false; + abRepeatedCollision1[i] = abRepeatedCollision2[i] = FALSE; for (i = 0; i < m_sCollisionManager.m_bCollisionsInQueue; i++) { for (j = 0; j < NUMAUDIOCOLLISIONS; j++) { @@ -344,8 +344,8 @@ cAudioManager::ServiceCollisions() && (m_sCollisionManager.m_asCollisions1[index].m_bSurface1 == m_sCollisionManager.m_asCollisions2[j].m_bSurface1) && (m_sCollisionManager.m_asCollisions1[index].m_bSurface2 == m_sCollisionManager.m_asCollisions2[j].m_bSurface2) ) { - abRepeatedCollision1[index] = true; - abRepeatedCollision2[j] = true; + abRepeatedCollision1[index] = TRUE; + abRepeatedCollision2[j] = TRUE; m_sCollisionManager.m_asCollisions1[index].m_nBaseVolume = ++m_sCollisionManager.m_asCollisions2[j].m_nBaseVolume; SetUpLoopingCollisionSound(m_sCollisionManager.m_asCollisions1[index], j); break; diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index ec364c27..2f173d5e 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -128,38 +128,38 @@ cAudioManager::PostInitialiseGameSpecificSetup() { m_nFireAudioEntity = CreateEntity(AUDIOTYPE_FIRE, &gFireManager); if (m_nFireAudioEntity >= 0) - SetEntityStatus(m_nFireAudioEntity, true); + SetEntityStatus(m_nFireAudioEntity, TRUE); m_nCollisionEntity = CreateEntity(AUDIOTYPE_COLLISION, (void *)1); if (m_nCollisionEntity >= 0) - SetEntityStatus(m_nCollisionEntity, true); + SetEntityStatus(m_nCollisionEntity, TRUE); m_nFrontEndEntity = CreateEntity(AUDIOTYPE_FRONTEND, (void *)1); if (m_nFrontEndEntity >= 0) - SetEntityStatus(m_nFrontEndEntity, true); + SetEntityStatus(m_nFrontEndEntity, TRUE); m_nProjectileEntity = CreateEntity(AUDIOTYPE_PROJECTILE, (void *)1); if (m_nProjectileEntity >= 0) - SetEntityStatus(m_nProjectileEntity, true); + SetEntityStatus(m_nProjectileEntity, TRUE); m_nWaterCannonEntity = CreateEntity(AUDIOTYPE_WATERCANNON, (void *)1); if (m_nWaterCannonEntity >= 0) - SetEntityStatus(m_nWaterCannonEntity, true); + SetEntityStatus(m_nWaterCannonEntity, TRUE); m_nPoliceChannelEntity = CreateEntity(AUDIOTYPE_POLICERADIO, (void *)1); if (m_nPoliceChannelEntity >= 0) - SetEntityStatus(m_nPoliceChannelEntity, true); + SetEntityStatus(m_nPoliceChannelEntity, TRUE); m_nBridgeEntity = CreateEntity(AUDIOTYPE_BRIDGE, (void *)1); if (m_nBridgeEntity >= 0) - SetEntityStatus(m_nBridgeEntity, true); + SetEntityStatus(m_nBridgeEntity, TRUE); m_sMissionAudio.m_nSampleIndex = NO_SAMPLE; m_sMissionAudio.m_nLoadingStatus = LOADING_STATUS_NOT_LOADED; m_sMissionAudio.m_nPlayStatus = PLAY_STATUS_STOPPED; - m_sMissionAudio.m_bIsPlaying = false; - m_sMissionAudio.m_bIsPlayed = false; - m_sMissionAudio.m_bPredefinedProperties = true; + m_sMissionAudio.m_bIsPlaying = FALSE; + m_sMissionAudio.m_bIsPlayed = FALSE; + m_sMissionAudio.m_bPredefinedProperties = TRUE; m_sMissionAudio.m_nMissionAudioCounter = 0; ResetAudioLogicTimers(CTimer::GetTimeInMilliseconds()); } @@ -240,7 +240,7 @@ cAudioManager::ProcessReverb() const ; i++) { if (m_asActiveSamples[i].m_bReverbFlag) - SampleManager.SetChannelReverbFlag(i, true); + SampleManager.SetChannelReverbFlag(i, TRUE); } } } @@ -253,11 +253,11 @@ cAudioManager::GetDistanceSquared(const CVector &v) const } void -cAudioManager::CalculateDistance(bool &distCalculated, float dist) +cAudioManager::CalculateDistance(bool8 &distCalculated, float dist) { if (!distCalculated) { m_sQueueSample.m_fDistance = Sqrt(dist); - distCalculated = true; + distCalculated = TRUE; } } @@ -291,53 +291,53 @@ cAudioManager::ProcessEntity(int32 id) switch (m_asAudioEntities[id].m_nType) { case AUDIOTYPE_PHYSICAL: if (!m_nUserPause) { - m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bReverbFlag = TRUE; ProcessPhysical(id); } break; case AUDIOTYPE_EXPLOSION: if (!m_nUserPause) { - m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bReverbFlag = TRUE; ProcessExplosions(id); } break; case AUDIOTYPE_FIRE: if (!m_nUserPause) { - m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bReverbFlag = TRUE; ProcessFires(id); } break; case AUDIOTYPE_WEATHER: if (!m_nUserPause) { - m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bReverbFlag = TRUE; ProcessWeather(id); } break; case AUDIOTYPE_CRANE: if (!m_nUserPause) { - m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bReverbFlag = TRUE; ProcessCrane(); } break; case AUDIOTYPE_SCRIPTOBJECT: if (!m_nUserPause) { - m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bReverbFlag = TRUE; ProcessScriptObject(id); } break; case AUDIOTYPE_BRIDGE: if (!m_nUserPause) { - m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bReverbFlag = TRUE; ProcessBridge(); } break; case AUDIOTYPE_FRONTEND: - m_sQueueSample.m_bReverbFlag = false; + m_sQueueSample.m_bReverbFlag = FALSE; ProcessFrontEnd(); break; case AUDIOTYPE_PROJECTILE: if (!m_nUserPause) { - m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bReverbFlag = TRUE; ProcessProjectiles(); } break; @@ -347,13 +347,13 @@ cAudioManager::ProcessEntity(int32 id) break; case AUDIOTYPE_FIREHYDRANT: if (!m_nUserPause) { - m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bReverbFlag = TRUE; ProcessFireHydrant(); } break; case AUDIOTYPE_WATERCANNON: if (!m_nUserPause) { - m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bReverbFlag = TRUE; ProcessWaterCannon(id); } break; @@ -548,25 +548,25 @@ const tVehicleSampleData aVehicleSettings[MAX_CARS] = { {SFX_CAR_REV_1, SFX_BANK_PACARD, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, OLD_DOOR}}; -bool bPlayerJustEnteredCar; - -const bool hornPatternsArray[8][44] = { - {false, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, false, false, false, false, - false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, false, false, false}, - {false, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, - true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, false}, - {false, false, true, true, true, true, true, true, true, true, true, true, false, false, false, false, true, true, true, true, true, false, - false, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false}, - {false, false, true, true, true, true, true, false, false, true, true, true, true, true, false, false, false, true, true, true, true, true, - true, true, true, true, true, false, false, false, true, true, true, true, true, true, true, true, true, true, true, true, true, false}, - {false, false, true, true, true, true, true, true, true, true, true, false, false, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}, - {false, false, true, true, true, false, false, false, true, true, true, false, false, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}, - {false, false, true, true, true, true, false, false, false, false, true, true, true, false, false, true, true, true, false, false, true, true, - true, true, true, true, false, false, false, false, false, true, true, true, true, true, true, true, true, true, true, true, false, false}, - {false, false, true, true, true, true, false, false, true, true, true, true, true, false, false, false, true, true, true, true, true, true, - false, false, false, false, true, true, true, true, true, true, true, true, true, true, true, true, true, false, false, false, false, false}, +bool8 bPlayerJustEnteredCar; + +const bool8 hornPatternsArray[8][44] = { + {FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, + FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE}, + {FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, + TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE}, + {FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, + FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE}, + {FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, + TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE}, + {FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, + FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE}, + {FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, + FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE}, + {FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, + TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE}, + {FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, + FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE}, }; @@ -578,7 +578,7 @@ cAudioManager::ProcessVehicle(CVehicle *veh) cVehicleParams params; m_sQueueSample.m_vecPos = veh->GetPosition(); - params.m_bDistanceCalculated = false; + params.m_bDistanceCalculated = FALSE; params.m_pVehicle = veh; params.m_fDistance = GetDistanceSquared(m_sQueueSample.m_vecPos); @@ -677,7 +677,7 @@ cAudioManager::ProcessRainOnVehicle(cVehicleParams& params) veh->m_bRainSamplesCounter = 68; m_sQueueSample.m_nSampleIndex = (m_anRandomTable[1] & 3) + SFX_CAR_RAIN_1; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nReleasingVolumeModificator = 9; m_sQueueSample.m_nFrequency = m_anRandomTable[1] % 4000 + 28000; m_sQueueSample.m_nLoopCount = 1; @@ -686,16 +686,16 @@ cAudioManager::ProcessRainOnVehicle(cVehicleParams& params) m_sQueueSample.m_nLoopEnd = -1; m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_fSoundIntensity = rainOnVehicleIntensity; - m_sQueueSample.m_bReleasingSoundFlag = true; - m_sQueueSample.m_bReverbFlag = false; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReleasingSoundFlag = TRUE; + m_sQueueSample.m_bReverbFlag = FALSE; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); } } } } -bool +bool8 cAudioManager::ProcessReverseGear(cVehicleParams& params) { const int reverseGearIntensity = 30; @@ -706,7 +706,7 @@ cAudioManager::ProcessReverseGear(cVehicleParams& params) float modificator; if (params.m_fDistance >= SQR(reverseGearIntensity)) - return false; + return FALSE; veh = params.m_pVehicle; if (veh->bEngineOn && (veh->m_fGasPedal < 0.0f || veh->m_nCurrentGear == 0)) { CalculateDistance(params.m_bDistanceCalculated, params.m_fDistance); @@ -730,7 +730,7 @@ cAudioManager::ProcessReverseGear(cVehicleParams& params) m_sQueueSample.m_nSampleIndex = SFX_REVERSE_GEAR; } m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_nFrequency = (6000.f * modificator) + 7000; m_sQueueSample.m_nLoopCount = 0; @@ -739,14 +739,14 @@ cAudioManager::ProcessReverseGear(cVehicleParams& params) m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 3.0f; m_sQueueSample.m_fSoundIntensity = reverseGearIntensity; - m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 5; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); } } - return true; + return TRUE; } void @@ -781,7 +781,7 @@ cAudioManager::ProcessModelCarEngine(cVehicleParams& params) m_sQueueSample.m_nCounter = 2; m_sQueueSample.m_nSampleIndex = SFX_REMOTE_CONTROLLED_CAR; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nFrequency = (11025.f * velocityChange / params.m_pTransmission->fMaxVelocity + 11025.f); m_sQueueSample.m_nLoopCount = 0; @@ -790,10 +790,10 @@ cAudioManager::ProcessModelCarEngine(cVehicleParams& params) m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 3.0f; m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; - m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 3; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); } } @@ -804,7 +804,7 @@ cAudioManager::ProcessModelCarEngine(cVehicleParams& params) -bool +bool8 cAudioManager::ProcessVehicleRoadNoise(cVehicleParams& params) { const float SOUND_INTENSITY = 95.0f; @@ -816,7 +816,7 @@ cAudioManager::ProcessVehicleRoadNoise(cVehicleParams& params) float velocity; if (params.m_fDistance >= SQR(SOUND_INTENSITY)) - return false; + return FALSE; if (params.m_pTransmission != nil) { if (((CAutomobile*)params.m_pVehicle)->m_nDriveWheelsOnGround != 0) { velocity = Abs(params.m_fVelocityChange); @@ -827,7 +827,7 @@ cAudioManager::ProcessVehicleRoadNoise(cVehicleParams& params) if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nReleasingVolumeModificator = 3; if (params.m_pVehicle->m_nSurfaceTouched == SURFACE_WATER) { m_sQueueSample.m_nSampleIndex = SFX_BOAT_WATER_LOOP; @@ -845,19 +845,19 @@ cAudioManager::ProcessVehicleRoadNoise(cVehicleParams& params) m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 6.0f; m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; - m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 4; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); } } } } - return true; + return TRUE; } -bool +bool8 cAudioManager::ProcessWetRoadNoise(cVehicleParams& params) { const float SOUND_INTENSITY = 30.0f; @@ -869,7 +869,7 @@ cAudioManager::ProcessWetRoadNoise(cVehicleParams& params) float velChange; if (params.m_fDistance >= SQR(SOUND_INTENSITY)) - return false; + return FALSE; if (params.m_pTransmission != nil) { if (((CAutomobile *)params.m_pVehicle)->m_nDriveWheelsOnGround != 0) { velChange = Abs(params.m_fVelocityChange); @@ -882,7 +882,7 @@ cAudioManager::ProcessWetRoadNoise(cVehicleParams& params) m_sQueueSample.m_nCounter = 1; m_sQueueSample.m_nSampleIndex = SFX_ROAD_NOISE; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nReleasingVolumeModificator = 3; #ifdef FIX_BUGS multiplier = (m_sQueueSample.m_fDistance / SOUND_INTENSITY) * 0.5f; @@ -897,16 +897,16 @@ cAudioManager::ProcessWetRoadNoise(cVehicleParams& params) m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 6.0f; m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; - m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 4; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); } } } } - return true; + return TRUE; } void @@ -1033,7 +1033,7 @@ cAudioManager::ProcessVehicleEngine(cVehicleParams& params) } } m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_nFrequency = freq + 100 * m_sQueueSample.m_nEntityIndex % 1000; if (m_sQueueSample.m_nSampleIndex == SFX_CAR_IDLE_6 || m_sQueueSample.m_nSampleIndex == SFX_CAR_REV_6) @@ -1044,10 +1044,10 @@ cAudioManager::ProcessVehicleEngine(cVehicleParams& params) m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 6.0f; m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; - m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 8; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); } } @@ -1070,7 +1070,7 @@ void cAudioManager::PlayerJustGotInCar() const { if (m_bIsInitialised) - bPlayerJustEnteredCar = true; + bPlayerJustEnteredCar = TRUE; } void @@ -1080,7 +1080,7 @@ cAudioManager::PlayerJustLeftCar(void) const } void -cAudioManager::AddPlayerCarSample(uint8 emittingVolume, int32 freq, uint32 sample, uint8 bank, uint8 counter, bool notLooping) +cAudioManager::AddPlayerCarSample(uint8 emittingVolume, int32 freq, uint32 sample, uint8 bank, uint8 counter, bool8 notLooping) { m_sQueueSample.m_nVolume = ComputeVolume(emittingVolume, 50.f, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { @@ -1091,7 +1091,7 @@ cAudioManager::AddPlayerCarSample(uint8 emittingVolume, int32 freq, uint32 sampl #else m_sQueueSample.m_nBankIndex = SFX_BANK_0; #endif // GTA_PS2 - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nReleasingVolumeModificator = 0; m_sQueueSample.m_nFrequency = freq; if (notLooping) { @@ -1105,9 +1105,9 @@ cAudioManager::AddPlayerCarSample(uint8 emittingVolume, int32 freq, uint32 sampl m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 6.0f; m_sQueueSample.m_fSoundIntensity = 50.0f; - m_sQueueSample.m_bReleasingSoundFlag = false; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReleasingSoundFlag = FALSE; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); } } @@ -1127,11 +1127,11 @@ cAudioManager::ProcessCesna(cVehicleParams& params) } else if (nAccel < 60) { ++nAccel; } - AddPlayerCarSample(85 * (60 - nAccel) / 60 + 20, 8500 * nAccel / 60 + 17000, SFX_CESNA_IDLE, SFX_BANK_0, 52, true); - AddPlayerCarSample(85 * nAccel / 60 + 20, 8500 * nAccel / 60 + 17000, SFX_CESNA_REV, SFX_BANK_0, 2, true); + AddPlayerCarSample(85 * (60 - nAccel) / 60 + 20, 8500 * nAccel / 60 + 17000, SFX_CESNA_IDLE, SFX_BANK_0, 52, TRUE); + AddPlayerCarSample(85 * nAccel / 60 + 20, 8500 * nAccel / 60 + 17000, SFX_CESNA_REV, SFX_BANK_0, 2, TRUE); } } else if (params.m_nIndex == DODO) { - AddPlayerCarSample(105, 17000, SFX_CESNA_IDLE, SFX_BANK_0, 52, true); + AddPlayerCarSample(105, 17000, SFX_CESNA_IDLE, SFX_BANK_0, 52, TRUE); } else if (params.m_fDistance < SQR(200)) { CalculateDistance(params.m_bDistanceCalculated, params.m_fDistance); m_sQueueSample.m_nVolume = ComputeVolume(80, 200.f, m_sQueueSample.m_fDistance); @@ -1139,7 +1139,7 @@ cAudioManager::ProcessCesna(cVehicleParams& params) m_sQueueSample.m_nCounter = 52; m_sQueueSample.m_nSampleIndex = SFX_CESNA_IDLE; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nReleasingVolumeModificator = 0; m_sQueueSample.m_nFrequency = 12500; m_sQueueSample.m_nLoopCount = 0; @@ -1149,9 +1149,9 @@ cAudioManager::ProcessCesna(cVehicleParams& params) m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 8.0f; m_sQueueSample.m_fSoundIntensity = 200.0f; - m_sQueueSample.m_bReleasingSoundFlag = false; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReleasingSoundFlag = FALSE; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); } if (params.m_fDistance < SQR(90)) { @@ -1160,7 +1160,7 @@ cAudioManager::ProcessCesna(cVehicleParams& params) m_sQueueSample.m_nCounter = 2; m_sQueueSample.m_nSampleIndex = SFX_CESNA_REV; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nReleasingVolumeModificator = 0; m_sQueueSample.m_nFrequency = 25000; m_sQueueSample.m_nLoopCount = 0; @@ -1170,9 +1170,9 @@ cAudioManager::ProcessCesna(cVehicleParams& params) m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 8.0f; m_sQueueSample.m_fSoundIntensity = 90.0f; - m_sQueueSample.m_bReleasingSoundFlag = false; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReleasingSoundFlag = FALSE; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); } } @@ -1199,9 +1199,9 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CAutomobile * int soundOffset; uint8 engineSoundType; int16 accelerateState; - bool channelUsed; - bool lostTraction; - bool processedAccelSampleStopped; + bool8 channelUsed; + bool8 lostTraction; + bool8 processedAccelSampleStopped; uint8 currentGear; float gasPedalAudio; CVector pos; @@ -1209,21 +1209,21 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CAutomobile * static int16 LastAccel = 0; static int16 LastBrake = 0; static uint8 CurrentPretendGear = 1; - static bool bLostTractionLastFrame = false; - static bool bHandbrakeOnLastFrame = false; + static bool8 bLostTractionLastFrame = FALSE; + static bool8 bHandbrakeOnLastFrame = FALSE; static int32 nCruising = 0; - static bool bAccelSampleStopped = true; + static bool8 bAccelSampleStopped = TRUE; - lostTraction = false; - processedAccelSampleStopped = false; + lostTraction = FALSE; + processedAccelSampleStopped = FALSE; if (bPlayerJustEnteredCar) { - bAccelSampleStopped = true; - bPlayerJustEnteredCar = false; + bAccelSampleStopped = TRUE; + bPlayerJustEnteredCar = FALSE; nCruising = 0; LastAccel = 0; - bLostTractionLastFrame = false; + bLostTractionLastFrame = FALSE; LastBrake = 0; - bHandbrakeOnLastFrame = false; + bHandbrakeOnLastFrame = FALSE; CurrentPretendGear = 1; } if (CReplay::IsPlayingBack()) @@ -1249,16 +1249,16 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CAutomobile * ++wheelInUseCounter; } if (wheelInUseCounter > 2) - lostTraction = true; + lostTraction = TRUE; break; case 'F': if ((automobile->m_aWheelState[CARWHEEL_FRONT_LEFT] != WHEEL_STATE_NORMAL || automobile->m_aWheelState[CARWHEEL_FRONT_RIGHT] != WHEEL_STATE_NORMAL) && (automobile->m_aWheelState[CARWHEEL_REAR_LEFT] != WHEEL_STATE_NORMAL || automobile->m_aWheelState[CARWHEEL_REAR_RIGHT] != WHEEL_STATE_NORMAL)) - lostTraction = true; + lostTraction = TRUE; break; case 'R': if ((automobile->m_aWheelState[CARWHEEL_REAR_LEFT] != WHEEL_STATE_NORMAL) || (automobile->m_aWheelState[CARWHEEL_REAR_RIGHT] != WHEEL_STATE_NORMAL)) - lostTraction = true; + lostTraction = TRUE; break; } @@ -1279,7 +1279,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CAutomobile * if (params.m_fVelocityChange < -0.001f) { if (channelUsed) { SampleManager.StopChannel(m_nActiveSamples); - bAccelSampleStopped = true; + bAccelSampleStopped = TRUE; } if (automobile->m_nWheelsOnGround == 0 || automobile->bIsHandbrakeOn || lostTraction) gasPedalAudio = automobile->m_fGasPedalAudio; @@ -1291,7 +1291,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CAutomobile * } else if (LastAccel > 0) { if (channelUsed) { SampleManager.StopChannel(m_nActiveSamples); - bAccelSampleStopped = true; + bAccelSampleStopped = TRUE; } nCruising = 0; if (automobile->m_nWheelsOnGround == 0 || automobile->bIsHandbrakeOn || lostTraction || @@ -1304,13 +1304,13 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CAutomobile * if (engineSoundType == SFX_BANK_TRUCK) freq /= 2; AddPlayerCarSample((25.f * (gasPedalAudio - 0.05f) * 20.f / 19) + 40, freq, (soundOffset + SFX_CAR_FINGER_OFF_ACCEL_1), engineSoundType, 63, - false); + FALSE); } } freq = (10000.f * gasPedalAudio) + 22050; if (engineSoundType == SFX_BANK_TRUCK) freq /= 2; - AddPlayerCarSample(110 - (40.f * gasPedalAudio), freq, (engineSoundType - CAR_SFX_BANKS_OFFSET + SFX_CAR_IDLE_1), SFX_BANK_0, 52, true); + AddPlayerCarSample(110 - (40.f * gasPedalAudio), freq, (engineSoundType - CAR_SFX_BANKS_OFFSET + SFX_CAR_IDLE_1), SFX_BANK_0, 52, TRUE); CurrentPretendGear = Max(1, currentGear); } else { @@ -1335,9 +1335,9 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CAutomobile * freq /= 2; if (channelUsed) { SampleManager.StopChannel(m_nActiveSamples); - 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); } else { TranslateEntity(&m_sQueueSample.m_vecPos, &pos); if (bAccelSampleStopped) { @@ -1347,8 +1347,8 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CAutomobile * gearNr = 1; CurrentPretendGear = gearNr; } - processedAccelSampleStopped = true; - bAccelSampleStopped = false; + processedAccelSampleStopped = TRUE; + bAccelSampleStopped = FALSE; } if (!channelUsed) { @@ -1375,14 +1375,14 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CAutomobile * freq /= 2; SampleManager.SetChannelFrequency(m_nActiveSamples, freq); if (!channelUsed) { - SampleManager.SetChannelReverbFlag(m_nActiveSamples, m_bDynamicAcousticModelingStatus != false); + SampleManager.SetChannelReverbFlag(m_nActiveSamples, m_bDynamicAcousticModelingStatus != FALSE); SampleManager.StartChannel(m_nActiveSamples); } } break; } if (nCruising != 0) { - bAccelSampleStopped = true; + bAccelSampleStopped = TRUE; if (accelerateState < 150 || automobile->m_nWheelsOnGround == 0 || automobile->bIsHandbrakeOn || lostTraction || currentGear < params.m_pTransmission->nNumberOfGears - 1) { nCruising = 0; @@ -1396,7 +1396,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CAutomobile * freq = 27 * nCruising + freqModifier + 22050; if (engineSoundType == SFX_BANK_TRUCK) freq /= 2; - AddPlayerCarSample(85, freq, (soundOffset + SFX_CAR_AFTER_ACCEL_1), engineSoundType, 64, true); + AddPlayerCarSample(85, freq, (soundOffset + SFX_CAR_AFTER_ACCEL_1), engineSoundType, 64, TRUE); } } } @@ -1406,7 +1406,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CAutomobile * bLostTractionLastFrame = lostTraction; } -bool +bool8 cAudioManager::ProcessVehicleSkidding(cVehicleParams& params) { const float SOUND_INTENSITY = 40.0f; @@ -1418,10 +1418,10 @@ cAudioManager::ProcessVehicleSkidding(cVehicleParams& params) float skidVal = 0.0f; if (params.m_fDistance >= SQR(SOUND_INTENSITY)) - return false; + return FALSE; automobile = (CAutomobile *)params.m_pVehicle; if (automobile->m_nWheelsOnGround == 0) - return true; + return TRUE; CalculateDistance(params.m_bDistanceCalculated, params.m_fDistance); for (int32 i = 0; i < ARRAY_SIZE(automobile->m_aWheelState); i++) { if (automobile->m_aWheelState[i] == WHEEL_STATE_NORMAL || automobile->Damage.GetWheelStatus(i) == WHEEL_STATUS_MISSING) @@ -1462,7 +1462,7 @@ cAudioManager::ProcessVehicleSkidding(cVehicleParams& params) m_sQueueSample.m_nFrequency = 13000.f * skidVal + 35000.f; m_sQueueSample.m_nVolume /= 4; if (m_sQueueSample.m_nVolume == 0) - return true; + return TRUE; break; case SURFACE_GRAVEL: case SURFACE_MUD_DRY: @@ -1479,7 +1479,7 @@ cAudioManager::ProcessVehicleSkidding(cVehicleParams& params) } m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nReleasingVolumeModificator = 8; m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nEmittingVolume = emittingVol; @@ -1487,14 +1487,14 @@ cAudioManager::ProcessVehicleSkidding(cVehicleParams& params) m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 3.0f; m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; - m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 3; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); } } - return true; + return TRUE; } float @@ -1569,7 +1569,7 @@ cAudioManager::ProcessVehicleHorn(cVehicleParams& params) m_sQueueSample.m_nCounter = 4; m_sQueueSample.m_nSampleIndex = aVehicleSettings[params.m_nIndex].m_nHornSample; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nReleasingVolumeModificator = 2; m_sQueueSample.m_nFrequency = aVehicleSettings[params.m_nIndex].m_nHornFrequency; m_sQueueSample.m_nLoopCount = 0; @@ -1578,10 +1578,10 @@ cAudioManager::ProcessVehicleHorn(cVehicleParams& params) m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 5.0f; m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; - m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 3; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); } } @@ -1589,7 +1589,7 @@ cAudioManager::ProcessVehicleHorn(cVehicleParams& params) } } -bool +bool8 cAudioManager::UsesSiren(int32 model) const { switch (model) { @@ -1599,13 +1599,13 @@ cAudioManager::UsesSiren(int32 model) const case POLICE: case ENFORCER: case PREDATOR: - return true; + return TRUE; default: - return false; + return FALSE; } } -bool +bool8 cAudioManager::UsesSirenSwitching(int32 model) const { switch (model) { @@ -1613,21 +1613,21 @@ cAudioManager::UsesSirenSwitching(int32 model) const case POLICE: case ENFORCER: case PREDATOR: - return true; + return TRUE; default: - return false; + return FALSE; } } -bool +bool8 cAudioManager::ProcessVehicleSirenOrAlarm(cVehicleParams& params) { const float SOUND_INTENSITY = 110.0f; if (params.m_fDistance < SQR(SOUND_INTENSITY)) { CVehicle *veh = params.m_pVehicle; - if (veh->m_bSirenOrAlarm == false && !veh->IsAlarmOn()) - return true; + if (veh->m_bSirenOrAlarm == FALSE && !veh->IsAlarmOn()) + return TRUE; CalculateDistance(params.m_bDistanceCalculated, params.m_fDistance); m_sQueueSample.m_nVolume = ComputeVolume(80, SOUND_INTENSITY, m_sQueueSample.m_fDistance); @@ -1635,7 +1635,7 @@ cAudioManager::ProcessVehicleSirenOrAlarm(cVehicleParams& params) m_sQueueSample.m_nCounter = 5; if (UsesSiren(params.m_nIndex)) { if (params.m_pVehicle->GetStatus() == STATUS_ABANDONED) - return true; + return TRUE; if (veh->m_nCarHornTimer && params.m_nIndex != FIRETRUK) { m_sQueueSample.m_nSampleIndex = SFX_SIREN_FAST; if (params.m_nIndex == FBICAR) @@ -1652,7 +1652,7 @@ cAudioManager::ProcessVehicleSirenOrAlarm(cVehicleParams& params) m_sQueueSample.m_nFrequency = aVehicleSettings[params.m_nIndex].m_nSirenOrAlarmFrequency; } m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nEmittingVolume = 80; @@ -1660,25 +1660,25 @@ cAudioManager::ProcessVehicleSirenOrAlarm(cVehicleParams& params) m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 7.0f; m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; - m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 5; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); - return true; + return TRUE; } else - return true; + return TRUE; } else - return false; + return FALSE; } -bool +bool8 cAudioManager::UsesReverseWarning(int32 model) const { return model == LINERUN || model == FIRETRUK || model == TRASH || model == BUS || model == COACH; } -bool +bool8 cAudioManager::ProcessVehicleReverseWarning(cVehicleParams& params) { const float SOUND_INTENSITY = 50.0f; @@ -1686,7 +1686,7 @@ cAudioManager::ProcessVehicleReverseWarning(cVehicleParams& params) CVehicle *veh = params.m_pVehicle; if (params.m_fDistance >= SQR(SOUND_INTENSITY)) - return false; + return FALSE; if (veh->bEngineOn && veh->m_fGasPedal < 0.0f) { CalculateDistance(params.m_bDistanceCalculated, params.m_fDistance); @@ -1695,7 +1695,7 @@ cAudioManager::ProcessVehicleReverseWarning(cVehicleParams& params) m_sQueueSample.m_nCounter = 12; m_sQueueSample.m_nSampleIndex = SFX_REVERSE_WARNING; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nReleasingVolumeModificator = 2; m_sQueueSample.m_nFrequency = (100 * m_sQueueSample.m_nEntityIndex & 1023) + SampleManager.GetSampleBaseFrequency(SFX_REVERSE_WARNING); m_sQueueSample.m_nLoopCount = 0; @@ -1704,17 +1704,17 @@ cAudioManager::ProcessVehicleReverseWarning(cVehicleParams& params) m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 3.0f; m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; - m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 3; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); } } - return true; + return TRUE; } -bool +bool8 cAudioManager::ProcessVehicleDoors(cVehicleParams& params) { const float SOUND_INTENSITY = 40.0f; @@ -1725,7 +1725,7 @@ cAudioManager::ProcessVehicleDoors(cVehicleParams& params) float velocity; if (params.m_fDistance >= SQR(SOUND_INTENSITY)) - return false; + return FALSE; automobile = (CAutomobile *)params.m_pVehicle; CalculateDistance(params.m_bDistanceCalculated, params.m_fDistance); @@ -1742,7 +1742,7 @@ cAudioManager::ProcessVehicleDoors(cVehicleParams& params) m_sQueueSample.m_nSampleIndex = m_anRandomTable[1] % 6 + SFX_COL_CAR_PANEL_1; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex) + RandomDisplacement(1000); m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nReleasingVolumeModificator = 10; m_sQueueSample.m_nLoopCount = 1; m_sQueueSample.m_nEmittingVolume = emittingVol; @@ -1750,33 +1750,33 @@ cAudioManager::ProcessVehicleDoors(cVehicleParams& params) m_sQueueSample.m_nLoopEnd = -1; m_sQueueSample.m_fSpeedMultiplier = 1.0f; m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; - m_sQueueSample.m_bReleasingSoundFlag = true; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = true; + m_sQueueSample.m_bReleasingSoundFlag = TRUE; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = TRUE; AddSampleToRequestedQueue(); } } } } } - return true; + return TRUE; } -bool +bool8 cAudioManager::ProcessAirBrakes(cVehicleParams& params) { CAutomobile *automobile; uint8 rand; if (params.m_fDistance > SQR(30)) - return false; + return FALSE; automobile = (CAutomobile *)params.m_pVehicle; if (!automobile->bEngineOn) - return true; + return TRUE; if ((automobile->m_fVelocityChangeForAudio < 0.025f || params.m_fVelocityChange >= 0.025f) && (automobile->m_fVelocityChangeForAudio > -0.025f || params.m_fVelocityChange <= 0.025f)) - return true; + return TRUE; CalculateDistance(params.m_bDistanceCalculated, params.m_fDistance); rand = m_anRandomTable[0] % 10 + 70; @@ -1787,7 +1787,7 @@ cAudioManager::ProcessAirBrakes(cVehicleParams& params) m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_AIR_BRAKES); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 16); m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nReleasingVolumeModificator = 10; m_sQueueSample.m_nLoopCount = 1; m_sQueueSample.m_nEmittingVolume = rand; @@ -1795,22 +1795,22 @@ cAudioManager::ProcessAirBrakes(cVehicleParams& params) m_sQueueSample.m_nLoopEnd = -1; m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_fSoundIntensity = 30.0f; - m_sQueueSample.m_bReleasingSoundFlag = true; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReleasingSoundFlag = TRUE; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); } - return true; + return TRUE; } -bool +bool8 cAudioManager::HasAirBrakes(int32 model) const { return model == LINERUN || model == FIRETRUK || model == TRASH || model == BUS || model == COACH; } -bool +bool8 cAudioManager::ProcessEngineDamage(cVehicleParams& params) { const int engineDamageIntensity = 40; @@ -1820,12 +1820,12 @@ cAudioManager::ProcessEngineDamage(cVehicleParams& params) uint8 emittingVolume; if (params.m_fDistance >= SQR(engineDamageIntensity)) - return false; + return FALSE; veh = (CAutomobile *)params.m_pVehicle; if (veh->bEngineOn) { engineStatus = veh->Damage.GetEngineStatus(); if (engineStatus > 250 || engineStatus < 100) - return true; + return TRUE; if (engineStatus < 225) { m_sQueueSample.m_nSampleIndex = SFX_JUMBO_TAXI; emittingVolume = 6; @@ -1842,30 +1842,30 @@ cAudioManager::ProcessEngineDamage(cVehicleParams& params) if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 28; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nEmittingVolume = emittingVolume; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_fSoundIntensity = engineDamageIntensity; - m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 3; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); } } - return true; + return TRUE; } -bool +bool8 cAudioManager::ProcessCarBombTick(cVehicleParams& params) { CAutomobile *automobile; if (params.m_fDistance >= SQR(40.f)) - return false; + return FALSE; automobile = (CAutomobile *)params.m_pVehicle; if (automobile->bEngineOn && automobile->m_bombType == CARBOMB_TIMEDACTIVE) { CalculateDistance(params.m_bDistanceCalculated, params.m_fDistance); @@ -1874,7 +1874,7 @@ cAudioManager::ProcessCarBombTick(cVehicleParams& params) m_sQueueSample.m_nCounter = 35; m_sQueueSample.m_nSampleIndex = SFX_COUNTDOWN; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nReleasingVolumeModificator = 0; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_COUNTDOWN); m_sQueueSample.m_nLoopCount = 0; @@ -1883,14 +1883,14 @@ cAudioManager::ProcessCarBombTick(cVehicleParams& params) m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_fSoundIntensity = 40.0f; - m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 3; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); } } - return true; + return TRUE; } void @@ -1900,7 +1900,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams& params) uint8 emittingVol; float relVol; float vol; - bool noReflections; + bool8 noReflections; float maxDist; static uint8 WaveIndex = 41; @@ -1910,7 +1910,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams& params) for (int i = 0; i < m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_AudioEvents; i++) { noReflections = 0; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bRequireReflection = FALSE; event = m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_awAudioEvent[i]; switch (event) { case SOUND_CAR_DOOR_CLOSE_BONNET: @@ -1950,7 +1950,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams& params) m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; - m_sQueueSample.m_bRequireReflection = true; + m_sQueueSample.m_bRequireReflection = TRUE; break; } case SOUND_CAR_DOOR_OPEN_BONNET: @@ -1988,7 +1988,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams& params) m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; - m_sQueueSample.m_bRequireReflection = true; + m_sQueueSample.m_bRequireReflection = TRUE; break; } case SOUND_CAR_WINDSHIELD_CRACK: { @@ -2034,7 +2034,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams& params) m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; - m_sQueueSample.m_bRequireReflection = true; + m_sQueueSample.m_bRequireReflection = TRUE; break; } case SOUND_CAR_LIGHT_BREAK: { @@ -2079,7 +2079,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams& params) m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; m_sQueueSample.m_nReleasingVolumeDivider = 7; - noReflections = true; + noReflections = TRUE; maxDist = SQR(SOUND_INTENSITY); emittingVol = m_anRandomTable[0] % 15 + 55; break; @@ -2161,7 +2161,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams& params) m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; emittingVol = (37.f * vol * 2500.0f / 96.0f) + 90; maxDist = SQR(SOUND_INTENSITY); - noReflections = true; + noReflections = TRUE; break; } case SOUND_CAR_BOMB_TICK: { @@ -2174,7 +2174,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams& params) m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; maxDist = SQR(SOUND_INTENSITY); - m_sQueueSample.m_bRequireReflection = true; + m_sQueueSample.m_bRequireReflection = TRUE; emittingVol = 60; break; } @@ -2234,7 +2234,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams& params) m_sQueueSample.m_nReleasingVolumeModificator = 0; m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; - m_sQueueSample.m_bRequireReflection = true; + m_sQueueSample.m_bRequireReflection = TRUE; emittingVol = 50; maxDist = SQR(SOUND_INTENSITY); break; @@ -2265,7 +2265,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams& params) m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; maxDist = SQR(SOUND_INTENSITY); - m_sQueueSample.m_bRequireReflection = true; + m_sQueueSample.m_bRequireReflection = TRUE; emittingVol = m_anRandomTable[4] % 20 + 90; break; } @@ -2282,7 +2282,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams& params) maxDist = SQR(SOUND_INTENSITY); emittingVol = m_anRandomTable[4] % 20 + 55; CrunchOffset %= 2; - m_sQueueSample.m_bRequireReflection = true; + m_sQueueSample.m_bRequireReflection = TRUE; break; } case SOUND_CAR_PED_COLLISION: { @@ -2311,23 +2311,23 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams& params) if (m_sQueueSample.m_nVolume != 0) { if (noReflections) { m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_bReleasingSoundFlag = FALSE; } else { m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_bReleasingSoundFlag = true; + m_sQueueSample.m_bReleasingSoundFlag = TRUE; } m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nEmittingVolume = emittingVol; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bIs2D = FALSE; AddSampleToRequestedQueue(); } } } } -bool +bool8 cAudioManager::ProcessTrainNoise(cVehicleParams& params) { const float SOUND_INTENSITY = 300.0f; @@ -2337,7 +2337,7 @@ cAudioManager::ProcessTrainNoise(cVehicleParams& params) float speedMultipler; if (params.m_fDistance >= SQR(SOUND_INTENSITY)) - return false; + return FALSE; if (params.m_fVelocityChange > 0.0f) { CalculateDistance(params.m_bDistanceCalculated, params.m_fDistance); @@ -2350,7 +2350,7 @@ cAudioManager::ProcessTrainNoise(cVehicleParams& params) m_sQueueSample.m_nCounter = 32; m_sQueueSample.m_nSampleIndex = SFX_TRAIN_FAR; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nReleasingVolumeModificator = 2; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_TRAIN_FAR); m_sQueueSample.m_nLoopCount = 0; @@ -2359,10 +2359,10 @@ cAudioManager::ProcessTrainNoise(cVehicleParams& params) m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 3.0f; m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; - m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 3; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); } } @@ -2373,7 +2373,7 @@ cAudioManager::ProcessTrainNoise(cVehicleParams& params) m_sQueueSample.m_nCounter = 33; m_sQueueSample.m_nSampleIndex = SFX_TRAIN_NEAR; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nReleasingVolumeModificator = 5; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_TRAIN_NEAR) + 100 * m_sQueueSample.m_nEntityIndex % 987; m_sQueueSample.m_nLoopCount = 0; @@ -2382,18 +2382,18 @@ cAudioManager::ProcessTrainNoise(cVehicleParams& params) m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 6.0f; m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; - m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 3; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); } } } - return true; + return TRUE; } -bool +bool8 cAudioManager::ProcessBoatEngine(cVehicleParams& params) { CBoat *boat; @@ -2419,7 +2419,7 @@ cAudioManager::ProcessBoatEngine(cVehicleParams& params) m_sQueueSample.m_nFrequency = 10386; m_sQueueSample.m_nFrequency += (m_sQueueSample.m_nEntityIndex * 65536) % 1000; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nEmittingVolume = 80; @@ -2427,10 +2427,10 @@ cAudioManager::ProcessBoatEngine(cVehicleParams& params) m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_fSoundIntensity = intensity; - m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 7; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); } if (FindPlayerVehicle() == params.m_pVehicle) { @@ -2454,12 +2454,12 @@ cAudioManager::ProcessBoatEngine(cVehicleParams& params) } m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, intensity, m_sQueueSample.m_fDistance); if (!m_sQueueSample.m_nVolume) - return true; + return TRUE; m_sQueueSample.m_nCounter = 40; m_sQueueSample.m_nSampleIndex = SFX_POLICE_BOAT_ACCEL; m_sQueueSample.m_nFrequency += (m_sQueueSample.m_nEntityIndex * 65536) % 1000; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nEmittingVolume = emittingVol; @@ -2467,10 +2467,10 @@ cAudioManager::ProcessBoatEngine(cVehicleParams& params) m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_fSoundIntensity = intensity; - m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 7; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = FALSE; } else { if (FindPlayerVehicle() == params.m_pVehicle) { padAccelerate = Max(Pads[0].GetAccelerate(), Pads[0].GetBrake()); @@ -2512,10 +2512,10 @@ cAudioManager::ProcessBoatEngine(cVehicleParams& params) CalculateDistance(params.m_bDistanceCalculated, params.m_fDistance); m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, intensity, m_sQueueSample.m_fDistance); if (!m_sQueueSample.m_nVolume) - return true; + return TRUE; m_sQueueSample.m_nFrequency += (m_sQueueSample.m_nEntityIndex * 65536) % 1000; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nEmittingVolume = emittingVol; @@ -2523,18 +2523,18 @@ cAudioManager::ProcessBoatEngine(cVehicleParams& params) m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_fSoundIntensity = intensity; - m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 7; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = FALSE; } AddSampleToRequestedQueue(); - return true; + return TRUE; } - return false; + return FALSE; } -bool +bool8 cAudioManager::ProcessBoatMovingOverWater(cVehicleParams& params) { float velocityChange; @@ -2542,11 +2542,11 @@ cAudioManager::ProcessBoatMovingOverWater(cVehicleParams& params) float multiplier; if (params.m_fDistance > SQR(50)) - return false; + return FALSE; velocityChange = Abs(params.m_fVelocityChange); if (velocityChange <= 0.0005f && ((CBoat*)params.m_pVehicle)->bBoatInWater) - return true; + return TRUE; velocityChange = Min(0.75f, velocityChange); multiplier = (velocityChange - 0.0005f) / (1499.0f / 2000.0f); @@ -2557,7 +2557,7 @@ cAudioManager::ProcessBoatMovingOverWater(cVehicleParams& params) m_sQueueSample.m_nCounter = 38; m_sQueueSample.m_nSampleIndex = SFX_BOAT_WATER_LOOP; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_nFrequency = (6050.f * multiplier) + 16000; m_sQueueSample.m_nLoopCount = 0; @@ -2566,14 +2566,14 @@ cAudioManager::ProcessBoatMovingOverWater(cVehicleParams& params) m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_fSoundIntensity = 50.0f; - m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 3; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); } - return true; + return TRUE; } struct tHelicopterSampleData { @@ -2582,7 +2582,7 @@ struct tHelicopterSampleData { uint8 m_bBaseVolume; }; -bool +bool8 cAudioManager::ProcessHelicopter(cVehicleParams& params) { CHeli *heli; @@ -2593,7 +2593,7 @@ cAudioManager::ProcessHelicopter(cVehicleParams& params) static const tHelicopterSampleData gHeliSfxRanges[3] = {{400.f, 380.f, 100}, {100.f, 70.f, MAX_VOLUME}, {60.f, 30.f, MAX_VOLUME}}; if (SQR(gHeliSfxRanges[0].m_fMaxDistance) <= params.m_fDistance) - return false; + return FALSE; CalculateDistance(params.m_bDistanceCalculated, params.m_fDistance); heli = (CHeli *)params.m_pVehicle; @@ -2601,7 +2601,7 @@ cAudioManager::ProcessHelicopter(cVehicleParams& params) MaxDist = gHeliSfxRanges[i].m_fMaxDistance; dist = m_sQueueSample.m_fDistance; if (dist >= MaxDist) - return true; + return TRUE; baseDist = gHeliSfxRanges[i].m_fBaseDistance; if (dist < baseDist) emittingVol = (gHeliSfxRanges[i].m_bBaseVolume * ((MaxDist - dist) / (MaxDist - baseDist))); @@ -2613,7 +2613,7 @@ cAudioManager::ProcessHelicopter(cVehicleParams& params) m_sQueueSample.m_nCounter = i + 65; m_sQueueSample.m_nSampleIndex = i + SFX_HELI_1; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nReleasingVolumeModificator = 0; m_sQueueSample.m_nFrequency = 1200 * heli->m_nHeliId + SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopCount = 0; @@ -2622,14 +2622,14 @@ cAudioManager::ProcessHelicopter(cVehicleParams& params) m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 6.0f; m_sQueueSample.m_fSoundIntensity = gHeliSfxRanges[i].m_fMaxDistance; - m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 3; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); } } - return true; + return TRUE; } void @@ -2771,12 +2771,12 @@ cAudioManager::ProcessJumboDecel(CPlane *plane) } } -bool +bool8 cAudioManager::SetupJumboTaxiSound(uint8 vol) { const float SOUND_INTENSITY = 180.0f; if (m_sQueueSample.m_fDistance >= SOUND_INTENSITY) - return false; + return FALSE; uint8 emittingVol = (vol / 2) + ((vol / 2) * m_sQueueSample.m_fDistance / SOUND_INTENSITY); @@ -2788,7 +2788,7 @@ cAudioManager::SetupJumboTaxiSound(uint8 vol) m_sQueueSample.m_nCounter = 1; m_sQueueSample.m_nSampleIndex = SFX_JUMBO_TAXI; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nFrequency = GetJumboTaxiFreq(); m_sQueueSample.m_nLoopCount = 0; @@ -2797,22 +2797,22 @@ cAudioManager::SetupJumboTaxiSound(uint8 vol) m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 4.0f; m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; - m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 4; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); } - return true; + return TRUE; } -bool +bool8 cAudioManager::SetupJumboWhineSound(uint8 emittingVol, uint32 freq) { const float SOUND_INTENSITY = 170.0f; if (m_sQueueSample.m_fDistance >= SOUND_INTENSITY) - return false; + return FALSE; m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance); @@ -2820,7 +2820,7 @@ cAudioManager::SetupJumboWhineSound(uint8 emittingVol, uint32 freq) m_sQueueSample.m_nCounter = 2; m_sQueueSample.m_nSampleIndex = SFX_JUMBO_WHINE; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nFrequency = freq; m_sQueueSample.m_nLoopCount = 0; @@ -2829,21 +2829,21 @@ cAudioManager::SetupJumboWhineSound(uint8 emittingVol, uint32 freq) m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 4.0f; m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; - m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 4; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); } - return true; + return TRUE; } -bool +bool8 cAudioManager::SetupJumboEngineSound(uint8 vol, uint32 freq) { const float SOUND_INTENSITY = 180.0f; if (m_sQueueSample.m_fDistance >= SOUND_INTENSITY) - return false; + return FALSE; uint8 emittingVol = vol - gJumboVolOffsetPercentage / 100; m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance); @@ -2851,7 +2851,7 @@ cAudioManager::SetupJumboEngineSound(uint8 vol, uint32 freq) m_sQueueSample.m_nCounter = 3; m_sQueueSample.m_nSampleIndex = SFX_JUMBO_ENGINE; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nFrequency = freq; m_sQueueSample.m_nLoopCount = 0; @@ -2860,21 +2860,21 @@ cAudioManager::SetupJumboEngineSound(uint8 vol, uint32 freq) m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 4.0f; m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; - m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 4; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); } - return true; + return TRUE; } -bool +bool8 cAudioManager::SetupJumboFlySound(uint8 emittingVol) { const float SOUND_INTENSITY = 440.0f; if (m_sQueueSample.m_fDistance >= SOUND_INTENSITY) - return false; + return FALSE; int32 vol = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance); m_sQueueSample.m_nVolume = vol; @@ -2882,29 +2882,29 @@ cAudioManager::SetupJumboFlySound(uint8 emittingVol) m_sQueueSample.m_nSampleIndex = SFX_JUMBO_DIST_FLY; m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nEmittingVolume = emittingVol; m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_JUMBO_DIST_FLY); m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; - m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_fSpeedMultiplier = 4.0f; - m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bReverbFlag = TRUE; m_sQueueSample.m_nReleasingVolumeDivider = 5; m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); AddSampleToRequestedQueue(); } - return true; + return TRUE; } -bool +bool8 cAudioManager::SetupJumboRumbleSound(uint8 emittingVol) { const float SOUND_INTENSITY = 240.0f; if (m_sQueueSample.m_fDistance >= SOUND_INTENSITY) - return false; + return FALSE; m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance); @@ -2912,7 +2912,7 @@ cAudioManager::SetupJumboRumbleSound(uint8 emittingVol) m_sQueueSample.m_nCounter = 5; m_sQueueSample.m_nSampleIndex = SFX_JUMBO_RUMBLE; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = true; + m_sQueueSample.m_bIs2D = TRUE; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_JUMBO_RUMBLE); m_sQueueSample.m_nLoopCount = 0; @@ -2921,11 +2921,11 @@ cAudioManager::SetupJumboRumbleSound(uint8 emittingVol) m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 4.0f; m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; - m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 12; m_sQueueSample.m_nOffset = 0; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); m_sQueueSample.m_nCounter = 6; m_sQueueSample.m_nSampleIndex = SFX_JUMBO_RUMBLE; @@ -2933,7 +2933,7 @@ cAudioManager::SetupJumboRumbleSound(uint8 emittingVol) m_sQueueSample.m_nOffset = MAX_VOLUME; AddSampleToRequestedQueue(); } - return true; + return TRUE; } int32 @@ -2954,7 +2954,7 @@ cAudioManager::ProcessPed(CPhysical *ped) m_sQueueSample.m_vecPos = ped->GetPosition(); - params.m_bDistanceCalculated = false; + params.m_bDistanceCalculated = FALSE; params.m_pPed = (CPed *)ped; params.m_fDistance = GetDistanceSquared(m_sQueueSample.m_vecPos); if (ped->GetModelIndex() == MI_FATMALE02) @@ -2993,7 +2993,7 @@ cAudioManager::ProcessPedHeadphones(cPedParams ¶ms) m_sQueueSample.m_nCounter = 64; m_sQueueSample.m_nSampleIndex = SFX_HEADPHONES; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nReleasingVolumeModificator = 5; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_HEADPHONES); m_sQueueSample.m_nLoopCount = 0; @@ -3002,10 +3002,10 @@ cAudioManager::ProcessPedHeadphones(cPedParams ¶ms) m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 4.0f; m_sQueueSample.m_fSoundIntensity = 7.0f; - m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 5; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); } return; @@ -3021,9 +3021,9 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) CPed *ped = params.m_pPed; - bool narrowSoundRange; + bool8 narrowSoundRange; int16 sound; - bool stereo; + bool8 stereo; CWeapon *weapon; float maxDist = 0.f; // uninitialized variable @@ -3031,9 +3031,9 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) weapon = params.m_pPed->GetWeapon(); for (uint32 i = 0; i < m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_AudioEvents; i++) { - stereo = false; - narrowSoundRange = false; - m_sQueueSample.m_bRequireReflection = false; + stereo = FALSE; + narrowSoundRange = FALSE; + m_sQueueSample.m_bRequireReflection = FALSE; sound = m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_awAudioEvent[i]; switch (sound) { case SOUND_STEP_START: @@ -3110,9 +3110,9 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) m_sQueueSample.m_nLoopStart = 0; m_sQueueSample.m_nLoopEnd = -1; m_sQueueSample.m_nEmittingVolume = emittingVol; - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_bReleasingSoundFlag = true; - m_sQueueSample.m_bRequireReflection = true; + m_sQueueSample.m_bIs2D = FALSE; + m_sQueueSample.m_bReleasingSoundFlag = TRUE; + m_sQueueSample.m_bRequireReflection = TRUE; break; case SOUND_FALL_LAND: case SOUND_FALL_COLLAPSE: @@ -3138,9 +3138,9 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) m_sQueueSample.m_nLoopStart = 0; m_sQueueSample.m_nLoopEnd = -1; m_sQueueSample.m_nEmittingVolume = emittingVol; - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_bReleasingSoundFlag = true; - m_sQueueSample.m_bRequireReflection = true; + m_sQueueSample.m_bIs2D = FALSE; + m_sQueueSample.m_bReleasingSoundFlag = TRUE; + m_sQueueSample.m_bRequireReflection = TRUE; break; case SOUND_FIGHT_PUNCH_33: m_sQueueSample.m_nSampleIndex = SFX_FIGHT_1; @@ -3192,7 +3192,7 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) AddFightSound: m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound; - narrowSoundRange = true; + narrowSoundRange = TRUE; ++iSound; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_fSpeedMultiplier = 0.0f; @@ -3203,15 +3203,15 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) emittingVol = m_anRandomTable[3] % 26 + 100; m_sQueueSample.m_nLoopEnd = -1; m_sQueueSample.m_nEmittingVolume = emittingVol; - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_bReleasingSoundFlag = true; - m_sQueueSample.m_bRequireReflection = true; + m_sQueueSample.m_bIs2D = FALSE; + m_sQueueSample.m_bReleasingSoundFlag = TRUE; + m_sQueueSample.m_bRequireReflection = TRUE; break; case SOUND_WEAPON_BAT_ATTACK: m_sQueueSample.m_nSampleIndex = SFX_BAT_HIT_LEFT; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound++; - narrowSoundRange = true; + narrowSoundRange = TRUE; m_sQueueSample.m_nFrequency = RandomDisplacement(2000) + 22000; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_fSpeedMultiplier = 0.0f; @@ -3222,12 +3222,12 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) m_sQueueSample.m_nLoopEnd = -1; emittingVol = m_anRandomTable[2] % 20 + 100; m_sQueueSample.m_nEmittingVolume = emittingVol; - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_bReleasingSoundFlag = true; + m_sQueueSample.m_bIs2D = FALSE; + m_sQueueSample.m_bReleasingSoundFlag = TRUE; if (m_bDynamicAcousticModelingStatus) - m_sQueueSample.m_bRequireReflection = true; + m_sQueueSample.m_bRequireReflection = TRUE; else - stereo = true; + stereo = TRUE; break; case SOUND_WEAPON_SHOT_FIRED: weapon = ped->GetWeapon(); @@ -3236,7 +3236,7 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) m_sQueueSample.m_nSampleIndex = SFX_COLT45_LEFT; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound++; - narrowSoundRange = true; + narrowSoundRange = TRUE; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_COLT45_LEFT); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 32); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -3248,18 +3248,18 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) m_sQueueSample.m_nLoopEnd = -1; emittingVol = m_anRandomTable[1] % 10 + 90; m_sQueueSample.m_nEmittingVolume = emittingVol; - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_bReleasingSoundFlag = true; + m_sQueueSample.m_bIs2D = FALSE; + m_sQueueSample.m_bReleasingSoundFlag = TRUE; if (m_bDynamicAcousticModelingStatus) - m_sQueueSample.m_bRequireReflection = true; + m_sQueueSample.m_bRequireReflection = TRUE; else - stereo = true; + stereo = TRUE; break; case WEAPONTYPE_UZI: m_sQueueSample.m_nSampleIndex = SFX_UZI_LEFT; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound++; - narrowSoundRange = true; + narrowSoundRange = TRUE; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_UZI_LEFT); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 32); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -3271,14 +3271,14 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) emittingVol = m_anRandomTable[3] % 15 + 70; m_sQueueSample.m_nLoopEnd = -1; m_sQueueSample.m_nEmittingVolume = emittingVol; - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_bReleasingSoundFlag = true; + m_sQueueSample.m_bIs2D = FALSE; + m_sQueueSample.m_bReleasingSoundFlag = TRUE; break; case WEAPONTYPE_SHOTGUN: m_sQueueSample.m_nSampleIndex = SFX_SHOTGUN_LEFT; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound++; - narrowSoundRange = true; + narrowSoundRange = TRUE; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_SHOTGUN_LEFT); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 32); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -3290,18 +3290,18 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) m_sQueueSample.m_nLoopEnd = -1; emittingVol = m_anRandomTable[2] % 10 + 100; m_sQueueSample.m_nEmittingVolume = emittingVol; - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_bReleasingSoundFlag = true; + m_sQueueSample.m_bIs2D = FALSE; + m_sQueueSample.m_bReleasingSoundFlag = TRUE; if (m_bDynamicAcousticModelingStatus) - m_sQueueSample.m_bRequireReflection = true; + m_sQueueSample.m_bRequireReflection = TRUE; else - stereo = true; + stereo = TRUE; break; case WEAPONTYPE_AK47: m_sQueueSample.m_nSampleIndex = SFX_AK47_LEFT; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound++; - narrowSoundRange = true; + narrowSoundRange = TRUE; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_AK47_LEFT); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 32); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -3313,14 +3313,14 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) emittingVol = m_anRandomTable[1] % 15 + 70; m_sQueueSample.m_nLoopEnd = -1; m_sQueueSample.m_nEmittingVolume = emittingVol; - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_bReleasingSoundFlag = true; + m_sQueueSample.m_bIs2D = FALSE; + m_sQueueSample.m_bReleasingSoundFlag = TRUE; break; case WEAPONTYPE_M16: m_sQueueSample.m_nSampleIndex = SFX_M16_LEFT; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound++; - narrowSoundRange = true; + narrowSoundRange = TRUE; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_M16_LEFT); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 32); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -3332,14 +3332,14 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) emittingVol = m_anRandomTable[4] % 15 + 70; m_sQueueSample.m_nLoopEnd = -1; m_sQueueSample.m_nEmittingVolume = emittingVol; - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_bReleasingSoundFlag = true; + m_sQueueSample.m_bIs2D = FALSE; + m_sQueueSample.m_bReleasingSoundFlag = TRUE; break; case WEAPONTYPE_SNIPERRIFLE: m_sQueueSample.m_nSampleIndex = SFX_SNIPER_LEFT; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound++; - narrowSoundRange = true; + narrowSoundRange = TRUE; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_SNIPER_LEFT); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 32); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -3351,18 +3351,18 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) m_sQueueSample.m_nLoopEnd = -1; emittingVol = m_anRandomTable[4] % 10 + 110; m_sQueueSample.m_nEmittingVolume = emittingVol; - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_bReleasingSoundFlag = true; + m_sQueueSample.m_bIs2D = FALSE; + m_sQueueSample.m_bReleasingSoundFlag = TRUE; if (m_bDynamicAcousticModelingStatus) - m_sQueueSample.m_bRequireReflection = true; + m_sQueueSample.m_bRequireReflection = TRUE; else - stereo = true; + stereo = TRUE; break; case WEAPONTYPE_ROCKETLAUNCHER: m_sQueueSample.m_nSampleIndex = SFX_ROCKET_LEFT; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound++; - narrowSoundRange = true; + narrowSoundRange = TRUE; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_ROCKET_LEFT); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 32); m_sQueueSample.m_nReleasingVolumeModificator = 1; @@ -3374,12 +3374,12 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) m_sQueueSample.m_nLoopEnd = -1; emittingVol = m_anRandomTable[0] % 20 + 80; m_sQueueSample.m_nEmittingVolume = emittingVol; - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_bReleasingSoundFlag = true; + m_sQueueSample.m_bIs2D = FALSE; + m_sQueueSample.m_bReleasingSoundFlag = TRUE; if (m_bDynamicAcousticModelingStatus) - m_sQueueSample.m_bRequireReflection = true; + m_sQueueSample.m_bRequireReflection = TRUE; else - stereo = true; + stereo = TRUE; break; case WEAPONTYPE_FLAMETHROWER: m_sQueueSample.m_nSampleIndex = SFX_FLAMETHROWER_LEFT; @@ -3395,13 +3395,13 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nEmittingVolume = 90; - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_bIs2D = FALSE; + m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 6; if (m_bDynamicAcousticModelingStatus) - m_sQueueSample.m_bRequireReflection = true; + m_sQueueSample.m_bRequireReflection = TRUE; else - stereo = true; + stereo = TRUE; break; default: continue; @@ -3444,7 +3444,7 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) } emittingVol = 75; m_sQueueSample.m_nCounter = iSound++; - narrowSoundRange = true; + narrowSoundRange = TRUE; m_sQueueSample.m_nFrequency += RandomDisplacement(300); m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nReleasingVolumeModificator = 5; @@ -3455,9 +3455,9 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) m_sQueueSample.m_nLoopStart = 0; m_sQueueSample.m_nLoopEnd = -1; m_sQueueSample.m_nEmittingVolume = 75; - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_bReleasingSoundFlag = true; - m_sQueueSample.m_bRequireReflection = true; + m_sQueueSample.m_bIs2D = FALSE; + m_sQueueSample.m_bReleasingSoundFlag = TRUE; + m_sQueueSample.m_bRequireReflection = TRUE; break; case SOUND_WEAPON_AK47_BULLET_ECHO: case SOUND_WEAPON_UZI_BULLET_ECHO: @@ -3465,7 +3465,7 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) m_sQueueSample.m_nSampleIndex = SFX_UZI_END_LEFT; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound++; - narrowSoundRange = true; + narrowSoundRange = TRUE; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_UZI_END_LEFT); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 16); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -3477,12 +3477,12 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) m_sQueueSample.m_nLoopEnd = -1; emittingVol = m_anRandomTable[4] % 10 + 40; m_sQueueSample.m_nEmittingVolume = emittingVol; - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_bReleasingSoundFlag = true; + m_sQueueSample.m_bIs2D = FALSE; + m_sQueueSample.m_bReleasingSoundFlag = TRUE; if (m_bDynamicAcousticModelingStatus) - m_sQueueSample.m_bRequireReflection = true; + m_sQueueSample.m_bRequireReflection = TRUE; else - stereo = true; + stereo = TRUE; break; case SOUND_WEAPON_FLAMETHROWER_FIRE: m_sQueueSample.m_nSampleIndex = SFX_FLAMETHROWER_START_LEFT; @@ -3499,14 +3499,14 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) m_sQueueSample.m_nLoopEnd = -1; emittingVol = 70; m_sQueueSample.m_nEmittingVolume = 70; - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_bReleasingSoundFlag = true; + m_sQueueSample.m_bIs2D = FALSE; + m_sQueueSample.m_bReleasingSoundFlag = TRUE; break; case SOUND_WEAPON_HIT_PED: m_sQueueSample.m_nSampleIndex = SFX_BULLET_PED; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound++; - narrowSoundRange = true; + narrowSoundRange = TRUE; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_BULLET_PED); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 8); m_sQueueSample.m_nReleasingVolumeModificator = 7; @@ -3518,14 +3518,14 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) emittingVol = m_anRandomTable[0] % 20 + 90; m_sQueueSample.m_nLoopEnd = -1; m_sQueueSample.m_nEmittingVolume = emittingVol; - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_bReleasingSoundFlag = true; + m_sQueueSample.m_bIs2D = FALSE; + m_sQueueSample.m_bReleasingSoundFlag = TRUE; break; case SOUND_SPLASH: m_sQueueSample.m_nSampleIndex = SFX_SPLASH_1; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound++; - narrowSoundRange = true; + narrowSoundRange = TRUE; m_sQueueSample.m_nFrequency = RandomDisplacement(1400) + 20000; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_fSpeedMultiplier = 0.0f; @@ -3536,9 +3536,9 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) emittingVol = m_anRandomTable[2] % 30 + 70; m_sQueueSample.m_nLoopEnd = -1; m_sQueueSample.m_nEmittingVolume = emittingVol; - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_bReleasingSoundFlag = true; - m_sQueueSample.m_bRequireReflection = true; + m_sQueueSample.m_bIs2D = FALSE; + m_sQueueSample.m_bReleasingSoundFlag = TRUE; + m_sQueueSample.m_bRequireReflection = TRUE; break; default: SetupPedComments(params, sound); @@ -3553,13 +3553,13 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) if (m_sQueueSample.m_nVolume != 0) { if (stereo) { if (m_sQueueSample.m_fDistance < 0.2f * m_sQueueSample.m_fSoundIntensity) { - m_sQueueSample.m_bIs2D = true; + m_sQueueSample.m_bIs2D = TRUE; m_sQueueSample.m_nOffset = 0; } else { - stereo = false; + stereo = FALSE; } } - m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bReverbFlag = TRUE; AddSampleToRequestedQueue(); if (stereo) { m_sQueueSample.m_nOffset = 127; @@ -6101,18 +6101,18 @@ cPedComments::Process() AudioManager.m_sQueueSample.m_fSoundIntensity = 50.0f; break; } - AudioManager.m_sQueueSample.m_bReleasingSoundFlag = true; + AudioManager.m_sQueueSample.m_bReleasingSoundFlag = TRUE; AudioManager.m_sQueueSample.m_vecPos = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_vecPos; if (sampleIndex >= SFX_AMMU_D && sampleIndex <= SFX_AMMU_F) { - AudioManager.m_sQueueSample.m_bReverbFlag = false; - AudioManager.m_sQueueSample.m_bRequireReflection = false; + AudioManager.m_sQueueSample.m_bReverbFlag = FALSE; + AudioManager.m_sQueueSample.m_bRequireReflection = FALSE; } else { - AudioManager.m_sQueueSample.m_bReverbFlag = true; - AudioManager.m_sQueueSample.m_bRequireReflection = true; + AudioManager.m_sQueueSample.m_bReverbFlag = TRUE; + AudioManager.m_sQueueSample.m_bRequireReflection = TRUE; } - AudioManager.m_sQueueSample.m_bIs2D = false; + AudioManager.m_sQueueSample.m_bIs2D = FALSE; AudioManager.m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(AudioManager.m_sQueueSample.m_nSampleIndex) + AudioManager.RandomDisplacement(750); if (CTimer::GetIsSlowMotionActive()) @@ -6203,15 +6203,15 @@ cAudioManager::ProcessExplosions(int32 explosion) if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = i; m_sQueueSample.m_fSpeedMultiplier = 2.0f; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_bReleasingSoundFlag = true; - m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bReleasingSoundFlag = TRUE; + m_sQueueSample.m_bReverbFlag = TRUE; m_sQueueSample.m_nEmittingVolume = MAX_VOLUME; m_sQueueSample.m_nLoopStart = 0; m_sQueueSample.m_nLoopEnd = -1; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = true; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = TRUE; AddSampleToRequestedQueue(); } } @@ -6273,14 +6273,14 @@ cAudioManager::ProcessFires(int32) m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_nReleasingVolumeDivider = 10; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nEmittingVolume = emittingVol; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); } } @@ -6317,14 +6317,14 @@ cAudioManager::ProcessWaterCannon(int32) m_sQueueSample.m_nCounter = i; m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_nReleasingVolumeDivider = 8; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nEmittingVolume = 50; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); } } @@ -6386,8 +6386,8 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) m_sQueueSample.m_nFrequency = 9000; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_bRequireReflection = true; + m_sQueueSample.m_bIs2D = FALSE; + m_sQueueSample.m_bRequireReflection = TRUE; emittingVolume = RandomDisplacement(10) + 50; break; case SCRIPT_SOUND_BULLET_HIT_GROUND_1: @@ -6400,7 +6400,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 32); m_sQueueSample.m_nReleasingVolumeModificator = 9; m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; emittingVolume = m_anRandomTable[2] % 20 + 90; break; case SCRIPT_SOUND_TRAIN_ANNOUNCEMENT_1: @@ -6414,7 +6414,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_TRAIN_STATION_ANNOUNCE); m_sQueueSample.m_nReleasingVolumeModificator = 0; m_sQueueSample.m_fSpeedMultiplier = 2.0f; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; break; case SCRIPT_SOUND_PAYPHONE_RINGING: m_sQueueSample.m_fSoundIntensity = 80.0f; @@ -6424,8 +6424,8 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_PHONE_RING); m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_fSpeedMultiplier = 2.0f; - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bIs2D = FALSE; + m_sQueueSample.m_bRequireReflection = FALSE; break; case SCRIPT_SOUND_GLASS_BREAK_L: m_sQueueSample.m_fSoundIntensity = 60.0f; @@ -6435,7 +6435,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_GLASS_SMASH); m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; break; case SCRIPT_SOUND_GLASS_BREAK_S: m_sQueueSample.m_fSoundIntensity = 60.0f; @@ -6445,7 +6445,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_GLASS_SMASH); m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; break; case SCRIPT_SOUND_GLASS_CRACK: m_sQueueSample.m_fSoundIntensity = 60.0f; @@ -6455,8 +6455,8 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_GLASS_CRACK); m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_bRequireReflection = true; + m_sQueueSample.m_bIs2D = FALSE; + m_sQueueSample.m_bRequireReflection = TRUE; break; case SCRIPT_SOUND_GLASS_LIGHT_BREAK: m_sQueueSample.m_fSoundIntensity = 55.0f; @@ -6465,7 +6465,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) m_sQueueSample.m_nFrequency = RandomDisplacement(2000) + 19000; m_sQueueSample.m_nReleasingVolumeModificator = 9; m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; emittingVolume = RandomDisplacement(11) + 25; break; case SCRIPT_SOUND_BOX_DESTROYED_1: @@ -6475,8 +6475,8 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) m_sQueueSample.m_nFrequency = RandomDisplacement(1500) + 18600; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_bRequireReflection = true; + m_sQueueSample.m_bIs2D = FALSE; + m_sQueueSample.m_bRequireReflection = TRUE; emittingVolume = m_anRandomTable[2] % 20 + 80; break; case SCRIPT_SOUND_BOX_DESTROYED_2: @@ -6486,8 +6486,8 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) m_sQueueSample.m_nFrequency = RandomDisplacement(1500) + 18600; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_bRequireReflection = true; + m_sQueueSample.m_bIs2D = FALSE; + m_sQueueSample.m_bRequireReflection = TRUE; emittingVolume = m_anRandomTable[2] % 20 + 80; break; case SCRIPT_SOUND_METAL_COLLISION: @@ -6498,8 +6498,8 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 16); m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_bRequireReflection = true; + m_sQueueSample.m_bIs2D = FALSE; + m_sQueueSample.m_bRequireReflection = TRUE; emittingVolume = m_anRandomTable[2] % 30 + 70; break; case SCRIPT_SOUND_TIRE_COLLISION: @@ -6510,8 +6510,8 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 16); m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_bRequireReflection = true; + m_sQueueSample.m_bIs2D = FALSE; + m_sQueueSample.m_bRequireReflection = TRUE; emittingVolume = m_anRandomTable[2] % 30 + 60; break; case SCRIPT_SOUND_GUNSHELL_DROP: @@ -6546,7 +6546,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) m_sQueueSample.m_fSoundIntensity = 20.0f; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; emittingVolume = m_anRandomTable[2] % 20 + 30; break; case SCRIPT_SOUND_GUNSHELL_DROP_SOFT: @@ -6556,7 +6556,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) m_sQueueSample.m_fSoundIntensity = 20.0f; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; emittingVolume = m_anRandomTable[2] % 20 + 30; break; default: @@ -6570,11 +6570,11 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = iSound++; m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_bReleasingSoundFlag = true; + m_sQueueSample.m_bReleasingSoundFlag = TRUE; m_sQueueSample.m_nEmittingVolume = emittingVolume; m_sQueueSample.m_nLoopStart = 0; m_sQueueSample.m_nLoopEnd = -1; - m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bReverbFlag = TRUE; AddSampleToRequestedQueue(); } } @@ -7175,14 +7175,14 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) m_sQueueSample.m_nVolume = ComputeVolume(emittingVolume, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 0; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_bReleasingSoundFlag = false; - m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bReleasingSoundFlag = FALSE; + m_sQueueSample.m_bReverbFlag = TRUE; m_sQueueSample.m_nEmittingVolume = emittingVolume; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); } } @@ -7247,16 +7247,16 @@ cAudioManager::ProcessPornCinema(uint8 sound) if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nCounter = 0; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_nEmittingVolume = MAX_VOLUME; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); } } @@ -7270,15 +7270,15 @@ cAudioManager::ProcessPornCinema(uint8 sound) m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 16); m_sQueueSample.m_nCounter = rand + 1; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_bReleasingSoundFlag = true; + m_sQueueSample.m_bReleasingSoundFlag = TRUE; m_sQueueSample.m_nReleasingVolumeModificator = 6; m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_nLoopStart = 0; m_sQueueSample.m_nLoopEnd = -1; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); gPornNextTime = time + 2000 + m_anRandomTable[3] % 6000; } @@ -7308,16 +7308,16 @@ cAudioManager::ProcessWorkShopScriptObject(uint8 sound) m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_WORKSHOP; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_WORKSHOP_1); m_sQueueSample.m_nCounter = 0; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeModificator = 5; m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_nEmittingVolume = 30; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); } } @@ -7347,16 +7347,16 @@ cAudioManager::ProcessSawMillScriptObject(uint8 sound) m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_SAWMILL; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_SAWMILL_LOOP); m_sQueueSample.m_nCounter = 0; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeModificator = 5; m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_nEmittingVolume = 30; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); } time = CTimer::GetTimeInMilliseconds(); @@ -7367,15 +7367,15 @@ cAudioManager::ProcessSawMillScriptObject(uint8 sound) m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_SAWMILL; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nCounter = 1; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_bReleasingSoundFlag = true; + m_sQueueSample.m_bReleasingSoundFlag = TRUE; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_nLoopStart = 0; m_sQueueSample.m_nLoopEnd = -1; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); gSawMillNextTime = time + 2000 + m_anRandomTable[3] % 4000; } @@ -7403,16 +7403,16 @@ cAudioManager::ProcessLaunderetteScriptObject(uint8 sound) m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_LAUNDERETTE; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_LAUNDERETTE_LOOP); m_sQueueSample.m_nCounter = 0; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeModificator = 5; m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_nEmittingVolume = 45; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); } m_sQueueSample.m_nVolume = ComputeVolume(110, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); @@ -7421,16 +7421,16 @@ cAudioManager::ProcessLaunderetteScriptObject(uint8 sound) m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_LAUNDERETTE; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_LAUNDERETTE_SONG_LOOP); m_sQueueSample.m_nCounter = 1; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_nEmittingVolume = 110; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); } } @@ -7460,16 +7460,16 @@ cAudioManager::ProcessShopScriptObject(uint8 sound) m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_SHOP; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_SHOP_LOOP); m_sQueueSample.m_nCounter = 0; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeModificator = 5; m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_nEmittingVolume = 30; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); } time = CTimer::GetTimeInMilliseconds(); @@ -7481,16 +7481,16 @@ cAudioManager::ProcessShopScriptObject(uint8 sound) m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_SHOP; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nCounter = rand + 1; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_bReleasingSoundFlag = true; + m_sQueueSample.m_bReleasingSoundFlag = TRUE; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_nEmittingVolume = 70; m_sQueueSample.m_nLoopStart = 0; m_sQueueSample.m_nLoopEnd = -1; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); gShopNextTime = time + 3000 + m_anRandomTable[3] % 7000; } @@ -7524,16 +7524,16 @@ cAudioManager::ProcessAirportScriptObject(uint8 sound) m_sQueueSample.m_nBankIndex = SFX_BANK_BUILDING_AIRPORT; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nCounter = iSound++; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_bReleasingSoundFlag = true; + m_sQueueSample.m_bReleasingSoundFlag = TRUE; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_nEmittingVolume = 110; m_sQueueSample.m_nLoopStart = 0; m_sQueueSample.m_nLoopEnd = -1; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); gAirportNextTime = time + 10000 + m_anRandomTable[3] % 20000; } @@ -7571,16 +7571,16 @@ cAudioManager::ProcessCinemaScriptObject(uint8 sound) m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 4); m_sQueueSample.m_nCounter = iSound++; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_bReleasingSoundFlag = true; + m_sQueueSample.m_bReleasingSoundFlag = TRUE; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_nEmittingVolume = rand; m_sQueueSample.m_nLoopStart = 0; m_sQueueSample.m_nLoopEnd = -1; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); gCinemaNextTime = time + 1000 + m_anRandomTable[3] % 4000; } @@ -7620,16 +7620,16 @@ cAudioManager::ProcessDocksScriptObject(uint8 sound) m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_DOCKS_FOGHORN); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 8); m_sQueueSample.m_nCounter = iSound++; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_bReleasingSoundFlag = true; + m_sQueueSample.m_bReleasingSoundFlag = TRUE; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_nEmittingVolume = rand; m_sQueueSample.m_nLoopStart = 0; m_sQueueSample.m_nLoopEnd = -1; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); gDocksNextTime = time + 10000 + m_anRandomTable[3] % 40000; } @@ -7668,16 +7668,16 @@ cAudioManager::ProcessHomeScriptObject(uint8 sound) m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 16); m_sQueueSample.m_nCounter = iSound++; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_bReleasingSoundFlag = true; + m_sQueueSample.m_bReleasingSoundFlag = TRUE; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_nEmittingVolume = rand; m_sQueueSample.m_nLoopStart = 0; m_sQueueSample.m_nLoopEnd = -1; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = true; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = TRUE; AddSampleToRequestedQueue(); gHomeNextTime = time + 1000 + m_anRandomTable[3] % 4000; } @@ -7720,19 +7720,19 @@ cAudioManager::ProcessPoliceCellBeatingScriptObject(uint8 sound) m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 16); m_sQueueSample.m_nCounter = iSound++; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_bReleasingSoundFlag = true; + m_sQueueSample.m_bReleasingSoundFlag = TRUE; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_nEmittingVolume = emittingVol; m_sQueueSample.m_nLoopStart = 0; m_sQueueSample.m_nLoopEnd = -1; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); cPedParams params; - params.m_bDistanceCalculated = true; + params.m_bDistanceCalculated = TRUE; params.m_fDistance = distSquared; SetupPedComments(params, SOUND_INJURED_PED_MALE_PRISON); } @@ -7768,14 +7768,14 @@ cAudioManager::ProcessWeather(int32 id) m_sQueueSample.m_nCounter = iSound++; m_sQueueSample.m_nReleasingVolumeModificator = 0; m_sQueueSample.m_nOffset = (m_anRandomTable[2] & 15) + 55; - m_sQueueSample.m_bIs2D = true; + m_sQueueSample.m_bIs2D = TRUE; m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_bReleasingSoundFlag = true; + m_sQueueSample.m_bReleasingSoundFlag = TRUE; m_sQueueSample.m_nEmittingVolume = m_sQueueSample.m_nVolume; m_sQueueSample.m_nLoopStart = 0; m_sQueueSample.m_nLoopEnd = -1; - m_sQueueSample.m_bReverbFlag = false; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReverbFlag = FALSE; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); } if (CWeather::Rain > 0.0f && (!CCullZones::CamNoRain() || !CCullZones::PlayerNoRain())) { @@ -7786,15 +7786,15 @@ cAudioManager::ProcessWeather(int32 id) m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nReleasingVolumeModificator = 0; m_sQueueSample.m_nOffset = 63; - m_sQueueSample.m_bIs2D = true; + m_sQueueSample.m_bIs2D = TRUE; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 30; - m_sQueueSample.m_bReverbFlag = false; + m_sQueueSample.m_bReverbFlag = FALSE; m_sQueueSample.m_nEmittingVolume = m_sQueueSample.m_nVolume; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); } } @@ -7802,10 +7802,10 @@ cAudioManager::ProcessWeather(int32 id) void cAudioManager::ProcessFrontEnd() { - bool stereo; - bool processedPickup; - bool processedMission; - bool frontendBank; + bool8 stereo; + bool8 processedPickup; + bool8 processedMission; + bool8 frontendBank; int16 sample; static uint8 iSound = 0; @@ -7813,10 +7813,10 @@ cAudioManager::ProcessFrontEnd() static uint32 cPartMisComNextFrame = 0; for (uint32 i = 0; i < m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_AudioEvents; i++) { - processedPickup = false; - stereo = false; - processedMission = false; - frontendBank = false; + processedPickup = FALSE; + stereo = FALSE; + processedMission = FALSE; + frontendBank = FALSE; switch (m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_awAudioEvent[i]) { case SOUND_WEAPON_SNIPER_SHOT_NO_ZOOM: m_sQueueSample.m_nSampleIndex = SFX_ERROR_FIRE_RIFLE; @@ -7828,7 +7828,7 @@ cAudioManager::ProcessFrontEnd() case SOUND_GARAGE_BAD_VEHICLE: case SOUND_GARAGE_BOMB_ALREADY_SET: m_sQueueSample.m_nSampleIndex = SFX_PICKUP_ERROR_LEFT; - stereo = true; + stereo = TRUE; break; case SOUND_GARAGE_OPENING: case SOUND_GARAGE_BOMB1_SET: @@ -7844,19 +7844,19 @@ cAudioManager::ProcessFrontEnd() case SOUND_EVIDENCE_PICKUP: case SOUND_UNLOAD_GOLD: m_sQueueSample.m_nSampleIndex = SFX_PICKUP_2_LEFT; - processedPickup = true; - stereo = true; + processedPickup = TRUE; + stereo = TRUE; break; case SOUND_PICKUP_WEAPON_BOUGHT: case SOUND_PICKUP_WEAPON: m_sQueueSample.m_nSampleIndex = SFX_PICKUP_1_LEFT; - processedPickup = true; - stereo = true; + processedPickup = TRUE; + stereo = TRUE; break; case SOUND_PICKUP_ERROR: m_sQueueSample.m_nSampleIndex = SFX_PICKUP_ERROR_LEFT; - processedPickup = true; - stereo = true; + processedPickup = TRUE; + stereo = TRUE; break; case SOUND_PICKUP_BONUS: case SOUND_PICKUP_MONEY: @@ -7865,8 +7865,8 @@ cAudioManager::ProcessFrontEnd() case SOUND_PICKUP_PACMAN_PACKAGE: case SOUND_PICKUP_FLOAT_PACKAGE: m_sQueueSample.m_nSampleIndex = SFX_PICKUP_3_LEFT; - processedPickup = true; - stereo = true; + processedPickup = TRUE; + stereo = TRUE; break; case SOUND_PAGER: // TODO: ps2 code @@ -7883,49 +7883,49 @@ cAudioManager::ProcessFrontEnd() break; case SOUND_PART_MISSION_COMPLETE: m_sQueueSample.m_nSampleIndex = SFX_PART_MISSION_COMPLETE; - processedMission = true; + processedMission = TRUE; break; case SOUND_FRONTEND_MENU_STARTING: m_sQueueSample.m_nSampleIndex = SFX_START_BUTTON_LEFT; - stereo = true; + stereo = TRUE; break; case SOUND_FRONTEND_MENU_NEW_PAGE: m_sQueueSample.m_nSampleIndex = SFX_PAGE_CHANGE_AND_BACK_LEFT; - stereo = true; - frontendBank = true; + stereo = TRUE; + frontendBank = TRUE; break; case SOUND_FRONTEND_MENU_NAVIGATION: m_sQueueSample.m_nSampleIndex = SFX_HIGHLIGHT_LEFT; - stereo = true; - frontendBank = true; + stereo = TRUE; + frontendBank = TRUE; break; case SOUND_FRONTEND_MENU_SETTING_CHANGE: m_sQueueSample.m_nSampleIndex = SFX_SELECT_LEFT; - stereo = true; - frontendBank = true; + stereo = TRUE; + frontendBank = TRUE; break; case SOUND_FRONTEND_MENU_BACK: m_sQueueSample.m_nSampleIndex = SFX_SUB_MENU_BACK_LEFT; - stereo = true; - frontendBank = true; + stereo = TRUE; + frontendBank = TRUE; break; case SOUND_FRONTEND_STEREO: m_sQueueSample.m_nSampleIndex = SFX_STEREO_LEFT; - stereo = true; - frontendBank = true; + stereo = TRUE; + frontendBank = TRUE; break; case SOUND_FRONTEND_MONO: m_sQueueSample.m_nSampleIndex = SFX_MONO; - frontendBank = true; + frontendBank = TRUE; break; case SOUND_FRONTEND_AUDIO_TEST: m_sQueueSample.m_nSampleIndex = m_anRandomTable[0] % 3 + SFX_NOISE_BURST_1; - frontendBank = true; + frontendBank = TRUE; break; case SOUND_FRONTEND_FAIL: m_sQueueSample.m_nSampleIndex = SFX_ERROR_LEFT; - frontendBank = true; - stereo = true; + frontendBank = TRUE; + stereo = TRUE; break; case SOUND_FRONTEND_RADIO_TURN_OFF: case SOUND_FRONTEND_RADIO_CHANGE: @@ -7962,10 +7962,10 @@ cAudioManager::ProcessFrontEnd() m_sQueueSample.m_nVolume = 110; m_sQueueSample.m_nCounter = iSound++; m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_bReleasingSoundFlag = true; + m_sQueueSample.m_bReleasingSoundFlag = TRUE; m_sQueueSample.m_nBankIndex = frontendBank ? SFX_BANK_FRONT_END_MENU : SFX_BANK_0; m_sQueueSample.m_nReleasingVolumeModificator = 0; - m_sQueueSample.m_bIs2D = true; + m_sQueueSample.m_bIs2D = TRUE; m_sQueueSample.m_nEmittingVolume = m_sQueueSample.m_nVolume; m_sQueueSample.m_nLoopStart = 0; m_sQueueSample.m_nLoopEnd = -1; @@ -7973,8 +7973,8 @@ cAudioManager::ProcessFrontEnd() m_sQueueSample.m_nOffset = m_anRandomTable[0] & 31; else m_sQueueSample.m_nOffset = 63; - m_sQueueSample.m_bReverbFlag = false; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReverbFlag = FALSE; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); if (stereo) { ++m_sQueueSample.m_nSampleIndex; @@ -7990,7 +7990,7 @@ cAudioManager::ProcessCrane() { CCrane *crane = (CCrane *)m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_pEntity; float distSquared; - bool distCalculated = false; + bool8 distCalculated = FALSE; static const int intensity = 80; if (crane) { @@ -8005,7 +8005,7 @@ cAudioManager::ProcessCrane() m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_nSampleIndex = SFX_CRANE_MAGNET; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nReleasingVolumeModificator = 2; m_sQueueSample.m_nFrequency = 6000; m_sQueueSample.m_nLoopCount = 0; @@ -8014,10 +8014,10 @@ cAudioManager::ProcessCrane() m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 4.0f; m_sQueueSample.m_fSoundIntensity = intensity; - m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 3; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); } if (m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_AudioEvents) { @@ -8025,9 +8025,9 @@ cAudioManager::ProcessCrane() m_sQueueSample.m_nSampleIndex = SFX_COL_CAR_2; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_COL_CAR_2); m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_bReleasingSoundFlag = true; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = true; + m_sQueueSample.m_bReleasingSoundFlag = TRUE; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = TRUE; AddSampleToRequestedQueue(); } } @@ -8075,14 +8075,14 @@ cAudioManager::ProcessProjectiles() m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = i; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nEmittingVolume = emittingVol; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_bReleasingSoundFlag = false; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReleasingSoundFlag = FALSE; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); } } @@ -8100,7 +8100,7 @@ cAudioManager::ProcessGarages() uint32 sampleIndex; uint8 j; float distSquared; - bool distCalculated; + bool8 distCalculated; static uint8 iSound = 32; @@ -8111,7 +8111,7 @@ cAudioManager::ProcessGarages() if (entity == nil) continue; m_sQueueSample.m_vecPos = entity->GetPosition(); - distCalculated = false; + distCalculated = FALSE; distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos); if (distSquared < SQR(SOUND_INTENSITY)) { state = CGarages::aGarages[i].m_eGarageState; @@ -8131,7 +8131,7 @@ cAudioManager::ProcessGarages() m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex) / 2; m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 16); m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_bReleasingSoundFlag = true; + m_sQueueSample.m_bReleasingSoundFlag = TRUE; m_sQueueSample.m_nCounter = iSound++; if (iSound < 32) iSound = 32; @@ -8143,7 +8143,7 @@ cAudioManager::ProcessGarages() m_sQueueSample.m_nCounter = i; m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nReleasingVolumeDivider = 3; - m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_bReleasingSoundFlag = FALSE; } } else { m_sQueueSample.m_nSampleIndex = SFX_GARAGE_DOOR_LOOP; @@ -8152,19 +8152,19 @@ cAudioManager::ProcessGarages() m_sQueueSample.m_nCounter = i; m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nReleasingVolumeDivider = 3; - m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_bReleasingSoundFlag = FALSE; } m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_nEmittingVolume = 90; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); } break; @@ -8193,16 +8193,16 @@ cAudioManager::ProcessGarages() m_sQueueSample.m_nEmittingVolume = 60; m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_bReleasingSoundFlag = true; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bIs2D = FALSE; + m_sQueueSample.m_bReleasingSoundFlag = TRUE; m_sQueueSample.m_nLoopCount = 1; m_sQueueSample.m_nLoopStart = 0; m_sQueueSample.m_nLoopEnd = -1; m_sQueueSample.m_nCounter = iSound++; if (iSound < 32) iSound = 32; - m_sQueueSample.m_bRequireReflection = true; + m_sQueueSample.m_bRequireReflection = TRUE; AddSampleToRequestedQueue(); } } @@ -8218,7 +8218,7 @@ void cAudioManager::ProcessFireHydrant() { float distSquared; - bool distCalculated = false; + bool8 distCalculated = FALSE; static const int intensity = 35; m_sQueueSample.m_vecPos = ((CEntity *)m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_pEntity)->GetPosition(); @@ -8230,7 +8230,7 @@ cAudioManager::ProcessFireHydrant() m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_nSampleIndex = SFX_JUMBO_TAXI; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nReleasingVolumeModificator = 4; m_sQueueSample.m_nFrequency = 15591; m_sQueueSample.m_nLoopCount = 0; @@ -8239,10 +8239,10 @@ cAudioManager::ProcessFireHydrant() m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_fSoundIntensity = intensity; - m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 3; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); } } @@ -8255,7 +8255,7 @@ void cAudioManager::ProcessBridge() { float dist; - bool distCalculated = false; + bool8 distCalculated = FALSE; if (CBridge::pLiftRoad) { m_sQueueSample.m_vecPos = CBridge::pLiftRoad->GetPosition(); @@ -8290,7 +8290,7 @@ cAudioManager::ProcessBridgeWarning() m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_nSampleIndex = SFX_BRIDGE_OPEN_WARNING; m_sQueueSample.m_nBankIndex = SFX_BANK_GENERIC_EXTRA; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_BRIDGE_OPEN_WARNING); m_sQueueSample.m_nLoopCount = 0; @@ -8299,10 +8299,10 @@ cAudioManager::ProcessBridgeWarning() m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_fSoundIntensity = 450.0f; - m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 8; - m_sQueueSample.m_bReverbFlag = false; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReverbFlag = FALSE; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); } } @@ -8317,7 +8317,7 @@ cAudioManager::ProcessBridgeMotor() m_sQueueSample.m_nCounter = 1; m_sQueueSample.m_nSampleIndex = SFX_FISHING_BOAT_IDLE; // todo check sfx name m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nFrequency = 5500; m_sQueueSample.m_nLoopCount = 0; @@ -8326,9 +8326,9 @@ cAudioManager::ProcessBridgeMotor() m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_fSoundIntensity = bridgeIntensity; - m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nReleasingVolumeDivider = 3; - m_sQueueSample.m_bReverbFlag = false; + m_sQueueSample.m_bReverbFlag = FALSE; AddSampleToRequestedQueue(); } } @@ -8352,7 +8352,7 @@ cAudioManager::ProcessBridgeOneShots() if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 2; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopCount = 1; @@ -8361,9 +8361,9 @@ cAudioManager::ProcessBridgeOneShots() m_sQueueSample.m_nLoopEnd = -1; m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_fSoundIntensity = bridgeIntensity; - m_sQueueSample.m_bReleasingSoundFlag = true; - m_sQueueSample.m_bReverbFlag = false; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bReleasingSoundFlag = TRUE; + m_sQueueSample.m_bReverbFlag = FALSE; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); } } @@ -8371,7 +8371,7 @@ cAudioManager::ProcessBridgeOneShots() #pragma endregion #pragma region MISSION_AUDIO -bool g_bMissionAudioLoadFailed; +bool8 g_bMissionAudioLoadFailed; struct MissionAudioData { const char *m_pName; @@ -8425,7 +8425,7 @@ FindMissionAudioSfx(const char *name) return NO_SAMPLE; } -bool +bool8 cAudioManager::MissionScriptAudioUsesPoliceChannel(int32 soundMission) const { switch (soundMission) { @@ -8441,9 +8441,9 @@ cAudioManager::MissionScriptAudioUsesPoliceChannel(int32 soundMission) const case STREAMED_SOUND_MISSION_R5_A: case STREAMED_SOUND_MISSION_LO2_A: case STREAMED_SOUND_MISSION_LO6_A: - return true; + return TRUE; default: - return false; + return FALSE; } } @@ -8456,12 +8456,12 @@ cAudioManager::PreloadMissionAudio(Const char *name) m_sMissionAudio.m_nSampleIndex = missionAudioSfx; m_sMissionAudio.m_nLoadingStatus = LOADING_STATUS_NOT_LOADED; m_sMissionAudio.m_nPlayStatus = PLAY_STATUS_STOPPED; - m_sMissionAudio.m_bIsPlaying = false; + m_sMissionAudio.m_bIsPlaying = FALSE; m_sMissionAudio.m_nMissionAudioCounter = m_nTimeSpent * SampleManager.GetStreamedFileLength(missionAudioSfx) / 1000; m_sMissionAudio.m_nMissionAudioCounter *= 4; - m_sMissionAudio.m_bIsPlayed = false; - m_sMissionAudio.m_bPredefinedProperties = true; - g_bMissionAudioLoadFailed = false; + m_sMissionAudio.m_bIsPlayed = FALSE; + m_sMissionAudio.m_bPredefinedProperties = TRUE; + g_bMissionAudioLoadFailed = FALSE; } } } @@ -8479,7 +8479,7 @@ void cAudioManager::SetMissionAudioLocation(float x, float y, float z) { if (m_bIsInitialised) { - m_sMissionAudio.m_bPredefinedProperties = false; + m_sMissionAudio.m_bPredefinedProperties = FALSE; m_sMissionAudio.m_vecPos = CVector(x, y, z); } } @@ -8489,10 +8489,10 @@ cAudioManager::PlayLoadedMissionAudio() { if (m_bIsInitialised && m_sMissionAudio.m_nSampleIndex != NO_SAMPLE && m_sMissionAudio.m_nLoadingStatus == LOADING_STATUS_LOADED && m_sMissionAudio.m_nPlayStatus == PLAY_STATUS_STOPPED) - m_sMissionAudio.m_bIsPlayed = true; + m_sMissionAudio.m_bIsPlayed = TRUE; } -bool +bool8 cAudioManager::IsMissionAudioSampleFinished() { if (m_bIsInitialised) @@ -8510,9 +8510,9 @@ cAudioManager::ClearMissionAudio() m_sMissionAudio.m_nSampleIndex = NO_SAMPLE; m_sMissionAudio.m_nLoadingStatus = LOADING_STATUS_NOT_LOADED; m_sMissionAudio.m_nPlayStatus = PLAY_STATUS_STOPPED; - m_sMissionAudio.m_bIsPlaying = false; - m_sMissionAudio.m_bIsPlayed = false; - m_sMissionAudio.m_bPredefinedProperties = true; + m_sMissionAudio.m_bIsPlaying = FALSE; + m_sMissionAudio.m_bIsPlayed = FALSE; + m_sMissionAudio.m_bPredefinedProperties = TRUE; m_sMissionAudio.m_nMissionAudioCounter = 0; } } @@ -8565,9 +8565,9 @@ cAudioManager::ProcessMissionAudio() SetMissionScriptPoliceAudio(m_sMissionAudio.m_nSampleIndex); } else { if (m_nUserPause) - SampleManager.PauseStream(1, 1); + SampleManager.PauseStream(TRUE, 1); if (m_sMissionAudio.m_bPredefinedProperties) { - SampleManager.SetStreamedVolumeAndPan(80, 63, 1, 1); + SampleManager.SetStreamedVolumeAndPan(80, 63, TRUE, 1); } else { distSquared = GetDistanceSquared(m_sMissionAudio.m_vecPos); if (distSquared >= SQR(50.0f)) { @@ -8579,7 +8579,7 @@ cAudioManager::ProcessMissionAudio() TranslateEntity(&m_sMissionAudio.m_vecPos, &vec); pan = ComputePan(50.f, &vec); } - SampleManager.SetStreamedVolumeAndPan(emittingVol, pan, 1, 1); + SampleManager.SetStreamedVolumeAndPan(emittingVol, pan, TRUE, 1); } SampleManager.StartPreloadedStreamedFile(1); } @@ -8606,9 +8606,9 @@ cAudioManager::ProcessMissionAudio() } else if (m_sMissionAudio.m_bIsPlaying) { if (SampleManager.IsStreamPlaying(1) || m_nUserPause || m_nPreviousUserPause) { if (m_nUserPause) - SampleManager.PauseStream(1, 1); + SampleManager.PauseStream(TRUE, 1); else - SampleManager.PauseStream(0, 1); + SampleManager.PauseStream(FALSE, 1); } else { m_sMissionAudio.m_nPlayStatus = PLAY_STATUS_FINISHED; m_sMissionAudio.m_nSampleIndex = NO_SAMPLE; @@ -8623,7 +8623,7 @@ cAudioManager::ProcessMissionAudio() break; nCheckPlayingDelay = 0; } - m_sMissionAudio.m_bIsPlaying = true; + m_sMissionAudio.m_bIsPlaying = TRUE; } break; default: @@ -8633,7 +8633,7 @@ cAudioManager::ProcessMissionAudio() case LOADING_STATUS_FAILED: if (++nFramesUntilFailedLoad >= 90) { nFramesForPretendPlaying = 0; - g_bMissionAudioLoadFailed = true; + g_bMissionAudioLoadFailed = TRUE; nFramesUntilFailedLoad = 0; m_sMissionAudio.m_nLoadingStatus = LOADING_STATUS_LOADED; } diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index f61350fb..c15d04bd 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -22,8 +22,8 @@ const int allChannels = channels + 2; cAudioManager::cAudioManager() { - m_bIsInitialised = false; - m_bReverb = true; + m_bIsInitialised = FALSE; + m_bReverb = TRUE; m_fSpeedOfSound = SPEED_OF_SOUND / TIME_SPENT; m_nTimeSpent = TIME_SPENT; m_nActiveSamples = NUM_SOUNDS_SAMPLES_SLOTS; @@ -34,16 +34,16 @@ cAudioManager::cAudioManager() ClearActiveSamples(); GenerateIntegerRandomNumberTable(); field_4 = 0; - m_bDynamicAcousticModelingStatus = true; + m_bDynamicAcousticModelingStatus = TRUE; for (int i = 0; i < NUM_AUDIOENTITIES; i++) { - m_asAudioEntities[i].m_bIsUsed = false; + m_asAudioEntities[i].m_bIsUsed = FALSE; m_anAudioEntityIndices[i] = NUM_AUDIOENTITIES; } m_nAudioEntitiesTotal = 0; m_FrameCounter = 0; - m_bFifthFrameFlag = false; - m_bTimerJustReset = false; + m_bFifthFrameFlag = FALSE; + m_bTimerJustReset = FALSE; m_nTimer = 0; } @@ -81,7 +81,7 @@ cAudioManager::Terminate() MusicManager.Terminate(); for (uint32 i = 0; i < NUM_AUDIOENTITIES; i++) { - m_asAudioEntities[i].m_bIsUsed = false; + m_asAudioEntities[i].m_bIsUsed = FALSE; m_anAudioEntityIndices[i] = ARRAY_SIZE(m_anAudioEntityIndices); } @@ -96,7 +96,7 @@ cAudioManager::Terminate() SampleManager.Terminate(); - m_bIsInitialised = false; + m_bIsInitialised = FALSE; PostTerminateGameSpecificShutdown(); } } @@ -108,7 +108,7 @@ cAudioManager::Service() if (m_bTimerJustReset) { ResetAudioLogicTimers(m_nTimer); MusicManager.ResetTimers(m_nTimer); - m_bTimerJustReset = false; + m_bTimerJustReset = FALSE; } if (m_bIsInitialised) { m_nPreviousUserPause = m_nUserPause; @@ -130,8 +130,8 @@ cAudioManager::CreateEntity(eAudioType type, void *entity) return AEHANDLE_ERROR_BADAUDIOTYPE; for (uint32 i = 0; i < ARRAY_SIZE(m_asAudioEntities); i++) { if (!m_asAudioEntities[i].m_bIsUsed) { - m_asAudioEntities[i].m_bIsUsed = true; - m_asAudioEntities[i].m_bStatus = false; + m_asAudioEntities[i].m_bIsUsed = TRUE; + m_asAudioEntities[i].m_bStatus = FALSE; m_asAudioEntities[i].m_nType = type; m_asAudioEntities[i].m_pEntity = entity; m_asAudioEntities[i].m_awAudioEvent[0] = SOUND_NO_SOUND; @@ -150,7 +150,7 @@ void cAudioManager::DestroyEntity(int32 id) { if (m_bIsInitialised && id >= 0 && id < NUM_AUDIOENTITIES && m_asAudioEntities[id].m_bIsUsed) { - m_asAudioEntities[id].m_bIsUsed = false; + m_asAudioEntities[id].m_bIsUsed = FALSE; for (int32 i = 0; i < m_nAudioEntitiesTotal; ++i) { if (id == m_anAudioEntityIndices[i]) { if (i < NUM_AUDIOENTITIES - 1) @@ -163,7 +163,7 @@ cAudioManager::DestroyEntity(int32 id) } void -cAudioManager::SetEntityStatus(int32 id, uint8 status) +cAudioManager::SetEntityStatus(int32 id, bool8 status) { if (m_bIsInitialised && id >= 0 && id < NUM_AUDIOENTITIES && m_asAudioEntities[id].m_bIsUsed) m_asAudioEntities[id].m_bStatus = status; @@ -191,7 +191,7 @@ cAudioManager::PlayOneShot(int32 index, uint16 sound, float vol) } } else { int32 i = 0; - while (true) { + while (TRUE) { if (i >= entity.m_AudioEvents) { if (entity.m_AudioEvents < ARRAY_SIZE(entity.m_awAudioEvent)) { entity.m_awAudioEvent[i] = sound; @@ -238,7 +238,7 @@ cAudioManager::SetEffectsFadeVol(uint8 volume) const } void -cAudioManager::SetMonoMode(uint8 mono) +cAudioManager::SetMonoMode(bool8 mono) { SampleManager.SetMonoMode(mono); } @@ -253,7 +253,7 @@ void cAudioManager::ResetTimers(uint32 time) { if (m_bIsInitialised) { - m_bTimerJustReset = true; + m_bTimerJustReset = TRUE; m_nTimer = time; ClearRequestedQueue(); if (m_nActiveSampleQueue) { @@ -372,13 +372,13 @@ cAudioManager::SetSpeakerConfig(int32 conf) const SampleManager.SetSpeakerConfig(conf); } -bool +bool8 cAudioManager::IsMP3RadioChannelAvailable() const { if (m_bIsInitialised) return SampleManager.IsMP3RadioChannelAvailable(); - return false; + return FALSE; } void @@ -398,12 +398,12 @@ cAudioManager::ReacquireDigitalHandle() const } void -cAudioManager::SetDynamicAcousticModelingStatus(uint8 status) +cAudioManager::SetDynamicAcousticModelingStatus(bool8 status) { - m_bDynamicAcousticModelingStatus = status!=0; + m_bDynamicAcousticModelingStatus = status; } -bool +bool8 cAudioManager::CheckForAnAudioFileOnCD() const { return SampleManager.CheckForAnAudioFileOnCD(); @@ -418,7 +418,7 @@ cAudioManager::GetCDAudioDriveLetter() const return 0; } -bool +bool8 cAudioManager::IsAudioInitialised() const { return m_bIsInitialised; @@ -527,7 +527,7 @@ cAudioManager::RandomDisplacement(uint32 seed) const { int32 value; - static bool bPos = true; + static bool8 bPos = TRUE; static uint32 Adjustment = 0; if (!seed) @@ -558,7 +558,7 @@ cAudioManager::AddSampleToRequestedQueue() { int32 calculatedVolume; uint8 sampleIndex; - bool bReflections; + bool8 bReflections; if (m_sQueueSample.m_nSampleIndex < TOTAL_AUDIO_SAMPLES) { calculatedVolume = m_sQueueSample.m_nReleasingVolumeModificator * (MAX_VOLUME - m_sQueueSample.m_nVolume); @@ -571,21 +571,21 @@ cAudioManager::AddSampleToRequestedQueue() ++m_SampleRequestQueuesStatus[m_nActiveSampleQueue]; } m_sQueueSample.m_nCalculatedVolume = calculatedVolume; - m_sQueueSample.m_bLoopEnded = false; + m_sQueueSample.m_bLoopEnded = FALSE; if (m_sQueueSample.m_bIs2D) { - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bRequireReflection = FALSE; m_sQueueSample.m_nLoopsRemaining = 0; } if (m_bDynamicAcousticModelingStatus && m_sQueueSample.m_nLoopCount) { bReflections = m_sQueueSample.m_bRequireReflection; } else { - bReflections = false; + bReflections = FALSE; m_sQueueSample.m_nLoopsRemaining = 0; } - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bRequireReflection = FALSE; if (!m_bDynamicAcousticModelingStatus) - m_sQueueSample.m_bReverbFlag = false; + m_sQueueSample.m_bReverbFlag = FALSE; m_asSamples[m_nActiveSampleQueue][sampleIndex] = m_sQueueSample; @@ -692,7 +692,7 @@ cAudioManager::UpdateReflections() void cAudioManager::AddReleasingSounds() { - bool toProcess[44]; // why not 27? + bool8 toProcess[44]; // why not 27? because PS2? int8 queue = m_nActiveSampleQueue == 0 ? 1 : 0; @@ -701,11 +701,11 @@ cAudioManager::AddReleasingSounds() if (sample.m_bLoopEnded) continue; - toProcess[i] = false; + toProcess[i] = FALSE; for (int32 j = 0; j < m_SampleRequestQueuesStatus[m_nActiveSampleQueue]; j++) { if (sample.m_nEntityIndex == m_asSamples[m_nActiveSampleQueue][m_abSampleQueueIndexTable[m_nActiveSampleQueue][j]].m_nEntityIndex && sample.m_nCounter == m_asSamples[m_nActiveSampleQueue][m_abSampleQueueIndexTable[m_nActiveSampleQueue][j]].m_nCounter) { - toProcess[i] = true; + toProcess[i] = TRUE; break; } } @@ -741,7 +741,7 @@ cAudioManager::AddReleasingSounds() void cAudioManager::ProcessActiveQueues() { - bool flag; + bool8 flag; float position2; float position1; @@ -758,8 +758,8 @@ cAudioManager::ProcessActiveQueues() CVector position; for (int32 i = 0; i < m_nActiveSamples; i++) { - m_asSamples[m_nActiveSampleQueue][i].m_bIsProcessed = false; - m_asActiveSamples[i].m_bIsProcessed = false; + m_asSamples[m_nActiveSampleQueue][i].m_bIsProcessed = FALSE; + m_asActiveSamples[i].m_bIsProcessed = FALSE; } for (int32 i = 0; i < m_SampleRequestQueuesStatus[m_nActiveSampleQueue]; ++i) { @@ -775,15 +775,15 @@ cAudioManager::ProcessActiveQueues() flag = !(j & 1); } if (flag && !SampleManager.GetChannelUsedFlag(j)) { - sample.m_bLoopEnded = true; - m_asActiveSamples[j].m_bLoopEnded = true; + sample.m_bLoopEnded = TRUE; + m_asActiveSamples[j].m_bLoopEnded = TRUE; m_asActiveSamples[j].m_nSampleIndex = NO_SAMPLE; m_asActiveSamples[j].m_nEntityIndex = AEHANDLE_NONE; continue; } } - sample.m_bIsProcessed = true; - m_asActiveSamples[j].m_bIsProcessed = true; + sample.m_bIsProcessed = TRUE; + m_asActiveSamples[j].m_bIsProcessed = TRUE; sample.m_nVolumeChange = -1; if (!sample.m_bReleasingSoundFlag) { if (sample.m_bIs2D) { @@ -837,8 +837,8 @@ cAudioManager::ProcessActiveQueues() SampleManager.SetChannelReverbFlag(j, sample.m_bReverbFlag); break; } - sample.m_bIsProcessed = false; - m_asActiveSamples[j].m_bIsProcessed = false; + sample.m_bIsProcessed = FALSE; + m_asActiveSamples[j].m_bIsProcessed = FALSE; } } } @@ -902,8 +902,8 @@ cAudioManager::ProcessActiveQueues() SampleManager.SetChannel3DDistances(j, m_asActiveSamples[j].m_fSoundIntensity, 0.25f * m_asActiveSamples[j].m_fSoundIntensity); SampleManager.StartChannel(j); } - m_asActiveSamples[j].m_bIsProcessed = true; - sample.m_bIsProcessed = true; + m_asActiveSamples[j].m_bIsProcessed = TRUE; + sample.m_bIsProcessed = TRUE; sample.m_nVolumeChange = -1; break; } @@ -930,28 +930,28 @@ cAudioManager::ClearActiveSamples() m_asActiveSamples[i].m_nCounter = 0; m_asActiveSamples[i].m_nSampleIndex = NO_SAMPLE; m_asActiveSamples[i].m_nBankIndex = INVALID_SFX_BANK; - m_asActiveSamples[i].m_bIs2D = false; + m_asActiveSamples[i].m_bIs2D = FALSE; m_asActiveSamples[i].m_nReleasingVolumeModificator = 5; m_asActiveSamples[i].m_nFrequency = 0; m_asActiveSamples[i].m_nVolume = 0; m_asActiveSamples[i].m_nEmittingVolume = 0; m_asActiveSamples[i].m_fDistance = 0.0f; - m_asActiveSamples[i].m_bIsProcessed = false; - m_asActiveSamples[i].m_bLoopEnded = false; + m_asActiveSamples[i].m_bIsProcessed = FALSE; + m_asActiveSamples[i].m_bLoopEnded = FALSE; m_asActiveSamples[i].m_nLoopCount = 1; m_asActiveSamples[i].m_nLoopStart = 0; m_asActiveSamples[i].m_nLoopEnd = -1; m_asActiveSamples[i].m_fSpeedMultiplier = 0.0f; m_asActiveSamples[i].m_fSoundIntensity = 200.0f; m_asActiveSamples[i].m_nOffset = 63; - m_asActiveSamples[i].m_bReleasingSoundFlag = false; + m_asActiveSamples[i].m_bReleasingSoundFlag = FALSE; m_asActiveSamples[i].m_nCalculatedVolume = 0; m_asActiveSamples[i].m_nReleasingVolumeDivider = 0; m_asActiveSamples[i].m_nVolumeChange = -1; m_asActiveSamples[i].m_vecPos = CVector(0.0f, 0.0f, 0.0f); - m_asActiveSamples[i].m_bReverbFlag = false; + m_asActiveSamples[i].m_bReverbFlag = FALSE; m_asActiveSamples[i].m_nLoopsRemaining = 0; - m_asActiveSamples[i].m_bRequireReflection = false; + m_asActiveSamples[i].m_bRequireReflection = FALSE; } } diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index 57fbc818..edf5eb63 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -11,7 +11,7 @@ public: int32 m_nCounter; int32 m_nSampleIndex; uint8 m_nBankIndex; - bool m_bIs2D; + bool8 m_bIs2D; int32 m_nReleasingVolumeModificator; uint32 m_nFrequency; uint8 m_nVolume; @@ -22,15 +22,15 @@ public: uint8 m_nEmittingVolume; float m_fSpeedMultiplier; float m_fSoundIntensity; - bool m_bReleasingSoundFlag; + bool8 m_bReleasingSoundFlag; CVector m_vecPos; - bool m_bReverbFlag; + bool8 m_bReverbFlag; uint8 m_nLoopsRemaining; - bool m_bRequireReflection; // Used for oneshots + bool8 m_bRequireReflection; // Used for oneshots uint8 m_nOffset; int32 m_nReleasingVolumeDivider; - bool m_bIsProcessed; - bool m_bLoopEnded; + bool8 m_bIsProcessed; + bool8 m_bLoopEnded; int32 m_nCalculatedVolume; int8 m_nVolumeChange; }; @@ -45,7 +45,7 @@ class tAudioEntity public: eAudioType m_nType; void *m_pEntity; - bool m_bIsUsed; + bool8 m_bIsUsed; uint8 m_bStatus; int16 m_awAudioEvent[NUM_AUDIOENTITY_EVENTS]; float m_afVolume[NUM_AUDIOENTITY_EVENTS]; @@ -99,13 +99,13 @@ class cMissionAudio { public: CVector m_vecPos; - bool m_bPredefinedProperties; + bool8 m_bPredefinedProperties; int32 m_nSampleIndex; uint8 m_nLoadingStatus; uint8 m_nPlayStatus; - bool m_bIsPlaying; + bool8 m_bIsPlaying; int32 m_nMissionAudioCounter; - bool m_bIsPlayed; + bool8 m_bIsPlayed; }; VALIDATE_SIZE(cMissionAudio, 32); @@ -129,7 +129,7 @@ class CPed; class cPedParams { public: - bool m_bDistanceCalculated; + bool8 m_bDistanceCalculated; float m_fDistance; CPed *m_pPed; @@ -144,7 +144,7 @@ public: class cVehicleParams { public: - bool m_bDistanceCalculated; + bool8 m_bDistanceCalculated; float m_fDistance; CVehicle *m_pVehicle; cTransmission *m_pTransmission; @@ -184,14 +184,14 @@ enum { class cAudioManager { public: - bool m_bIsInitialised; - bool m_bReverb; // unused - bool m_bFifthFrameFlag; + bool8 m_bIsInitialised; + bool8 m_bReverb; // unused + bool8 m_bFifthFrameFlag; uint8 m_nActiveSamples; uint8 field_4; // unused - bool m_bDynamicAcousticModelingStatus; + bool8 m_bDynamicAcousticModelingStatus; float m_fSpeedOfSound; - bool m_bTimerJustReset; + bool8 m_bTimerJustReset; int32 m_nTimer; tSound m_sQueueSample; uint8 m_nActiveSampleQueue; @@ -230,19 +230,19 @@ public: 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; } - bool ShouldDuckMissionAudio() const { return m_sMissionAudio.m_nPlayStatus == 1; } + bool8 ShouldDuckMissionAudio() const { return m_sMissionAudio.m_nPlayStatus == 1; } // "Should" be in alphabetic order, except "getXTalkSfx" void AddDetailsToRequestedOrderList(uint8 sample); void AddPlayerCarSample(uint8 emittingVolume, int32 freq, uint32 sample, uint8 bank, - uint8 counter, bool notLooping); + uint8 counter, bool8 notLooping); void AddReflectionsToRequestedQueue(); void AddReleasingSounds(); void AddSampleToRequestedQueue(); void AgeCrimes(); - void CalculateDistance(bool &condition, float dist); - bool CheckForAnAudioFileOnCD() const; + void CalculateDistance(bool8 &condition, float dist); + bool8 CheckForAnAudioFileOnCD() const; void ClearActiveSamples(); void ClearMissionAudio(); void ClearRequestedQueue(); @@ -355,17 +355,17 @@ public: float GetVehicleNonDriveWheelSkidValue(uint8 wheel, CAutomobile *automobile, cTransmission *transmission, float velocityChange); - bool HasAirBrakes(int32 model) const; + bool8 HasAirBrakes(int32 model) const; void Initialise(); void InitialisePoliceRadio(); void InitialisePoliceRadioZones(); void InterrogateAudioEntities(); - bool IsAudioInitialised() const; - bool IsMissionAudioSampleFinished(); - bool IsMP3RadioChannelAvailable() const; + bool8 IsAudioInitialised() const; + bool8 IsMissionAudioSampleFinished(); + bool8 IsMP3RadioChannelAvailable() const; - bool MissionScriptAudioUsesPoliceChannel(int32 soundMission) const; + bool8 MissionScriptAudioUsesPoliceChannel(int32 soundMission) const; void PlayLoadedMissionAudio(); void PlayOneShot(int32 index, uint16 sound, float vol); @@ -379,27 +379,27 @@ public: void PreTerminateGameSpecificShutdown(); /// processX - main logic of adding new sounds void ProcessActiveQueues(); - bool ProcessAirBrakes(cVehicleParams& params); + bool8 ProcessAirBrakes(cVehicleParams& params); void ProcessAirportScriptObject(uint8 sound); - bool ProcessBoatEngine(cVehicleParams& params); - bool ProcessBoatMovingOverWater(cVehicleParams& params); + bool8 ProcessBoatEngine(cVehicleParams& params); + bool8 ProcessBoatMovingOverWater(cVehicleParams& params); void ProcessBridge(); void ProcessBridgeMotor(); void ProcessBridgeOneShots(); void ProcessBridgeWarning(); - bool ProcessCarBombTick(cVehicleParams& params); + bool8 ProcessCarBombTick(cVehicleParams& params); void ProcessCesna(cVehicleParams& params); void ProcessCinemaScriptObject(uint8 sound); void ProcessCrane(); void ProcessDocksScriptObject(uint8 sound); - bool ProcessEngineDamage(cVehicleParams& params); + bool8 ProcessEngineDamage(cVehicleParams& params); void ProcessEntity(int32 sound); void ProcessExplosions(int32 explosion); void ProcessFireHydrant(); void ProcessFires(int32 entity); void ProcessFrontEnd(); void ProcessGarages(); - bool ProcessHelicopter(cVehicleParams& params); + bool8 ProcessHelicopter(cVehicleParams& params); void ProcessHomeScriptObject(uint8 sound); void ProcessJumbo(cVehicleParams& params); void ProcessJumboAccel(CPlane *plane); @@ -424,24 +424,24 @@ public: void ProcessProjectiles(); void ProcessRainOnVehicle(cVehicleParams& params); void ProcessReverb() const; - bool ProcessReverseGear(cVehicleParams& params); + bool8 ProcessReverseGear(cVehicleParams& params); void ProcessSawMillScriptObject(uint8 sound); void ProcessScriptObject(int32 id); void ProcessShopScriptObject(uint8 sound); void ProcessSpecial(); - bool ProcessTrainNoise(cVehicleParams& params); + bool8 ProcessTrainNoise(cVehicleParams& params); void ProcessVehicle(CVehicle *vehicle); - bool ProcessVehicleDoors(cVehicleParams& params); + bool8 ProcessVehicleDoors(cVehicleParams& params); void ProcessVehicleEngine(cVehicleParams& params); void ProcessVehicleHorn(cVehicleParams& params); void ProcessVehicleOneShots(cVehicleParams& params); - bool ProcessVehicleReverseWarning(cVehicleParams& params); - bool ProcessVehicleRoadNoise(cVehicleParams& params); - bool ProcessVehicleSirenOrAlarm(cVehicleParams& params); - bool ProcessVehicleSkidding(cVehicleParams& params); + bool8 ProcessVehicleReverseWarning(cVehicleParams& params); + bool8 ProcessVehicleRoadNoise(cVehicleParams& params); + bool8 ProcessVehicleSirenOrAlarm(cVehicleParams& params); + bool8 ProcessVehicleSkidding(cVehicleParams& params); void ProcessWaterCannon(int32); void ProcessWeather(int32 id); - bool ProcessWetRoadNoise(cVehicleParams& params); + bool8 ProcessWetRoadNoise(cVehicleParams& params); void ProcessWorkShopScriptObject(uint8 sound); int32 RandomDisplacement(uint32 seed) const; @@ -460,25 +460,25 @@ public: void ServicePoliceRadioChannel(uint8 wantedLevel); void ServiceSoundEffects(); int8 SetCurrent3DProvider(uint8 which); - void SetDynamicAcousticModelingStatus(uint8 status); + void SetDynamicAcousticModelingStatus(bool8 status); void SetEffectsFadeVol(uint8 volume) const; void SetEffectsMasterVolume(uint8 volume) const; - void SetEntityStatus(int32 id, uint8 status); + void SetEntityStatus(int32 id, bool8 status); uint32 SetLoopingCollisionRequestedSfxFreqAndGetVol(const cAudioCollision &audioCollision); void SetMissionAudioLocation(float x, float y, float z); void SetMissionScriptPoliceAudio(int32 sfx) const; - void SetMonoMode(uint8 mono); + void SetMonoMode(bool8 mono); void SetMusicFadeVol(uint8 volume) const; void SetMusicMasterVolume(uint8 volume) const; void SetSpeakerConfig(int32 conf) const; void SetUpLoopingCollisionSound(const cAudioCollision &col, uint8 counter); void SetUpOneShotCollisionSound(const cAudioCollision &col); - bool SetupCrimeReport(); - bool SetupJumboEngineSound(uint8 vol, uint32 freq); - bool SetupJumboFlySound(uint8 emittingVol); - bool SetupJumboRumbleSound(uint8 emittingVol); - bool SetupJumboTaxiSound(uint8 vol); - bool SetupJumboWhineSound(uint8 emittingVol, uint32 freq); + bool8 SetupCrimeReport(); + bool8 SetupJumboEngineSound(uint8 vol, uint32 freq); + bool8 SetupJumboFlySound(uint8 emittingVol); + bool8 SetupJumboRumbleSound(uint8 emittingVol); + bool8 SetupJumboTaxiSound(uint8 vol); + bool8 SetupJumboWhineSound(uint8 emittingVol, uint32 freq); void SetupPedComments(cPedParams ¶ms, uint16 sound); void SetupSuspectLastSeenReport(); @@ -487,9 +487,9 @@ public: void UpdateGasPedalAudio(CAutomobile *automobile); void UpdateReflections(); - bool UsesReverseWarning(int32 model) const; - bool UsesSiren(int32 model) const; - bool UsesSirenSwitching(int32 model) const; + bool8 UsesReverseWarning(int32 model) const; + bool8 UsesSiren(int32 model) const; + bool8 UsesSirenSwitching(int32 model) const; #ifdef GTA_PC // only used in pc diff --git a/src/audio/DMAudio.cpp b/src/audio/DMAudio.cpp index 1027a084..eea91bd1 100644 --- a/src/audio/DMAudio.cpp +++ b/src/audio/DMAudio.cpp @@ -39,7 +39,7 @@ cDMAudio::DestroyEntity(int32 audioEntity) } void -cDMAudio::SetEntityStatus(int32 audioEntity, uint8 status) +cDMAudio::SetEntityStatus(int32 audioEntity, bool8 status) { AudioManager.SetEntityStatus(audioEntity, status); } @@ -57,7 +57,7 @@ cDMAudio::DestroyAllGameCreatedEntities(void) } void -cDMAudio::SetMonoMode(uint8 mono) +cDMAudio::SetMonoMode(bool8 mono) { AudioManager.SetMonoMode(mono); } @@ -128,7 +128,7 @@ cDMAudio::SetSpeakerConfig(int32 config) AudioManager.SetSpeakerConfig(config); } -bool +bool8 cDMAudio::IsMP3RadioChannelAvailable(void) { return AudioManager.IsMP3RadioChannelAvailable(); @@ -147,12 +147,12 @@ cDMAudio::ReacquireDigitalHandle(void) } void -cDMAudio::SetDynamicAcousticModelingStatus(uint8 status) +cDMAudio::SetDynamicAcousticModelingStatus(bool8 status) { AudioManager.SetDynamicAcousticModelingStatus(status); } -bool +bool8 cDMAudio::CheckForAnAudioFileOnCD(void) { return AudioManager.CheckForAnAudioFileOnCD(); @@ -164,7 +164,7 @@ cDMAudio::GetCDAudioDriveLetter(void) return AudioManager.GetCDAudioDriveLetter(); } -bool +bool8 cDMAudio::IsAudioInitialised(void) { return AudioManager.IsAudioInitialised(); @@ -182,7 +182,7 @@ cDMAudio::CreateLoopingScriptObject(cAudioScriptObject *scriptObject) int32 audioEntity = AudioManager.CreateEntity(AUDIOTYPE_SCRIPTOBJECT, scriptObject); if ( AEHANDLE_IS_OK(audioEntity) ) - AudioManager.SetEntityStatus(audioEntity, true); + AudioManager.SetEntityStatus(audioEntity, TRUE); return audioEntity; } @@ -200,7 +200,7 @@ cDMAudio::CreateOneShotScriptObject(cAudioScriptObject *scriptObject) if ( AEHANDLE_IS_OK(audioEntity) ) { - AudioManager.SetEntityStatus(audioEntity, true); + AudioManager.SetEntityStatus(audioEntity, TRUE); AudioManager.PlayOneShot(audioEntity, scriptObject->AudioId, 0.0f); } } @@ -230,7 +230,7 @@ cDMAudio::PlayRadioAnnouncement(uint8 announcement) } void -cDMAudio::PlayFrontEndTrack(uint8 track, uint8 frontendFlag) +cDMAudio::PlayFrontEndTrack(uint8 track, bool8 frontendFlag) { MusicManager.PlayFrontEndTrack(track, frontendFlag); } @@ -295,7 +295,7 @@ cDMAudio::PlayLoadedMissionAudio(void) AudioManager.PlayLoadedMissionAudio(); } -bool +bool8 cDMAudio::IsMissionAudioSampleFinished(void) { return AudioManager.IsMissionAudioSampleFinished(); diff --git a/src/audio/DMAudio.h b/src/audio/DMAudio.h index 3e6d5603..19689fab 100644 --- a/src/audio/DMAudio.h +++ b/src/audio/DMAudio.h @@ -22,11 +22,11 @@ public: int32 CreateEntity(eAudioType type, void *UID); void DestroyEntity(int32 audioEntity); - void SetEntityStatus(int32 audioEntity, uint8 status); + void SetEntityStatus(int32 audioEntity, bool8 status); void PlayOneShot(int32 audioEntity, uint16 oneShot, float volume); void DestroyAllGameCreatedEntities(void); - void SetMonoMode(uint8 mono); + void SetMonoMode(bool8 mono); void SetEffectsMasterVolume(uint8 volume); void SetMusicMasterVolume(uint8 volume); void SetEffectsFadeVol(uint8 volume); @@ -40,17 +40,17 @@ public: void SetSpeakerConfig(int32 config); - bool IsMP3RadioChannelAvailable(void); + bool8 IsMP3RadioChannelAvailable(void); void ReleaseDigitalHandle(void); void ReacquireDigitalHandle(void); - void SetDynamicAcousticModelingStatus(uint8 status); + void SetDynamicAcousticModelingStatus(bool8 status); - bool CheckForAnAudioFileOnCD(void); + bool8 CheckForAnAudioFileOnCD(void); char GetCDAudioDriveLetter(void); - bool IsAudioInitialised(void); + bool8 IsAudioInitialised(void); void ReportCrime(eCrimeType crime, CVector const &pos); @@ -64,7 +64,7 @@ public: void PlayFrontEndSound(uint16 frontend, uint32 volume); void PlayRadioAnnouncement(uint8 announcement); - void PlayFrontEndTrack(uint8 track, uint8 frontendFlag); + void PlayFrontEndTrack(uint8 track, bool8 frontendFlag); void StopFrontEndTrack(void); void ResetTimers(uint32 time); @@ -79,7 +79,7 @@ public: uint8 GetMissionAudioLoadingStatus(void); void SetMissionAudioLocation(float x, float y, float z); void PlayLoadedMissionAudio(void); - bool IsMissionAudioSampleFinished(void); + bool8 IsMissionAudioSampleFinished(void); void ClearMissionAudio(void); uint8 GetRadioInCar(void); diff --git a/src/audio/MusicManager.cpp b/src/audio/MusicManager.cpp index 3e1a7384..88ef96fa 100644 --- a/src/audio/MusicManager.cpp +++ b/src/audio/MusicManager.cpp @@ -22,42 +22,42 @@ static_assert(false, "RADIO_SCROLL_TO_PREV_STATION and RADIO_OFF_TEXT won't work cMusicManager MusicManager; int32 gNumRetunePresses; int32 gRetuneCounter; -bool bHasStarted; +bool8 bHasStarted; cMusicManager::cMusicManager() { - m_bIsInitialised = false; - m_bDisabled = false; + m_bIsInitialised = FALSE; + m_bDisabled = FALSE; m_nMusicMode = MUSICMODE_DISABLED; m_nNextTrack = NO_TRACK; m_nPlayingTrack = NO_TRACK; - m_bFrontendTrackFinished = false; - m_bPlayInFrontend = false; - m_bSetNextStation = false; + m_bFrontendTrackFinished = FALSE; + m_bPlayInFrontend = FALSE; + m_bSetNextStation = FALSE; m_nAnnouncement = NO_TRACK; - m_bPreviousPlayerInCar = false; - m_bPlayerInCar = false; - m_bAnnouncementInProgress = false; - m_bVerifyAmbienceTrackStartedToPlay = false; - bHasStarted = false; + m_bPreviousPlayerInCar = FALSE; + m_bPlayerInCar = FALSE; + m_bAnnouncementInProgress = FALSE; + m_bVerifyAmbienceTrackStartedToPlay = FALSE; + bHasStarted = FALSE; } -bool +bool8 cMusicManager::PlayerInCar() { if(!FindPlayerVehicle()) - return false; + return FALSE; int32 State = FindPlayerPed()->m_nPedState; if(State == PED_DRAG_FROM_CAR || State == PED_EXIT_CAR || State == PED_ARRESTED) - return false; + return FALSE; if (!FindPlayerVehicle()) - return true; + return TRUE; if (FindPlayerVehicle()->GetStatus() == STATUS_WRECKED) - return false; + return FALSE; switch (FindPlayerVehicle()->GetModelIndex()) { case MI_FIRETRUCK: @@ -67,8 +67,8 @@ cMusicManager::PlayerInCar() case MI_TRAIN: case MI_SPEEDER: case MI_REEFER: - case MI_GHOST: return false; - default: return true; + case MI_GHOST: return FALSE; + default: return TRUE; } } @@ -224,7 +224,7 @@ cMusicManager::DisplayRadioStationName() } } -bool +bool8 cMusicManager::Initialise() { int pos; @@ -265,18 +265,18 @@ cMusicManager::Initialise() m_aTracks[i].m_nLastPosCheckTimer = CTimer::GetTimeInMillisecondsPauseMode(); } - m_bResetTimers = false; + m_bResetTimers = FALSE; m_nResetTime = 0; m_nTimer = m_nLastTrackServiceTime = CTimer::GetTimeInMillisecondsPauseMode(); - m_bDoTrackService = false; - m_bIgnoreTimeDelay = false; - m_bRadioSetByScript = false; + m_bDoTrackService = FALSE; + m_bIgnoreTimeDelay = FALSE; + m_bRadioSetByScript = FALSE; m_nRadioStationScript = HEAD_RADIO; m_nRadioPosition = -1; m_nRadioInCar = NO_TRACK; gNumRetunePresses = 0; gRetuneCounter = 0; - m_bIsInitialised = true; + m_bIsInitialised = TRUE; } return m_bIsInitialised; } @@ -291,7 +291,7 @@ cMusicManager::Terminate() m_nNextTrack = NO_TRACK; m_nPlayingTrack = NO_TRACK; } - m_bIsInitialised = false; + m_bIsInitialised = FALSE; } void @@ -325,16 +325,16 @@ cMusicManager::ChangeMusicMode(uint8 mode) } m_nNextTrack = NO_TRACK; m_nPlayingTrack = NO_TRACK; - m_bFrontendTrackFinished = false; - m_bPlayInFrontend = false; - m_bSetNextStation = false; - m_bPreviousPlayerInCar = false; - m_bPlayerInCar = false; - m_bAnnouncementInProgress = false; + m_bFrontendTrackFinished = FALSE; + m_bPlayInFrontend = FALSE; + m_bSetNextStation = FALSE; + m_bPreviousPlayerInCar = FALSE; + m_bPlayerInCar = FALSE; + m_bAnnouncementInProgress = FALSE; m_nTimer = m_nLastTrackServiceTime = CTimer::GetTimeInMillisecondsPauseMode(); - m_bDoTrackService = false; - m_bIgnoreTimeDelay = true; - m_bVerifyAmbienceTrackStartedToPlay = false; + m_bDoTrackService = FALSE; + m_bIgnoreTimeDelay = TRUE; + m_bVerifyAmbienceTrackStartedToPlay = FALSE; m_nMusicMode = mode2; break; default: return; @@ -383,7 +383,7 @@ void cMusicManager::SetRadioChannelByScript(uint8 station, int32 pos) { if (m_bIsInitialised && station < RADIO_OFF) { - m_bRadioSetByScript = true; + m_bRadioSetByScript = TRUE; m_nRadioStationScript = station; m_nRadioPosition = pos == -1 ? -1 : pos % m_aTracks[station].m_nLength; } @@ -393,12 +393,12 @@ cMusicManager::SetRadioChannelByScript(uint8 station, int32 pos) void cMusicManager::ResetMusicAfterReload() { - m_bRadioSetByScript = false; + m_bRadioSetByScript = FALSE; m_nRadioStationScript = 0; m_nRadioPosition = -1; m_nAnnouncement = NO_TRACK; - m_bAnnouncementInProgress = false; - m_bSetNextStation = false; + m_bAnnouncementInProgress = FALSE; + m_bSetNextStation = FALSE; gRetuneCounter = 0; gNumRetunePresses = 0; } @@ -407,7 +407,7 @@ cMusicManager::ResetMusicAfterReload() void cMusicManager::ResetTimers(int32 time) { - m_bResetTimers = true; + m_bResetTimers = TRUE; m_nResetTime = time; } @@ -415,23 +415,23 @@ void cMusicManager::Service() { if (m_bResetTimers) { - m_bResetTimers = false; + m_bResetTimers = FALSE; m_nLastTrackServiceTime = m_nResetTime; } if (!m_bIsInitialised || m_bDisabled) return; if (m_nMusicMode == MUSICMODE_CUTSCENE) { - SampleManager.SetStreamedVolumeAndPan(MAX_VOLUME, 63, 1, 0); + SampleManager.SetStreamedVolumeAndPan(MAX_VOLUME, 63, TRUE, 0); return; } m_nTimer = CTimer::GetTimeInMillisecondsPauseMode(); if (m_nTimer > (m_nLastTrackServiceTime + 2000) || m_bIgnoreTimeDelay) { - m_bIgnoreTimeDelay = false; - m_bDoTrackService = true; + m_bIgnoreTimeDelay = FALSE; + m_bDoTrackService = TRUE; m_nLastTrackServiceTime = m_nTimer; - } else m_bDoTrackService = false; + } else m_bDoTrackService = FALSE; if (m_nNextTrack == NO_TRACK && SampleManager.IsStreamPlaying(0)) SampleManager.StopStreamedFile(0); @@ -466,22 +466,22 @@ cMusicManager::ServiceFrontEndMode() if (!SampleManager.IsStreamPlaying(0)) SampleManager.StartStreamedFile(m_nNextTrack, 0, 0); } else { - SampleManager.SetStreamedVolumeAndPan(0, 63, 0, 0); + SampleManager.SetStreamedVolumeAndPan(0, 63, FALSE, 0); if (!SampleManager.StartStreamedFile(m_nNextTrack, m_nNextTrack < NUM_RADIOS ? GetTrackStartPos(m_nNextTrack) : 0, 0)) return; - SampleManager.SetStreamedVolumeAndPan(100, 63, 0, 0); - if (m_bPlayInFrontend) bHasStarted = true; - else m_bFrontendTrackFinished = true; + SampleManager.SetStreamedVolumeAndPan(100, 63, FALSE, 0); + if (m_bPlayInFrontend) bHasStarted = TRUE; + else m_bFrontendTrackFinished = TRUE; } } if (SampleManager.IsStreamPlaying(0)) - SampleManager.SetStreamedVolumeAndPan((CPad::GetPad(0)->bDisplayNoControllerMessage || CPad::GetPad(0)->bObsoleteControllerMessage) ? 0 : 100, 63, 0, 0); + SampleManager.SetStreamedVolumeAndPan((CPad::GetPad(0)->bDisplayNoControllerMessage || CPad::GetPad(0)->bObsoleteControllerMessage) ? 0 : 100, 63, FALSE, 0); } void cMusicManager::ServiceGameMode() { - bool bRadioOff = false; + bool8 bRadioOff = FALSE; static int8 nFramesSinceCutsceneEnded = -1; uint8 volume; @@ -525,7 +525,7 @@ cMusicManager::ServiceGameMode() } if (AudioManager.m_nPreviousUserPause) - m_bPreviousPlayerInCar = false; + m_bPreviousPlayerInCar = FALSE; if (!m_bPlayerInCar) { if (m_bPreviousPlayerInCar) { if (m_nNextTrack != STREAMED_SOUND_RADIO_POLICE) @@ -541,7 +541,7 @@ cMusicManager::ServiceGameMode() && ServiceAnnouncement()) { if (m_bAnnouncementInProgress) { - m_bSetNextStation = false; + m_bSetNextStation = FALSE; return; } m_nPlayingTrack = m_nNextTrack; @@ -558,7 +558,7 @@ cMusicManager::ServiceGameMode() AudioManager.PlayOneShot(AudioManager.m_nFrontEndEntity, SOUND_FRONTEND_RADIO_CHANGE, 1.0f); gRetuneCounter = 0; gNumRetunePresses = 0; - m_bSetNextStation = false; + m_bSetNextStation = FALSE; } // Because when you switch radio back and forth, gNumRetunePresses will be 0 but gRetuneCounter won't. #ifdef RADIO_SCROLL_TO_PREV_STATION @@ -566,24 +566,24 @@ cMusicManager::ServiceGameMode() if (gRetuneCounter > 1) gRetuneCounter--; else if (gRetuneCounter == 1) gRetuneCounter = -1; else if (gRetuneCounter == -1) { - m_bSetNextStation = true; + m_bSetNextStation = TRUE; gRetuneCounter = 0; } } #else if (gNumRetunePresses) { if (gRetuneCounter != 0) gRetuneCounter--; - else m_bSetNextStation = true; + else m_bSetNextStation = TRUE; } #endif if (gRetuneCounter) AudioManager.DoPoliceRadioCrackle(); if (m_bSetNextStation) { - m_bSetNextStation = false; + m_bSetNextStation = FALSE; m_nPlayingTrack = m_nNextTrack; m_nNextTrack = GetNextCarTuning(); if (m_nNextTrack == STREAMED_SOUND_CITY_AMBIENT || m_nNextTrack == STREAMED_SOUND_WATER_AMBIENT) - bRadioOff = true; + bRadioOff = TRUE; if (m_nPlayingTrack == STREAMED_SOUND_CITY_AMBIENT || m_nPlayingTrack == STREAMED_SOUND_WATER_AMBIENT) AudioManager.PlayOneShot(AudioManager.m_nFrontEndEntity, SOUND_FRONTEND_RADIO_CHANGE, 0.0f); @@ -592,7 +592,7 @@ cMusicManager::ServiceGameMode() if (ChangeRadioChannel()) { ServiceTrack(); } else { - m_bPlayerInCar = false; + m_bPlayerInCar = FALSE; if (FindPlayerVehicle()) FindPlayerVehicle()->m_nRadioStation = m_nNextTrack; m_nNextTrack = NO_TRACK; @@ -601,7 +601,7 @@ cMusicManager::ServiceGameMode() if (TheCamera.pTargetEntity != nil) { float DistToTargetSq = (TheCamera.pTargetEntity->GetPosition() - TheCamera.GetPosition()).MagnitudeSqr(); if (DistToTargetSq >= SQR(55.0f)) { - SampleManager.SetStreamedVolumeAndPan(0, 63, 0, 0); + SampleManager.SetStreamedVolumeAndPan(0, 63, FALSE, 0); } else if (DistToTargetSq >= SQR(10.0f)) { volume = ((45.0f - (Sqrt(DistToTargetSq) - 10.0f)) / 45.0f * 100.0f); uint8 pan; @@ -616,17 +616,17 @@ cMusicManager::ServiceGameMode() } if (gRetuneCounter) volume /= 4; - SampleManager.SetStreamedVolumeAndPan(volume, pan, 0, 0); + SampleManager.SetStreamedVolumeAndPan(volume, pan, FALSE, 0); } else if (AudioManager.ShouldDuckMissionAudio()) { - SampleManager.SetStreamedVolumeAndPan(25, 63, 0, 0); + SampleManager.SetStreamedVolumeAndPan(25, 63, FALSE, 0); } else if (gRetuneCounter) { - SampleManager.SetStreamedVolumeAndPan(25, 63, 0, 0); + SampleManager.SetStreamedVolumeAndPan(25, 63, FALSE, 0); } else { - SampleManager.SetStreamedVolumeAndPan(100, 63, 0, 0); + SampleManager.SetStreamedVolumeAndPan(100, 63, FALSE, 0); } } } else if (AudioManager.ShouldDuckMissionAudio()) { - SampleManager.SetStreamedVolumeAndPan(25, 63, 0, 0); + SampleManager.SetStreamedVolumeAndPan(25, 63, FALSE, 0); nFramesSinceCutsceneEnded = 0; } else { if (nFramesSinceCutsceneEnded == -1) { @@ -643,7 +643,7 @@ cMusicManager::ServiceGameMode() } if (gRetuneCounter != 0) volume /= 4; - SampleManager.SetStreamedVolumeAndPan(volume, 63, 0, 0); + SampleManager.SetStreamedVolumeAndPan(volume, 63, FALSE, 0); } return; } @@ -663,7 +663,7 @@ cMusicManager::ServiceGameMode() m_nNextTrack = m_nRadioStationScript; if (FindPlayerVehicle()->m_nRadioStation == m_nNextTrack) { m_nPlayingTrack = NO_TRACK; - SampleManager.SetStreamedVolumeAndPan(0, 63, 0, 0); + SampleManager.SetStreamedVolumeAndPan(0, 63, FALSE, 0); SampleManager.StopStreamedFile(0); } if (m_nRadioPosition != -1) { @@ -680,11 +680,11 @@ cMusicManager::ServiceGameMode() } if (ChangeRadioChannel()) { if (m_bRadioSetByScript) { - m_bRadioSetByScript = false; + m_bRadioSetByScript = FALSE; FindPlayerVehicle()->m_nRadioStation = m_nNextTrack; } } else { - m_bPlayerInCar = false; + m_bPlayerInCar = FALSE; m_nNextTrack = NO_TRACK; } } @@ -709,14 +709,14 @@ cMusicManager::PlayAnnouncement(uint8 announcement) } void -cMusicManager::PlayFrontEndTrack(uint8 track, uint8 bPlayInFrontend) +cMusicManager::PlayFrontEndTrack(uint8 track, bool8 bPlayInFrontend) { if (IsInitialised() && !m_bDisabled && track < TOTAL_STREAMED_SOUNDS) { if (m_nMusicMode == MUSICMODE_GAME) { if (m_nNextTrack != NO_TRACK) { if (m_bAnnouncementInProgress) { m_nAnnouncement = NO_TRACK; - m_bAnnouncementInProgress = false; + m_bAnnouncementInProgress = FALSE; } m_aTracks[m_nNextTrack].m_nPosition = SampleManager.GetStreamedFilePosition(0); m_aTracks[m_nNextTrack].m_nLastPosCheckTimer = CTimer::GetTimeInMillisecondsPauseMode(); @@ -732,10 +732,10 @@ cMusicManager::PlayFrontEndTrack(uint8 track, uint8 bPlayInFrontend) m_nPlayingTrack = m_nNextTrack; m_nNextTrack = track; - m_bPlayInFrontend = !!bPlayInFrontend; - m_bFrontendTrackFinished = false; - m_bDoTrackService = true; - bHasStarted = false; + m_bPlayInFrontend = bPlayInFrontend; + m_bFrontendTrackFinished = FALSE; + m_bDoTrackService = TRUE; + bHasStarted = FALSE; if (m_nNextTrack < NUM_RADIOS) { gRetuneCounter = 0; gNumRetunePresses = 0; @@ -751,7 +751,7 @@ cMusicManager::PreloadCutSceneMusic(uint8 track) while (SampleManager.IsStreamPlaying(0)) SampleManager.StopStreamedFile(0); SampleManager.PreloadStreamedFile(track, 0); - SampleManager.SetStreamedVolumeAndPan(MAX_VOLUME, 63, 1, 0); + SampleManager.SetStreamedVolumeAndPan(MAX_VOLUME, 63, TRUE, 0); m_nNextTrack = track; } } @@ -787,7 +787,7 @@ cMusicManager::GetTrackStartPos(uint8 track) } -bool +bool8 cMusicManager::UsesPoliceRadio(CVehicle *veh) { switch (veh->GetModelIndex()) @@ -798,9 +798,9 @@ cMusicManager::UsesPoliceRadio(CVehicle *veh) case MI_PREDATOR: case MI_RHINO: case MI_BARRACKS: - return true; + return TRUE; } - return false; + return FALSE; } void @@ -810,7 +810,7 @@ cMusicManager::ServiceAmbience() if (m_bAnnouncementInProgress) { m_nAnnouncement = NO_TRACK; - m_bAnnouncementInProgress = false; + m_bAnnouncementInProgress = FALSE; } if (m_nNextTrack < RADIO_OFF) { if (SampleManager.IsStreamPlaying(0)) { @@ -831,11 +831,11 @@ cMusicManager::ServiceAmbience() m_nNextTrack = TheCamera.DistanceToWater <= 45.0f ? STREAMED_SOUND_WATER_AMBIENT : STREAMED_SOUND_CITY_AMBIENT; if (m_nNextTrack == m_nPlayingTrack) { - ComputeAmbienceVol(false, volume); - SampleManager.SetStreamedVolumeAndPan(volume, 63, 1, 0); + ComputeAmbienceVol(FALSE, volume); + SampleManager.SetStreamedVolumeAndPan(volume, 63, TRUE, 0); if (m_bVerifyAmbienceTrackStartedToPlay) { if (SampleManager.IsStreamPlaying(0)) - m_bVerifyAmbienceTrackStartedToPlay = false; + m_bVerifyAmbienceTrackStartedToPlay = FALSE; } else ServiceTrack(); } else { if (m_nPlayingTrack < TOTAL_STREAMED_SOUNDS) { @@ -844,18 +844,18 @@ cMusicManager::ServiceAmbience() SampleManager.StopStreamedFile(0); } uint32 pos = GetTrackStartPos(m_nNextTrack); - SampleManager.SetStreamedVolumeAndPan(0, 63, 1, 0); + SampleManager.SetStreamedVolumeAndPan(0, 63, TRUE, 0); if (SampleManager.StartStreamedFile(m_nNextTrack, pos, 0)) { - ComputeAmbienceVol(true, volume); - SampleManager.SetStreamedVolumeAndPan(volume, 63, 1, 0); - m_bVerifyAmbienceTrackStartedToPlay = true; + ComputeAmbienceVol(TRUE, volume); + SampleManager.SetStreamedVolumeAndPan(volume, 63, TRUE, 0); + m_bVerifyAmbienceTrackStartedToPlay = TRUE; } else m_nNextTrack = NO_TRACK; } } void -cMusicManager::ComputeAmbienceVol(uint8 reset, uint8 &outVolume) +cMusicManager::ComputeAmbienceVol(bool8 reset, uint8 &outVolume) { static float fVol = 0.0f; @@ -883,16 +883,16 @@ cMusicManager::ServiceTrack() } } -bool +bool8 cMusicManager::ServiceAnnouncement() { static int8 cCheck = 0; if (m_bAnnouncementInProgress) { if (!SampleManager.IsStreamPlaying(0)) { m_nAnnouncement = NO_TRACK; - m_bAnnouncementInProgress = false; + m_bAnnouncementInProgress = FALSE; } - return true; + return TRUE; } if (++cCheck >= 30) { @@ -906,21 +906,21 @@ cMusicManager::ServiceAnnouncement() } } - SampleManager.SetStreamedVolumeAndPan(0, 63, 0, 0); + SampleManager.SetStreamedVolumeAndPan(0, 63, FALSE, 0); if (SampleManager.StartStreamedFile(m_nAnnouncement, 0, 0)) { - SampleManager.SetStreamedVolumeAndPan(AudioManager.ShouldDuckMissionAudio() ? 25 : 100, 63, 0, 0); - m_bAnnouncementInProgress = true; + SampleManager.SetStreamedVolumeAndPan(AudioManager.ShouldDuckMissionAudio() ? 25 : 100, 63, FALSE, 0); + m_bAnnouncementInProgress = TRUE; m_nPlayingTrack = m_nNextTrack; m_nNextTrack = m_nAnnouncement; - return true; + return TRUE; } if (cCheck != 0) cCheck--; else cCheck = 30; - return false; + return FALSE; } - return false; + return FALSE; } uint8 @@ -987,21 +987,21 @@ cMusicManager::GetNextCarTuning() return veh->m_nRadioStation; } -bool +bool8 cMusicManager::ChangeRadioChannel() { if (m_nNextTrack != m_nPlayingTrack) { if (m_nPlayingTrack < TOTAL_STREAMED_SOUNDS) { m_aTracks[m_nPlayingTrack].m_nPosition = SampleManager.GetStreamedFilePosition(0); m_aTracks[m_nPlayingTrack].m_nLastPosCheckTimer = CTimer::GetTimeInMillisecondsPauseMode(); - SampleManager.SetStreamedVolumeAndPan(0, 63, 0, 0); + SampleManager.SetStreamedVolumeAndPan(0, 63, FALSE, 0); SampleManager.StopStreamedFile(0); } if (SampleManager.IsStreamPlaying(0)) - return false; + return FALSE; if (!SampleManager.StartStreamedFile(m_nNextTrack, GetTrackStartPos(m_nNextTrack), 0)) - return false; - SampleManager.SetStreamedVolumeAndPan(AudioManager.ShouldDuckMissionAudio() ? 25 : 100, 63, 0, 0); + return FALSE; + SampleManager.SetStreamedVolumeAndPan(AudioManager.ShouldDuckMissionAudio() ? 25 : 100, 63, FALSE, 0); } - return true; + return TRUE; } diff --git a/src/audio/MusicManager.h b/src/audio/MusicManager.h index 5d277f0e..4c4447fe 100644 --- a/src/audio/MusicManager.h +++ b/src/audio/MusicManager.h @@ -15,48 +15,48 @@ class CVehicle; class cMusicManager { public: - bool m_bIsInitialised; - bool m_bDisabled; + bool8 m_bIsInitialised; + bool8 m_bDisabled; uint8 m_nMusicMode; uint8 m_nNextTrack; uint8 m_nPlayingTrack; - bool m_bFrontendTrackFinished; - bool m_bPlayInFrontend; - bool m_bSetNextStation; + bool8 m_bFrontendTrackFinished; + bool8 m_bPlayInFrontend; + bool8 m_bSetNextStation; uint8 m_nAnnouncement; - bool m_bPreviousPlayerInCar; - bool m_bPlayerInCar; - bool m_bAnnouncementInProgress; + bool8 m_bPreviousPlayerInCar; + bool8 m_bPlayerInCar; + bool8 m_bAnnouncementInProgress; tStreamedSample m_aTracks[TOTAL_STREAMED_SOUNDS]; - bool m_bResetTimers; + bool8 m_bResetTimers; uint32 m_nResetTime; uint32 m_nLastTrackServiceTime; uint32 m_nTimer; - bool m_bDoTrackService; - bool m_bIgnoreTimeDelay; - bool m_bVerifyAmbienceTrackStartedToPlay; - bool m_bRadioSetByScript; + bool8 m_bDoTrackService; + bool8 m_bIgnoreTimeDelay; + bool8 m_bVerifyAmbienceTrackStartedToPlay; + bool8 m_bRadioSetByScript; uint8 m_nRadioStationScript; int32 m_nRadioPosition; uint8 m_nRadioInCar; public: cMusicManager(); - bool IsInitialised() { return m_bIsInitialised; } + bool8 IsInitialised() { return m_bIsInitialised; } uint32 GetMusicMode() { return m_nMusicMode; } uint8 GetNextTrack() { return m_nNextTrack; } - bool Initialise(); + bool8 Initialise(); void Terminate(); void ChangeMusicMode(uint8 mode); void StopFrontEndTrack(); - bool PlayerInCar(); + bool8 PlayerInCar(); void DisplayRadioStationName(); void PlayAnnouncement(uint8); - void PlayFrontEndTrack(uint8, uint8); + void PlayFrontEndTrack(uint8, bool8); void PreloadCutSceneMusic(uint8); void PlayPreloadedCutSceneMusic(void); void StopCutSceneMusic(void); @@ -73,15 +73,15 @@ public: void ServiceAmbience(); void ServiceTrack(); - bool UsesPoliceRadio(CVehicle *veh); + bool8 UsesPoliceRadio(CVehicle *veh); uint32 GetTrackStartPos(uint8); - void ComputeAmbienceVol(uint8 reset, uint8& outVolume); - bool ServiceAnnouncement(); + void ComputeAmbienceVol(bool8 reset, uint8& outVolume); + bool8 ServiceAnnouncement(); uint8 GetCarTuning(); uint8 GetNextCarTuning(); - bool ChangeRadioChannel(); + bool8 ChangeRadioChannel(); }; VALIDATE_SIZE(cMusicManager, 0x95C); diff --git a/src/audio/PolRadio.cpp b/src/audio/PolRadio.cpp index cb12a2fe..3664796b 100644 --- a/src/audio/PolRadio.cpp +++ b/src/audio/PolRadio.cpp @@ -94,8 +94,8 @@ cAudioManager::InitialisePoliceRadio() for (int32 i = 0; i < ARRAY_SIZE(m_sPoliceRadioQueue.crimes); i++) m_sPoliceRadioQueue.crimes[i].type = CRIME_NONE; - SampleManager.SetChannelReverbFlag(policeChannel, false); - gSpecialSuspectLastSeenReport = false; + SampleManager.SetChannelReverbFlag(policeChannel, FALSE); + gSpecialSuspectLastSeenReport = FALSE; for (int32 i = 0; i < ARRAY_SIZE(gMinTimeToNextReport); i++) gMinTimeToNextReport[i] = m_FrameCounter; } @@ -131,7 +131,7 @@ cAudioManager::DoPoliceRadioCrackle() m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_nSampleIndex = SFX_POLICE_RADIO_CRACKLE; m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = true; + m_sQueueSample.m_bIs2D = TRUE; m_sQueueSample.m_nReleasingVolumeModificator = 10; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_POLICE_RADIO_CRACKLE); m_sQueueSample.m_nVolume = m_anRandomTable[2] % 20 + 15; @@ -139,11 +139,11 @@ cAudioManager::DoPoliceRadioCrackle() m_sQueueSample.m_nEmittingVolume = m_sQueueSample.m_nVolume; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(SFX_POLICE_RADIO_CRACKLE); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(SFX_POLICE_RADIO_CRACKLE); - m_sQueueSample.m_bReleasingSoundFlag = false; - m_sQueueSample.m_bReverbFlag = false; + m_sQueueSample.m_bReleasingSoundFlag = FALSE; + m_sQueueSample.m_bReverbFlag = FALSE; m_sQueueSample.m_nOffset = 63; m_sQueueSample.m_nReleasingVolumeDivider = 3; - m_sQueueSample.m_bRequireReflection = false; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); } @@ -156,7 +156,7 @@ cAudioManager::ServicePoliceRadio() if(!m_bIsInitialised) return; if(m_nUserPause == 0) { - bool crimeReport = SetupCrimeReport(); + bool8 crimeReport = SetupCrimeReport(); #ifdef FIX_BUGS // Crash at 0x5fe6ef if(CReplay::IsPlayingBack() || !FindPlayerPed() || !FindPlayerPed()->m_pWanted) return; @@ -179,12 +179,12 @@ cAudioManager::ServicePoliceRadio() void cAudioManager::ServicePoliceRadioChannel(uint8 wantedLevel) { - bool processed = false; + bool8 processed = FALSE; uint32 sample; int32 freq; static int cWait = 0; - static bool bChannelOpen = false; + static bool8 bChannelOpen = FALSE; static uint8 bMissionAudioPhysicalPlayingStatus = 0; static int32 PoliceChannelFreq = 5500; @@ -194,14 +194,14 @@ cAudioManager::ServicePoliceRadioChannel(uint8 wantedLevel) if (SampleManager.GetChannelUsedFlag(policeChannel)) SampleManager.StopChannel(policeChannel); if (g_nMissionAudioSfx != TOTAL_AUDIO_SAMPLES && bMissionAudioPhysicalPlayingStatus == 1 && SampleManager.IsStreamPlaying(1)) { - SampleManager.PauseStream(1, 1); + SampleManager.PauseStream(TRUE, 1); } } else { if (m_nPreviousUserPause && g_nMissionAudioSfx != TOTAL_AUDIO_SAMPLES && bMissionAudioPhysicalPlayingStatus == 1) { - SampleManager.PauseStream(0, 1); + SampleManager.PauseStream(FALSE, 1); } - if (m_sPoliceRadioQueue.policeChannelTimer == 0) bChannelOpen = false; + if (m_sPoliceRadioQueue.policeChannelTimer == 0) bChannelOpen = FALSE; if (cWait) { --cWait; return; @@ -225,7 +225,7 @@ cAudioManager::ServicePoliceRadioChannel(uint8 wantedLevel) } } else if (!SampleManager.GetChannelUsedFlag(policeChannel)) { SampleManager.PreloadStreamedFile(g_nMissionAudioSfx, 1); - SampleManager.SetStreamedVolumeAndPan(MAX_VOLUME, 63, 1, 1); + SampleManager.SetStreamedVolumeAndPan(MAX_VOLUME, 63, TRUE, 1); SampleManager.StartPreloadedStreamedFile(1); g_nMissionAudioPlayingStatus = 1; bMissionAudioPhysicalPlayingStatus = 0; @@ -246,8 +246,8 @@ cAudioManager::ServicePoliceRadioChannel(uint8 wantedLevel) if (gSpecialSuspectLastSeenReport) { gSpecialSuspectLastSeenReport = 0; } else if (((sample >= SFX_POLICE_RADIO_MESSAGE_NOISE_1) && (sample <= SFX_POLICE_RADIO_MESSAGE_NOISE_3)) || sample == TOTAL_AUDIO_SAMPLES) { - bChannelOpen = false; - processed = true; + bChannelOpen = FALSE; + processed = TRUE; } } if (sample == TOTAL_AUDIO_SAMPLES) { @@ -259,7 +259,7 @@ cAudioManager::ServicePoliceRadioChannel(uint8 wantedLevel) case SFX_POLICE_RADIO_MESSAGE_NOISE_2: case SFX_POLICE_RADIO_MESSAGE_NOISE_3: freq = m_anRandomTable[4] % 2000 + 10025; - bChannelOpen = bChannelOpen == false; + bChannelOpen = bChannelOpen == FALSE; break; default: freq = SampleManager.GetSampleBaseFrequency(sample); break; } @@ -276,7 +276,7 @@ cAudioManager::ServicePoliceRadioChannel(uint8 wantedLevel) } } -bool +bool8 cAudioManager::SetupCrimeReport() { int16 audioZoneId; @@ -289,13 +289,13 @@ cAudioManager::SetupCrimeReport() float quarterY; int i; int32 sampleIndex; - bool processed = false; + bool8 processed = FALSE; - if (MusicManager.m_nMusicMode == MUSICMODE_CUTSCENE) return false; + if (MusicManager.m_nMusicMode == MUSICMODE_CUTSCENE) return FALSE; if (60 - m_sPoliceRadioQueue.policeChannelTimer <= 9) { AgeCrimes(); - return true; + return TRUE; } for (i = 0; i < ARRAY_SIZE(m_sPoliceRadioQueue.crimes); i++) { @@ -303,7 +303,7 @@ cAudioManager::SetupCrimeReport() break; } - if (i == ARRAY_SIZE(m_sPoliceRadioQueue.crimes)) return false; + if (i == ARRAY_SIZE(m_sPoliceRadioQueue.crimes)) return FALSE; audioZoneId = CTheZones::FindAudioZone(&m_sPoliceRadioQueue.crimes[i].position); if (audioZoneId >= 0 && audioZoneId < NUMAUDIOZONES) { zone = CTheZones::GetAudioZone(audioZoneId); @@ -336,10 +336,10 @@ cAudioManager::SetupCrimeReport() if (m_sPoliceRadioQueue.crimes[i].position.y > halfY + quarterY) { m_sPoliceRadioQueue.Add(SFX_NORTH); - processed = true; + processed = TRUE; } else if (m_sPoliceRadioQueue.crimes[i].position.y < halfY - quarterY) { m_sPoliceRadioQueue.Add(SFX_SOUTH); - processed = true; + processed = TRUE; } if (m_sPoliceRadioQueue.crimes[i].position.x > halfX + quarterX) @@ -359,7 +359,7 @@ cAudioManager::SetupCrimeReport() } m_sPoliceRadioQueue.crimes[i].type = CRIME_NONE; AgeCrimes(); - return true; + return TRUE; } void @@ -714,7 +714,7 @@ cAudioManager::PlaySuspectLastSeen(float x, float y, float z) float quarterX; float quarterY; int32 sample; - bool processed = false; + bool8 processed = false; CVector vec = CVector(x, y, z); if (!m_bIsInitialised) return; @@ -745,10 +745,10 @@ cAudioManager::PlaySuspectLastSeen(float x, float y, float z) if (vec.y > halfY + quarterY) { m_sPoliceRadioQueue.Add(SFX_NORTH); - processed = true; + processed = TRUE; } else if (vec.y < halfY - quarterY) { m_sPoliceRadioQueue.Add(SFX_SOUTH); - processed = true; + processed = TRUE; } if (vec.x > halfX + quarterX) @@ -761,7 +761,7 @@ cAudioManager::PlaySuspectLastSeen(float x, float y, float z) m_sPoliceRadioQueue.Add(sample); m_sPoliceRadioQueue.Add(m_anRandomTable[2] % 3 + SFX_POLICE_RADIO_MESSAGE_NOISE_1); m_sPoliceRadioQueue.Add(TOTAL_AUDIO_SAMPLES); - gSpecialSuspectLastSeenReport = true; + gSpecialSuspectLastSeenReport = TRUE; break; } } diff --git a/src/audio/sampman.h b/src/audio/sampman.h index a5f6c7e2..765c75d3 100644 --- a/src/audio/sampman.h +++ b/src/audio/sampman.h @@ -118,10 +118,10 @@ class cSampleManager uint8 m_nMusicVolume; uint8 m_nEffectsFadeVolume; uint8 m_nMusicFadeVolume; - uint8 m_nMonoMode; + bool8 m_nMonoMode; char unk; char m_szCDRomRootPath[80]; - bool m_bInitialised; + bool8 m_bInitialised; uint8 m_nNumberOfProviders; char *m_aAudioProviders[MAXPROVIDERS]; tSample m_aSamples[TOTAL_AUDIO_SAMPLES]; @@ -145,16 +145,16 @@ public: int8 GetCurrent3DProviderIndex(void); int8 SetCurrent3DProvider(uint8 which); - bool IsMP3RadioChannelAvailable(void); + bool8 IsMP3RadioChannelAvailable(void); void ReleaseDigitalHandle (void); void ReacquireDigitalHandle(void); - bool Initialise(void); - void Terminate (void); + bool8 Initialise(void); + void Terminate (void); - bool CheckForAnAudioFileOnCD(void); - char GetCDAudioDriveLetter (void); + bool8 CheckForAnAudioFileOnCD(void); + char GetCDAudioDriveLetter (void); void UpdateEffectsVolume(void); @@ -162,14 +162,14 @@ public: void SetMusicMasterVolume (uint8 nVolume); void SetEffectsFadeVolume (uint8 nVolume); void SetMusicFadeVolume (uint8 nVolume); - void SetMonoMode (uint8 nMode); + void SetMonoMode (bool8 nMode); - bool LoadSampleBank (uint8 nBank); - void UnloadSampleBank (uint8 nBank); - bool IsSampleBankLoaded(uint8 nBank); + bool8 LoadSampleBank (uint8 nBank); + void UnloadSampleBank (uint8 nBank); + bool8 IsSampleBankLoaded(uint8 nBank); - bool IsPedCommentLoaded(uint32 nComment); - bool LoadPedComment (uint32 nComment); + bool8 IsPedCommentLoaded(uint32 nComment); + bool8 LoadPedComment (uint32 nComment); int32 GetBankContainingSound(uint32 offset); int32 _GetPedCommentSlot(uint32 nComment); @@ -179,10 +179,10 @@ public: int32 GetSampleLoopEndOffset (uint32 nSample); uint32 GetSampleLength (uint32 nSample); - bool UpdateReverb(void); + bool8 UpdateReverb(void); - void SetChannelReverbFlag (uint32 nChannel, uint8 nReverbFlag); - bool InitialiseChannel (uint32 nChannel, uint32 nSfx, uint8 nBank); + void SetChannelReverbFlag (uint32 nChannel, bool8 nReverbFlag); + bool8 InitialiseChannel (uint32 nChannel, uint32 nSfx, uint8 nBank); void SetChannelEmittingVolume(uint32 nChannel, uint32 nVolume); void SetChannel3DPosition (uint32 nChannel, float fX, float fY, float fZ); void SetChannel3DDistances (uint32 nChannel, float fMax, float fMin); @@ -191,23 +191,23 @@ public: void SetChannelFrequency (uint32 nChannel, uint32 nFreq); void SetChannelLoopPoints (uint32 nChannel, uint32 nLoopStart, int32 nLoopEnd); void SetChannelLoopCount (uint32 nChannel, uint32 nLoopCount); - bool GetChannelUsedFlag (uint32 nChannel); + bool8 GetChannelUsedFlag (uint32 nChannel); void StartChannel (uint32 nChannel); void StopChannel (uint32 nChannel); void PreloadStreamedFile (uint8 nFile, uint8 nStream); - void PauseStream (uint8 nPauseFlag, uint8 nStream); + void PauseStream (bool8 nPauseFlag, uint8 nStream); void StartPreloadedStreamedFile (uint8 nStream); - bool StartStreamedFile (uint8 nFile, uint32 nPos, uint8 nStream); + bool8 StartStreamedFile (uint8 nFile, uint32 nPos, uint8 nStream); void StopStreamedFile (uint8 nStream); int32 GetStreamedFilePosition (uint8 nStream); - void SetStreamedVolumeAndPan(uint8 nVolume, uint8 nPan, uint8 nEffectFlag, uint8 nStream); + void SetStreamedVolumeAndPan(uint8 nVolume, uint8 nPan, bool8 nEffectFlag, uint8 nStream); int32 GetStreamedFileLength (uint8 nStream); - bool IsStreamPlaying (uint8 nStream); + bool8 IsStreamPlaying (uint8 nStream); #ifdef AUDIO_OAL void Service(void); #endif - bool InitialiseSampleBanks(void); + bool8 InitialiseSampleBanks(void); }; extern cSampleManager SampleManager; diff --git a/src/audio/sampman_miles.cpp b/src/audio/sampman_miles.cpp index 351c4958..4237c6a3 100644 --- a/src/audio/sampman_miles.cpp +++ b/src/audio/sampman_miles.cpp @@ -28,7 +28,7 @@ char SampleBankDataFilename[] = "AUDIO\\SFX.RAW"; FILE *fpSampleDescHandle; FILE *fpSampleDataHandle; -bool bSampleBankLoaded [MAX_SFX_BANKS]; +bool8 bSampleBankLoaded [MAX_SFX_BANKS]; int32 nSampleBankDiscStartOffset [MAX_SFX_BANKS]; int32 nSampleBankSize [MAX_SFX_BANKS]; int32 nSampleBankMemoryStartAddress[MAX_SFX_BANKS]; @@ -62,16 +62,16 @@ int8 nStreamPan [MAX_STREAMS]; int8 nStreamVolume[MAX_STREAMS]; uint32 _CurMP3Index; int32 _CurMP3Pos; -bool _bIsMp3Active; +bool8 _bIsMp3Active; #if GTA_VERSION >= GTA3_PC_11 || defined(NO_CDCHECK) -bool _bUseHDDAudio; +bool8 _bUseHDDAudio; char _aHDDPath[MAX_PATH]; #endif /////////////////////////////////////////////////////////////// -bool _bSampmanInitialised = false; +bool8 _bSampmanInitialised = FALSE; // // Miscellaneous globals / defines @@ -98,7 +98,7 @@ S32 speaker_type=0; U32 _maxSamples; float _fPrevEaxRatioDestination; -bool _usingMilesFast2D; +bool8 _usingMilesFast2D; float _fEffectsLevel; @@ -170,17 +170,17 @@ release_existing() } _fPrevEaxRatioDestination = 0.0f; - _usingMilesFast2D = false; + _usingMilesFast2D = FALSE; _fEffectsLevel = 0.0f; } -static bool +static bool8 set_new_provider(S32 index) { DWORD result; if ( curprovider == index ) - return true; + return TRUE; //close the already opened provider curprovider = index; @@ -207,7 +207,7 @@ set_new_provider(S32 index) release_existing(); - return false; + return FALSE; } else { @@ -238,7 +238,7 @@ set_new_provider(S32 index) AIL_set_3D_room_type(opened_provider, ENVIRONMENT_CAVE); if ( !strcmp(providers[index].name, "Miles Fast 2D Positional Audio") ) - _usingMilesFast2D = true; + _usingMilesFast2D = TRUE; } AIL_3D_provider_attribute(opened_provider, "Maximum supported samples", &_maxSamples); @@ -256,11 +256,11 @@ set_new_provider(S32 index) AIL_set_3D_sample_effects_level(opened_samples[i], 0.0f); } - return true; + return TRUE; } } - return false; + return FALSE; } cSampleManager::cSampleManager(void) : @@ -353,7 +353,7 @@ cSampleManager::SetCurrent3DProvider(uint8 nProvider) return curprovider; } -static bool +static bool8 _ResolveLink(char const *path, char *out) { IShellLink* psl; @@ -389,7 +389,7 @@ _ResolveLink(char const *path, char *out) ppf->Release(); psl->Release(); #endif - return true; + return TRUE; } } } @@ -399,15 +399,15 @@ _ResolveLink(char const *path, char *out) psl->Release(); } - return false; + return FALSE; } static void _FindMP3s(void) { tMP3Entry *pList; - bool bShortcut; - bool bInitFirstEntry; + bool8 bShortcut; + bool8 bInitFirstEntry; HANDLE hFind; char path[MAX_PATH]; char filepath[MAX_PATH*2]; @@ -474,10 +474,10 @@ _FindMP3s(void) if ( f ) fprintf(f, " - couldn't resolve shortcut"); } - bShortcut = true; + bShortcut = TRUE; } else - bShortcut = false; + bShortcut = FALSE; } mp3Stream[0] = AIL_open_stream(DIG, filepath, 0); @@ -524,7 +524,7 @@ _FindMP3s(void) if ( f ) fprintf(f, " - OK\n"); - bInitFirstEntry = false; + bInitFirstEntry = FALSE; } else { @@ -534,10 +534,10 @@ _FindMP3s(void) if ( f ) fprintf(f, " - not an MP3 or supported MP3 type\n"); - bInitFirstEntry = true; + bInitFirstEntry = TRUE; } - while ( true ) + while ( TRUE ) { if ( !FindNextFile(hFind, &fd) ) break; @@ -569,11 +569,11 @@ _FindMP3s(void) if ( f ) fprintf(f, " - couldn't resolve shortcut"); } - bShortcut = true; + bShortcut = TRUE; } else { - bShortcut = false; + bShortcut = FALSE; if ( filepathlen > MAX_PATH ) { @@ -620,7 +620,7 @@ _FindMP3s(void) if ( f ) fprintf(f, " - OK\n"); - bInitFirstEntry = false; + bInitFirstEntry = FALSE; } else { @@ -658,11 +658,11 @@ _FindMP3s(void) if ( f ) fprintf(f, " - couldn't resolve shortcut"); } - bShortcut = true; + bShortcut = TRUE; } else { - bShortcut = false; + bShortcut = FALSE; } } @@ -784,7 +784,7 @@ _GetMP3EntryByIndex(uint32 idx) return NULL; } -static inline bool +static inline bool8 _GetMP3PosFromStreamPos(uint32 *pPosition, tMP3Entry **pEntry) { _CurMP3Index = 0; @@ -797,7 +797,7 @@ _GetMP3PosFromStreamPos(uint32 *pPosition, tMP3Entry **pEntry) *pPosition -= (*pEntry)->nTrackStreamPos; _CurMP3Pos = *pPosition; - return true; + return TRUE; } _CurMP3Index++; @@ -808,10 +808,10 @@ _GetMP3PosFromStreamPos(uint32 *pPosition, tMP3Entry **pEntry) _CurMP3Pos = 0; _CurMP3Index = 0; - return false; + return FALSE; } -bool +bool8 cSampleManager::IsMP3RadioChannelAvailable(void) { return nNumMP3s != 0; @@ -840,13 +840,13 @@ cSampleManager::ReacquireDigitalHandle(void) } } -bool +bool8 cSampleManager::Initialise(void) { TRACE("start"); if ( _bSampmanInitialised ) - return true; + return TRUE; { for ( int32 i = 0; i < TOTAL_AUDIO_SAMPLES; i++ ) @@ -872,7 +872,7 @@ cSampleManager::Initialise(void) curprovider = -1; prevprovider = -1; - _usingMilesFast2D = false; + _usingMilesFast2D = FALSE; usingEAX=0; usingEAX3=0; @@ -897,7 +897,7 @@ cSampleManager::Initialise(void) for ( int32 i = 0; i < MAX_SFX_BANKS; i++ ) { - bSampleBankLoaded[i] = false; + bSampleBankLoaded[i] = FALSE; nSampleBankDiscStartOffset[i] = 0; nSampleBankSize[i] = 0; nSampleBankMemoryStartAddress[i] = 0; @@ -936,7 +936,7 @@ cSampleManager::Initialise(void) { OutputDebugString(AIL_last_error()); Terminate(); - return false; + return FALSE; } add_providers(); @@ -944,14 +944,14 @@ cSampleManager::Initialise(void) if ( !InitialiseSampleBanks() ) { Terminate(); - return false; + return FALSE; } nSampleBankMemoryStartAddress[SFX_BANK_0] = (int32)AIL_mem_alloc_lock(nSampleBankSize[SFX_BANK_0]); if ( !nSampleBankMemoryStartAddress[SFX_BANK_0] ) { Terminate(); - return false; + return FALSE; } nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = (int32)AIL_mem_alloc_lock(PED_BLOCKSIZE*MAX_PEDSFX); @@ -964,7 +964,7 @@ cSampleManager::Initialise(void) if (cacheFile) { fread(nStreamLength, sizeof(uint32), TOTAL_STREAMED_SOUNDS, cacheFile); fclose(cacheFile); - m_bInitialised = true; + m_bInitialised = TRUE; }else { #endif TRACE("cdrom"); @@ -973,9 +973,9 @@ cSampleManager::Initialise(void) char filepath[MAX_PATH]; { - m_bInitialised = false; + m_bInitialised = FALSE; - while (true) + while (TRUE) { int32 drive = 'C'; @@ -1000,7 +1000,7 @@ cSampleManager::Initialise(void) { fclose(f); - bool bFileNotFound = false; + bool8 bFileNotFound = FALSE; for ( int32 i = 0; i < TOTAL_STREAMED_SOUNDS; i++ ) { @@ -1020,19 +1020,19 @@ cSampleManager::Initialise(void) } else { - bFileNotFound = true; + bFileNotFound = TRUE; break; } } if ( !bFileNotFound ) { - m_bInitialised = true; + m_bInitialised = TRUE; break; } else { - m_bInitialised = false; + m_bInitialised = FALSE; continue; } } @@ -1047,11 +1047,11 @@ cSampleManager::Initialise(void) if ( FrontEndMenuManager.m_bQuitGameNoCD ) { Terminate(); - return false; + return FALSE; } continue; #else - m_bInitialised = true; + m_bInitialised = TRUE; #endif } @@ -1071,7 +1071,7 @@ cSampleManager::Initialise(void) { int32 streamLength[TOTAL_STREAMED_SOUNDS]; - bool bFileNotFound = false; + bool8 bFileNotFound = FALSE; char rootpath[MAX_PATH]; strcpy(_aHDDPath, m_szCDRomRootPath); @@ -1101,14 +1101,14 @@ cSampleManager::Initialise(void) } else { - bFileNotFound = true; + bFileNotFound = TRUE; break; } } } else - bFileNotFound = true; + bFileNotFound = TRUE; if ( !bFileNotFound ) { @@ -1117,10 +1117,10 @@ cSampleManager::Initialise(void) for ( int32 i = 0; i < TOTAL_STREAMED_SOUNDS; i++ ) nStreamLength[i] = streamLength[i]; - _bUseHDDAudio = true; + _bUseHDDAudio = TRUE; } else - _bUseHDDAudio = false; + _bUseHDDAudio = FALSE; } #endif #ifdef AUDIO_CACHE @@ -1152,7 +1152,7 @@ cSampleManager::Initialise(void) TRACE("providerset"); { - _bSampmanInitialised = true; + _bSampmanInitialised = TRUE; U32 n = 0; @@ -1169,7 +1169,7 @@ cSampleManager::Initialise(void) if ( n == m_nNumberOfProviders ) { Terminate(); - return false; + return FALSE; } } @@ -1198,13 +1198,13 @@ cSampleManager::Initialise(void) time_t t = time(NULL); tm *localtm; - bool bUseRandomTable; + bool8 bUseRandomTable; if ( t == -1 ) - bUseRandomTable = true; + bUseRandomTable = TRUE; else { - bUseRandomTable = false; + bUseRandomTable = FALSE; localtm = localtime(&t); } @@ -1236,12 +1236,12 @@ cSampleManager::Initialise(void) else _CurMP3Pos = 0; - _bIsMp3Active = false; + _bIsMp3Active = FALSE; } TRACE("end"); - return true; + return TRUE; } void @@ -1290,10 +1290,10 @@ cSampleManager::Terminate(void) AIL_shutdown(); - _bSampmanInitialised = false; + _bSampmanInitialised = FALSE; } -bool +bool8 cSampleManager::CheckForAnAudioFileOnCD(void) { #if GTA_VERSION < GTA3_PC_STEAM && !defined(NO_CDCHECK) @@ -1316,13 +1316,13 @@ cSampleManager::CheckForAnAudioFileOnCD(void) { fclose(f); - return true; + return TRUE; } - return false; + return FALSE; #else - return true; + return TRUE; #endif // #if GTA_VERSION < GTA3_PC_STEAM && !defined(NO_CDCHECK) } @@ -1415,48 +1415,48 @@ cSampleManager::SetMusicFadeVolume(uint8 nVolume) } void -cSampleManager::SetMonoMode(uint8 nMode) +cSampleManager::SetMonoMode(bool8 nMode) { m_nMonoMode = nMode; } -bool +bool8 cSampleManager::LoadSampleBank(uint8 nBank) { if ( CTimer::GetIsCodePaused() ) - return false; + return FALSE; if ( MusicManager.IsInitialised() && MusicManager.GetMusicMode() == MUSICMODE_CUTSCENE && nBank != SFX_BANK_0 ) { - return false; + return FALSE; } if ( fseek(fpSampleDataHandle, nSampleBankDiscStartOffset[nBank], SEEK_SET) != 0 ) - return false; + return FALSE; if ( fread((void *)nSampleBankMemoryStartAddress[nBank], 1, nSampleBankSize[nBank],fpSampleDataHandle) != nSampleBankSize[nBank] ) - return false; + return FALSE; - bSampleBankLoaded[nBank] = true; + bSampleBankLoaded[nBank] = TRUE; - return true; + return TRUE; } void cSampleManager::UnloadSampleBank(uint8 nBank) { - bSampleBankLoaded[nBank] = false; + bSampleBankLoaded[nBank] = FALSE; } -bool +bool8 cSampleManager::IsSampleBankLoaded(uint8 nBank) { return bSampleBankLoaded[nBank]; } -bool +bool8 cSampleManager::IsPedCommentLoaded(uint32 nComment) { int8 slot; @@ -1469,10 +1469,10 @@ cSampleManager::IsPedCommentLoaded(uint32 nComment) slot += ARRAY_SIZE(nPedSlotSfx); #endif if ( nComment == nPedSlotSfx[slot] ) - return true; + return TRUE; } - return false; + return FALSE; } int32 @@ -1494,11 +1494,11 @@ cSampleManager::_GetPedCommentSlot(uint32 nComment) return -1; } -bool +bool8 cSampleManager::LoadPedComment(uint32 nComment) { if ( CTimer::GetIsCodePaused() ) - return false; + return FALSE; // no talking peds during cutsenes or the game end if ( MusicManager.IsInitialised() ) @@ -1507,7 +1507,7 @@ cSampleManager::LoadPedComment(uint32 nComment) { case MUSICMODE_CUTSCENE: { - return false; + return FALSE; break; } @@ -1515,7 +1515,7 @@ cSampleManager::LoadPedComment(uint32 nComment) case MUSICMODE_FRONTEND: { if ( MusicManager.GetNextTrack() == STREAMED_SOUND_GAME_COMPLETED ) - return false; + return FALSE; break; } @@ -1523,10 +1523,10 @@ cSampleManager::LoadPedComment(uint32 nComment) } if ( fseek(fpSampleDataHandle, m_aSamples[nComment].nOffset, SEEK_SET) != 0 ) - return false; + return FALSE; if ( fread((void *)(nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BLOCKSIZE*nCurrentPedSlot), 1, m_aSamples[nComment].nSize, fpSampleDataHandle) != m_aSamples[nComment].nSize ) - return false; + return FALSE; nPedSlotSfxAddr[nCurrentPedSlot] = nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BLOCKSIZE*nCurrentPedSlot; nPedSlotSfx [nCurrentPedSlot] = nComment; @@ -1534,7 +1534,7 @@ cSampleManager::LoadPedComment(uint32 nComment) if ( ++nCurrentPedSlot >= MAX_PEDSFX ) nCurrentPedSlot = 0; - return true; + return TRUE; } int32 @@ -1573,14 +1573,14 @@ cSampleManager::GetSampleLength(uint32 nSample) return m_aSamples[nSample].nSize >> 1; } -bool +bool8 cSampleManager::UpdateReverb(void) { if ( !usingEAX ) - return false; + return FALSE; if ( AudioManager.GetFrameCounter() & 15 ) - return false; + return FALSE; float y = AudioManager.GetReflectionsDistance(REFLECTION_TOP) + AudioManager.GetReflectionsDistance(REFLECTION_BOTTOM); float x = AudioManager.GetReflectionsDistance(REFLECTION_LEFT) + AudioManager.GetReflectionsDistance(REFLECTION_RIGHT); @@ -1627,7 +1627,7 @@ cSampleManager::UpdateReverb(void) fRatio = clamp(fRatio, usingEAX3==1 ? 0.0f : 0.30f, 1.0f); if ( fRatio == _fPrevEaxRatioDestination ) - return false; + return FALSE; if ( usingEAX3 ) { @@ -1647,26 +1647,26 @@ cSampleManager::UpdateReverb(void) _fPrevEaxRatioDestination = fRatio; - return true; + return TRUE; } void -cSampleManager::SetChannelReverbFlag(uint32 nChannel, uint8 nReverbFlag) +cSampleManager::SetChannelReverbFlag(uint32 nChannel, bool8 nReverbFlag) { - bool b2d = false; + bool8 b2d = FALSE; switch ( nChannel ) { case CHANNEL2D: { - b2d = true; + b2d = TRUE; break; } } if ( usingEAX ) { - if ( nReverbFlag != 0 ) + if ( nReverbFlag != FALSE ) { if ( !b2d ) AIL_set_3D_sample_effects_level(opened_samples[nChannel], _fEffectsLevel); @@ -1679,16 +1679,16 @@ cSampleManager::SetChannelReverbFlag(uint32 nChannel, uint8 nReverbFlag) } } -bool +bool8 cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank) { - bool b2d = false; + bool8 b2d = FALSE; switch ( nChannel ) { case CHANNEL2D: { - b2d = true; + b2d = TRUE; break; } } @@ -1698,14 +1698,14 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank) if ( nSfx < SAMPLEBANK_MAX ) { if ( !IsSampleBankLoaded(nBank) ) - return false; + return FALSE; addr = nSampleBankMemoryStartAddress[nBank] + m_aSamples[nSfx].nOffset - m_aSamples[BankStartOffset[nBank]].nOffset; } else { if ( !IsPedCommentLoaded(nSfx) ) - return false; + return FALSE; int32 slot = _GetPedCommentSlot(nSfx); @@ -1717,10 +1717,10 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank) if ( opened_2dsamples[nChannel - MAXCHANNELS] ) { AIL_set_sample_address(opened_2dsamples[nChannel - MAXCHANNELS], (void *)addr, m_aSamples[nSfx].nSize); - return true; + return TRUE; } else - return false; + return FALSE; } else { @@ -1736,10 +1736,10 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank) if ( AIL_set_3D_sample_info(opened_samples[nChannel], &info) == 0 ) { OutputDebugString(AIL_last_error()); - return false; + return FALSE; } - return true; + return TRUE; } } @@ -1831,13 +1831,13 @@ cSampleManager::SetChannelPan(uint32 nChannel, uint32 nPan) void cSampleManager::SetChannelFrequency(uint32 nChannel, uint32 nFreq) { - bool b2d = false; + bool8 b2d = FALSE; switch ( nChannel ) { case CHANNEL2D: { - b2d = true; + b2d = TRUE; break; } } @@ -1857,13 +1857,13 @@ cSampleManager::SetChannelFrequency(uint32 nChannel, uint32 nFreq) void cSampleManager::SetChannelLoopPoints(uint32 nChannel, uint32 nLoopStart, int32 nLoopEnd) { - bool b2d = false; + bool8 b2d = FALSE; switch ( nChannel ) { case CHANNEL2D: { - b2d = true; + b2d = TRUE; break; } } @@ -1883,13 +1883,13 @@ cSampleManager::SetChannelLoopPoints(uint32 nChannel, uint32 nLoopStart, int32 n void cSampleManager::SetChannelLoopCount(uint32 nChannel, uint32 nLoopCount) { - bool b2d = false; + bool8 b2d = FALSE; switch ( nChannel ) { case CHANNEL2D: { - b2d = true; + b2d = TRUE; break; } } @@ -1906,16 +1906,16 @@ cSampleManager::SetChannelLoopCount(uint32 nChannel, uint32 nLoopCount) } } -bool +bool8 cSampleManager::GetChannelUsedFlag(uint32 nChannel) { - bool b2d = false; + bool8 b2d = FALSE; switch ( nChannel ) { case CHANNEL2D: { - b2d = true; + b2d = TRUE; break; } } @@ -1925,14 +1925,14 @@ cSampleManager::GetChannelUsedFlag(uint32 nChannel) if ( opened_2dsamples[nChannel - MAXCHANNELS] ) return AIL_sample_status(opened_2dsamples[nChannel - MAXCHANNELS]) == SMP_PLAYING; else - return false; + return FALSE; } else { if ( opened_samples[nChannel] ) return AIL_3D_sample_status(opened_samples[nChannel]) == SMP_PLAYING; else - return false; + return FALSE; } } @@ -1940,13 +1940,13 @@ cSampleManager::GetChannelUsedFlag(uint32 nChannel) void cSampleManager::StartChannel(uint32 nChannel) { - bool b2d = false; + bool8 b2d = FALSE; switch ( nChannel ) { case CHANNEL2D: { - b2d = true; + b2d = TRUE; break; } } @@ -1966,13 +1966,13 @@ cSampleManager::StartChannel(uint32 nChannel) void cSampleManager::StopChannel(uint32 nChannel) { - bool b2d = false; + bool8 b2d = FALSE; switch ( nChannel ) { case CHANNEL2D: { - b2d = true; + b2d = TRUE; break; } } @@ -2024,12 +2024,12 @@ cSampleManager::PreloadStreamedFile(uint8 nFile, uint8 nStream) } void -cSampleManager::PauseStream(uint8 nPauseFlag, uint8 nStream) +cSampleManager::PauseStream(bool8 nPauseFlag, uint8 nStream) { if ( m_bInitialised ) { if ( mp3Stream[nStream] ) - AIL_pause_stream(mp3Stream[nStream], nPauseFlag != 0); + AIL_pause_stream(mp3Stream[nStream], nPauseFlag != FALSE); } } @@ -2043,7 +2043,7 @@ cSampleManager::StartPreloadedStreamedFile(uint8 nStream) } } -bool +bool8 cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) { int i = 0; @@ -2051,7 +2051,7 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) char filename[MAX_PATH]; if ( !m_bInitialised || nFile >= TOTAL_STREAMED_SOUNDS ) - return false; + return FALSE; if ( mp3Stream[nStream] ) { @@ -2081,9 +2081,9 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) AIL_set_stream_loop_count(mp3Stream[nStream], 1); AIL_set_stream_ms_position(mp3Stream[nStream], position); AIL_pause_stream(mp3Stream[nStream], 0); - return true; + return TRUE; } - return false; + return FALSE; } else { if ( e->pLinkPath != NULL ) @@ -2100,9 +2100,9 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) AIL_set_stream_ms_position(mp3Stream[nStream], position); AIL_pause_stream(mp3Stream[nStream], 0); - _bIsMp3Active = true; + _bIsMp3Active = TRUE; - return true; + return TRUE; } // fall through, start playing from another song } @@ -2128,9 +2128,9 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) AIL_set_stream_loop_count(mp3Stream[nStream], 1); AIL_set_stream_ms_position(mp3Stream[nStream], position); AIL_pause_stream(mp3Stream[nStream], 0); - return true; + return TRUE; } - return false; + return FALSE; } } if(mp3->pLinkPath != NULL) @@ -2148,9 +2148,9 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) AIL_set_stream_ms_position(mp3Stream[nStream], 0); AIL_pause_stream(mp3Stream[nStream], 0); #ifdef FIX_BUGS - _bIsMp3Active = true; + _bIsMp3Active = TRUE; #endif - return true; + return TRUE; } } @@ -2169,9 +2169,9 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) AIL_set_stream_loop_count(mp3Stream[nStream], 1); AIL_set_stream_ms_position(mp3Stream[nStream], position); AIL_pause_stream(mp3Stream[nStream], 0); - return true; + return TRUE; } - return false; + return FALSE; } void @@ -2187,7 +2187,7 @@ cSampleManager::StopStreamedFile(uint8 nStream) mp3Stream[nStream] = NULL; if ( nStream == 0 ) - _bIsMp3Active = false; + _bIsMp3Active = FALSE; } } } @@ -2225,7 +2225,7 @@ cSampleManager::GetStreamedFilePosition(uint8 nStream) } void -cSampleManager::SetStreamedVolumeAndPan(uint8 nVolume, uint8 nPan, uint8 nEffectFlag, uint8 nStream) +cSampleManager::SetStreamedVolumeAndPan(uint8 nVolume, uint8 nPan, bool8 nEffectFlag, uint8 nStream) { uint8 vol = nVolume; @@ -2258,7 +2258,7 @@ cSampleManager::GetStreamedFileLength(uint8 nStream) return 0; } -bool +bool8 cSampleManager::IsStreamPlaying(uint8 nStream) { if ( m_bInitialised ) @@ -2266,23 +2266,23 @@ cSampleManager::IsStreamPlaying(uint8 nStream) if ( mp3Stream[nStream] ) { if ( AIL_stream_status(mp3Stream[nStream]) == SMP_PLAYING ) - return true; + return TRUE; else - return false; + return FALSE; } } - return false; + return FALSE; } -bool +bool8 cSampleManager::InitialiseSampleBanks(void) { int32 nBank = SFX_BANK_0; fpSampleDescHandle = fopen(SampleBankDescFilename, "rb"); if ( fpSampleDescHandle == NULL ) - return false; + return FALSE; fpSampleDataHandle = fopen(SampleBankDataFilename, "rb"); if ( fpSampleDataHandle == NULL ) @@ -2290,7 +2290,7 @@ cSampleManager::InitialiseSampleBanks(void) fclose(fpSampleDescHandle); fpSampleDescHandle = NULL; - return false; + return FALSE; } fseek(fpSampleDataHandle, 0, SEEK_END); @@ -2317,7 +2317,7 @@ cSampleManager::InitialiseSampleBanks(void) nSampleBankSize[SFX_BANK_0] = nSampleBankDiscStartOffset[SFX_BANK_PED_COMMENTS] - nSampleBankDiscStartOffset[SFX_BANK_0]; nSampleBankSize[SFX_BANK_PED_COMMENTS] = _nSampleDataEndOffset - nSampleBankDiscStartOffset[SFX_BANK_PED_COMMENTS]; - return true; + return TRUE; } #endif diff --git a/src/audio/sampman_null.cpp b/src/audio/sampman_null.cpp index e44e5b57..95603c72 100644 --- a/src/audio/sampman_null.cpp +++ b/src/audio/sampman_null.cpp @@ -4,7 +4,7 @@ #include "AudioManager.h" cSampleManager SampleManager; -bool _bSampmanInitialised = false; +bool8 _bSampmanInitialised = FALSE; uint32 BankStartOffset[MAX_SFX_BANKS]; uint32 nNumMP3s; @@ -60,7 +60,7 @@ int8 cSampleManager::SetCurrent3DProvider(uint8 nProvider) return 0; } -bool +bool8 cSampleManager::IsMP3RadioChannelAvailable(void) { return nNumMP3s != 0; @@ -75,10 +75,10 @@ void cSampleManager::ReacquireDigitalHandle(void) { } -bool +bool8 cSampleManager::Initialise(void) { - return true; + return TRUE; } void @@ -87,9 +87,9 @@ cSampleManager::Terminate(void) } -bool cSampleManager::CheckForAnAudioFileOnCD(void) +bool8 cSampleManager::CheckForAnAudioFileOnCD(void) { - return true; + return TRUE; } char cSampleManager::GetCDAudioDriveLetter(void) @@ -128,11 +128,11 @@ cSampleManager::SetMonoMode(uint8 nMode) { } -bool +bool8 cSampleManager::LoadSampleBank(uint8 nBank) { ASSERT( nBank < MAX_SFX_BANKS ); - return false; + return FALSE; } void @@ -141,20 +141,20 @@ cSampleManager::UnloadSampleBank(uint8 nBank) ASSERT( nBank < MAX_SFX_BANKS ); } -bool +bool8 cSampleManager::IsSampleBankLoaded(uint8 nBank) { ASSERT( nBank < MAX_SFX_BANKS ); - return false; + return FALSE; } -bool +bool8 cSampleManager::IsPedCommentLoaded(uint32 nComment) { ASSERT( nComment < TOTAL_AUDIO_SAMPLES ); - return false; + return FALSE; } @@ -164,11 +164,11 @@ cSampleManager::_GetPedCommentSlot(uint32 nComment) return -1; } -bool +bool8 cSampleManager::LoadPedComment(uint32 nComment) { ASSERT( nComment < TOTAL_AUDIO_SAMPLES ); - return false; + return FALSE; } int32 @@ -205,22 +205,22 @@ cSampleManager::GetSampleLength(uint32 nSample) return 0; } -bool cSampleManager::UpdateReverb(void) +bool8 cSampleManager::UpdateReverb(void) { - return false; + return FALSE; } void -cSampleManager::SetChannelReverbFlag(uint32 nChannel, uint8 nReverbFlag) +cSampleManager::SetChannelReverbFlag(uint32 nChannel, bool8 nReverbFlag) { ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); } -bool +bool8 cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank) { ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); - return false; + return FALSE; } void @@ -276,12 +276,12 @@ cSampleManager::SetChannelLoopCount(uint32 nChannel, uint32 nLoopCount) ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); } -bool +bool8 cSampleManager::GetChannelUsedFlag(uint32 nChannel) { ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); - return false; + return FALSE; } void @@ -303,7 +303,7 @@ cSampleManager::PreloadStreamedFile(uint8 nFile, uint8 nStream) } void -cSampleManager::PauseStream(uint8 nPauseFlag, uint8 nStream) +cSampleManager::PauseStream(bool8 nPauseFlag, uint8 nStream) { ASSERT( nStream < MAX_STREAMS ); } @@ -314,12 +314,12 @@ cSampleManager::StartPreloadedStreamedFile(uint8 nStream) ASSERT( nStream < MAX_STREAMS ); } -bool +bool8 cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) { ASSERT( nStream < MAX_STREAMS ); - return false; + return FALSE; } void @@ -350,19 +350,19 @@ cSampleManager::GetStreamedFileLength(uint8 nStream) return 1; } -bool +bool8 cSampleManager::IsStreamPlaying(uint8 nStream) { ASSERT( nStream < MAX_STREAMS ); - return false; + return FALSE; } -bool +bool8 cSampleManager::InitialiseSampleBanks(void) { - return true; + return TRUE; } #endif diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp index 3d4b8dbd..15add7cb 100644 --- a/src/audio/sampman_oal.cpp +++ b/src/audio/sampman_oal.cpp @@ -48,7 +48,7 @@ //TODO: max channels cSampleManager SampleManager; -bool _bSampmanInitialised = false; +bool8 _bSampmanInitialised = FALSE; uint32 BankStartOffset[MAX_SFX_BANKS]; @@ -84,7 +84,7 @@ OggOpusFile *fpSampleDataHandle; #else FILE *fpSampleDataHandle; #endif -bool bSampleBankLoaded [MAX_SFX_BANKS]; +bool8 bSampleBankLoaded [MAX_SFX_BANKS]; int32 nSampleBankDiscStartOffset [MAX_SFX_BANKS]; int32 nSampleBankSize [MAX_SFX_BANKS]; uintptr nSampleBankMemoryStartAddress[MAX_SFX_BANKS]; @@ -120,7 +120,7 @@ uint8 nStreamPan [MAX_STREAMS]; uint8 nStreamVolume[MAX_STREAMS]; uint32 _CurMP3Index; int32 _CurMP3Pos; -bool _bIsMp3Active; +bool8 _bIsMp3Active; /////////////////////////////////////////////////////////////// // Env Size Diffus Room RoomHF RoomLF DecTm DcHF DcLF Refl RefDel Ref Pan Revb RevDel Rev Pan EchTm EchDp ModTm ModDp AirAbs HFRef LFRef RRlOff FLAGS EAXLISTENERPROPERTIES StartEAX3 = @@ -265,11 +265,11 @@ release_existing() DEV("release_existing()\n"); } -static bool +static bool8 set_new_provider(int index) { if ( curprovider == index ) - return true; + return TRUE; curprovider = index; @@ -301,7 +301,7 @@ set_new_provider(int index) { curprovider=-1; release_existing(); - return false; + return FALSE; } alListenerf (AL_GAIN, 1.0f); @@ -382,13 +382,13 @@ set_new_provider(int index) aChannel[i].SetReverbMix(ALEffectSlot, 0.0f); } - return true; + return TRUE; } - return false; + return FALSE; } -static bool +static bool8 IsThisTrackAt16KHz(uint32 track) { return track == STREAMED_SOUND_RADIO_CHAT; @@ -456,13 +456,13 @@ int8 cSampleManager::SetCurrent3DProvider(uint8 nProvider) return curprovider; } -static bool +static bool8 _ResolveLink(char const *path, char *out) { #ifdef _WIN32 size_t len = strlen(path); if (len < 4 || strcmp(&path[len - 4], ".lnk") != 0) - return false; + return FALSE; IShellLink* psl; WIN32_FIND_DATA fd; @@ -497,7 +497,7 @@ _ResolveLink(char const *path, char *out) ppf->Release(); psl->Release(); #endif - return true; + return TRUE; } } } @@ -507,31 +507,31 @@ _ResolveLink(char const *path, char *out) psl->Release(); } - return false; + return FALSE; #else struct stat sb; if (lstat(path, &sb) == -1) { perror("lstat: "); - return false; + return FALSE; } if (S_ISLNK(sb.st_mode)) { char* linkname = (char*)alloca(sb.st_size + 1); if (linkname == NULL) { fprintf(stderr, "insufficient memory\n"); - return false; + return FALSE; } if (readlink(path, linkname, sb.st_size + 1) < 0) { perror("readlink: "); - return false; + return FALSE; } linkname[sb.st_size] = '\0'; strcpy(out, linkname); - return true; + return TRUE; } else { - return false; + return FALSE; } #endif } @@ -540,8 +540,8 @@ static void _FindMP3s(void) { tMP3Entry *pList; - bool bShortcut; - bool bInitFirstEntry; + bool8 bShortcut; + bool8 bInitFirstEntry; HANDLE hFind; char path[MAX_PATH]; char filepath[MAX_PATH*2]; @@ -584,9 +584,9 @@ _FindMP3s(void) { OutputDebugString("Resolving Link"); OutputDebugString(filepath); - bShortcut = true; + bShortcut = TRUE; } else - bShortcut = false; + bShortcut = FALSE; aStream[0] = new CStream(filepath, ALStreamSources[0], ALStreamBuffers[0]); @@ -626,7 +626,7 @@ _FindMP3s(void) _pMP3List->pLinkPath = NULL; } - bInitFirstEntry = false; + bInitFirstEntry = FALSE; } else { @@ -634,10 +634,10 @@ _FindMP3s(void) OutputDebugString(filepath); - bInitFirstEntry = true; + bInitFirstEntry = TRUE; } - while ( true ) + while ( TRUE ) { if ( !FindNextFile(hFind, &fd) ) break; @@ -655,9 +655,9 @@ _FindMP3s(void) { OutputDebugString("Resolving Link"); OutputDebugString(filepath); - bShortcut = true; + bShortcut = TRUE; } else { - bShortcut = false; + bShortcut = FALSE; if (filepathlen > MAX_PATH) { continue; } @@ -696,7 +696,7 @@ _FindMP3s(void) pList = _pMP3List; - bInitFirstEntry = false; + bInitFirstEntry = FALSE; } else { @@ -718,9 +718,9 @@ _FindMP3s(void) { OutputDebugString("Resolving Link"); OutputDebugString(filepath); - bShortcut = true; + bShortcut = TRUE; } else - bShortcut = false; + bShortcut = FALSE; aStream[0] = new CStream(filepath, ALStreamSources[0], ALStreamBuffers[0]); @@ -830,7 +830,7 @@ _GetMP3EntryByIndex(uint32 idx) return NULL; } -static inline bool +static inline bool8 _GetMP3PosFromStreamPos(uint32 *pPosition, tMP3Entry **pEntry) { _CurMP3Index = 0; @@ -843,7 +843,7 @@ _GetMP3PosFromStreamPos(uint32 *pPosition, tMP3Entry **pEntry) *pPosition -= (*pEntry)->nTrackStreamPos; _CurMP3Pos = *pPosition; - return true; + return TRUE; } _CurMP3Index++; @@ -854,10 +854,10 @@ _GetMP3PosFromStreamPos(uint32 *pPosition, tMP3Entry **pEntry) _CurMP3Pos = 0; _CurMP3Index = 0; - return false; + return FALSE; } -bool +bool8 cSampleManager::IsMP3RadioChannelAvailable(void) { return nNumMP3s != 0; @@ -883,11 +883,11 @@ void cSampleManager::ReacquireDigitalHandle(void) } } -bool +bool8 cSampleManager::Initialise(void) { if ( _bSampmanInitialised ) - return true; + return TRUE; EFXInit(); CStream::Initialise(); @@ -932,7 +932,7 @@ cSampleManager::Initialise(void) for ( int32 i = 0; i < MAX_SFX_BANKS; i++ ) { - bSampleBankLoaded[i] = false; + bSampleBankLoaded[i] = FALSE; nSampleBankDiscStartOffset[i] = 0; nSampleBankSize[i] = 0; nSampleBankMemoryStartAddress[i] = 0; @@ -1000,7 +1000,7 @@ cSampleManager::Initialise(void) if ( !InitialiseSampleBanks() ) { Terminate(); - return false; + return FALSE; } nSampleBankMemoryStartAddress[SFX_BANK_0] = (uintptr)malloc(nSampleBankSize[SFX_BANK_0]); @@ -1009,7 +1009,7 @@ cSampleManager::Initialise(void) if ( nSampleBankMemoryStartAddress[SFX_BANK_0] == 0 ) { Terminate(); - return false; + return FALSE; } nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = (uintptr)malloc(PED_BLOCKSIZE*MAX_PEDSFX); @@ -1028,7 +1028,7 @@ cSampleManager::Initialise(void) } { - _bSampmanInitialised = true; + _bSampmanInitialised = TRUE; if ( defaultProvider >= 0 && defaultProvider < m_nNumberOfProviders ) { @@ -1037,7 +1037,7 @@ cSampleManager::Initialise(void) else { Terminate(); - return false; + return FALSE; } } @@ -1060,13 +1060,13 @@ cSampleManager::Initialise(void) time_t t = time(NULL); tm *localtm; - bool bUseRandomTable; + bool8 bUseRandomTable; if ( t == -1 ) - bUseRandomTable = true; + bUseRandomTable = TRUE; else { - bUseRandomTable = false; + bUseRandomTable = FALSE; localtm = localtime(&t); } @@ -1098,10 +1098,10 @@ cSampleManager::Initialise(void) else _CurMP3Pos = 0; - _bIsMp3Active = false; + _bIsMp3Active = FALSE; } - return true; + return TRUE; } void @@ -1135,12 +1135,12 @@ cSampleManager::Terminate(void) nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = 0; } - _bSampmanInitialised = false; + _bSampmanInitialised = FALSE; } -bool cSampleManager::CheckForAnAudioFileOnCD(void) +bool8 cSampleManager::CheckForAnAudioFileOnCD(void) { - return true; + return TRUE; } char cSampleManager::GetCDAudioDriveLetter(void) @@ -1196,19 +1196,19 @@ cSampleManager::SetMonoMode(uint8 nMode) m_nMonoMode = nMode; } -bool +bool8 cSampleManager::LoadSampleBank(uint8 nBank) { ASSERT( nBank < MAX_SFX_BANKS); if ( CTimer::GetIsCodePaused() ) - return false; + return FALSE; if ( MusicManager.IsInitialised() && MusicManager.GetMusicMode() == MUSICMODE_CUTSCENE && nBank != SFX_BANK_0 ) { - return false; + return FALSE; } #ifdef OPUS_SFX @@ -1227,14 +1227,14 @@ cSampleManager::LoadSampleBank(uint8 nBank) } #else if ( fseek(fpSampleDataHandle, nSampleBankDiscStartOffset[nBank], SEEK_SET) != 0 ) - return false; + return FALSE; if ( fread((void *)nSampleBankMemoryStartAddress[nBank], 1, nSampleBankSize[nBank], fpSampleDataHandle) != nSampleBankSize[nBank] ) - return false; + return FALSE; #endif - bSampleBankLoaded[nBank] = true; + bSampleBankLoaded[nBank] = TRUE; - return true; + return TRUE; } void @@ -1242,10 +1242,10 @@ cSampleManager::UnloadSampleBank(uint8 nBank) { ASSERT( nBank < MAX_SFX_BANKS); - bSampleBankLoaded[nBank] = false; + bSampleBankLoaded[nBank] = FALSE; } -bool +bool8 cSampleManager::IsSampleBankLoaded(uint8 nBank) { ASSERT( nBank < MAX_SFX_BANKS); @@ -1253,7 +1253,7 @@ cSampleManager::IsSampleBankLoaded(uint8 nBank) return bSampleBankLoaded[nBank]; } -bool +bool8 cSampleManager::IsPedCommentLoaded(uint32 nComment) { ASSERT( nComment < TOTAL_AUDIO_SAMPLES ); @@ -1268,10 +1268,10 @@ cSampleManager::IsPedCommentLoaded(uint32 nComment) slot += ARRAY_SIZE(nPedSlotSfx); #endif if ( nComment == nPedSlotSfx[slot] ) - return true; + return TRUE; } - return false; + return FALSE; } @@ -1294,13 +1294,13 @@ cSampleManager::_GetPedCommentSlot(uint32 nComment) return -1; } -bool +bool8 cSampleManager::LoadPedComment(uint32 nComment) { ASSERT( nComment < TOTAL_AUDIO_SAMPLES ); if ( CTimer::GetIsCodePaused() ) - return false; + return FALSE; // no talking peds during cutsenes or the game end if ( MusicManager.IsInitialised() ) @@ -1309,7 +1309,7 @@ cSampleManager::LoadPedComment(uint32 nComment) { case MUSICMODE_CUTSCENE: { - return false; + return FALSE; break; } @@ -1317,7 +1317,7 @@ cSampleManager::LoadPedComment(uint32 nComment) case MUSICMODE_FRONTEND: { if ( MusicManager.GetNextTrack() == STREAMED_SOUND_GAME_COMPLETED ) - return false; + return FALSE; break; } @@ -1332,17 +1332,17 @@ cSampleManager::LoadPedComment(uint32 nComment) int size = op_read(fpSampleDataHandle, (opus_int16 *)(nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BLOCKSIZE * nCurrentPedSlot + samplesRead), samplesSize, NULL); if (size <= 0) { - return false; + return FALSE; } samplesRead += size * 2; samplesSize -= size; } #else if ( fseek(fpSampleDataHandle, m_aSamples[nComment].nOffset, SEEK_SET) != 0 ) - return false; + return FALSE; if ( fread((void *)(nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BLOCKSIZE*nCurrentPedSlot), 1, m_aSamples[nComment].nSize, fpSampleDataHandle) != m_aSamples[nComment].nSize ) - return false; + return FALSE; #endif nPedSlotSfx[nCurrentPedSlot] = nComment; @@ -1350,7 +1350,7 @@ cSampleManager::LoadPedComment(uint32 nComment) if ( ++nCurrentPedSlot >= MAX_PEDSFX ) nCurrentPedSlot = 0; - return true; + return TRUE; } int32 @@ -1393,13 +1393,13 @@ cSampleManager::GetSampleLength(uint32 nSample) return m_aSamples[nSample].nSize / sizeof(uint16); } -bool cSampleManager::UpdateReverb(void) +bool8 cSampleManager::UpdateReverb(void) { if ( !usingEAX && !_usingEFX ) - return false; + return FALSE; if ( AudioManager.GetFrameCounter() & 15 ) - return false; + return FALSE; float y = AudioManager.GetReflectionsDistance(REFLECTION_TOP) + AudioManager.GetReflectionsDistance(REFLECTION_BOTTOM); float x = AudioManager.GetReflectionsDistance(REFLECTION_LEFT) + AudioManager.GetReflectionsDistance(REFLECTION_RIGHT); @@ -1420,7 +1420,7 @@ bool cSampleManager::UpdateReverb(void) fRatio = clamp(fRatio, usingEAX3==1 ? 0.0f : 0.30f, 1.0f); if ( fRatio == _fPrevEaxRatioDestination ) - return false; + return FALSE; #ifdef JUICY_OAL if ( usingEAX3 || _usingEFX ) @@ -1455,11 +1455,11 @@ bool cSampleManager::UpdateReverb(void) _fPrevEaxRatioDestination = fRatio; - return true; + return TRUE; } void -cSampleManager::SetChannelReverbFlag(uint32 nChannel, uint8 nReverbFlag) +cSampleManager::SetChannelReverbFlag(uint32 nChannel, bool8 nReverbFlag) { ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); @@ -1469,7 +1469,7 @@ cSampleManager::SetChannelReverbFlag(uint32 nChannel, uint8 nReverbFlag) { alAuxiliaryEffectSloti(ALEffectSlot, AL_EFFECTSLOT_EFFECT, ALEffect); - if ( nReverbFlag != 0 ) + if ( nReverbFlag != FALSE ) aChannel[nChannel].SetReverbMix(ALEffectSlot, _fEffectsLevel); else aChannel[nChannel].SetReverbMix(ALEffectSlot, 0.0f); @@ -1477,7 +1477,7 @@ cSampleManager::SetChannelReverbFlag(uint32 nChannel, uint8 nReverbFlag) } } -bool +bool8 cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank) { ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); @@ -1487,14 +1487,14 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank) if ( nSfx < SAMPLEBANK_MAX ) { if ( !IsSampleBankLoaded(nBank) ) - return false; + return FALSE; addr = nSampleBankMemoryStartAddress[nBank] + m_aSamples[nSfx].nOffset - m_aSamples[BankStartOffset[nBank]].nOffset; } else { if ( !IsPedCommentLoaded(nSfx) ) - return false; + return FALSE; int32 slot = _GetPedCommentSlot(nSfx); addr = (nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BLOCKSIZE * slot); @@ -1512,10 +1512,10 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank) aChannel[nChannel].SetSampleData ((void*)addr, m_aSamples[nSfx].nSize, m_aSamples[nSfx].nFrequency); aChannel[nChannel].SetLoopPoints (0, -1); aChannel[nChannel].SetPitch (1.0f); - return true; + return TRUE; } - return false; + return FALSE; } void @@ -1619,7 +1619,7 @@ cSampleManager::SetChannelLoopCount(uint32 nChannel, uint32 nLoopCount) aChannel[nChannel].SetLoopCount(nLoopCount); } -bool +bool8 cSampleManager::GetChannelUsedFlag(uint32 nChannel) { ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); @@ -1673,7 +1673,7 @@ cSampleManager::PreloadStreamedFile(uint8 nFile, uint8 nStream) } void -cSampleManager::PauseStream(uint8 nPauseFlag, uint8 nStream) +cSampleManager::PauseStream(bool8 nPauseFlag, uint8 nStream) { ASSERT( nStream < MAX_STREAMS ); @@ -1681,7 +1681,7 @@ cSampleManager::PauseStream(uint8 nPauseFlag, uint8 nStream) if ( stream ) { - stream->SetPause(nPauseFlag != 0); + stream->SetPause(nPauseFlag != FALSE); } } @@ -1701,7 +1701,7 @@ cSampleManager::StartPreloadedStreamedFile(uint8 nStream) } } -bool +bool8 cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) { int i = 0; @@ -1709,7 +1709,7 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) char filename[MAX_PATH]; if ( nFile >= TOTAL_STREAMED_SOUNDS ) - return false; + return FALSE; if ( aStream[nStream] ) { @@ -1742,12 +1742,12 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) stream->Start(); - return true; + return TRUE; } else { delete stream; aStream[nStream] = NULL; } - return false; + return FALSE; } else { if ( e->pLinkPath != NULL ) @@ -1765,8 +1765,8 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) aStream[nStream]->Start(); - _bIsMp3Active = true; - return true; + _bIsMp3Active = TRUE; + return TRUE; } else { delete aStream[nStream]; aStream[nStream] = NULL; @@ -1798,12 +1798,12 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) stream->Start(); - return true; + return TRUE; } else { delete stream; aStream[nStream] = NULL; } - return false; + return FALSE; } } if(mp3->pLinkPath != NULL) @@ -1818,9 +1818,9 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) if (aStream[nStream]->Setup()) { aStream[nStream]->Start(); #ifdef FIX_BUGS - _bIsMp3Active = true; + _bIsMp3Active = TRUE; #endif - return true; + return TRUE; } else { delete aStream[nStream]; aStream[nStream] = NULL; @@ -1845,12 +1845,12 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) stream->Start(); - return true; + return TRUE; } else { delete stream; aStream[nStream] = NULL; } - return false; + return FALSE; } void @@ -1866,7 +1866,7 @@ cSampleManager::StopStreamedFile(uint8 nStream) aStream[nStream] = NULL; if ( nStream == 0 ) - _bIsMp3Active = false; + _bIsMp3Active = FALSE; } } @@ -1934,7 +1934,7 @@ cSampleManager::GetStreamedFileLength(uint8 nStream) return nStreamLength[nStream]; } -bool +bool8 cSampleManager::IsStreamPlaying(uint8 nStream) { ASSERT( nStream < MAX_STREAMS ); @@ -1944,10 +1944,10 @@ cSampleManager::IsStreamPlaying(uint8 nStream) if ( stream ) { if ( stream->IsPlaying() ) - return true; + return TRUE; } - return false; + return FALSE; } void @@ -1968,14 +1968,14 @@ cSampleManager::Service(void) } } -bool +bool8 cSampleManager::InitialiseSampleBanks(void) { int32 nBank = SFX_BANK_0; fpSampleDescHandle = fcaseopen(SampleBankDescFilename, "rb"); if ( fpSampleDescHandle == NULL ) - return false; + return FALSE; #ifndef OPUS_SFX fpSampleDataHandle = fcaseopen(SampleBankDataFilename, "rb"); if ( fpSampleDataHandle == NULL ) @@ -1983,7 +1983,7 @@ cSampleManager::InitialiseSampleBanks(void) fclose(fpSampleDescHandle); fpSampleDescHandle = NULL; - return false; + return FALSE; } fseek(fpSampleDataHandle, 0, SEEK_END); @@ -2015,6 +2015,6 @@ cSampleManager::InitialiseSampleBanks(void) nSampleBankSize[SFX_BANK_0] = nSampleBankDiscStartOffset[SFX_BANK_PED_COMMENTS] - nSampleBankDiscStartOffset[SFX_BANK_0]; nSampleBankSize[SFX_BANK_PED_COMMENTS] = _nSampleDataEndOffset - nSampleBankDiscStartOffset[SFX_BANK_PED_COMMENTS]; - return true; + return TRUE; } #endif -- cgit v1.2.3 From 319bf9d8d218d79d31f8fc0dfac2908b6c869c54 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 22 May 2021 12:16:10 +0300 Subject: Fix return type --- src/audio/AudioManager.cpp | 4 ++-- src/audio/AudioManager.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/audio') diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index c15d04bd..8d9d867d 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -409,13 +409,13 @@ cAudioManager::CheckForAnAudioFileOnCD() const return SampleManager.CheckForAnAudioFileOnCD(); } -uint8 +char cAudioManager::GetCDAudioDriveLetter() const { if (m_bIsInitialised) return SampleManager.GetCDAudioDriveLetter(); - return 0; + return '\0'; } bool8 diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index edf5eb63..4a888788 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -338,7 +338,7 @@ public: void GenerateIntegerRandomNumberTable(); char *Get3DProviderName(uint8 id) const; - uint8 GetCDAudioDriveLetter() const; + char GetCDAudioDriveLetter() const; int8 GetCurrent3DProviderIndex() const; float GetCollisionLoopingRatio(uint32 a, uint32 b, float c) const; // not used float GetCollisionOneShotRatio(int32 a, float b) const; -- cgit v1.2.3 From c37f4c3c1aab1ae9e531294c89b95f1cd571ebd8 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 22 May 2021 13:34:13 +0300 Subject: Fix cAudioManager::SetupJumboFlySound --- src/audio/AudioLogic.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/audio') diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 2f173d5e..75d7d6a3 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -2879,21 +2879,22 @@ cAudioManager::SetupJumboFlySound(uint8 emittingVol) int32 vol = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance); m_sQueueSample.m_nVolume = vol; if (m_sQueueSample.m_nVolume != 0) { - m_sQueueSample.m_nSampleIndex = SFX_JUMBO_DIST_FLY; m_sQueueSample.m_nCounter = 0; + m_sQueueSample.m_nSampleIndex = SFX_JUMBO_DIST_FLY; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nReleasingVolumeModificator = 1; - m_sQueueSample.m_nEmittingVolume = emittingVol; - m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_JUMBO_DIST_FLY); + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = emittingVol; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_fSpeedMultiplier = 4.0f; m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; m_sQueueSample.m_bReleasingSoundFlag = FALSE; - m_sQueueSample.m_fSpeedMultiplier = 4.0f; - m_sQueueSample.m_bReverbFlag = TRUE; m_sQueueSample.m_nReleasingVolumeDivider = 5; - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); } return TRUE; -- cgit v1.2.3 From c9804510d1c29662b33a1fa51b8ccdc6de614f5c Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 22 May 2021 13:43:38 +0300 Subject: This means sound should be panned right, not volume --- src/audio/AudioLogic.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/audio') diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 75d7d6a3..f63ea4b3 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -2931,7 +2931,7 @@ cAudioManager::SetupJumboRumbleSound(uint8 emittingVol) m_sQueueSample.m_nCounter = 6; m_sQueueSample.m_nSampleIndex = SFX_JUMBO_RUMBLE; m_sQueueSample.m_nFrequency += 200; - m_sQueueSample.m_nOffset = MAX_VOLUME; + m_sQueueSample.m_nOffset = 127; AddSampleToRequestedQueue(); } return TRUE; @@ -7980,7 +7980,7 @@ cAudioManager::ProcessFrontEnd() if (stereo) { ++m_sQueueSample.m_nSampleIndex; m_sQueueSample.m_nCounter = iSound++; - m_sQueueSample.m_nOffset = MAX_VOLUME - m_sQueueSample.m_nOffset; + m_sQueueSample.m_nOffset = 127 - m_sQueueSample.m_nOffset; AddSampleToRequestedQueue(); } } -- cgit v1.2.3 From 7a2dbd9112d9537453bb51a503858b769af32204 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sun, 23 May 2021 16:14:30 +0300 Subject: Increase the number of audio channels to PS2 count and some small audio fixes --- src/audio/AudioLogic.cpp | 44 +++++++++++++++++++----------------- src/audio/AudioManager.cpp | 17 +++++++------- src/audio/AudioManager.h | 8 +++---- src/audio/audio_enums.h | 22 ++++++++++++++++++ src/audio/oal/channel.cpp | 18 +++++++-------- src/audio/sampman.h | 14 ++++++++---- src/audio/sampman_miles.cpp | 20 ++++++++--------- src/audio/sampman_oal.cpp | 55 +++++++++++++++++++++------------------------ 8 files changed, 113 insertions(+), 85 deletions(-) (limited to 'src/audio') diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index f63ea4b3..17d31330 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -38,9 +38,9 @@ #include "ZoneCull.h" #include "sampman.h" -const int channels = ARRAY_SIZE(AudioManager.m_asActiveSamples); -const int policeChannel = channels + 1; -const int allChannels = channels + 2; +#ifndef GTA_PS2 +#define CHANNEL_PLAYER_VEHICLE_ENGINE m_nActiveSamples +#endif uint32 gPornNextTime; uint32 gSawMillNextTime; @@ -224,24 +224,26 @@ cAudioManager::ResetAudioLogicTimers(uint32 timer) } } ClearMissionAudio(); - SampleManager.StopChannel(policeChannel); + SampleManager.StopChannel(CHANNEL_POLICE_RADIO); } void cAudioManager::ProcessReverb() const { if (SampleManager.UpdateReverb() && m_bDynamicAcousticModelingStatus) { +#ifndef GTA_PS2 for (uint32 i = 0; i < #ifdef FIX_BUGS - channels + NUM_CHANNELS_GENERIC #else - 28 + NUM_CHANNELS_GENERIC+1 #endif ; i++) { if (m_asActiveSamples[i].m_bReverbFlag) SampleManager.SetChannelReverbFlag(i, TRUE); } +#endif } } @@ -278,7 +280,7 @@ cAudioManager::ProcessSpecial() CPlayerPed *playerPed = FindPlayerPed(); if (playerPed) { 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(); veh = params.m_pVehicle; if (playerVeh == veh && veh->GetStatus() == STATUS_WRECKED) { - SampleManager.StopChannel(m_nActiveSamples); + SampleManager.StopChannel(CHANNEL_PLAYER_VEHICLE_ENGINE); return; } if (veh->bEngineOn) { @@ -1231,7 +1233,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CAutomobile * else accelerateState = Pads[0].GetAccelerate(); - channelUsed = SampleManager.GetChannelUsedFlag(m_nActiveSamples); + channelUsed = SampleManager.GetChannelUsedFlag(CHANNEL_PLAYER_VEHICLE_ENGINE); transmission = params.m_pTransmission; velocityChange = params.m_fVelocityChange; relativeVelocityChange = 2.0f * velocityChange / transmission->fMaxVelocity; @@ -1278,7 +1280,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CAutomobile * if (accelerateState <= 0) { if (params.m_fVelocityChange < -0.001f) { if (channelUsed) { - SampleManager.StopChannel(m_nActiveSamples); + SampleManager.StopChannel(CHANNEL_PLAYER_VEHICLE_ENGINE); bAccelSampleStopped = TRUE; } if (automobile->m_nWheelsOnGround == 0 || automobile->bIsHandbrakeOn || lostTraction) @@ -1290,7 +1292,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CAutomobile * automobile->m_fGasPedalAudio = gasPedalAudio; } else if (LastAccel > 0) { if (channelUsed) { - SampleManager.StopChannel(m_nActiveSamples); + SampleManager.StopChannel(CHANNEL_PLAYER_VEHICLE_ENGINE); bAccelSampleStopped = TRUE; } nCruising = 0; @@ -1334,7 +1336,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CAutomobile * if (engineSoundType == SFX_BANK_TRUCK) freq /= 2; if (channelUsed) { - SampleManager.StopChannel(m_nActiveSamples); + SampleManager.StopChannel(CHANNEL_PLAYER_VEHICLE_ENGINE); bAccelSampleStopped = 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; - SampleManager.SetChannelLoopCount(m_nActiveSamples, 1); - SampleManager.SetChannelLoopPoints(m_nActiveSamples, 0, -1); + SampleManager.SetChannelLoopCount(CHANNEL_PLAYER_VEHICLE_ENGINE, 1); + SampleManager.SetChannelLoopPoints(CHANNEL_PLAYER_VEHICLE_ENGINE, 0, -1); } - SampleManager.SetChannelEmittingVolume(m_nActiveSamples, 85); - SampleManager.SetChannel3DPosition(m_nActiveSamples, pos.x, pos.y, pos.z); - SampleManager.SetChannel3DDistances(m_nActiveSamples, 50.f, 12.5f); + SampleManager.SetChannelEmittingVolume(CHANNEL_PLAYER_VEHICLE_ENGINE, 85); + SampleManager.SetChannel3DPosition(CHANNEL_PLAYER_VEHICLE_ENGINE, pos.x, pos.y, pos.z); + SampleManager.SetChannel3DDistances(CHANNEL_PLAYER_VEHICLE_ENGINE, 50.f, 12.5f); freq = GearFreqAdj[CurrentPretendGear] + freqModifier + 22050; if (engineSoundType == SFX_BANK_TRUCK) freq /= 2; - SampleManager.SetChannelFrequency(m_nActiveSamples, freq); + SampleManager.SetChannelFrequency(CHANNEL_PLAYER_VEHICLE_ENGINE, freq); if (!channelUsed) { - SampleManager.SetChannelReverbFlag(m_nActiveSamples, m_bDynamicAcousticModelingStatus != FALSE); - SampleManager.StartChannel(m_nActiveSamples); + SampleManager.SetChannelReverbFlag(CHANNEL_PLAYER_VEHICLE_ENGINE, m_bDynamicAcousticModelingStatus != FALSE); + SampleManager.StartChannel(CHANNEL_PLAYER_VEHICLE_ENGINE); } } break; diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index 8d9d867d..1f758dd2 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -13,10 +13,6 @@ 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 TIME_SPENT 50 @@ -26,7 +22,7 @@ cAudioManager::cAudioManager() m_bReverb = TRUE; m_fSpeedOfSound = SPEED_OF_SOUND / TIME_SPENT; m_nTimeSpent = TIME_SPENT; - m_nActiveSamples = NUM_SOUNDS_SAMPLES_SLOTS; + m_nActiveSamples = NUM_CHANNELS_GENERIC; m_nActiveSampleQueue = 1; ClearRequestedQueue(); m_nActiveSampleQueue = 0; @@ -267,7 +263,7 @@ cAudioManager::ResetTimers(uint32 time) } ClearActiveSamples(); ClearMissionAudio(); - SampleManager.StopChannel(policeChannel); + SampleManager.StopChannel(CHANNEL_POLICE_RADIO); SampleManager.SetEffectsFadeVolume(0); SampleManager.SetMusicFadeVolume(0); MusicManager.ResetMusicAfterReload(); @@ -429,7 +425,7 @@ cAudioManager::ServiceSoundEffects() { m_bFifthFrameFlag = (m_FrameCounter++ % 5) == 0; if (m_nUserPause && !m_nPreviousUserPause) { - for (int32 i = 0; i < allChannels; i++) + for (int32 i = 0; i < NUM_CHANNELS; i++) SampleManager.StopChannel(i); ClearRequestedQueue(); @@ -692,7 +688,12 @@ cAudioManager::UpdateReflections() void 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; diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index 4a888788..a3ae4cfb 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -195,10 +195,10 @@ public: int32 m_nTimer; tSound m_sQueueSample; uint8 m_nActiveSampleQueue; - tSound m_asSamples[NUM_SOUNDS_SAMPLES_BANKS][NUM_SOUNDS_SAMPLES_SLOTS]; - uint8 m_abSampleQueueIndexTable[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_CHANNELS_GENERIC]; 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]; int32 m_anAudioEntityIndices[NUM_AUDIOENTITIES]; int32 m_nAudioEntitiesTotal; @@ -498,7 +498,7 @@ public: #endif }; -#ifdef AUDIO_MSS +#if defined(AUDIO_MSS) && !defined(PS2_AUDIO_CHANNELS) static_assert(sizeof(cAudioManager) == 19220, "cAudioManager: error"); #endif diff --git a/src/audio/audio_enums.h b/src/audio/audio_enums.h index 027042cb..69d37a64 100644 --- a/src/audio/audio_enums.h +++ b/src/audio/audio_enums.h @@ -254,3 +254,25 @@ enum eAudioType AUDIOTYPE_POLICERADIO, 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 diff --git a/src/audio/oal/channel.cpp b/src/audio/oal/channel.cpp index 1bb4c4a8..04e7e529 100644 --- a/src/audio/oal/channel.cpp +++ b/src/audio/oal/channel.cpp @@ -10,9 +10,9 @@ extern bool IsFXSupported(); -ALuint alSources[MAXCHANNELS+MAX2DCHANNELS]; -ALuint alFilters[MAXCHANNELS+MAX2DCHANNELS]; -ALuint alBuffers[MAXCHANNELS+MAX2DCHANNELS]; +ALuint alSources[NUM_CHANNELS]; +ALuint alFilters[NUM_CHANNELS]; +ALuint alBuffers[NUM_CHANNELS]; bool bChannelsCreated = false; int32 CChannel::channelsThatNeedService = 0; @@ -22,10 +22,10 @@ uint8 tempStereoBuffer[PED_BLOCKSIZE * 2]; void CChannel::InitChannels() { - alGenSources(MAXCHANNELS+MAX2DCHANNELS, alSources); - alGenBuffers(MAXCHANNELS+MAX2DCHANNELS, alBuffers); + alGenSources(NUM_CHANNELS, alSources); + alGenBuffers(NUM_CHANNELS, alBuffers); if (IsFXSupported()) - alGenFilters(MAXCHANNELS + MAX2DCHANNELS, alFilters); + alGenFilters(NUM_CHANNELS, alFilters); bChannelsCreated = true; } @@ -34,13 +34,13 @@ CChannel::DestroyChannels() { if (bChannelsCreated) { - alDeleteSources(MAXCHANNELS + MAX2DCHANNELS, alSources); + alDeleteSources(NUM_CHANNELS, alSources); memset(alSources, 0, sizeof(alSources)); - alDeleteBuffers(MAXCHANNELS + MAX2DCHANNELS, alBuffers); + alDeleteBuffers(NUM_CHANNELS, alBuffers); memset(alBuffers, 0, sizeof(alBuffers)); if (IsFXSupported()) { - alDeleteFilters(MAXCHANNELS + MAX2DCHANNELS, alFilters); + alDeleteFilters(NUM_CHANNELS, alFilters); memset(alFilters, 0, sizeof(alFilters)); } bChannelsCreated = false; diff --git a/src/audio/sampman.h b/src/audio/sampman.h index 765c75d3..b5f72d5c 100644 --- a/src/audio/sampman.h +++ b/src/audio/sampman.h @@ -1,5 +1,6 @@ #pragma once #include "AudioSamples.h" +#include "audio_enums.h" #define MAX_VOLUME 127 #define MAX_FREQ DIGITALRATE @@ -99,10 +100,9 @@ enum #define MAXPROVIDERS 64 -#define MAXCHANNELS 28 -#define MAXCHANNELS_SURROUND 24 +#define MAXCHANNELS (NUM_CHANNELS_GENERIC+1) +#define MAXCHANNELS_SURROUND (MAXCHANNELS-4) #define MAX2DCHANNELS 1 -#define CHANNEL2D MAXCHANNELS #define MAX_STREAMS 2 @@ -110,7 +110,13 @@ enum #define DIGITALBITS 16 #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 { diff --git a/src/audio/sampman_miles.cpp b/src/audio/sampman_miles.cpp index 4237c6a3..ddfaaa5f 100644 --- a/src/audio/sampman_miles.cpp +++ b/src/audio/sampman_miles.cpp @@ -1657,7 +1657,7 @@ cSampleManager::SetChannelReverbFlag(uint32 nChannel, bool8 nReverbFlag) switch ( nChannel ) { - case CHANNEL2D: + case CHANNEL_POLICE_RADIO: { b2d = TRUE; break; @@ -1686,7 +1686,7 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank) switch ( nChannel ) { - case CHANNEL2D: + case CHANNEL_POLICE_RADIO: { b2d = TRUE; break; @@ -1786,7 +1786,7 @@ cSampleManager::SetChannelVolume(uint32 nChannel, uint32 nVolume) switch ( nChannel ) { - case CHANNEL2D: + case CHANNEL_POLICE_RADIO: { nChannelVolume[nChannel] = vol; @@ -1814,7 +1814,7 @@ cSampleManager::SetChannelPan(uint32 nChannel, uint32 nPan) { switch ( nChannel ) { - case CHANNEL2D: + case CHANNEL_POLICE_RADIO: { #ifndef FIX_BUGS if ( opened_samples[nChannel - MAXCHANNELS] ) // BUG @@ -1835,7 +1835,7 @@ cSampleManager::SetChannelFrequency(uint32 nChannel, uint32 nFreq) switch ( nChannel ) { - case CHANNEL2D: + case CHANNEL_POLICE_RADIO: { b2d = TRUE; break; @@ -1861,7 +1861,7 @@ cSampleManager::SetChannelLoopPoints(uint32 nChannel, uint32 nLoopStart, int32 n switch ( nChannel ) { - case CHANNEL2D: + case CHANNEL_POLICE_RADIO: { b2d = TRUE; break; @@ -1887,7 +1887,7 @@ cSampleManager::SetChannelLoopCount(uint32 nChannel, uint32 nLoopCount) switch ( nChannel ) { - case CHANNEL2D: + case CHANNEL_POLICE_RADIO: { b2d = TRUE; break; @@ -1913,7 +1913,7 @@ cSampleManager::GetChannelUsedFlag(uint32 nChannel) switch ( nChannel ) { - case CHANNEL2D: + case CHANNEL_POLICE_RADIO: { b2d = TRUE; break; @@ -1944,7 +1944,7 @@ cSampleManager::StartChannel(uint32 nChannel) switch ( nChannel ) { - case CHANNEL2D: + case CHANNEL_POLICE_RADIO: { b2d = TRUE; break; @@ -1970,7 +1970,7 @@ cSampleManager::StopChannel(uint32 nChannel) switch ( nChannel ) { - case CHANNEL2D: + case CHANNEL_POLICE_RADIO: { b2d = TRUE; break; diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp index 15add7cb..18d1ca37 100644 --- a/src/audio/sampman_oal.cpp +++ b/src/audio/sampman_oal.cpp @@ -94,8 +94,8 @@ int32 nPedSlotSfx [MAX_PEDSFX]; int32 nPedSlotSfxAddr[MAX_PEDSFX]; uint8 nCurrentPedSlot; -CChannel aChannel[MAXCHANNELS+MAX2DCHANNELS]; -uint8 nChannelVolume[MAXCHANNELS+MAX2DCHANNELS]; +CChannel aChannel[NUM_CHANNELS]; +uint8 nChannelVolume[NUM_CHANNELS]; uint32 nStreamLength[TOTAL_STREAMED_SOUNDS]; ALuint ALStreamSources[MAX_STREAMS][2]; @@ -212,9 +212,8 @@ add_providers() static void release_existing() { - for ( int32 i = 0; i < MAXCHANNELS; i++ ) + for ( int32 i = 0; i < NUM_CHANNELS; i++ ) aChannel[i].Term(); - aChannel[CHANNEL2D].Term(); if ( IsFXSupported() ) { @@ -283,7 +282,7 @@ set_new_provider(int index) _maxSamples = MAXCHANNELS; ALCint attr[] = {ALC_FREQUENCY,MAX_FREQ, - ALC_MONO_SOURCES, MAX_STREAMS * 2 + MAXCHANNELS, + ALC_MONO_SOURCES, MAX_DIGITAL_MIXER_CHANNELS, 0, }; @@ -370,7 +369,8 @@ set_new_provider(int index) for ( int32 i = 0; i < MAXCHANNELS; 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() ) { @@ -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; } @@ -1153,7 +1153,7 @@ cSampleManager::UpdateEffectsVolume(void) { if ( _bSampmanInitialised ) { - for ( int32 i = 0; i < MAXCHANNELS+MAX2DCHANNELS; i++ ) + for ( int32 i = 0; i < NUM_CHANNELS; i++ ) { if ( GetChannelUsedFlag(i) ) { @@ -1461,7 +1461,7 @@ bool8 cSampleManager::UpdateReverb(void) void cSampleManager::SetChannelReverbFlag(uint32 nChannel, bool8 nReverbFlag) { - ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); + ASSERT( nChannel < NUM_CHANNELS ); if ( usingEAX || _usingEFX ) { @@ -1480,7 +1480,7 @@ cSampleManager::SetChannelReverbFlag(uint32 nChannel, bool8 nReverbFlag) bool8 cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank) { - ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); + ASSERT( nChannel < NUM_CHANNELS ); uintptr addr; @@ -1521,8 +1521,7 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank) void cSampleManager::SetChannelEmittingVolume(uint32 nChannel, uint32 nVolume) { - ASSERT( nChannel != CHANNEL2D ); - ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); + ASSERT( nChannel < MAXCHANNELS ); uint32 vol = nVolume; if ( vol > MAX_VOLUME ) vol = MAX_VOLUME; @@ -1544,8 +1543,7 @@ cSampleManager::SetChannelEmittingVolume(uint32 nChannel, uint32 nVolume) void cSampleManager::SetChannel3DPosition(uint32 nChannel, float fX, float fY, float fZ) { - ASSERT( nChannel != CHANNEL2D ); - ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); + ASSERT( nChannel < MAXCHANNELS ); aChannel[nChannel].SetPosition(-fX, fY, fZ); } @@ -1553,18 +1551,17 @@ cSampleManager::SetChannel3DPosition(uint32 nChannel, float fX, float fY, float void cSampleManager::SetChannel3DDistances(uint32 nChannel, float fMax, float fMin) { - ASSERT( nChannel != CHANNEL2D ); - ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); + ASSERT( nChannel < MAXCHANNELS ); aChannel[nChannel].SetDistances(fMax, fMin); } void cSampleManager::SetChannelVolume(uint32 nChannel, uint32 nVolume) { - ASSERT( nChannel == CHANNEL2D ); - ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); + ASSERT( nChannel >= MAXCHANNELS ); + ASSERT( nChannel < NUM_CHANNELS ); - if ( nChannel == CHANNEL2D ) + if ( nChannel == CHANNEL_POLICE_RADIO ) { uint32 vol = nVolume; if ( vol > MAX_VOLUME ) vol = MAX_VOLUME; @@ -1586,10 +1583,10 @@ cSampleManager::SetChannelVolume(uint32 nChannel, uint32 nVolume) void cSampleManager::SetChannelPan(uint32 nChannel, uint32 nPan) { - ASSERT(nChannel == CHANNEL2D); - ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); + ASSERT( nChannel >= MAXCHANNELS ); + ASSERT( nChannel < NUM_CHANNELS ); - if ( nChannel == CHANNEL2D ) + if ( nChannel == CHANNEL_POLICE_RADIO ) { aChannel[nChannel].SetPan(nPan); } @@ -1598,7 +1595,7 @@ cSampleManager::SetChannelPan(uint32 nChannel, uint32 nPan) void cSampleManager::SetChannelFrequency(uint32 nChannel, uint32 nFreq) { - ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); + ASSERT( nChannel < NUM_CHANNELS ); aChannel[nChannel].SetCurrentFreq(nFreq); } @@ -1606,7 +1603,7 @@ cSampleManager::SetChannelFrequency(uint32 nChannel, uint32 nFreq) void 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)); } @@ -1614,7 +1611,7 @@ cSampleManager::SetChannelLoopPoints(uint32 nChannel, uint32 nLoopStart, int32 n void cSampleManager::SetChannelLoopCount(uint32 nChannel, uint32 nLoopCount) { - ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); + ASSERT( nChannel < NUM_CHANNELS ); aChannel[nChannel].SetLoopCount(nLoopCount); } @@ -1622,7 +1619,7 @@ cSampleManager::SetChannelLoopCount(uint32 nChannel, uint32 nLoopCount) bool8 cSampleManager::GetChannelUsedFlag(uint32 nChannel) { - ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); + ASSERT( nChannel < NUM_CHANNELS ); return aChannel[nChannel].IsUsed(); } @@ -1630,7 +1627,7 @@ cSampleManager::GetChannelUsedFlag(uint32 nChannel) void cSampleManager::StartChannel(uint32 nChannel) { - ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); + ASSERT( nChannel < NUM_CHANNELS ); aChannel[nChannel].Start(); } @@ -1638,7 +1635,7 @@ cSampleManager::StartChannel(uint32 nChannel) void cSampleManager::StopChannel(uint32 nChannel) { - ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); + ASSERT( nChannel < NUM_CHANNELS ); aChannel[nChannel].Stop(); } @@ -1961,7 +1958,7 @@ cSampleManager::Service(void) stream->Update(); } 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() ) refCount--; -- cgit v1.2.3 From 5a55d3a949038662a6a0ff8860dbe41e243b45bf Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sun, 23 May 2021 16:24:05 +0300 Subject: Patch PolRadio --- src/audio/PolRadio.cpp | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) (limited to 'src/audio') diff --git a/src/audio/PolRadio.cpp b/src/audio/PolRadio.cpp index 3664796b..36eb8824 100644 --- a/src/audio/PolRadio.cpp +++ b/src/audio/PolRadio.cpp @@ -15,9 +15,6 @@ #include "sampman.h" #include "Wanted.h" -const int channels = ARRAY_SIZE(AudioManager.m_asActiveSamples); -const int policeChannel = channels + 1; - struct tPoliceRadioZone { char m_aName[8]; uint32 m_nSampleIndex; @@ -94,7 +91,7 @@ cAudioManager::InitialisePoliceRadio() for (int32 i = 0; i < ARRAY_SIZE(m_sPoliceRadioQueue.crimes); i++) m_sPoliceRadioQueue.crimes[i].type = CRIME_NONE; - SampleManager.SetChannelReverbFlag(policeChannel, FALSE); + SampleManager.SetChannelReverbFlag(CHANNEL_POLICE_RADIO, FALSE); gSpecialSuspectLastSeenReport = FALSE; for (int32 i = 0; i < ARRAY_SIZE(gMinTimeToNextReport); i++) gMinTimeToNextReport[i] = m_FrameCounter; @@ -104,7 +101,7 @@ void cAudioManager::ResetPoliceRadio() { if (!m_bIsInitialised) return; - if (SampleManager.GetChannelUsedFlag(policeChannel)) SampleManager.StopChannel(policeChannel); + if (SampleManager.GetChannelUsedFlag(CHANNEL_POLICE_RADIO)) SampleManager.StopChannel(CHANNEL_POLICE_RADIO); InitialisePoliceRadio(); } @@ -191,7 +188,7 @@ cAudioManager::ServicePoliceRadioChannel(uint8 wantedLevel) if (!m_bIsInitialised) return; if (m_nUserPause != 0) { - if (SampleManager.GetChannelUsedFlag(policeChannel)) SampleManager.StopChannel(policeChannel); + if (SampleManager.GetChannelUsedFlag(CHANNEL_POLICE_RADIO)) SampleManager.StopChannel(CHANNEL_POLICE_RADIO); if (g_nMissionAudioSfx != TOTAL_AUDIO_SAMPLES && bMissionAudioPhysicalPlayingStatus == 1 && SampleManager.IsStreamPlaying(1)) { SampleManager.PauseStream(TRUE, 1); @@ -223,7 +220,7 @@ cAudioManager::ServicePoliceRadioChannel(uint8 wantedLevel) } return; } - } else if (!SampleManager.GetChannelUsedFlag(policeChannel)) { + } else if (!SampleManager.GetChannelUsedFlag(CHANNEL_POLICE_RADIO)) { SampleManager.PreloadStreamedFile(g_nMissionAudioSfx, 1); SampleManager.SetStreamedVolumeAndPan(MAX_VOLUME, 63, TRUE, 1); SampleManager.StartPreloadedStreamedFile(1); @@ -234,7 +231,7 @@ cAudioManager::ServicePoliceRadioChannel(uint8 wantedLevel) } if (bChannelOpen) DoPoliceRadioCrackle(); if ((g_nMissionAudioSfx == TOTAL_AUDIO_SAMPLES || g_nMissionAudioPlayingStatus != 1) && - !SampleManager.GetChannelUsedFlag(policeChannel) && m_sPoliceRadioQueue.policeChannelTimer) { + !SampleManager.GetChannelUsedFlag(CHANNEL_POLICE_RADIO) && m_sPoliceRadioQueue.policeChannelTimer) { if (m_sPoliceRadioQueue.policeChannelTimer) { sample = m_sPoliceRadioQueue.crimesSamples[m_sPoliceRadioQueue.policeChannelCounterSeconds]; m_sPoliceRadioQueue.policeChannelTimer--; @@ -253,7 +250,7 @@ cAudioManager::ServicePoliceRadioChannel(uint8 wantedLevel) if (sample == TOTAL_AUDIO_SAMPLES) { if (!processed) cWait = 30; } else { - SampleManager.InitialiseChannel(policeChannel, sample, 0); + SampleManager.InitialiseChannel(CHANNEL_POLICE_RADIO, sample, 0); switch (sample) { case SFX_POLICE_RADIO_MESSAGE_NOISE_1: case SFX_POLICE_RADIO_MESSAGE_NOISE_2: @@ -264,12 +261,12 @@ cAudioManager::ServicePoliceRadioChannel(uint8 wantedLevel) default: freq = SampleManager.GetSampleBaseFrequency(sample); break; } PoliceChannelFreq = freq; - SampleManager.SetChannelFrequency(policeChannel, freq); - SampleManager.SetChannelVolume(policeChannel, 100); - SampleManager.SetChannelPan(policeChannel, 63); - SampleManager.SetChannelLoopCount(policeChannel, 1); - SampleManager.SetChannelLoopPoints(policeChannel, 0, -1); - SampleManager.StartChannel(policeChannel); + SampleManager.SetChannelFrequency(CHANNEL_POLICE_RADIO, freq); + SampleManager.SetChannelVolume(CHANNEL_POLICE_RADIO, 100); + SampleManager.SetChannelPan(CHANNEL_POLICE_RADIO, 63); + SampleManager.SetChannelLoopCount(CHANNEL_POLICE_RADIO, 1); + SampleManager.SetChannelLoopPoints(CHANNEL_POLICE_RADIO, 0, -1); + SampleManager.StartChannel(CHANNEL_POLICE_RADIO); } if (processed) ResetPoliceRadio(); } -- cgit v1.2.3 From 1e084dfab7136f991975be28f7e5e50c483e7452 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sun, 23 May 2021 16:48:20 +0300 Subject: Set number of stereo sources --- src/audio/sampman_oal.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/audio') diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp index 18d1ca37..fae010ed 100644 --- a/src/audio/sampman_oal.cpp +++ b/src/audio/sampman_oal.cpp @@ -282,7 +282,8 @@ set_new_provider(int index) _maxSamples = MAXCHANNELS; ALCint attr[] = {ALC_FREQUENCY,MAX_FREQ, - ALC_MONO_SOURCES, MAX_DIGITAL_MIXER_CHANNELS, + ALC_MONO_SOURCES, MAX_DIGITAL_MIXER_CHANNELS - MAX2DCHANNELS, + ALC_STEREO_SOURCES, MAX2DCHANNELS, 0, }; -- cgit v1.2.3 From edc25a689fed2bb08d6b6af4b67e9f84c460c5dc Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Fri, 28 May 2021 15:12:28 +0300 Subject: Fix typo --- src/audio/sampman_oal.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/audio') diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp index fae010ed..0a1e7563 100644 --- a/src/audio/sampman_oal.cpp +++ b/src/audio/sampman_oal.cpp @@ -1416,7 +1416,7 @@ bool8 cSampleManager::UpdateReverb(void) float fRatio = CALCRATIO(normx, normy, normz, 0.3f, 0.5f, (normy+normx+normz)/3.0f); #undef CALCRATIO - #undef ZE + #undef ZR fRatio = clamp(fRatio, usingEAX3==1 ? 0.0f : 0.30f, 1.0f); -- cgit v1.2.3 From 939d0c59a3994a564b2257b8d9e5ec107b1b7933 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 12 Jun 2021 19:19:31 +0300 Subject: Add macros to set sample loop offsets --- src/audio/AudioCollision.cpp | 8 +- src/audio/AudioLogic.cpp | 236 +++++++++++++++---------------------------- src/audio/AudioManager.cpp | 2 + src/audio/AudioManager.h | 19 ++++ src/audio/PolRadio.cpp | 5 +- 5 files changed, 105 insertions(+), 165 deletions(-) (limited to 'src/audio') diff --git a/src/audio/AudioCollision.cpp b/src/audio/AudioCollision.cpp index 0f96cec4..fd819641 100644 --- a/src/audio/AudioCollision.cpp +++ b/src/audio/AudioCollision.cpp @@ -170,10 +170,7 @@ cAudioManager::SetUpLoopingCollisionSound(const cAudioCollision &col, uint8 coun m_sQueueSample.m_nReleasingVolumeModificator = 7; m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nEmittingVolume = emittingVol; - m_sQueueSample.m_nLoopStart = - SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = - SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 4.0f; m_sQueueSample.m_fSoundIntensity = CollisionSoundIntensity; m_sQueueSample.m_bReleasingSoundFlag = FALSE; @@ -311,8 +308,7 @@ cAudioManager::SetUpOneShotCollisionSound(const cAudioCollision &col) m_sQueueSample.m_nReleasingVolumeModificator = 11; m_sQueueSample.m_nLoopCount = 1; m_sQueueSample.m_nEmittingVolume = emittingVol; - m_sQueueSample.m_nLoopStart = 0; - m_sQueueSample.m_nLoopEnd = -1; + RESET_LOOP_OFFSETS m_sQueueSample.m_fSpeedMultiplier = 4.0f; m_sQueueSample.m_fSoundIntensity = CollisionSoundIntensity; m_sQueueSample.m_bReleasingSoundFlag = TRUE; diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 17d31330..a5de21d0 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -684,8 +684,7 @@ cAudioManager::ProcessRainOnVehicle(cVehicleParams& params) m_sQueueSample.m_nFrequency = m_anRandomTable[1] % 4000 + 28000; m_sQueueSample.m_nLoopCount = 1; m_sQueueSample.m_nEmittingVolume = (uint8)emittingVol; - m_sQueueSample.m_nLoopStart = 0; - m_sQueueSample.m_nLoopEnd = -1; + RESET_LOOP_OFFSETS m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_fSoundIntensity = rainOnVehicleIntensity; m_sQueueSample.m_bReleasingSoundFlag = TRUE; @@ -737,8 +736,7 @@ cAudioManager::ProcessReverseGear(cVehicleParams& params) m_sQueueSample.m_nFrequency = (6000.f * modificator) + 7000; m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nEmittingVolume = emittingVol; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 3.0f; m_sQueueSample.m_fSoundIntensity = reverseGearIntensity; m_sQueueSample.m_bReleasingSoundFlag = FALSE; @@ -788,8 +786,7 @@ cAudioManager::ProcessModelCarEngine(cVehicleParams& params) m_sQueueSample.m_nFrequency = (11025.f * velocityChange / params.m_pTransmission->fMaxVelocity + 11025.f); m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nEmittingVolume = emittingVol; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 3.0f; m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; m_sQueueSample.m_bReleasingSoundFlag = FALSE; @@ -843,8 +840,7 @@ cAudioManager::ProcessVehicleRoadNoise(cVehicleParams& params) m_sQueueSample.m_nFrequency = freq; m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nEmittingVolume = emittingVol; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 6.0f; m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; m_sQueueSample.m_bReleasingSoundFlag = FALSE; @@ -895,8 +891,7 @@ cAudioManager::ProcessWetRoadNoise(cVehicleParams& params) m_sQueueSample.m_nFrequency = freq + freq * multiplier; m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nEmittingVolume = emittingVol; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 6.0f; m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; m_sQueueSample.m_bReleasingSoundFlag = FALSE; @@ -1042,8 +1037,7 @@ cAudioManager::ProcessVehicleEngine(cVehicleParams& params) m_sQueueSample.m_nFrequency /= 2; m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nEmittingVolume = emittingVol; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 6.0f; m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; m_sQueueSample.m_bReleasingSoundFlag = FALSE; @@ -1103,8 +1097,7 @@ cAudioManager::AddPlayerCarSample(uint8 emittingVolume, int32 freq, uint32 sampl m_sQueueSample.m_nLoopCount = 1; } m_sQueueSample.m_nEmittingVolume = emittingVolume; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 6.0f; m_sQueueSample.m_fSoundIntensity = 50.0f; m_sQueueSample.m_bReleasingSoundFlag = FALSE; @@ -1147,8 +1140,7 @@ cAudioManager::ProcessCesna(cVehicleParams& params) m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nReleasingVolumeDivider = 8; m_sQueueSample.m_nEmittingVolume = 80; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 8.0f; m_sQueueSample.m_fSoundIntensity = 200.0f; m_sQueueSample.m_bReleasingSoundFlag = FALSE; @@ -1168,8 +1160,7 @@ cAudioManager::ProcessCesna(cVehicleParams& params) m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nReleasingVolumeDivider = 4; m_sQueueSample.m_nEmittingVolume = 80; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 8.0f; m_sQueueSample.m_fSoundIntensity = 90.0f; m_sQueueSample.m_bReleasingSoundFlag = FALSE; @@ -1485,8 +1476,7 @@ cAudioManager::ProcessVehicleSkidding(cVehicleParams& params) m_sQueueSample.m_nReleasingVolumeModificator = 8; m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nEmittingVolume = emittingVol; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 3.0f; m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; m_sQueueSample.m_bReleasingSoundFlag = FALSE; @@ -1576,8 +1566,7 @@ cAudioManager::ProcessVehicleHorn(cVehicleParams& params) m_sQueueSample.m_nFrequency = aVehicleSettings[params.m_nIndex].m_nHornFrequency; m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nEmittingVolume = 80; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 5.0f; m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; m_sQueueSample.m_bReleasingSoundFlag = FALSE; @@ -1658,8 +1647,7 @@ cAudioManager::ProcessVehicleSirenOrAlarm(cVehicleParams& params) m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nEmittingVolume = 80; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 7.0f; m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; m_sQueueSample.m_bReleasingSoundFlag = FALSE; @@ -1702,8 +1690,7 @@ cAudioManager::ProcessVehicleReverseWarning(cVehicleParams& params) m_sQueueSample.m_nFrequency = (100 * m_sQueueSample.m_nEntityIndex & 1023) + SampleManager.GetSampleBaseFrequency(SFX_REVERSE_WARNING); m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nEmittingVolume = 60; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 3.0f; m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; m_sQueueSample.m_bReleasingSoundFlag = FALSE; @@ -1748,8 +1735,7 @@ cAudioManager::ProcessVehicleDoors(cVehicleParams& params) m_sQueueSample.m_nReleasingVolumeModificator = 10; m_sQueueSample.m_nLoopCount = 1; m_sQueueSample.m_nEmittingVolume = emittingVol; - m_sQueueSample.m_nLoopStart = 0; - m_sQueueSample.m_nLoopEnd = -1; + RESET_LOOP_OFFSETS m_sQueueSample.m_fSpeedMultiplier = 1.0f; m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; m_sQueueSample.m_bReleasingSoundFlag = TRUE; @@ -1793,8 +1779,7 @@ cAudioManager::ProcessAirBrakes(cVehicleParams& params) m_sQueueSample.m_nReleasingVolumeModificator = 10; m_sQueueSample.m_nLoopCount = 1; m_sQueueSample.m_nEmittingVolume = rand; - m_sQueueSample.m_nLoopStart = 0; - m_sQueueSample.m_nLoopEnd = -1; + RESET_LOOP_OFFSETS m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_fSoundIntensity = 30.0f; m_sQueueSample.m_bReleasingSoundFlag = TRUE; @@ -1847,8 +1832,7 @@ cAudioManager::ProcessEngineDamage(cVehicleParams& params) m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nEmittingVolume = emittingVolume; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_fSoundIntensity = engineDamageIntensity; m_sQueueSample.m_bReleasingSoundFlag = FALSE; @@ -1881,8 +1865,7 @@ cAudioManager::ProcessCarBombTick(cVehicleParams& params) m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_COUNTDOWN); m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nEmittingVolume = 60; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_fSoundIntensity = 40.0f; m_sQueueSample.m_bReleasingSoundFlag = FALSE; @@ -2318,8 +2301,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams& params) m_sQueueSample.m_nLoopCount = 1; m_sQueueSample.m_bReleasingSoundFlag = TRUE; } - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_nEmittingVolume = emittingVol; m_sQueueSample.m_bReverbFlag = TRUE; m_sQueueSample.m_bIs2D = FALSE; @@ -2357,8 +2339,7 @@ cAudioManager::ProcessTrainNoise(cVehicleParams& params) m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_TRAIN_FAR); m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nEmittingVolume = emittingVol; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 3.0f; m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; m_sQueueSample.m_bReleasingSoundFlag = FALSE; @@ -2380,8 +2361,7 @@ cAudioManager::ProcessTrainNoise(cVehicleParams& params) m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_TRAIN_NEAR) + 100 * m_sQueueSample.m_nEntityIndex % 987; m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nEmittingVolume = emittingVol; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 6.0f; m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; m_sQueueSample.m_bReleasingSoundFlag = FALSE; @@ -2425,8 +2405,7 @@ cAudioManager::ProcessBoatEngine(cVehicleParams& params) m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nEmittingVolume = 80; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_fSoundIntensity = intensity; m_sQueueSample.m_bReleasingSoundFlag = FALSE; @@ -2465,8 +2444,7 @@ cAudioManager::ProcessBoatEngine(cVehicleParams& params) m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nEmittingVolume = emittingVol; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_fSoundIntensity = intensity; m_sQueueSample.m_bReleasingSoundFlag = FALSE; @@ -2521,8 +2499,7 @@ cAudioManager::ProcessBoatEngine(cVehicleParams& params) m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nEmittingVolume = emittingVol; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_fSoundIntensity = intensity; m_sQueueSample.m_bReleasingSoundFlag = FALSE; @@ -2564,8 +2541,7 @@ cAudioManager::ProcessBoatMovingOverWater(cVehicleParams& params) m_sQueueSample.m_nFrequency = (6050.f * multiplier) + 16000; m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nEmittingVolume = vol; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_fSoundIntensity = 50.0f; m_sQueueSample.m_bReleasingSoundFlag = FALSE; @@ -2620,8 +2596,7 @@ cAudioManager::ProcessHelicopter(cVehicleParams& params) m_sQueueSample.m_nFrequency = 1200 * heli->m_nHeliId + SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nEmittingVolume = emittingVol; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 6.0f; m_sQueueSample.m_fSoundIntensity = gHeliSfxRanges[i].m_fMaxDistance; m_sQueueSample.m_bReleasingSoundFlag = FALSE; @@ -2795,8 +2770,7 @@ cAudioManager::SetupJumboTaxiSound(uint8 vol) m_sQueueSample.m_nFrequency = GetJumboTaxiFreq(); m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nEmittingVolume = emittingVol; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 4.0f; m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; m_sQueueSample.m_bReleasingSoundFlag = FALSE; @@ -2827,8 +2801,7 @@ cAudioManager::SetupJumboWhineSound(uint8 emittingVol, uint32 freq) m_sQueueSample.m_nFrequency = freq; m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nEmittingVolume = emittingVol; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 4.0f; m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; m_sQueueSample.m_bReleasingSoundFlag = FALSE; @@ -2858,8 +2831,7 @@ cAudioManager::SetupJumboEngineSound(uint8 vol, uint32 freq) m_sQueueSample.m_nFrequency = freq; m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nEmittingVolume = emittingVol; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 4.0f; m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; m_sQueueSample.m_bReleasingSoundFlag = FALSE; @@ -2889,8 +2861,7 @@ cAudioManager::SetupJumboFlySound(uint8 emittingVol) m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_JUMBO_DIST_FLY); m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nEmittingVolume = emittingVol; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 4.0f; m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; m_sQueueSample.m_bReleasingSoundFlag = FALSE; @@ -2920,8 +2891,7 @@ cAudioManager::SetupJumboRumbleSound(uint8 emittingVol) m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_JUMBO_RUMBLE); m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nEmittingVolume = emittingVol; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 4.0f; m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; m_sQueueSample.m_bReleasingSoundFlag = FALSE; @@ -3001,8 +2971,7 @@ cAudioManager::ProcessPedHeadphones(cPedParams ¶ms) m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_HEADPHONES); m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nEmittingVolume = emittingVol; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 4.0f; m_sQueueSample.m_fSoundIntensity = 7.0f; m_sQueueSample.m_bReleasingSoundFlag = FALSE; @@ -3110,8 +3079,7 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_fSoundIntensity = 20.0f; m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_nLoopStart = 0; - m_sQueueSample.m_nLoopEnd = -1; + RESET_LOOP_OFFSETS m_sQueueSample.m_nEmittingVolume = emittingVol; m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_bReleasingSoundFlag = TRUE; @@ -3138,8 +3106,7 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_fSoundIntensity = 30.0f; m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_nLoopStart = 0; - m_sQueueSample.m_nLoopEnd = -1; + RESET_LOOP_OFFSETS m_sQueueSample.m_nEmittingVolume = emittingVol; m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_bReleasingSoundFlag = TRUE; @@ -3202,9 +3169,8 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) m_sQueueSample.m_fSoundIntensity = 30.0f; maxDist = SQR(30); m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_nLoopStart = 0; + RESET_LOOP_OFFSETS emittingVol = m_anRandomTable[3] % 26 + 100; - m_sQueueSample.m_nLoopEnd = -1; m_sQueueSample.m_nEmittingVolume = emittingVol; m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_bReleasingSoundFlag = TRUE; @@ -3221,8 +3187,7 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) m_sQueueSample.m_fSoundIntensity = 30.0f; maxDist = SQR(30); m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_nLoopStart = 0; - m_sQueueSample.m_nLoopEnd = -1; + RESET_LOOP_OFFSETS emittingVol = m_anRandomTable[2] % 20 + 100; m_sQueueSample.m_nEmittingVolume = emittingVol; m_sQueueSample.m_bIs2D = FALSE; @@ -3247,8 +3212,7 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) m_sQueueSample.m_fSoundIntensity = 50.0f; maxDist = SQR(50); m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_nLoopStart = 0; - m_sQueueSample.m_nLoopEnd = -1; + RESET_LOOP_OFFSETS emittingVol = m_anRandomTable[1] % 10 + 90; m_sQueueSample.m_nEmittingVolume = emittingVol; m_sQueueSample.m_bIs2D = FALSE; @@ -3270,9 +3234,8 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) m_sQueueSample.m_fSoundIntensity = 80.0f; maxDist = SQR(80); m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_nLoopStart = 0; + RESET_LOOP_OFFSETS emittingVol = m_anRandomTable[3] % 15 + 70; - m_sQueueSample.m_nLoopEnd = -1; m_sQueueSample.m_nEmittingVolume = emittingVol; m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_bReleasingSoundFlag = TRUE; @@ -3289,8 +3252,7 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) m_sQueueSample.m_fSoundIntensity = 60.0f; maxDist = SQR(60); m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_nLoopStart = 0; - m_sQueueSample.m_nLoopEnd = -1; + RESET_LOOP_OFFSETS emittingVol = m_anRandomTable[2] % 10 + 100; m_sQueueSample.m_nEmittingVolume = emittingVol; m_sQueueSample.m_bIs2D = FALSE; @@ -3312,9 +3274,8 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) m_sQueueSample.m_fSoundIntensity = 80.0f; maxDist = SQR(80); m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_nLoopStart = 0; + RESET_LOOP_OFFSETS emittingVol = m_anRandomTable[1] % 15 + 70; - m_sQueueSample.m_nLoopEnd = -1; m_sQueueSample.m_nEmittingVolume = emittingVol; m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_bReleasingSoundFlag = TRUE; @@ -3331,9 +3292,8 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) m_sQueueSample.m_fSoundIntensity = 80.0f; maxDist = SQR(80); m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_nLoopStart = 0; + RESET_LOOP_OFFSETS emittingVol = m_anRandomTable[4] % 15 + 70; - m_sQueueSample.m_nLoopEnd = -1; m_sQueueSample.m_nEmittingVolume = emittingVol; m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_bReleasingSoundFlag = TRUE; @@ -3350,8 +3310,7 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) m_sQueueSample.m_fSoundIntensity = 60.0f; maxDist = SQR(60); m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_nLoopStart = 0; - m_sQueueSample.m_nLoopEnd = -1; + RESET_LOOP_OFFSETS emittingVol = m_anRandomTable[4] % 10 + 110; m_sQueueSample.m_nEmittingVolume = emittingVol; m_sQueueSample.m_bIs2D = FALSE; @@ -3373,8 +3332,7 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) m_sQueueSample.m_fSoundIntensity = 90.0f; maxDist = SQR(90); m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_nLoopStart = 0; - m_sQueueSample.m_nLoopEnd = -1; + RESET_LOOP_OFFSETS emittingVol = m_anRandomTable[0] % 20 + 80; m_sQueueSample.m_nEmittingVolume = emittingVol; m_sQueueSample.m_bIs2D = FALSE; @@ -3395,8 +3353,7 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) m_sQueueSample.m_fSoundIntensity = 60.0f; maxDist = SQR(60); m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_nEmittingVolume = 90; m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_bReleasingSoundFlag = FALSE; @@ -3455,8 +3412,7 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) m_sQueueSample.m_fSoundIntensity = 30.0f; maxDist = SQR(30); m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_nLoopStart = 0; - m_sQueueSample.m_nLoopEnd = -1; + RESET_LOOP_OFFSETS m_sQueueSample.m_nEmittingVolume = 75; m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_bReleasingSoundFlag = TRUE; @@ -3476,8 +3432,7 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) m_sQueueSample.m_fSoundIntensity = 80.0f; maxDist = SQR(80); m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_nLoopStart = 0; - m_sQueueSample.m_nLoopEnd = -1; + RESET_LOOP_OFFSETS emittingVol = m_anRandomTable[4] % 10 + 40; m_sQueueSample.m_nEmittingVolume = emittingVol; m_sQueueSample.m_bIs2D = FALSE; @@ -3498,8 +3453,7 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) m_sQueueSample.m_fSoundIntensity = 60.0f; maxDist = SQR(60); m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_nLoopStart = 0; - m_sQueueSample.m_nLoopEnd = -1; + RESET_LOOP_OFFSETS emittingVol = 70; m_sQueueSample.m_nEmittingVolume = 70; m_sQueueSample.m_bIs2D = FALSE; @@ -3517,9 +3471,8 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) m_sQueueSample.m_fSoundIntensity = 30.0f; maxDist = SQR(30); m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_nLoopStart = 0; + RESET_LOOP_OFFSETS emittingVol = m_anRandomTable[0] % 20 + 90; - m_sQueueSample.m_nLoopEnd = -1; m_sQueueSample.m_nEmittingVolume = emittingVol; m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_bReleasingSoundFlag = TRUE; @@ -3535,9 +3488,8 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms) m_sQueueSample.m_fSoundIntensity = 40.0f; maxDist = SQR(40); m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_nLoopStart = 0; + RESET_LOOP_OFFSETS emittingVol = m_anRandomTable[2] % 30 + 70; - m_sQueueSample.m_nLoopEnd = -1; m_sQueueSample.m_nEmittingVolume = emittingVol; m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_bReleasingSoundFlag = TRUE; @@ -6090,8 +6042,10 @@ cPedComments::Process() AudioManager.m_sQueueSample.m_nVolume = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_bVolume; AudioManager.m_sQueueSample.m_fDistance = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_fDistance; AudioManager.m_sQueueSample.m_nLoopCount = 1; +#ifndef GTA_PS2 AudioManager.m_sQueueSample.m_nLoopStart = 0; AudioManager.m_sQueueSample.m_nLoopEnd = -1; +#endif // !GTA_PS2 AudioManager.m_sQueueSample.m_nEmittingVolume = MAX_VOLUME; AudioManager.m_sQueueSample.m_fSpeedMultiplier = 3.0f; switch (sampleIndex) { @@ -6211,8 +6165,7 @@ cAudioManager::ProcessExplosions(int32 explosion) m_sQueueSample.m_bReleasingSoundFlag = TRUE; m_sQueueSample.m_bReverbFlag = TRUE; m_sQueueSample.m_nEmittingVolume = MAX_VOLUME; - m_sQueueSample.m_nLoopStart = 0; - m_sQueueSample.m_nLoopEnd = -1; + RESET_LOOP_OFFSETS m_sQueueSample.m_bReverbFlag = TRUE; m_sQueueSample.m_bRequireReflection = TRUE; AddSampleToRequestedQueue(); @@ -6280,8 +6233,7 @@ cAudioManager::ProcessFires(int32) m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nEmittingVolume = emittingVol; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_bReverbFlag = TRUE; m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); @@ -6324,8 +6276,7 @@ cAudioManager::ProcessWaterCannon(int32) m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_nEmittingVolume = 50; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_bReverbFlag = TRUE; m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); @@ -6575,8 +6526,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) m_sQueueSample.m_nLoopCount = 1; m_sQueueSample.m_bReleasingSoundFlag = TRUE; m_sQueueSample.m_nEmittingVolume = emittingVolume; - m_sQueueSample.m_nLoopStart = 0; - m_sQueueSample.m_nLoopEnd = -1; + RESET_LOOP_OFFSETS m_sQueueSample.m_bReverbFlag = TRUE; AddSampleToRequestedQueue(); } @@ -7183,8 +7133,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_bReverbFlag = TRUE; m_sQueueSample.m_nEmittingVolume = emittingVolume; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); } @@ -7256,8 +7205,7 @@ cAudioManager::ProcessPornCinema(uint8 sound) m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_nEmittingVolume = MAX_VOLUME; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_bReverbFlag = TRUE; m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); @@ -7278,8 +7226,7 @@ cAudioManager::ProcessPornCinema(uint8 sound) m_sQueueSample.m_bReleasingSoundFlag = TRUE; m_sQueueSample.m_nReleasingVolumeModificator = 6; m_sQueueSample.m_fSpeedMultiplier = 0.0f; - m_sQueueSample.m_nLoopStart = 0; - m_sQueueSample.m_nLoopEnd = -1; + RESET_LOOP_OFFSETS m_sQueueSample.m_bReverbFlag = TRUE; m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); @@ -7317,8 +7264,7 @@ cAudioManager::ProcessWorkShopScriptObject(uint8 sound) m_sQueueSample.m_nReleasingVolumeModificator = 5; m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_nEmittingVolume = 30; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_bReverbFlag = TRUE; m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); @@ -7356,8 +7302,7 @@ cAudioManager::ProcessSawMillScriptObject(uint8 sound) m_sQueueSample.m_nReleasingVolumeModificator = 5; m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_nEmittingVolume = 30; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_bReverbFlag = TRUE; m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); @@ -7375,8 +7320,7 @@ cAudioManager::ProcessSawMillScriptObject(uint8 sound) m_sQueueSample.m_bReleasingSoundFlag = TRUE; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; - m_sQueueSample.m_nLoopStart = 0; - m_sQueueSample.m_nLoopEnd = -1; + RESET_LOOP_OFFSETS m_sQueueSample.m_bReverbFlag = TRUE; m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); @@ -7412,8 +7356,7 @@ cAudioManager::ProcessLaunderetteScriptObject(uint8 sound) m_sQueueSample.m_nReleasingVolumeModificator = 5; m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_nEmittingVolume = 45; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_bReverbFlag = TRUE; m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); @@ -7430,8 +7373,7 @@ cAudioManager::ProcessLaunderetteScriptObject(uint8 sound) m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_nEmittingVolume = 110; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_bReverbFlag = TRUE; m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); @@ -7469,8 +7411,7 @@ cAudioManager::ProcessShopScriptObject(uint8 sound) m_sQueueSample.m_nReleasingVolumeModificator = 5; m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_nEmittingVolume = 30; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_bReverbFlag = TRUE; m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); @@ -7490,8 +7431,7 @@ cAudioManager::ProcessShopScriptObject(uint8 sound) m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_nEmittingVolume = 70; - m_sQueueSample.m_nLoopStart = 0; - m_sQueueSample.m_nLoopEnd = -1; + RESET_LOOP_OFFSETS m_sQueueSample.m_bReverbFlag = TRUE; m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); @@ -7533,8 +7473,7 @@ cAudioManager::ProcessAirportScriptObject(uint8 sound) m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_nEmittingVolume = 110; - m_sQueueSample.m_nLoopStart = 0; - m_sQueueSample.m_nLoopEnd = -1; + RESET_LOOP_OFFSETS m_sQueueSample.m_bReverbFlag = TRUE; m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); @@ -7580,8 +7519,7 @@ cAudioManager::ProcessCinemaScriptObject(uint8 sound) m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_nEmittingVolume = rand; - m_sQueueSample.m_nLoopStart = 0; - m_sQueueSample.m_nLoopEnd = -1; + RESET_LOOP_OFFSETS m_sQueueSample.m_bReverbFlag = TRUE; m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); @@ -7629,8 +7567,7 @@ cAudioManager::ProcessDocksScriptObject(uint8 sound) m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_nEmittingVolume = rand; - m_sQueueSample.m_nLoopStart = 0; - m_sQueueSample.m_nLoopEnd = -1; + RESET_LOOP_OFFSETS m_sQueueSample.m_bReverbFlag = TRUE; m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); @@ -7677,8 +7614,7 @@ cAudioManager::ProcessHomeScriptObject(uint8 sound) m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_nEmittingVolume = rand; - m_sQueueSample.m_nLoopStart = 0; - m_sQueueSample.m_nLoopEnd = -1; + RESET_LOOP_OFFSETS m_sQueueSample.m_bReverbFlag = TRUE; m_sQueueSample.m_bRequireReflection = TRUE; AddSampleToRequestedQueue(); @@ -7729,8 +7665,7 @@ cAudioManager::ProcessPoliceCellBeatingScriptObject(uint8 sound) m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_nEmittingVolume = emittingVol; - m_sQueueSample.m_nLoopStart = 0; - m_sQueueSample.m_nLoopEnd = -1; + RESET_LOOP_OFFSETS m_sQueueSample.m_bReverbFlag = TRUE; m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); @@ -7775,8 +7710,7 @@ cAudioManager::ProcessWeather(int32 id) m_sQueueSample.m_nLoopCount = 1; m_sQueueSample.m_bReleasingSoundFlag = TRUE; m_sQueueSample.m_nEmittingVolume = m_sQueueSample.m_nVolume; - m_sQueueSample.m_nLoopStart = 0; - m_sQueueSample.m_nLoopEnd = -1; + RESET_LOOP_OFFSETS m_sQueueSample.m_bReverbFlag = FALSE; m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); @@ -7795,8 +7729,7 @@ cAudioManager::ProcessWeather(int32 id) m_sQueueSample.m_nReleasingVolumeDivider = 30; m_sQueueSample.m_bReverbFlag = FALSE; m_sQueueSample.m_nEmittingVolume = m_sQueueSample.m_nVolume; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_bRequireReflection = FALSE; AddSampleToRequestedQueue(); } @@ -7970,8 +7903,7 @@ cAudioManager::ProcessFrontEnd() m_sQueueSample.m_nReleasingVolumeModificator = 0; m_sQueueSample.m_bIs2D = TRUE; m_sQueueSample.m_nEmittingVolume = m_sQueueSample.m_nVolume; - m_sQueueSample.m_nLoopStart = 0; - m_sQueueSample.m_nLoopEnd = -1; + RESET_LOOP_OFFSETS if (stereo) m_sQueueSample.m_nOffset = m_anRandomTable[0] & 31; else @@ -8013,8 +7945,7 @@ cAudioManager::ProcessCrane() m_sQueueSample.m_nFrequency = 6000; m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nEmittingVolume = 100; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 4.0f; m_sQueueSample.m_fSoundIntensity = intensity; m_sQueueSample.m_bReleasingSoundFlag = FALSE; @@ -8081,8 +8012,7 @@ cAudioManager::ProcessProjectiles() m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nEmittingVolume = emittingVol; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_bReverbFlag = TRUE; m_sQueueSample.m_bRequireReflection = FALSE; @@ -8162,8 +8092,7 @@ cAudioManager::ProcessGarages() m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_nEmittingVolume = 90; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; m_sQueueSample.m_bReverbFlag = TRUE; @@ -8200,8 +8129,7 @@ cAudioManager::ProcessGarages() m_sQueueSample.m_bIs2D = FALSE; m_sQueueSample.m_bReleasingSoundFlag = TRUE; m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_nLoopStart = 0; - m_sQueueSample.m_nLoopEnd = -1; + RESET_LOOP_OFFSETS m_sQueueSample.m_nCounter = iSound++; if (iSound < 32) iSound = 32; @@ -8238,8 +8166,7 @@ cAudioManager::ProcessFireHydrant() m_sQueueSample.m_nFrequency = 15591; m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nEmittingVolume = 40; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_fSoundIntensity = intensity; m_sQueueSample.m_bReleasingSoundFlag = FALSE; @@ -8298,8 +8225,7 @@ cAudioManager::ProcessBridgeWarning() m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_BRIDGE_OPEN_WARNING); m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nEmittingVolume = 100; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_fSoundIntensity = 450.0f; m_sQueueSample.m_bReleasingSoundFlag = FALSE; @@ -8325,8 +8251,7 @@ cAudioManager::ProcessBridgeMotor() m_sQueueSample.m_nFrequency = 5500; m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nEmittingVolume = MAX_VOLUME; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_fSoundIntensity = bridgeIntensity; m_sQueueSample.m_bReleasingSoundFlag = FALSE; @@ -8360,8 +8285,7 @@ cAudioManager::ProcessBridgeOneShots() m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopCount = 1; m_sQueueSample.m_nEmittingVolume = MAX_VOLUME; - m_sQueueSample.m_nLoopStart = 0; - m_sQueueSample.m_nLoopEnd = -1; + RESET_LOOP_OFFSETS m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_fSoundIntensity = bridgeIntensity; m_sQueueSample.m_bReleasingSoundFlag = TRUE; diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index 1f758dd2..5312bfad 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -940,8 +940,10 @@ cAudioManager::ClearActiveSamples() m_asActiveSamples[i].m_bIsProcessed = FALSE; m_asActiveSamples[i].m_bLoopEnded = FALSE; m_asActiveSamples[i].m_nLoopCount = 1; +#ifndef GTA_PS2 m_asActiveSamples[i].m_nLoopStart = 0; m_asActiveSamples[i].m_nLoopEnd = -1; +#endif m_asActiveSamples[i].m_fSpeedMultiplier = 0.0f; m_asActiveSamples[i].m_fSoundIntensity = 200.0f; m_asActiveSamples[i].m_nOffset = 63; diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index a3ae4cfb..70302745 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -17,8 +17,10 @@ public: uint8 m_nVolume; float m_fDistance; int32 m_nLoopCount; +#ifndef GTA_PS2 int32 m_nLoopStart; int32 m_nLoopEnd; +#endif uint8 m_nEmittingVolume; float m_fSpeedMultiplier; float m_fSoundIntensity; @@ -498,6 +500,23 @@ public: #endif }; +/* + Manual loop points are not on PS2 so let's have these macros to avoid massive ifndefs. + Setting these manually was pointless anyway since they never change from sdt values. + What were they thinking? +*/ +#ifndef GTA_PS2 +#define RESET_LOOP_OFFSETS \ + m_sQueueSample.m_nLoopStart = 0; \ + m_sQueueSample.m_nLoopEnd = -1; +#define SET_LOOP_OFFSETS(sample) \ + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(sample); \ + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(sample); +#else +#define RESET_LOOP_OFFSETS +#define SET_LOOP_OFFSETS(sample) +#endif + #if defined(AUDIO_MSS) && !defined(PS2_AUDIO_CHANNELS) static_assert(sizeof(cAudioManager) == 19220, "cAudioManager: error"); #endif diff --git a/src/audio/PolRadio.cpp b/src/audio/PolRadio.cpp index 36eb8824..4eae169d 100644 --- a/src/audio/PolRadio.cpp +++ b/src/audio/PolRadio.cpp @@ -134,8 +134,7 @@ cAudioManager::DoPoliceRadioCrackle() m_sQueueSample.m_nVolume = m_anRandomTable[2] % 20 + 15; m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nEmittingVolume = m_sQueueSample.m_nVolume; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(SFX_POLICE_RADIO_CRACKLE); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(SFX_POLICE_RADIO_CRACKLE); + SET_LOOP_OFFSETS(SFX_POLICE_RADIO_CRACKLE) m_sQueueSample.m_bReleasingSoundFlag = FALSE; m_sQueueSample.m_bReverbFlag = FALSE; m_sQueueSample.m_nOffset = 63; @@ -250,7 +249,7 @@ cAudioManager::ServicePoliceRadioChannel(uint8 wantedLevel) if (sample == TOTAL_AUDIO_SAMPLES) { if (!processed) cWait = 30; } else { - SampleManager.InitialiseChannel(CHANNEL_POLICE_RADIO, sample, 0); + SampleManager.InitialiseChannel(CHANNEL_POLICE_RADIO, sample, SFX_BANK_0); switch (sample) { case SFX_POLICE_RADIO_MESSAGE_NOISE_1: case SFX_POLICE_RADIO_MESSAGE_NOISE_2: -- cgit v1.2.3 From 8fc99387f5a8cedd3cf7f28d54a733df0a031955 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 12 Jun 2021 20:10:08 +0300 Subject: Fix use of enum in ped comment banks switch --- src/audio/AudioLogic.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/audio') diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index a5de21d0..8472cda6 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -6079,12 +6079,12 @@ cPedComments::Process() } // Switch bank - if (m_nActiveBank) { - actualUsedBank = SFX_BANK_PED_COMMENTS; - m_nActiveBank = SFX_BANK_0; + if (m_nActiveBank == 0) { + actualUsedBank = 0; + m_nActiveBank = 1; } else { - actualUsedBank = SFX_BANK_0; - m_nActiveBank = SFX_BANK_PED_COMMENTS; + actualUsedBank = 1; + m_nActiveBank = 0; } comment = m_asPedComments[actualUsedBank]; for (uint32 i = 0; i < m_nCommentsInBank[actualUsedBank]; i++) { -- cgit v1.2.3 From f2390deaa99ab453122d6c56d4a62006c5efaf31 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Thu, 24 Jun 2021 02:46:23 +0300 Subject: Make sampman stream functions default to stream 0 --- src/audio/MusicManager.cpp | 126 ++++++++++++++++++++++----------------------- src/audio/sampman.h | 18 +++---- 2 files changed, 72 insertions(+), 72 deletions(-) (limited to 'src/audio') diff --git a/src/audio/MusicManager.cpp b/src/audio/MusicManager.cpp index 88ef96fa..4eaa37d5 100644 --- a/src/audio/MusicManager.cpp +++ b/src/audio/MusicManager.cpp @@ -286,8 +286,8 @@ cMusicManager::Terminate() { if (!IsInitialised()) return; - if (SampleManager.IsStreamPlaying(0)) { - SampleManager.StopStreamedFile(0); + if (SampleManager.IsStreamPlaying()) { + SampleManager.StopStreamedFile(); m_nNextTrack = NO_TRACK; m_nPlayingTrack = NO_TRACK; } @@ -316,12 +316,12 @@ cMusicManager::ChangeMusicMode(uint8 mode) case MUSICMODE_GAME: case MUSICMODE_CUTSCENE: case MUSICMODE_DISABLED: - if (SampleManager.IsStreamPlaying(0)) { + if (SampleManager.IsStreamPlaying()) { if (m_nNextTrack < TOTAL_STREAMED_SOUNDS) { - m_aTracks[m_nNextTrack].m_nPosition = SampleManager.GetStreamedFilePosition(0); + m_aTracks[m_nNextTrack].m_nPosition = SampleManager.GetStreamedFilePosition(); m_aTracks[m_nNextTrack].m_nLastPosCheckTimer = CTimer::GetTimeInMillisecondsPauseMode(); } - SampleManager.StopStreamedFile(0); + SampleManager.StopStreamedFile(); } m_nNextTrack = NO_TRACK; m_nPlayingTrack = NO_TRACK; @@ -422,7 +422,7 @@ cMusicManager::Service() if (!m_bIsInitialised || m_bDisabled) return; if (m_nMusicMode == MUSICMODE_CUTSCENE) { - SampleManager.SetStreamedVolumeAndPan(MAX_VOLUME, 63, TRUE, 0); + SampleManager.SetStreamedVolumeAndPan(MAX_VOLUME, 63, TRUE); return; } @@ -433,8 +433,8 @@ cMusicManager::Service() m_nLastTrackServiceTime = m_nTimer; } else m_bDoTrackService = FALSE; - if (m_nNextTrack == NO_TRACK && SampleManager.IsStreamPlaying(0)) - SampleManager.StopStreamedFile(0); + if (m_nNextTrack == NO_TRACK && SampleManager.IsStreamPlaying()) + SampleManager.StopStreamedFile(); else switch (m_nMusicMode) { case MUSICMODE_FRONTEND: ServiceFrontEndMode(); break; case MUSICMODE_GAME: ServiceGameMode(); break; @@ -446,7 +446,7 @@ cMusicManager::ServiceFrontEndMode() { if (m_nNextTrack < TOTAL_STREAMED_SOUNDS) { if (m_bFrontendTrackFinished) { - if (!SampleManager.IsStreamPlaying(0)) { + if (!SampleManager.IsStreamPlaying()) { switch (m_nNextTrack) { case STREAMED_SOUND_MISSION_COMPLETED: @@ -463,19 +463,19 @@ cMusicManager::ServiceFrontEndMode() m_nPlayingTrack = NO_TRACK; } } else if (bHasStarted) { - if (!SampleManager.IsStreamPlaying(0)) - SampleManager.StartStreamedFile(m_nNextTrack, 0, 0); + if (!SampleManager.IsStreamPlaying()) + SampleManager.StartStreamedFile(m_nNextTrack, 0); } else { - SampleManager.SetStreamedVolumeAndPan(0, 63, FALSE, 0); - if (!SampleManager.StartStreamedFile(m_nNextTrack, m_nNextTrack < NUM_RADIOS ? GetTrackStartPos(m_nNextTrack) : 0, 0)) + SampleManager.SetStreamedVolumeAndPan(0, 63, FALSE); + if (!SampleManager.StartStreamedFile(m_nNextTrack, m_nNextTrack < NUM_RADIOS ? GetTrackStartPos(m_nNextTrack) : 0)) return; - SampleManager.SetStreamedVolumeAndPan(100, 63, FALSE, 0); + SampleManager.SetStreamedVolumeAndPan(100, 63, FALSE); if (m_bPlayInFrontend) bHasStarted = TRUE; else m_bFrontendTrackFinished = TRUE; } } - if (SampleManager.IsStreamPlaying(0)) - SampleManager.SetStreamedVolumeAndPan((CPad::GetPad(0)->bDisplayNoControllerMessage || CPad::GetPad(0)->bObsoleteControllerMessage) ? 0 : 100, 63, FALSE, 0); + if (SampleManager.IsStreamPlaying()) + SampleManager.SetStreamedVolumeAndPan((CPad::GetPad(0)->bDisplayNoControllerMessage || CPad::GetPad(0)->bObsoleteControllerMessage) ? 0 : 100, 63, FALSE); } void @@ -601,7 +601,7 @@ cMusicManager::ServiceGameMode() if (TheCamera.pTargetEntity != nil) { float DistToTargetSq = (TheCamera.pTargetEntity->GetPosition() - TheCamera.GetPosition()).MagnitudeSqr(); if (DistToTargetSq >= SQR(55.0f)) { - SampleManager.SetStreamedVolumeAndPan(0, 63, FALSE, 0); + SampleManager.SetStreamedVolumeAndPan(0, 63, FALSE); } else if (DistToTargetSq >= SQR(10.0f)) { volume = ((45.0f - (Sqrt(DistToTargetSq) - 10.0f)) / 45.0f * 100.0f); uint8 pan; @@ -616,17 +616,17 @@ cMusicManager::ServiceGameMode() } if (gRetuneCounter) volume /= 4; - SampleManager.SetStreamedVolumeAndPan(volume, pan, FALSE, 0); + SampleManager.SetStreamedVolumeAndPan(volume, pan, FALSE); } else if (AudioManager.ShouldDuckMissionAudio()) { - SampleManager.SetStreamedVolumeAndPan(25, 63, FALSE, 0); + SampleManager.SetStreamedVolumeAndPan(25, 63, FALSE); } else if (gRetuneCounter) { - SampleManager.SetStreamedVolumeAndPan(25, 63, FALSE, 0); + SampleManager.SetStreamedVolumeAndPan(25, 63, FALSE); } else { - SampleManager.SetStreamedVolumeAndPan(100, 63, FALSE, 0); + SampleManager.SetStreamedVolumeAndPan(100, 63, FALSE); } } } else if (AudioManager.ShouldDuckMissionAudio()) { - SampleManager.SetStreamedVolumeAndPan(25, 63, FALSE, 0); + SampleManager.SetStreamedVolumeAndPan(25, 63, FALSE); nFramesSinceCutsceneEnded = 0; } else { if (nFramesSinceCutsceneEnded == -1) { @@ -643,7 +643,7 @@ cMusicManager::ServiceGameMode() } if (gRetuneCounter != 0) volume /= 4; - SampleManager.SetStreamedVolumeAndPan(volume, 63, FALSE, 0); + SampleManager.SetStreamedVolumeAndPan(volume, 63, FALSE); } return; } @@ -663,8 +663,8 @@ cMusicManager::ServiceGameMode() m_nNextTrack = m_nRadioStationScript; if (FindPlayerVehicle()->m_nRadioStation == m_nNextTrack) { m_nPlayingTrack = NO_TRACK; - SampleManager.SetStreamedVolumeAndPan(0, 63, FALSE, 0); - SampleManager.StopStreamedFile(0); + SampleManager.SetStreamedVolumeAndPan(0, 63, FALSE); + SampleManager.StopStreamedFile(); } if (m_nRadioPosition != -1) { m_aTracks[m_nNextTrack].m_nPosition = m_nRadioPosition; @@ -693,9 +693,9 @@ void cMusicManager::StopFrontEndTrack() { if (IsInitialised() && !m_bDisabled && m_nMusicMode == MUSICMODE_FRONTEND && m_nNextTrack != NO_TRACK) { - m_aTracks[m_nNextTrack].m_nPosition = SampleManager.GetStreamedFilePosition(0); + m_aTracks[m_nNextTrack].m_nPosition = SampleManager.GetStreamedFilePosition(); m_aTracks[m_nNextTrack].m_nLastPosCheckTimer = CTimer::GetTimeInMillisecondsPauseMode(); - SampleManager.StopStreamedFile(0); + SampleManager.StopStreamedFile(); m_nPlayingTrack = NO_TRACK; m_nNextTrack = NO_TRACK; } @@ -718,16 +718,16 @@ cMusicManager::PlayFrontEndTrack(uint8 track, bool8 bPlayInFrontend) m_nAnnouncement = NO_TRACK; m_bAnnouncementInProgress = FALSE; } - m_aTracks[m_nNextTrack].m_nPosition = SampleManager.GetStreamedFilePosition(0); + m_aTracks[m_nNextTrack].m_nPosition = SampleManager.GetStreamedFilePosition(); m_aTracks[m_nNextTrack].m_nLastPosCheckTimer = CTimer::GetTimeInMillisecondsPauseMode(); } - SampleManager.StopStreamedFile(0); + SampleManager.StopStreamedFile(); } else if (m_nMusicMode == MUSICMODE_FRONTEND) { if (m_nNextTrack != NO_TRACK) { - m_aTracks[m_nNextTrack].m_nPosition = SampleManager.GetStreamedFilePosition(0); + m_aTracks[m_nNextTrack].m_nPosition = SampleManager.GetStreamedFilePosition(); m_aTracks[m_nNextTrack].m_nLastPosCheckTimer = CTimer::GetTimeInMillisecondsPauseMode(); } - SampleManager.StopStreamedFile(0); + SampleManager.StopStreamedFile(); } m_nPlayingTrack = m_nNextTrack; @@ -748,10 +748,10 @@ cMusicManager::PreloadCutSceneMusic(uint8 track) { if (IsInitialised() && !m_bDisabled && track < TOTAL_STREAMED_SOUNDS && m_nMusicMode == MUSICMODE_CUTSCENE) { AudioManager.ResetPoliceRadio(); - while (SampleManager.IsStreamPlaying(0)) - SampleManager.StopStreamedFile(0); - SampleManager.PreloadStreamedFile(track, 0); - SampleManager.SetStreamedVolumeAndPan(MAX_VOLUME, 63, TRUE, 0); + while (SampleManager.IsStreamPlaying()) + SampleManager.StopStreamedFile(); + SampleManager.PreloadStreamedFile(track); + SampleManager.SetStreamedVolumeAndPan(MAX_VOLUME, 63, TRUE); m_nNextTrack = track; } } @@ -760,14 +760,14 @@ void cMusicManager::PlayPreloadedCutSceneMusic(void) { if (IsInitialised() && !m_bDisabled && m_nMusicMode == MUSICMODE_CUTSCENE) - SampleManager.StartPreloadedStreamedFile(0); + SampleManager.StartPreloadedStreamedFile(); } void cMusicManager::StopCutSceneMusic(void) { if (IsInitialised() && !m_bDisabled && m_nMusicMode == MUSICMODE_CUTSCENE) { - SampleManager.StopStreamedFile(0); + SampleManager.StopStreamedFile(); m_nNextTrack = NO_TRACK; } } @@ -813,16 +813,16 @@ cMusicManager::ServiceAmbience() m_bAnnouncementInProgress = FALSE; } if (m_nNextTrack < RADIO_OFF) { - if (SampleManager.IsStreamPlaying(0)) { - m_aTracks[m_nNextTrack].m_nPosition = SampleManager.GetStreamedFilePosition(0); + if (SampleManager.IsStreamPlaying()) { + m_aTracks[m_nNextTrack].m_nPosition = SampleManager.GetStreamedFilePosition(); m_aTracks[m_nNextTrack].m_nLastPosCheckTimer = CTimer::GetTimeInMillisecondsPauseMode(); - SampleManager.StopStreamedFile(0); + SampleManager.StopStreamedFile(); m_nNextTrack = NO_TRACK; return; } m_nNextTrack = RADIO_OFF; } - if (CWorld::Players[CWorld::PlayerInFocus].m_WBState != WBSTATE_PLAYING && !SampleManager.IsStreamPlaying(0)) { + if (CWorld::Players[CWorld::PlayerInFocus].m_WBState != WBSTATE_PLAYING && !SampleManager.IsStreamPlaying()) { m_nNextTrack = NO_TRACK; return; } @@ -832,22 +832,22 @@ cMusicManager::ServiceAmbience() if (m_nNextTrack == m_nPlayingTrack) { ComputeAmbienceVol(FALSE, volume); - SampleManager.SetStreamedVolumeAndPan(volume, 63, TRUE, 0); + SampleManager.SetStreamedVolumeAndPan(volume, 63, TRUE); if (m_bVerifyAmbienceTrackStartedToPlay) { - if (SampleManager.IsStreamPlaying(0)) + if (SampleManager.IsStreamPlaying()) m_bVerifyAmbienceTrackStartedToPlay = FALSE; } else ServiceTrack(); } else { if (m_nPlayingTrack < TOTAL_STREAMED_SOUNDS) { - m_aTracks[m_nPlayingTrack].m_nPosition = SampleManager.GetStreamedFilePosition(0); + m_aTracks[m_nPlayingTrack].m_nPosition = SampleManager.GetStreamedFilePosition(); m_aTracks[m_nPlayingTrack].m_nLastPosCheckTimer = CTimer::GetTimeInMillisecondsPauseMode(); - SampleManager.StopStreamedFile(0); + SampleManager.StopStreamedFile(); } uint32 pos = GetTrackStartPos(m_nNextTrack); - SampleManager.SetStreamedVolumeAndPan(0, 63, TRUE, 0); - if (SampleManager.StartStreamedFile(m_nNextTrack, pos, 0)) { + SampleManager.SetStreamedVolumeAndPan(0, 63, TRUE); + if (SampleManager.StartStreamedFile(m_nNextTrack, pos)) { ComputeAmbienceVol(TRUE, volume); - SampleManager.SetStreamedVolumeAndPan(volume, 63, TRUE, 0); + SampleManager.SetStreamedVolumeAndPan(volume, 63, TRUE); m_bVerifyAmbienceTrackStartedToPlay = TRUE; } else m_nNextTrack = NO_TRACK; @@ -878,8 +878,8 @@ void cMusicManager::ServiceTrack() { if (m_bDoTrackService) { - if (!SampleManager.IsStreamPlaying(0)) - SampleManager.StartStreamedFile(m_nNextTrack, 0, 0); + if (!SampleManager.IsStreamPlaying()) + SampleManager.StartStreamedFile(m_nNextTrack, 0); } } @@ -888,7 +888,7 @@ cMusicManager::ServiceAnnouncement() { static int8 cCheck = 0; if (m_bAnnouncementInProgress) { - if (!SampleManager.IsStreamPlaying(0)) { + if (!SampleManager.IsStreamPlaying()) { m_nAnnouncement = NO_TRACK; m_bAnnouncementInProgress = FALSE; } @@ -897,18 +897,18 @@ cMusicManager::ServiceAnnouncement() if (++cCheck >= 30) { cCheck = 0; - int pos = SampleManager.GetStreamedFilePosition(0); - if (SampleManager.IsStreamPlaying(0)) { + int pos = SampleManager.GetStreamedFilePosition(); + if (SampleManager.IsStreamPlaying()) { if (m_nNextTrack != NO_TRACK) { m_aTracks[m_nNextTrack].m_nPosition = pos; m_aTracks[m_nNextTrack].m_nLastPosCheckTimer = CTimer::GetTimeInMillisecondsPauseMode(); - SampleManager.StopStreamedFile(0); + SampleManager.StopStreamedFile(); } } - SampleManager.SetStreamedVolumeAndPan(0, 63, FALSE, 0); - if (SampleManager.StartStreamedFile(m_nAnnouncement, 0, 0)) { - SampleManager.SetStreamedVolumeAndPan(AudioManager.ShouldDuckMissionAudio() ? 25 : 100, 63, FALSE, 0); + SampleManager.SetStreamedVolumeAndPan(0, 63, FALSE); + if (SampleManager.StartStreamedFile(m_nAnnouncement, 0)) { + SampleManager.SetStreamedVolumeAndPan(AudioManager.ShouldDuckMissionAudio() ? 25 : 100, 63, FALSE); m_bAnnouncementInProgress = TRUE; m_nPlayingTrack = m_nNextTrack; m_nNextTrack = m_nAnnouncement; @@ -992,16 +992,16 @@ cMusicManager::ChangeRadioChannel() { if (m_nNextTrack != m_nPlayingTrack) { if (m_nPlayingTrack < TOTAL_STREAMED_SOUNDS) { - m_aTracks[m_nPlayingTrack].m_nPosition = SampleManager.GetStreamedFilePosition(0); + m_aTracks[m_nPlayingTrack].m_nPosition = SampleManager.GetStreamedFilePosition(); m_aTracks[m_nPlayingTrack].m_nLastPosCheckTimer = CTimer::GetTimeInMillisecondsPauseMode(); - SampleManager.SetStreamedVolumeAndPan(0, 63, FALSE, 0); - SampleManager.StopStreamedFile(0); + SampleManager.SetStreamedVolumeAndPan(0, 63, FALSE); + SampleManager.StopStreamedFile(); } - if (SampleManager.IsStreamPlaying(0)) + if (SampleManager.IsStreamPlaying()) return FALSE; - if (!SampleManager.StartStreamedFile(m_nNextTrack, GetTrackStartPos(m_nNextTrack), 0)) + if (!SampleManager.StartStreamedFile(m_nNextTrack, GetTrackStartPos(m_nNextTrack))) return FALSE; - SampleManager.SetStreamedVolumeAndPan(AudioManager.ShouldDuckMissionAudio() ? 25 : 100, 63, FALSE, 0); + SampleManager.SetStreamedVolumeAndPan(AudioManager.ShouldDuckMissionAudio() ? 25 : 100, 63, FALSE); } return TRUE; } diff --git a/src/audio/sampman.h b/src/audio/sampman.h index b5f72d5c..d1ad9a26 100644 --- a/src/audio/sampman.h +++ b/src/audio/sampman.h @@ -201,15 +201,15 @@ public: void StartChannel (uint32 nChannel); void StopChannel (uint32 nChannel); - void PreloadStreamedFile (uint8 nFile, uint8 nStream); - void PauseStream (bool8 nPauseFlag, uint8 nStream); - void StartPreloadedStreamedFile (uint8 nStream); - bool8 StartStreamedFile (uint8 nFile, uint32 nPos, uint8 nStream); - void StopStreamedFile (uint8 nStream); - int32 GetStreamedFilePosition (uint8 nStream); - void SetStreamedVolumeAndPan(uint8 nVolume, uint8 nPan, bool8 nEffectFlag, uint8 nStream); - int32 GetStreamedFileLength (uint8 nStream); - bool8 IsStreamPlaying (uint8 nStream); + void PreloadStreamedFile (uint8 nFile, uint8 nStream = 0); + void PauseStream (bool8 nPauseFlag, uint8 nStream = 0); + void StartPreloadedStreamedFile (uint8 nStream = 0); + bool8 StartStreamedFile (uint8 nFile, uint32 nPos, uint8 nStream = 0); + void StopStreamedFile (uint8 nStream = 0); + int32 GetStreamedFilePosition (uint8 nStream = 0); + void SetStreamedVolumeAndPan(uint8 nVolume, uint8 nPan, bool8 nEffectFlag, uint8 nStream = 0); + int32 GetStreamedFileLength (uint8 nStream = 0); + bool8 IsStreamPlaying (uint8 nStream = 0); #ifdef AUDIO_OAL void Service(void); #endif -- cgit v1.2.3 From cacec36dd1dd6141986631ae22d6d40a64358a41 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Fri, 28 May 2021 19:03:16 +0300 Subject: Fix cut off sfx on high framerates --- src/audio/AudioManager.cpp | 21 +++++++++++++++++++-- src/audio/AudioManager.h | 4 ++++ 2 files changed, 23 insertions(+), 2 deletions(-) (limited to 'src/audio') diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index 5312bfad..69126c23 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -41,6 +41,11 @@ cAudioManager::cAudioManager() m_bFifthFrameFlag = FALSE; m_bTimerJustReset = FALSE; m_nTimer = 0; + +#ifdef FIX_BUGS + m_LogicalFrameCounter = 0; + m_bLogicalFrameUpdate = FALSE; +#endif } cAudioManager::~cAudioManager() @@ -100,6 +105,12 @@ cAudioManager::Terminate() void cAudioManager::Service() { +#ifdef FIX_BUGS + m_bLogicalFrameUpdate = m_LogicalFrameCounter != CTimer::GetLogicalFrameCounter(); + if(m_bLogicalFrameUpdate) + m_LogicalFrameCounter = CTimer::GetLogicalFrameCounter(); +#endif + GenerateIntegerRandomNumberTable(); if (m_bTimerJustReset) { ResetAudioLogicTimers(m_nTimer); @@ -423,6 +434,9 @@ cAudioManager::IsAudioInitialised() const void cAudioManager::ServiceSoundEffects() { +#ifdef FIX_BUGS + if(m_bLogicalFrameUpdate) +#endif m_bFifthFrameFlag = (m_FrameCounter++ % 5) == 0; if (m_nUserPause && !m_nPreviousUserPause) { for (int32 i = 0; i < NUM_CHANNELS; i++) @@ -712,9 +726,9 @@ cAudioManager::AddReleasingSounds() } if (!toProcess[i]) { if (sample.m_nCounter <= 255 || !sample.m_nLoopsRemaining) { - if (!sample.m_nReleasingVolumeDivider) + if (sample.m_nReleasingVolumeDivider == 0) continue; - if (!sample.m_nLoopCount) { + if (sample.m_nLoopCount == 0) { if (sample.m_nVolumeChange == -1) { sample.m_nVolumeChange = sample.m_nVolume / sample.m_nReleasingVolumeDivider; if (sample.m_nVolumeChange <= 0) @@ -726,6 +740,9 @@ cAudioManager::AddReleasingSounds() } sample.m_nVolume -= sample.m_nVolumeChange; } +#ifdef FIX_BUGS + if(m_bLogicalFrameUpdate) +#endif --sample.m_nReleasingVolumeDivider; if (m_bFifthFrameFlag) { if (sample.m_nReleasingVolumeModificator < 20) diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index 70302745..dcd6c7c4 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -223,6 +223,10 @@ public: uint8 m_nUserPause; uint8 m_nPreviousUserPause; uint32 m_FrameCounter; +#ifdef FIX_BUGS + uint32 m_LogicalFrameCounter; + bool8 m_bLogicalFrameUpdate; +#endif cAudioManager(); ~cAudioManager(); -- cgit v1.2.3 From f741101e4458d2515c57ae11f3f6c0088206524f Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 29 May 2021 11:57:51 +0300 Subject: Fix redone + add hud fix --- src/audio/AudioManager.cpp | 15 ++------------- src/audio/AudioManager.h | 4 ---- src/audio/MusicManager.cpp | 4 ++++ 3 files changed, 6 insertions(+), 17 deletions(-) (limited to 'src/audio') diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index 69126c23..c49ce552 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -41,11 +41,6 @@ cAudioManager::cAudioManager() m_bFifthFrameFlag = FALSE; m_bTimerJustReset = FALSE; m_nTimer = 0; - -#ifdef FIX_BUGS - m_LogicalFrameCounter = 0; - m_bLogicalFrameUpdate = FALSE; -#endif } cAudioManager::~cAudioManager() @@ -105,12 +100,6 @@ cAudioManager::Terminate() void cAudioManager::Service() { -#ifdef FIX_BUGS - m_bLogicalFrameUpdate = m_LogicalFrameCounter != CTimer::GetLogicalFrameCounter(); - if(m_bLogicalFrameUpdate) - m_LogicalFrameCounter = CTimer::GetLogicalFrameCounter(); -#endif - GenerateIntegerRandomNumberTable(); if (m_bTimerJustReset) { ResetAudioLogicTimers(m_nTimer); @@ -435,7 +424,7 @@ void cAudioManager::ServiceSoundEffects() { #ifdef FIX_BUGS - if(m_bLogicalFrameUpdate) + if(CTimer::GetLogicalFramesPassed() != 0) #endif m_bFifthFrameFlag = (m_FrameCounter++ % 5) == 0; if (m_nUserPause && !m_nPreviousUserPause) { @@ -741,7 +730,7 @@ cAudioManager::AddReleasingSounds() sample.m_nVolume -= sample.m_nVolumeChange; } #ifdef FIX_BUGS - if(m_bLogicalFrameUpdate) + if(CTimer::GetLogicalFramesPassed() != 0) #endif --sample.m_nReleasingVolumeDivider; if (m_bFifthFrameFlag) { diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index dcd6c7c4..70302745 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -223,10 +223,6 @@ public: uint8 m_nUserPause; uint8 m_nPreviousUserPause; uint32 m_FrameCounter; -#ifdef FIX_BUGS - uint32 m_LogicalFrameCounter; - bool8 m_bLogicalFrameUpdate; -#endif cAudioManager(); ~cAudioManager(); diff --git a/src/audio/MusicManager.cpp b/src/audio/MusicManager.cpp index 4eaa37d5..957fce55 100644 --- a/src/audio/MusicManager.cpp +++ b/src/audio/MusicManager.cpp @@ -195,7 +195,11 @@ cMusicManager::DisplayRadioStationName() cDisplay = 60; } else { if(cDisplay == 0) return; +#ifdef FIX_BUGS + cDisplay -= CTimer::GetLogicalFramesPassed(); +#else cDisplay--; +#endif } CFont::SetJustifyOff(); -- cgit v1.2.3 From a446dbefaa184dfeba5a0b9538b221f330e8703d Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 12 Jun 2021 19:07:51 +0300 Subject: Fix police scanner on high fps --- src/audio/PolRadio.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/audio') diff --git a/src/audio/PolRadio.cpp b/src/audio/PolRadio.cpp index 4eae169d..235a53d3 100644 --- a/src/audio/PolRadio.cpp +++ b/src/audio/PolRadio.cpp @@ -161,7 +161,11 @@ cAudioManager::ServicePoliceRadio() if(!crimeReport) { if(wantedLevel != 0) { if(nLastSeen != 0) { +#ifdef FIX_BUGS + nLastSeen -= CTimer::GetLogicalFramesPassed(); +#else --nLastSeen; +#endif } else { nLastSeen = m_anRandomTable[1] % 1000 + 2000; SetupSuspectLastSeenReport(); @@ -199,7 +203,11 @@ cAudioManager::ServicePoliceRadioChannel(uint8 wantedLevel) } if (m_sPoliceRadioQueue.policeChannelTimer == 0) bChannelOpen = FALSE; if (cWait) { +#ifdef FIX_BUGS + cWait -= CTimer::GetLogicalFramesPassed(); +#else --cWait; +#endif return; } if (g_nMissionAudioSfx != TOTAL_AUDIO_SAMPLES && !bChannelOpen) { -- cgit v1.2.3 From 5c1af537af94fdc1af9881d0d8e5c32f46b89e56 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sun, 20 Jun 2021 21:28:53 +0300 Subject: Don't restart OAL device when switching EAX --- src/audio/oal/aldlist.cpp | 26 +---- src/audio/oal/aldlist.h | 15 ++- src/audio/sampman_oal.cpp | 288 +++++++++++++++++++++++----------------------- 3 files changed, 167 insertions(+), 162 deletions(-) (limited to 'src/audio') diff --git a/src/audio/oal/aldlist.cpp b/src/audio/oal/aldlist.cpp index 881418c1..6024adf2 100644 --- a/src/audio/oal/aldlist.cpp +++ b/src/audio/oal/aldlist.cpp @@ -24,12 +24,6 @@ #include "aldlist.h" -#ifndef _WIN32 -#define _stricmp strcasecmp -#define _strnicmp strncasecmp -#define _strdup strdup -#endif - #ifdef AUDIO_OAL /* * Init call @@ -47,8 +41,8 @@ ALDeviceList::ALDeviceList() defaultDeviceIndex = 0; if (alcIsExtensionPresent(NULL, "ALC_ENUMERATION_EXT")) { - devices = (char *)alcGetString(NULL, ALC_DEVICE_SPECIFIER); - defaultDeviceName = (char *)alcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER); + devices = (char *)alcGetString(NULL, ALC_ALL_DEVICES_SPECIFIER); + defaultDeviceName = (char *)alcGetString(NULL, ALC_DEFAULT_ALL_DEVICES_SPECIFIER); index = 0; // go through device list (each device terminated with a single NULL, list terminated with double NULL) @@ -62,17 +56,11 @@ ALDeviceList::ALDeviceList() if (context) { alcMakeContextCurrent(context); // if new actual device name isn't already in the list, then add it... - actualDeviceName = alcGetString(device, ALC_DEVICE_SPECIFIER); - bool bNewName = true; - for (unsigned int i = 0; i < GetNumDevices(); i++) { - if (strcmp(GetDeviceName(i), actualDeviceName) == 0) { - bNewName = false; - } - } - if ((bNewName) && (actualDeviceName != NULL) && (strlen(actualDeviceName) > 0)) { - ALDEVICEINFO ALDeviceInfo; + actualDeviceName = alcGetString(device, ALC_ALL_DEVICES_SPECIFIER); + if ((actualDeviceName != NULL) && (strlen(actualDeviceName) > 0)) { + ALDEVICEINFO &ALDeviceInfo = aDeviceInfo[nNumOfDevices++]; ALDeviceInfo.bSelected = true; - ALDeviceInfo.strDeviceName = _strdup(actualDeviceName); + ALDeviceInfo.SetName(actualDeviceName); alcGetIntegerv(device, ALC_MAJOR_VERSION, sizeof(int), &ALDeviceInfo.iMajorVersion); alcGetIntegerv(device, ALC_MINOR_VERSION, sizeof(int), &ALDeviceInfo.iMinorVersion); @@ -105,8 +93,6 @@ ALDeviceList::ALDeviceList() // Get Source Count ALDeviceInfo.uiSourceCount = GetMaxNumSources(); - - aDeviceInfo[nNumOfDevices++] = ALDeviceInfo; } alcMakeContextCurrent(NULL); alcDestroyContext(context); diff --git a/src/audio/oal/aldlist.h b/src/audio/oal/aldlist.h index 417bd314..3ed12d84 100644 --- a/src/audio/oal/aldlist.h +++ b/src/audio/oal/aldlist.h @@ -21,7 +21,7 @@ enum }; struct ALDEVICEINFO { - const char *strDeviceName; + char *strDeviceName; int iMajorVersion; int iMinorVersion; unsigned int uiSourceCount; @@ -33,6 +33,19 @@ struct ALDEVICEINFO { strDeviceName = NULL; Extensions = 0; } + + ~ALDEVICEINFO() + { + delete[] strDeviceName; + strDeviceName = NULL; + } + + void SetName(const char *name) + { + if(strDeviceName) delete[] strDeviceName; + strDeviceName = new char[strlen(name) + 1]; + strcpy(strDeviceName, name); + } }; typedef ALDEVICEINFO *LPALDEVICEINFO; diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp index 0a1e7563..f2771885 100644 --- a/src/audio/sampman_oal.cpp +++ b/src/audio/sampman_oal.cpp @@ -45,7 +45,6 @@ #endif //TODO: fix eax3 reverb -//TODO: max channels cSampleManager SampleManager; bool8 _bSampmanInitialised = FALSE; @@ -61,15 +60,17 @@ ALCdevice *ALDevice = NULL; ALCcontext *ALContext = NULL; unsigned int _maxSamples; float _fPrevEaxRatioDestination; +bool _effectsSupported = false; bool _usingEFX; float _fEffectsLevel; ALuint ALEffect = AL_EFFECT_NULL; ALuint ALEffectSlot = AL_EFFECTSLOT_NULL; struct { - char id[256]; + const char *id; char name[256]; int sources; + bool bSupportsFx; }providers[MAXPROVIDERS]; int defaultProvider; @@ -134,7 +135,7 @@ EAXLISTENERPROPERTIES EAX3Params; bool IsFXSupported() { - return usingEAX || usingEAX3 || _usingEFX; + return _effectsSupported; // usingEAX || usingEAX3 || _usingEFX; } void EAX_SetAll(const EAXLISTENERPROPERTIES *allparameters) @@ -150,47 +151,49 @@ add_providers() { SampleManager.SetNum3DProvidersAvailable(0); - ALDeviceList *pDeviceList = NULL; - pDeviceList = new ALDeviceList(); + static ALDeviceList DeviceList; + ALDeviceList *pDeviceList = &DeviceList; if ((pDeviceList) && (pDeviceList->GetNumDevices())) { const int devNumber = Min(pDeviceList->GetNumDevices(), MAXPROVIDERS); int n = 0; - for (int i = 0; i < devNumber; i++) + //for (int i = 0; i < devNumber; i++) + int i = pDeviceList->GetDefaultDevice(); { if ( n < MAXPROVIDERS ) { - strcpy(providers[n].id, pDeviceList->GetDeviceName(i)); - strncpy(providers[n].name, pDeviceList->GetDeviceName(i), sizeof(providers[n].name)); + providers[n].id = pDeviceList->GetDeviceName(i); + strcpy(providers[n].name, "OPENAL SOFT"); providers[n].sources = pDeviceList->GetMaxNumSources(i); SampleManager.Set3DProviderName(n, providers[n].name); n++; } - + if ( alGetEnumValue("AL_EFFECT_EAXREVERB") != 0 || pDeviceList->IsExtensionSupported(i, ADEXT_EAX2) || pDeviceList->IsExtensionSupported(i, ADEXT_EAX3) || pDeviceList->IsExtensionSupported(i, ADEXT_EAX4) || pDeviceList->IsExtensionSupported(i, ADEXT_EAX5) ) { + providers[n - 1].bSupportsFx = true; if ( n < MAXPROVIDERS ) { - strcpy(providers[n].id, pDeviceList->GetDeviceName(i)); - strncpy(providers[n].name, pDeviceList->GetDeviceName(i), sizeof(providers[n].name)); - strcat(providers[n].name, " EAX"); + providers[n].id = pDeviceList->GetDeviceName(i); + strcpy(providers[n].name, "OPENAL SOFT EAX"); providers[n].sources = pDeviceList->GetMaxNumSources(i); + providers[n].bSupportsFx = true; SampleManager.Set3DProviderName(n, providers[n].name); n++; } if ( n < MAXPROVIDERS ) { - strcpy(providers[n].id, pDeviceList->GetDeviceName(i)); - strncpy(providers[n].name, pDeviceList->GetDeviceName(i), sizeof(providers[n].name)); - strcat(providers[n].name, " EAX3"); + providers[n].id = pDeviceList->GetDeviceName(i); + strcpy(providers[n].name, "OPENAL SOFT EAX3"); providers[n].sources = pDeviceList->GetMaxNumSources(i); + providers[n].bSupportsFx = true; SampleManager.Set3DProviderName(n, providers[n].name); n++; } @@ -201,66 +204,29 @@ add_providers() for(int j=n;jGetDefaultDevice(); - if ( defaultProvider > MAXPROVIDERS ) - defaultProvider = 0; + // devices are gone now + //defaultProvider = pDeviceList->GetDefaultDevice(); + //if ( defaultProvider > MAXPROVIDERS ) + defaultProvider = 0; } - - delete pDeviceList; } static void release_existing() { - for ( int32 i = 0; i < NUM_CHANNELS; i++ ) - aChannel[i].Term(); - if ( IsFXSupported() ) { if ( alIsEffect(ALEffect) ) { alEffecti(ALEffect, AL_EFFECT_TYPE, AL_EFFECT_NULL); - alDeleteEffects(1, &ALEffect); - ALEffect = AL_EFFECT_NULL; } if (alIsAuxiliaryEffectSlot(ALEffectSlot)) { alAuxiliaryEffectSloti(ALEffectSlot, AL_EFFECTSLOT_EFFECT, AL_EFFECT_NULL); - - alDeleteAuxiliaryEffectSlots(1, &ALEffectSlot); - ALEffectSlot = AL_EFFECTSLOT_NULL; } } - for ( int32 i = 0; i < MAX_STREAMS; i++ ) - { - CStream *stream = aStream[i]; - if (stream) - stream->ProviderTerm(); - - alDeleteBuffers(NUM_STREAMBUFFERS, ALStreamBuffers[i]); - } - alDeleteSources(MAX_STREAMS*2, ALStreamSources[0]); - - CChannel::DestroyChannels(); - - if ( ALContext ) - { - alcMakeContextCurrent(NULL); - alcSuspendContext(ALContext); - alcDestroyContext(ALContext); - } - if ( ALDevice ) - alcCloseDevice(ALDevice); - - ALDevice = NULL; - ALContext = NULL; - - _fPrevEaxRatioDestination = 0.0f; - _usingEFX = false; - _fEffectsLevel = 0.0f; - DEV("release_existing()\n"); } @@ -278,62 +244,6 @@ set_new_provider(int index) { DEV("set_new_provider()\n"); - //TODO: - _maxSamples = MAXCHANNELS; - - ALCint attr[] = {ALC_FREQUENCY,MAX_FREQ, - ALC_MONO_SOURCES, MAX_DIGITAL_MIXER_CHANNELS - MAX2DCHANNELS, - ALC_STEREO_SOURCES, MAX2DCHANNELS, - 0, - }; - - ALDevice = alcOpenDevice(providers[index].id); - ASSERT(ALDevice != NULL); - - ALContext = alcCreateContext(ALDevice, attr); - ASSERT(ALContext != NULL); - - alcMakeContextCurrent(ALContext); - - const char* ext=(const char*)alGetString(AL_EXTENSIONS); - ASSERT(strstr(ext,"AL_SOFT_loop_points")!=NULL); - if ( strstr(ext,"AL_SOFT_loop_points")==NULL ) - { - curprovider=-1; - release_existing(); - return FALSE; - } - - alListenerf (AL_GAIN, 1.0f); - alListener3f(AL_POSITION, 0.0f, 0.0f, 0.0f); - alListener3f(AL_VELOCITY, 0.0f, 0.0f, 0.0f); - ALfloat orientation[6] = { 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f }; - alListenerfv(AL_ORIENTATION, orientation); - - alDistanceModel(AL_INVERSE_DISTANCE_CLAMPED); - - if ( alcIsExtensionPresent(ALDevice, (ALCchar*)ALC_EXT_EFX_NAME) ) - { - alGenAuxiliaryEffectSlots(1, &ALEffectSlot); - alGenEffects(1, &ALEffect); - } - - alGenSources(MAX_STREAMS*2, ALStreamSources[0]); - for ( int32 i = 0; i < MAX_STREAMS; i++ ) - { - alGenBuffers(NUM_STREAMBUFFERS, ALStreamBuffers[i]); - alSourcei(ALStreamSources[i][0], AL_SOURCE_RELATIVE, AL_TRUE); - alSource3f(ALStreamSources[i][0], AL_POSITION, 0.0f, 0.0f, 0.0f); - alSourcef(ALStreamSources[i][0], AL_GAIN, 1.0f); - alSourcei(ALStreamSources[i][1], AL_SOURCE_RELATIVE, AL_TRUE); - alSource3f(ALStreamSources[i][1], AL_POSITION, 0.0f, 0.0f, 0.0f); - alSourcef(ALStreamSources[i][1], AL_GAIN, 1.0f); - - CStream *stream = aStream[i]; - if (stream) - stream->ProviderInit(); - } - usingEAX = 0; usingEAX3 = 0; _usingEFX = false; @@ -341,16 +251,16 @@ set_new_provider(int index) if ( !strcmp(&providers[index].name[strlen(providers[index].name) - strlen(" EAX3")], " EAX3") && alcIsExtensionPresent(ALDevice, (ALCchar*)ALC_EXT_EFX_NAME) ) { - EAX_SetAll(&FinishEAX3); usingEAX = 1; usingEAX3 = 1; + alAuxiliaryEffectSloti(ALEffectSlot, AL_EFFECTSLOT_EFFECT, ALEffect); + EAX_SetAll(&FinishEAX3); DEV("EAX3\n"); } else if ( alcIsExtensionPresent(ALDevice, (ALCchar*)ALC_EXT_EFX_NAME) ) { - EAX_SetAll(&EAX30_ORIGINAL_PRESETS[EAX_ENVIRONMENT_CAVE]); if ( !strcmp(&providers[index].name[strlen(providers[index].name) - strlen(" EAX")], " EAX")) { @@ -362,23 +272,14 @@ set_new_provider(int index) _usingEFX = true; DEV("EFX\n"); } + alAuxiliaryEffectSloti(ALEffectSlot, AL_EFFECTSLOT_EFFECT, ALEffect); + EAX_SetAll(&EAX30_ORIGINAL_PRESETS[EAX_ENVIRONMENT_CAVE]); } //SampleManager.SetSpeakerConfig(speaker_type); - - CChannel::InitChannels(); - for ( int32 i = 0; i < MAXCHANNELS; i++ ) - aChannel[i].Init(i); - for ( int32 i = 0; i < MAX2DCHANNELS; i++ ) - aChannel[MAXCHANNELS+i].Init(MAXCHANNELS+i, true); - if ( IsFXSupported() ) { - /**/ - alAuxiliaryEffectSloti(ALEffectSlot, AL_EFFECTSLOT_EFFECT, ALEffect); - /**/ - for ( int32 i = 0; i < MAXCHANNELS; i++ ) aChannel[i].SetReverbMix(ALEffectSlot, 0.0f); } @@ -867,21 +768,12 @@ cSampleManager::IsMP3RadioChannelAvailable(void) void cSampleManager::ReleaseDigitalHandle(void) { - if ( ALDevice ) - { - prevprovider = curprovider; - release_existing(); - curprovider = -1; - } + // TODO? alcSuspendContext } void cSampleManager::ReacquireDigitalHandle(void) { - if ( ALDevice ) - { - if ( prevprovider != -1 ) - set_new_provider(prevprovider); - } + // TODO? alcProcessContext } bool8 @@ -898,7 +790,7 @@ cSampleManager::Initialise(void) { m_aSamples[i].nOffset = 0; m_aSamples[i].nSize = 0; - m_aSamples[i].nFrequency = MAX_FREQ; + m_aSamples[i].nFrequency = 22050; m_aSamples[i].nLoopStart = 0; m_aSamples[i].nLoopEnd = -1; } @@ -954,13 +846,84 @@ cSampleManager::Initialise(void) for ( int32 i = 0; i < NUM_CHANNELS; i++ ) nChannelVolume[i] = 0; } + + add_providers(); + + { + int index = 0; + _maxSamples = Min(MAXCHANNELS, providers[index].sources); + + ALCint attr[] = {ALC_FREQUENCY,MAX_FREQ, + ALC_MONO_SOURCES, MAX_DIGITAL_MIXER_CHANNELS - MAX2DCHANNELS, + ALC_STEREO_SOURCES, MAX2DCHANNELS, + 0, + }; + + ALDevice = alcOpenDevice(providers[index].id); + ASSERT(ALDevice != NULL); + + ALContext = alcCreateContext(ALDevice, attr); + ASSERT(ALContext != NULL); + + alcMakeContextCurrent(ALContext); + + const char* ext=(const char*)alGetString(AL_EXTENSIONS); + ASSERT(strstr(ext,"AL_SOFT_loop_points")!=NULL); + if ( strstr(ext,"AL_SOFT_loop_points")==NULL ) + { + Terminate(); + return FALSE; + } + + alListenerf (AL_GAIN, 1.0f); + alListener3f(AL_POSITION, 0.0f, 0.0f, 0.0f); + alListener3f(AL_VELOCITY, 0.0f, 0.0f, 0.0f); + ALfloat orientation[6] = { 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f }; + alListenerfv(AL_ORIENTATION, orientation); + + alDistanceModel(AL_INVERSE_DISTANCE_CLAMPED); + + if ( alcIsExtensionPresent(ALDevice, (ALCchar*)ALC_EXT_EFX_NAME) ) + { + _effectsSupported = providers[index].bSupportsFx; + alGenAuxiliaryEffectSlots(1, &ALEffectSlot); + alGenEffects(1, &ALEffect); + } + + alGenSources(MAX_STREAMS*2, ALStreamSources[0]); + for ( int32 i = 0; i < MAX_STREAMS; i++ ) + { + alGenBuffers(NUM_STREAMBUFFERS, ALStreamBuffers[i]); + alSourcei(ALStreamSources[i][0], AL_SOURCE_RELATIVE, AL_TRUE); + alSource3f(ALStreamSources[i][0], AL_POSITION, 0.0f, 0.0f, 0.0f); + alSourcef(ALStreamSources[i][0], AL_GAIN, 1.0f); + alSourcei(ALStreamSources[i][1], AL_SOURCE_RELATIVE, AL_TRUE); + alSource3f(ALStreamSources[i][1], AL_POSITION, 0.0f, 0.0f, 0.0f); + alSourcef(ALStreamSources[i][1], AL_GAIN, 1.0f); + } + + CChannel::InitChannels(); + + for ( int32 i = 0; i < MAXCHANNELS; i++ ) + aChannel[i].Init(i); + for ( int32 i = 0; i < MAX2DCHANNELS; i++ ) + aChannel[MAXCHANNELS+i].Init(MAXCHANNELS+i, true); + + if ( IsFXSupported() ) + { + /**/ + alAuxiliaryEffectSloti(ALEffectSlot, AL_EFFECTSLOT_EFFECT, ALEffect); + /**/ + + for ( int32 i = 0; i < MAXCHANNELS; i++ ) + aChannel[i].SetReverbMix(ALEffectSlot, 0.0f); + } + } { for ( int32 i = 0; i < TOTAL_STREAMED_SOUNDS; i++ ) nStreamLength[i] = 0; } - - add_providers(); #ifdef AUDIO_CACHE FILE *cacheFile = fcaseopen("audio\\sound.cache", "rb"); @@ -1117,8 +1080,51 @@ cSampleManager::Terminate(void) aStream[i] = NULL; } } - - release_existing(); + + for ( int32 i = 0; i < NUM_CHANNELS; i++ ) + aChannel[i].Term(); + + if ( IsFXSupported() ) + { + if ( alIsEffect(ALEffect) ) + { + alEffecti(ALEffect, AL_EFFECT_TYPE, AL_EFFECT_NULL); + alDeleteEffects(1, &ALEffect); + ALEffect = AL_EFFECT_NULL; + } + + if (alIsAuxiliaryEffectSlot(ALEffectSlot)) + { + alAuxiliaryEffectSloti(ALEffectSlot, AL_EFFECTSLOT_EFFECT, AL_EFFECT_NULL); + + alDeleteAuxiliaryEffectSlots(1, &ALEffectSlot); + ALEffectSlot = AL_EFFECTSLOT_NULL; + } + } + + for ( int32 i = 0; i < MAX_STREAMS; i++ ) + { + alDeleteBuffers(NUM_STREAMBUFFERS, ALStreamBuffers[i]); + } + alDeleteSources(MAX_STREAMS*2, ALStreamSources[0]); + + CChannel::DestroyChannels(); + + if ( ALContext ) + { + alcMakeContextCurrent(NULL); + alcSuspendContext(ALContext); + alcDestroyContext(ALContext); + } + if ( ALDevice ) + alcCloseDevice(ALDevice); + + ALDevice = NULL; + ALContext = NULL; + + _fPrevEaxRatioDestination = 0.0f; + _usingEFX = false; + _fEffectsLevel = 0.0f; _DeleteMP3Entries(); -- cgit v1.2.3 From 2b67aba94cb6448fb24c869559465eddf2bad069 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Fri, 25 Jun 2021 19:03:05 +0300 Subject: Redo ReadSaveBuf + common.h cleanup --- src/audio/AudioScriptObject.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/audio') diff --git a/src/audio/AudioScriptObject.cpp b/src/audio/AudioScriptObject.cpp index ac30f757..623c43ca 100644 --- a/src/audio/AudioScriptObject.cpp +++ b/src/audio/AudioScriptObject.cpp @@ -3,6 +3,7 @@ #include "AudioScriptObject.h" #include "Pools.h" #include "DMAudio.h" +#include "SaveBuf.h" cAudioScriptObject::cAudioScriptObject() { @@ -53,12 +54,14 @@ cAudioScriptObject::LoadAllAudioScriptObjects(uint8 *buf, uint32 size) CheckSaveHeader(buf, 'A', 'U', 'D', '\0', size - SAVE_HEADER_SIZE); - int32 pool_size = ReadSaveBuf(buf); + int32 pool_size; + ReadSaveBuf(&pool_size, buf); for (int32 i = 0; i < pool_size; i++) { - int handle = ReadSaveBuf(buf); + int32 handle; + ReadSaveBuf(&handle, buf); cAudioScriptObject *p = new(handle) cAudioScriptObject; assert(p != nil); - *p = ReadSaveBuf(buf); + ReadSaveBuf(p, buf); p->AudioEntity = DMAudio.CreateLoopingScriptObject(p); } -- cgit v1.2.3 From af7573ddbe38e0aaa485877e7ccb2e704b0f5a7f Mon Sep 17 00:00:00 2001 From: erorcun Date: Sat, 26 Jun 2021 00:25:59 +0300 Subject: Revert "Redo ReadSaveBuf + common.h cleanup" This reverts commit 2b67aba94cb6448fb24c869559465eddf2bad069. --- src/audio/AudioScriptObject.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/audio') diff --git a/src/audio/AudioScriptObject.cpp b/src/audio/AudioScriptObject.cpp index 623c43ca..ac30f757 100644 --- a/src/audio/AudioScriptObject.cpp +++ b/src/audio/AudioScriptObject.cpp @@ -3,7 +3,6 @@ #include "AudioScriptObject.h" #include "Pools.h" #include "DMAudio.h" -#include "SaveBuf.h" cAudioScriptObject::cAudioScriptObject() { @@ -54,14 +53,12 @@ cAudioScriptObject::LoadAllAudioScriptObjects(uint8 *buf, uint32 size) CheckSaveHeader(buf, 'A', 'U', 'D', '\0', size - SAVE_HEADER_SIZE); - int32 pool_size; - ReadSaveBuf(&pool_size, buf); + int32 pool_size = ReadSaveBuf(buf); for (int32 i = 0; i < pool_size; i++) { - int32 handle; - ReadSaveBuf(&handle, buf); + int handle = ReadSaveBuf(buf); cAudioScriptObject *p = new(handle) cAudioScriptObject; assert(p != nil); - ReadSaveBuf(p, buf); + *p = ReadSaveBuf(buf); p->AudioEntity = DMAudio.CreateLoopingScriptObject(p); } -- cgit v1.2.3 From 9b5caa190e30131e361e77e0921653d13f5d124f Mon Sep 17 00:00:00 2001 From: erorcun Date: Sat, 26 Jun 2021 00:27:12 +0300 Subject: Pool fixes Mostly for Linux --- src/audio/AudioScriptObject.cpp | 8 ++++---- src/audio/AudioScriptObject.h | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src/audio') diff --git a/src/audio/AudioScriptObject.cpp b/src/audio/AudioScriptObject.cpp index ac30f757..c74feb92 100644 --- a/src/audio/AudioScriptObject.cpp +++ b/src/audio/AudioScriptObject.cpp @@ -23,25 +23,25 @@ cAudioScriptObject::Reset() } void * -cAudioScriptObject::operator new(size_t sz) +cAudioScriptObject::operator new(size_t sz) throw() { return CPools::GetAudioScriptObjectPool()->New(); } void * -cAudioScriptObject::operator new(size_t sz, int handle) +cAudioScriptObject::operator new(size_t sz, int handle) throw() { return CPools::GetAudioScriptObjectPool()->New(handle); } void -cAudioScriptObject::operator delete(void *p, size_t sz) +cAudioScriptObject::operator delete(void *p, size_t sz) throw() { CPools::GetAudioScriptObjectPool()->Delete((cAudioScriptObject *)p); } void -cAudioScriptObject::operator delete(void *p, int handle) +cAudioScriptObject::operator delete(void *p, int handle) throw() { CPools::GetAudioScriptObjectPool()->Delete((cAudioScriptObject *)p); } diff --git a/src/audio/AudioScriptObject.h b/src/audio/AudioScriptObject.h index 8110b2bb..b9a7e61b 100644 --- a/src/audio/AudioScriptObject.h +++ b/src/audio/AudioScriptObject.h @@ -12,10 +12,10 @@ public: void Reset(); /// ok - static void* operator new(size_t); - static void* operator new(size_t, int); - static void operator delete(void*, size_t); - static void operator delete(void*, int); + static void* operator new(size_t) throw(); + static void* operator new(size_t, int) throw(); + static void operator delete(void*, size_t) throw(); + static void operator delete(void*, int) throw(); static void LoadAllAudioScriptObjects(uint8 *buf, uint32 size); static void SaveAllAudioScriptObjects(uint8 *buf, uint32 *size); -- cgit v1.2.3 From f3a931e1c99372ae4bc224ef482d4052a09580cb Mon Sep 17 00:00:00 2001 From: withmorten Date: Sat, 26 Jun 2021 19:14:46 +0200 Subject: Revert "Revert "Redo ReadSaveBuf + common.h cleanup"" This reverts commit af7573ddbe38e0aaa485877e7ccb2e704b0f5a7f. --- src/audio/AudioScriptObject.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/audio') diff --git a/src/audio/AudioScriptObject.cpp b/src/audio/AudioScriptObject.cpp index c74feb92..03efdea9 100644 --- a/src/audio/AudioScriptObject.cpp +++ b/src/audio/AudioScriptObject.cpp @@ -3,6 +3,7 @@ #include "AudioScriptObject.h" #include "Pools.h" #include "DMAudio.h" +#include "SaveBuf.h" cAudioScriptObject::cAudioScriptObject() { @@ -53,12 +54,14 @@ cAudioScriptObject::LoadAllAudioScriptObjects(uint8 *buf, uint32 size) CheckSaveHeader(buf, 'A', 'U', 'D', '\0', size - SAVE_HEADER_SIZE); - int32 pool_size = ReadSaveBuf(buf); + int32 pool_size; + ReadSaveBuf(&pool_size, buf); for (int32 i = 0; i < pool_size; i++) { - int handle = ReadSaveBuf(buf); + int32 handle; + ReadSaveBuf(&handle, buf); cAudioScriptObject *p = new(handle) cAudioScriptObject; assert(p != nil); - *p = ReadSaveBuf(buf); + ReadSaveBuf(p, buf); p->AudioEntity = DMAudio.CreateLoopingScriptObject(p); } -- cgit v1.2.3 From 091a65996ef9eba0dfeb49508927ebb521c0f15b Mon Sep 17 00:00:00 2001 From: erorcun Date: Sun, 27 Jun 2021 17:53:14 +0300 Subject: Use PS2-y global names on SampMan --- src/audio/AudioLogic.cpp | 122 ++++++++++++------------- src/audio/oal/channel.cpp | 2 +- src/audio/sampman.h | 6 +- src/audio/sampman_miles.cpp | 196 +++++++++++++++++++-------------------- src/audio/sampman_null.cpp | 2 +- src/audio/sampman_oal.cpp | 218 ++++++++++++++++++++++---------------------- 6 files changed, 273 insertions(+), 273 deletions(-) (limited to 'src/audio') diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 8472cda6..7fcab57d 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -58,69 +58,69 @@ enum LOADING_STATUS { LOADING_STATUS_NOT_LOADED = 0, LOADING_STATUS_LOADED, LOAD void cAudioManager::PreInitialiseGameSpecificSetup() const { - BankStartOffset[SFX_BANK_0] = SAMPLEBANK_START; + gBankStartOffset[SFX_BANK_0] = SAMPLEBANK_START; #ifdef GTA_PS2 - BankStartOffset[SFX_BANK_PACARD] = SFX_CAR_ACCEL_1; - BankStartOffset[SFX_BANK_PATHFINDER] = SFX_CAR_ACCEL_2; - BankStartOffset[SFX_BANK_PORSCHE] = SFX_CAR_ACCEL_3; - BankStartOffset[SFX_BANK_SPIDER] = SFX_CAR_ACCEL_4; - BankStartOffset[SFX_BANK_MERC] = SFX_CAR_ACCEL_5; - BankStartOffset[SFX_BANK_TRUCK] = SFX_CAR_ACCEL_6; - BankStartOffset[SFX_BANK_HOTROD] = SFX_CAR_ACCEL_7; - BankStartOffset[SFX_BANK_COBRA] = SFX_CAR_ACCEL_8; - BankStartOffset[SFX_BANK_NONE] = SFX_CAR_ACCEL_9; - BankStartOffset[SFX_BANK_FRONT_END_MENU] = SFX_PAGE_CHANGE_AND_BACK_LEFT; - BankStartOffset[SFX_BANK_TRAIN] = SFX_TRAIN_STATION_AMBIENCE_LOOP; - BankStartOffset[SFX_BANK_BUILDING_CLUB_1] = SFX_CLUB_1; - BankStartOffset[SFX_BANK_BUILDING_CLUB_2] = SFX_CLUB_2; - BankStartOffset[SFX_BANK_BUILDING_CLUB_3] = SFX_CLUB_3; - BankStartOffset[SFX_BANK_BUILDING_CLUB_4] = SFX_CLUB_4; - BankStartOffset[SFX_BANK_BUILDING_CLUB_5] = SFX_CLUB_5; - BankStartOffset[SFX_BANK_BUILDING_CLUB_6] = SFX_CLUB_6; - BankStartOffset[SFX_BANK_BUILDING_CLUB_7] = SFX_CLUB_7; - BankStartOffset[SFX_BANK_BUILDING_CLUB_8] = SFX_CLUB_8; - BankStartOffset[SFX_BANK_BUILDING_CLUB_9] = SFX_CLUB_9; - BankStartOffset[SFX_BANK_BUILDING_CLUB_10] = SFX_CLUB_10; - BankStartOffset[SFX_BANK_BUILDING_CLUB_11] = SFX_CLUB_11; - BankStartOffset[SFX_BANK_BUILDING_CLUB_12] = SFX_CLUB_12; - BankStartOffset[SFX_BANK_BUILDING_CLUB_RAGGA] = SFX_CLUB_RAGGA; - BankStartOffset[SFX_BANK_BUILDING_STRIP_CLUB_1] = SFX_STRIP_CLUB_1; - BankStartOffset[SFX_BANK_BUILDING_STRIP_CLUB_2] = SFX_STRIP_CLUB_2; - BankStartOffset[SFX_BANK_BUILDING_WORKSHOP] = SFX_WORKSHOP_1; - BankStartOffset[SFX_BANK_BUILDING_PIANO_BAR] = SFX_PIANO_BAR_1; - BankStartOffset[SFX_BANK_BUILDING_SAWMILL] = SFX_SAWMILL_LOOP; - BankStartOffset[SFX_BANK_BUILDING_DOG_FOOD_FACTORY] = SFX_DOG_FOOD_FACTORY; - BankStartOffset[SFX_BANK_BUILDING_LAUNDERETTE] = SFX_LAUNDERETTE_LOOP; - BankStartOffset[SFX_BANK_BUILDING_RESTAURANT_CHINATOWN] = SFX_RESTAURANT_CHINATOWN; - BankStartOffset[SFX_BANK_BUILDING_RESTAURANT_ITALY] = SFX_RESTAURANT_ITALY; - BankStartOffset[SFX_BANK_BUILDING_RESTAURANT_GENERIC_1] = SFX_RESTAURANT_GENERIC_1; - BankStartOffset[SFX_BANK_BUILDING_RESTAURANT_GENERIC_2] = SFX_RESTAURANT_GENERIC_2; - BankStartOffset[SFX_BANK_BUILDING_AIRPORT] = SFX_AIRPORT_ANNOUNCEMENT_1; - BankStartOffset[SFX_BANK_BUILDING_SHOP] = SFX_SHOP_LOOP; - BankStartOffset[SFX_BANK_BUILDING_CINEMA] = SFX_CINEMA_BASS_1; - BankStartOffset[SFX_BANK_BUILDING_DOCKS] = SFX_DOCKS_FOGHORN; - BankStartOffset[SFX_BANK_BUILDING_HOME] = SFX_HOME_1; - BankStartOffset[SFX_BANK_BUILDING_PORN_1] = SFX_PORN_1_LOOP; - BankStartOffset[SFX_BANK_BUILDING_PORN_2] = SFX_PORN_2_LOOP; - BankStartOffset[SFX_BANK_BUILDING_PORN_3] = SFX_PORN_3_LOOP; - BankStartOffset[SFX_BANK_BUILDING_POLICE_BALL] = SFX_POLICE_BALL_1; - BankStartOffset[SFX_BANK_BUILDING_BANK_ALARM] = SFX_BANK_ALARM_1; - BankStartOffset[SFX_BANK_BUILDING_RAVE_INDUSTRIAL] = SFX_RAVE_INDUSTRIAL; - BankStartOffset[SFX_BANK_BUILDING_RAVE_COMMERCIAL] = SFX_RAVE_COMMERCIAL; - BankStartOffset[SFX_BANK_BUILDING_RAVE_SUBURBAN] = SFX_RAVE_SUBURBAN; - BankStartOffset[SFX_BANK_BUILDING_RAVE_COMMERCIAL_2] = SFX_RAVE_COMMERCIAL_2; - BankStartOffset[SFX_BANK_BUILDING_39] = SFX_CLUB_1_1; - BankStartOffset[SFX_BANK_BUILDING_40] = SFX_CLUB_1_2; - BankStartOffset[SFX_BANK_BUILDING_41] = SFX_CLUB_1_3; - BankStartOffset[SFX_BANK_BUILDING_42] = SFX_CLUB_1_4; - BankStartOffset[SFX_BANK_BUILDING_43] = SFX_CLUB_1_5; - BankStartOffset[SFX_BANK_BUILDING_44] = SFX_CLUB_1_6; - BankStartOffset[SFX_BANK_BUILDING_45] = SFX_CLUB_1_7; - BankStartOffset[SFX_BANK_BUILDING_46] = SFX_CLUB_1_8; - BankStartOffset[SFX_BANK_BUILDING_47] = SFX_CLUB_1_9; - BankStartOffset[SFX_BANK_GENERIC_EXTRA] = SFX_EXPLOSION_1; + gBankStartOffset[SFX_BANK_PACARD] = SFX_CAR_ACCEL_1; + gBankStartOffset[SFX_BANK_PATHFINDER] = SFX_CAR_ACCEL_2; + gBankStartOffset[SFX_BANK_PORSCHE] = SFX_CAR_ACCEL_3; + gBankStartOffset[SFX_BANK_SPIDER] = SFX_CAR_ACCEL_4; + gBankStartOffset[SFX_BANK_MERC] = SFX_CAR_ACCEL_5; + gBankStartOffset[SFX_BANK_TRUCK] = SFX_CAR_ACCEL_6; + gBankStartOffset[SFX_BANK_HOTROD] = SFX_CAR_ACCEL_7; + gBankStartOffset[SFX_BANK_COBRA] = SFX_CAR_ACCEL_8; + gBankStartOffset[SFX_BANK_NONE] = SFX_CAR_ACCEL_9; + gBankStartOffset[SFX_BANK_FRONT_END_MENU] = SFX_PAGE_CHANGE_AND_BACK_LEFT; + gBankStartOffset[SFX_BANK_TRAIN] = SFX_TRAIN_STATION_AMBIENCE_LOOP; + gBankStartOffset[SFX_BANK_BUILDING_CLUB_1] = SFX_CLUB_1; + gBankStartOffset[SFX_BANK_BUILDING_CLUB_2] = SFX_CLUB_2; + gBankStartOffset[SFX_BANK_BUILDING_CLUB_3] = SFX_CLUB_3; + gBankStartOffset[SFX_BANK_BUILDING_CLUB_4] = SFX_CLUB_4; + gBankStartOffset[SFX_BANK_BUILDING_CLUB_5] = SFX_CLUB_5; + gBankStartOffset[SFX_BANK_BUILDING_CLUB_6] = SFX_CLUB_6; + gBankStartOffset[SFX_BANK_BUILDING_CLUB_7] = SFX_CLUB_7; + gBankStartOffset[SFX_BANK_BUILDING_CLUB_8] = SFX_CLUB_8; + gBankStartOffset[SFX_BANK_BUILDING_CLUB_9] = SFX_CLUB_9; + gBankStartOffset[SFX_BANK_BUILDING_CLUB_10] = SFX_CLUB_10; + gBankStartOffset[SFX_BANK_BUILDING_CLUB_11] = SFX_CLUB_11; + gBankStartOffset[SFX_BANK_BUILDING_CLUB_12] = SFX_CLUB_12; + gBankStartOffset[SFX_BANK_BUILDING_CLUB_RAGGA] = SFX_CLUB_RAGGA; + gBankStartOffset[SFX_BANK_BUILDING_STRIP_CLUB_1] = SFX_STRIP_CLUB_1; + gBankStartOffset[SFX_BANK_BUILDING_STRIP_CLUB_2] = SFX_STRIP_CLUB_2; + gBankStartOffset[SFX_BANK_BUILDING_WORKSHOP] = SFX_WORKSHOP_1; + gBankStartOffset[SFX_BANK_BUILDING_PIANO_BAR] = SFX_PIANO_BAR_1; + gBankStartOffset[SFX_BANK_BUILDING_SAWMILL] = SFX_SAWMILL_LOOP; + gBankStartOffset[SFX_BANK_BUILDING_DOG_FOOD_FACTORY] = SFX_DOG_FOOD_FACTORY; + gBankStartOffset[SFX_BANK_BUILDING_LAUNDERETTE] = SFX_LAUNDERETTE_LOOP; + gBankStartOffset[SFX_BANK_BUILDING_RESTAURANT_CHINATOWN] = SFX_RESTAURANT_CHINATOWN; + gBankStartOffset[SFX_BANK_BUILDING_RESTAURANT_ITALY] = SFX_RESTAURANT_ITALY; + gBankStartOffset[SFX_BANK_BUILDING_RESTAURANT_GENERIC_1] = SFX_RESTAURANT_GENERIC_1; + gBankStartOffset[SFX_BANK_BUILDING_RESTAURANT_GENERIC_2] = SFX_RESTAURANT_GENERIC_2; + gBankStartOffset[SFX_BANK_BUILDING_AIRPORT] = SFX_AIRPORT_ANNOUNCEMENT_1; + gBankStartOffset[SFX_BANK_BUILDING_SHOP] = SFX_SHOP_LOOP; + gBankStartOffset[SFX_BANK_BUILDING_CINEMA] = SFX_CINEMA_BASS_1; + gBankStartOffset[SFX_BANK_BUILDING_DOCKS] = SFX_DOCKS_FOGHORN; + gBankStartOffset[SFX_BANK_BUILDING_HOME] = SFX_HOME_1; + gBankStartOffset[SFX_BANK_BUILDING_PORN_1] = SFX_PORN_1_LOOP; + gBankStartOffset[SFX_BANK_BUILDING_PORN_2] = SFX_PORN_2_LOOP; + gBankStartOffset[SFX_BANK_BUILDING_PORN_3] = SFX_PORN_3_LOOP; + gBankStartOffset[SFX_BANK_BUILDING_POLICE_BALL] = SFX_POLICE_BALL_1; + gBankStartOffset[SFX_BANK_BUILDING_BANK_ALARM] = SFX_BANK_ALARM_1; + gBankStartOffset[SFX_BANK_BUILDING_RAVE_INDUSTRIAL] = SFX_RAVE_INDUSTRIAL; + gBankStartOffset[SFX_BANK_BUILDING_RAVE_COMMERCIAL] = SFX_RAVE_COMMERCIAL; + gBankStartOffset[SFX_BANK_BUILDING_RAVE_SUBURBAN] = SFX_RAVE_SUBURBAN; + gBankStartOffset[SFX_BANK_BUILDING_RAVE_COMMERCIAL_2] = SFX_RAVE_COMMERCIAL_2; + gBankStartOffset[SFX_BANK_BUILDING_39] = SFX_CLUB_1_1; + gBankStartOffset[SFX_BANK_BUILDING_40] = SFX_CLUB_1_2; + gBankStartOffset[SFX_BANK_BUILDING_41] = SFX_CLUB_1_3; + gBankStartOffset[SFX_BANK_BUILDING_42] = SFX_CLUB_1_4; + gBankStartOffset[SFX_BANK_BUILDING_43] = SFX_CLUB_1_5; + gBankStartOffset[SFX_BANK_BUILDING_44] = SFX_CLUB_1_6; + gBankStartOffset[SFX_BANK_BUILDING_45] = SFX_CLUB_1_7; + gBankStartOffset[SFX_BANK_BUILDING_46] = SFX_CLUB_1_8; + gBankStartOffset[SFX_BANK_BUILDING_47] = SFX_CLUB_1_9; + gBankStartOffset[SFX_BANK_GENERIC_EXTRA] = SFX_EXPLOSION_1; #endif // GTA_PS2 - BankStartOffset[SFX_BANK_PED_COMMENTS] = SAMPLEBANK_PED_START; + gBankStartOffset[SFX_BANK_PED_COMMENTS] = SAMPLEBANK_PED_START; } void diff --git a/src/audio/oal/channel.cpp b/src/audio/oal/channel.cpp index 04e7e529..2ae12fcf 100644 --- a/src/audio/oal/channel.cpp +++ b/src/audio/oal/channel.cpp @@ -17,7 +17,7 @@ bool bChannelsCreated = false; int32 CChannel::channelsThatNeedService = 0; -uint8 tempStereoBuffer[PED_BLOCKSIZE * 2]; +uint8 tempStereoBuffer[PED_BUFFERSIZE * 2]; void CChannel::InitChannels() diff --git a/src/audio/sampman.h b/src/audio/sampman.h index d1ad9a26..08e5dde0 100644 --- a/src/audio/sampman.h +++ b/src/audio/sampman.h @@ -96,7 +96,7 @@ enum }; #define MAX_PEDSFX 7 -#define PED_BLOCKSIZE 79000 +#define PED_BUFFERSIZE 79000 #define MAXPROVIDERS 64 @@ -130,7 +130,7 @@ class cSampleManager bool8 m_bInitialised; uint8 m_nNumberOfProviders; char *m_aAudioProviders[MAXPROVIDERS]; - tSample m_aSamples[TOTAL_AUDIO_SAMPLES]; + tSample m_aSampleDataTable[TOTAL_AUDIO_SAMPLES]; public: @@ -217,7 +217,7 @@ public: }; extern cSampleManager SampleManager; -extern uint32 BankStartOffset[MAX_SFX_BANKS]; +extern uint32 gBankStartOffset[MAX_SFX_BANKS]; #ifdef AUDIO_OAL extern int defaultProvider; diff --git a/src/audio/sampman_miles.cpp b/src/audio/sampman_miles.cpp index ddfaaa5f..3149b306 100644 --- a/src/audio/sampman_miles.cpp +++ b/src/audio/sampman_miles.cpp @@ -20,27 +20,27 @@ #pragma comment( lib, "mss32.lib" ) cSampleManager SampleManager; -uint32 BankStartOffset[MAX_SFX_BANKS]; +uint32 gBankStartOffset[MAX_SFX_BANKS]; /////////////////////////////////////////////////////////////// char SampleBankDescFilename[] = "AUDIO\\SFX.SDT"; char SampleBankDataFilename[] = "AUDIO\\SFX.RAW"; -FILE *fpSampleDescHandle; -FILE *fpSampleDataHandle; -bool8 bSampleBankLoaded [MAX_SFX_BANKS]; -int32 nSampleBankDiscStartOffset [MAX_SFX_BANKS]; -int32 nSampleBankSize [MAX_SFX_BANKS]; -int32 nSampleBankMemoryStartAddress[MAX_SFX_BANKS]; +FILE *gFileHandleSampleDesc; +FILE *gFileHandleSampleData; +bool8 gBankLoaded [MAX_SFX_BANKS]; +int32 gSampleBankDiscStartOffset [MAX_SFX_BANKS]; +int32 gSampleBankSize [MAX_SFX_BANKS]; +int32 gSampleBankMemoryStartAddress[MAX_SFX_BANKS]; int32 _nSampleDataEndOffset; -int32 nPedSlotSfx [MAX_PEDSFX]; -int32 nPedSlotSfxAddr[MAX_PEDSFX]; -uint8 nCurrentPedSlot; +int32 gPedSfx [MAX_PEDSFX]; +int32 gPedSfxAddr[MAX_PEDSFX]; +uint8 gCurPedIndex; -uint8 nChannelVolume[MAXCHANNELS+MAX2DCHANNELS]; +uint8 gChannelVolume[MAXCHANNELS+MAX2DCHANNELS]; -uint32 nStreamLength[TOTAL_STREAMED_SOUNDS]; +uint32 gStreamLength[TOTAL_STREAMED_SOUNDS]; /////////////////////////////////////////////////////////////// struct tMP3Entry @@ -851,11 +851,11 @@ cSampleManager::Initialise(void) { for ( int32 i = 0; i < TOTAL_AUDIO_SAMPLES; i++ ) { - m_aSamples[i].nOffset = 0; - m_aSamples[i].nSize = 0; - m_aSamples[i].nFrequency = 22050; - m_aSamples[i].nLoopStart = 0; - m_aSamples[i].nLoopEnd = -1; + m_aSampleDataTable[i].nOffset = 0; + m_aSampleDataTable[i].nSize = 0; + m_aSampleDataTable[i].nFrequency = 22050; + m_aSampleDataTable[i].nLoopStart = 0; + m_aSampleDataTable[i].nLoopEnd = -1; } m_nEffectsVolume = MAX_VOLUME; @@ -890,17 +890,17 @@ cSampleManager::Initialise(void) // banks TRACE("banks"); { - fpSampleDescHandle = NULL; - fpSampleDataHandle = NULL; + gFileHandleSampleDesc = NULL; + gFileHandleSampleData = NULL; _nSampleDataEndOffset = 0; for ( int32 i = 0; i < MAX_SFX_BANKS; i++ ) { - bSampleBankLoaded[i] = FALSE; - nSampleBankDiscStartOffset[i] = 0; - nSampleBankSize[i] = 0; - nSampleBankMemoryStartAddress[i] = 0; + gBankLoaded[i] = FALSE; + gSampleBankDiscStartOffset[i] = 0; + gSampleBankSize[i] = 0; + gSampleBankMemoryStartAddress[i] = 0; } } @@ -909,18 +909,18 @@ cSampleManager::Initialise(void) { for ( int32 i = 0; i < MAX_PEDSFX; i++ ) { - nPedSlotSfx[i] = NO_SAMPLE; - nPedSlotSfxAddr[i] = 0; + gPedSfx[i] = NO_SAMPLE; + gPedSfxAddr[i] = 0; } - nCurrentPedSlot = 0; + gCurPedIndex = 0; } // channel volume TRACE("vol"); { for ( int32 i = 0; i < MAXCHANNELS+MAX2DCHANNELS; i++ ) - nChannelVolume[i] = 0; + gChannelVolume[i] = 0; } TRACE("mss"); @@ -947,14 +947,14 @@ cSampleManager::Initialise(void) return FALSE; } - nSampleBankMemoryStartAddress[SFX_BANK_0] = (int32)AIL_mem_alloc_lock(nSampleBankSize[SFX_BANK_0]); - if ( !nSampleBankMemoryStartAddress[SFX_BANK_0] ) + gSampleBankMemoryStartAddress[SFX_BANK_0] = (int32)AIL_mem_alloc_lock(gSampleBankSize[SFX_BANK_0]); + if ( !gSampleBankMemoryStartAddress[SFX_BANK_0] ) { Terminate(); return FALSE; } - nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = (int32)AIL_mem_alloc_lock(PED_BLOCKSIZE*MAX_PEDSFX); + gSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = (int32)AIL_mem_alloc_lock(PED_BUFFERSIZE*MAX_PEDSFX); } @@ -962,7 +962,7 @@ cSampleManager::Initialise(void) TRACE("cache"); FILE *cacheFile = fopen("audio\\sound.cache", "rb"); if (cacheFile) { - fread(nStreamLength, sizeof(uint32), TOTAL_STREAMED_SOUNDS, cacheFile); + fread(gStreamLength, sizeof(uint32), TOTAL_STREAMED_SOUNDS, cacheFile); fclose(cacheFile); m_bInitialised = TRUE; }else { @@ -1016,7 +1016,7 @@ cSampleManager::Initialise(void) AIL_close_stream(mp3Stream[0]); mp3Stream[0] = NULL; - nStreamLength[i] = tatalms; + gStreamLength[i] = tatalms; } else { @@ -1115,7 +1115,7 @@ cSampleManager::Initialise(void) strcpy(m_szCDRomRootPath, rootpath); for ( int32 i = 0; i < TOTAL_STREAMED_SOUNDS; i++ ) - nStreamLength[i] = streamLength[i]; + gStreamLength[i] = streamLength[i]; _bUseHDDAudio = TRUE; } @@ -1125,7 +1125,7 @@ cSampleManager::Initialise(void) #endif #ifdef AUDIO_CACHE cacheFile = fopen("audio\\sound.cache", "wb"); - fwrite(nStreamLength, sizeof(uint32), TOTAL_STREAMED_SOUNDS, cacheFile); + fwrite(gStreamLength, sizeof(uint32), TOTAL_STREAMED_SOUNDS, cacheFile); fclose(cacheFile); } #endif @@ -1188,12 +1188,12 @@ cSampleManager::Initialise(void) if ( nNumMP3s != 0 ) { - nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] = 0; + gStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] = 0; for ( tMP3Entry *e = _pMP3List; e != NULL; e = e->pNext ) { - e->nTrackStreamPos = nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER]; - nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] += e->nTrackLength; + e->nTrackStreamPos = gStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER]; + gStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] += e->nTrackLength; } time_t t = time(NULL); @@ -1270,16 +1270,16 @@ cSampleManager::Terminate(void) _DeleteMP3Entries(); - if ( nSampleBankMemoryStartAddress[SFX_BANK_0] != 0 ) + if ( gSampleBankMemoryStartAddress[SFX_BANK_0] != 0 ) { - AIL_mem_free_lock((void *)nSampleBankMemoryStartAddress[SFX_BANK_0]); - nSampleBankMemoryStartAddress[SFX_BANK_0] = 0; + AIL_mem_free_lock((void *)gSampleBankMemoryStartAddress[SFX_BANK_0]); + gSampleBankMemoryStartAddress[SFX_BANK_0] = 0; } - if ( nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] != 0 ) + if ( gSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] != 0 ) { - AIL_mem_free_lock((void *)nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS]); - nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = 0; + AIL_mem_free_lock((void *)gSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS]); + gSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = 0; } if ( DIG ) @@ -1363,10 +1363,10 @@ cSampleManager::UpdateEffectsVolume(void) //[Y], cSampleManager::UpdateSoundBuff { if ( opened_samples[i] && GetChannelUsedFlag(i) ) { - if ( nChannelVolume[i] ) + if ( gChannelVolume[i] ) { AIL_set_3D_sample_volume(opened_samples[i], - m_nEffectsFadeVolume * nChannelVolume[i] * m_nEffectsVolume >> 14); + m_nEffectsFadeVolume * gChannelVolume[i] * m_nEffectsVolume >> 14); } } } @@ -1376,10 +1376,10 @@ cSampleManager::UpdateEffectsVolume(void) //[Y], cSampleManager::UpdateSoundBuff { if ( GetChannelUsedFlag(i - MAXCHANNELS) ) { - if ( nChannelVolume[i - MAXCHANNELS] ) + if ( gChannelVolume[i - MAXCHANNELS] ) { AIL_set_sample_volume(opened_2dsamples[i - MAXCHANNELS], - m_nEffectsFadeVolume * nChannelVolume[i - MAXCHANNELS] * m_nEffectsVolume >> 14); + m_nEffectsFadeVolume * gChannelVolume[i - MAXCHANNELS] * m_nEffectsVolume >> 14); } } } @@ -1433,13 +1433,13 @@ cSampleManager::LoadSampleBank(uint8 nBank) return FALSE; } - if ( fseek(fpSampleDataHandle, nSampleBankDiscStartOffset[nBank], SEEK_SET) != 0 ) + if ( fseek(gFileHandleSampleData, gSampleBankDiscStartOffset[nBank], SEEK_SET) != 0 ) return FALSE; - if ( fread((void *)nSampleBankMemoryStartAddress[nBank], 1, nSampleBankSize[nBank],fpSampleDataHandle) != nSampleBankSize[nBank] ) + if ( fread((void *)gSampleBankMemoryStartAddress[nBank], 1, gSampleBankSize[nBank],gFileHandleSampleData) != gSampleBankSize[nBank] ) return FALSE; - bSampleBankLoaded[nBank] = TRUE; + gBankLoaded[nBank] = TRUE; return TRUE; } @@ -1447,13 +1447,13 @@ cSampleManager::LoadSampleBank(uint8 nBank) void cSampleManager::UnloadSampleBank(uint8 nBank) { - bSampleBankLoaded[nBank] = FALSE; + gBankLoaded[nBank] = FALSE; } bool8 cSampleManager::IsSampleBankLoaded(uint8 nBank) { - return bSampleBankLoaded[nBank]; + return gBankLoaded[nBank]; } bool8 @@ -1463,12 +1463,12 @@ cSampleManager::IsPedCommentLoaded(uint32 nComment) for ( int32 i = 0; i < _TODOCONST(3); i++ ) { - slot = nCurrentPedSlot - i - 1; + slot = gCurPedIndex - i - 1; #ifdef FIX_BUGS if (slot < 0) - slot += ARRAY_SIZE(nPedSlotSfx); + slot += ARRAY_SIZE(gPedSfx); #endif - if ( nComment == nPedSlotSfx[slot] ) + if ( nComment == gPedSfx[slot] ) return TRUE; } @@ -1482,12 +1482,12 @@ cSampleManager::_GetPedCommentSlot(uint32 nComment) for ( int32 i = 0; i < _TODOCONST(3); i++ ) { - slot = nCurrentPedSlot - i - 1; + slot = gCurPedIndex - i - 1; #ifdef FIX_BUGS if (slot < 0) - slot += ARRAY_SIZE(nPedSlotSfx); + slot += ARRAY_SIZE(gPedSfx); #endif - if ( nComment == nPedSlotSfx[slot] ) + if ( nComment == gPedSfx[slot] ) return slot; } @@ -1522,17 +1522,17 @@ cSampleManager::LoadPedComment(uint32 nComment) } } - if ( fseek(fpSampleDataHandle, m_aSamples[nComment].nOffset, SEEK_SET) != 0 ) + if ( fseek(gFileHandleSampleData, m_aSampleDataTable[nComment].nOffset, SEEK_SET) != 0 ) return FALSE; - if ( fread((void *)(nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BLOCKSIZE*nCurrentPedSlot), 1, m_aSamples[nComment].nSize, fpSampleDataHandle) != m_aSamples[nComment].nSize ) + if ( fread((void *)(gSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BUFFERSIZE*gCurPedIndex), 1, m_aSampleDataTable[nComment].nSize, gFileHandleSampleData) != m_aSampleDataTable[nComment].nSize ) return FALSE; - nPedSlotSfxAddr[nCurrentPedSlot] = nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BLOCKSIZE*nCurrentPedSlot; - nPedSlotSfx [nCurrentPedSlot] = nComment; + gPedSfxAddr[gCurPedIndex] = gSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BUFFERSIZE*gCurPedIndex; + gPedSfx [gCurPedIndex] = nComment; - if ( ++nCurrentPedSlot >= MAX_PEDSFX ) - nCurrentPedSlot = 0; + if ( ++gCurPedIndex >= MAX_PEDSFX ) + gCurPedIndex = 0; return TRUE; } @@ -1540,10 +1540,10 @@ cSampleManager::LoadPedComment(uint32 nComment) int32 cSampleManager::GetBankContainingSound(uint32 offset) { - if ( offset >= BankStartOffset[SFX_BANK_PED_COMMENTS] ) + if ( offset >= gBankStartOffset[SFX_BANK_PED_COMMENTS] ) return SFX_BANK_PED_COMMENTS; - if ( offset >= BankStartOffset[SFX_BANK_0] ) + if ( offset >= gBankStartOffset[SFX_BANK_0] ) return SFX_BANK_0; return INVALID_SFX_BANK; @@ -1552,25 +1552,25 @@ cSampleManager::GetBankContainingSound(uint32 offset) int32 cSampleManager::GetSampleBaseFrequency(uint32 nSample) { - return m_aSamples[nSample].nFrequency; + return m_aSampleDataTable[nSample].nFrequency; } int32 cSampleManager::GetSampleLoopStartOffset(uint32 nSample) { - return m_aSamples[nSample].nLoopStart; + return m_aSampleDataTable[nSample].nLoopStart; } int32 cSampleManager::GetSampleLoopEndOffset(uint32 nSample) { - return m_aSamples[nSample].nLoopEnd; + return m_aSampleDataTable[nSample].nLoopEnd; } uint32 cSampleManager::GetSampleLength(uint32 nSample) { - return m_aSamples[nSample].nSize >> 1; + return m_aSampleDataTable[nSample].nSize >> 1; } bool8 @@ -1700,7 +1700,7 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank) if ( !IsSampleBankLoaded(nBank) ) return FALSE; - addr = nSampleBankMemoryStartAddress[nBank] + m_aSamples[nSfx].nOffset - m_aSamples[BankStartOffset[nBank]].nOffset; + addr = gSampleBankMemoryStartAddress[nBank] + m_aSampleDataTable[nSfx].nOffset - m_aSampleDataTable[gBankStartOffset[nBank]].nOffset; } else { @@ -1709,14 +1709,14 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank) int32 slot = _GetPedCommentSlot(nSfx); - addr = nPedSlotSfxAddr[slot]; + addr = gPedSfxAddr[slot]; } if ( b2d ) { if ( opened_2dsamples[nChannel - MAXCHANNELS] ) { - AIL_set_sample_address(opened_2dsamples[nChannel - MAXCHANNELS], (void *)addr, m_aSamples[nSfx].nSize); + AIL_set_sample_address(opened_2dsamples[nChannel - MAXCHANNELS], (void *)addr, m_aSampleDataTable[nSfx].nSize); return TRUE; } else @@ -1729,8 +1729,8 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank) info.format = WAVE_FORMAT_PCM; info.data_ptr = (void *)addr; info.channels = 1; - info.data_len = m_aSamples[nSfx].nSize; - info.rate = m_aSamples[nSfx].nFrequency; + info.data_len = m_aSampleDataTable[nSfx].nSize; + info.rate = m_aSampleDataTable[nSfx].nFrequency; info.bits = 16; if ( AIL_set_3D_sample_info(opened_samples[nChannel], &info) == 0 ) @@ -1749,18 +1749,18 @@ cSampleManager::SetChannelEmittingVolume(uint32 nChannel, uint32 nVolume) uint32 vol = nVolume; if ( vol > MAX_VOLUME ) vol = MAX_VOLUME; - nChannelVolume[nChannel] = vol; + gChannelVolume[nChannel] = vol; // increase the volume for JB.MP3 and S4_BDBD.MP3 if ( MusicManager.GetMusicMode() == MUSICMODE_CUTSCENE && MusicManager.GetNextTrack() != STREAMED_SOUND_NEWS_INTRO && MusicManager.GetNextTrack() != STREAMED_SOUND_CUTSCENE_SAL4_BDBD ) { - nChannelVolume[nChannel] >>= 2; + gChannelVolume[nChannel] >>= 2; } if ( opened_samples[nChannel] ) - AIL_set_3D_sample_volume(opened_samples[nChannel], m_nEffectsFadeVolume*nChannelVolume[nChannel]*m_nEffectsVolume >> 14); + AIL_set_3D_sample_volume(opened_samples[nChannel], m_nEffectsFadeVolume*gChannelVolume[nChannel]*m_nEffectsVolume >> 14); } @@ -1788,14 +1788,14 @@ cSampleManager::SetChannelVolume(uint32 nChannel, uint32 nVolume) { case CHANNEL_POLICE_RADIO: { - nChannelVolume[nChannel] = vol; + gChannelVolume[nChannel] = vol; // increase the volume for JB.MP3 and S4_BDBD.MP3 if ( MusicManager.GetMusicMode() == MUSICMODE_CUTSCENE && MusicManager.GetNextTrack() != STREAMED_SOUND_NEWS_INTRO && MusicManager.GetNextTrack() != STREAMED_SOUND_CUTSCENE_SAL4_BDBD ) { - nChannelVolume[nChannel] >>= 2; + gChannelVolume[nChannel] >>= 2; } if ( opened_2dsamples[nChannel - MAXCHANNELS] ) @@ -2065,7 +2065,7 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) // Just switched to MP3 player if ( !_bIsMp3Active && i == 0 ) { - if ( nPos > nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] ) + if ( nPos > gStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] ) position = 0; tMP3Entry *e = _pMP3List; @@ -2253,7 +2253,7 @@ int32 cSampleManager::GetStreamedFileLength(uint8 nStream) { if ( m_bInitialised ) - return nStreamLength[nStream]; + return gStreamLength[nStream]; return 0; } @@ -2280,42 +2280,42 @@ cSampleManager::InitialiseSampleBanks(void) { int32 nBank = SFX_BANK_0; - fpSampleDescHandle = fopen(SampleBankDescFilename, "rb"); - if ( fpSampleDescHandle == NULL ) + gFileHandleSampleDesc = fopen(SampleBankDescFilename, "rb"); + if ( gFileHandleSampleDesc == NULL ) return FALSE; - fpSampleDataHandle = fopen(SampleBankDataFilename, "rb"); - if ( fpSampleDataHandle == NULL ) + gFileHandleSampleData = fopen(SampleBankDataFilename, "rb"); + if ( gFileHandleSampleData == NULL ) { - fclose(fpSampleDescHandle); - fpSampleDescHandle = NULL; + fclose(gFileHandleSampleDesc); + gFileHandleSampleDesc = NULL; return FALSE; } - fseek(fpSampleDataHandle, 0, SEEK_END); - _nSampleDataEndOffset = ftell(fpSampleDataHandle); - rewind(fpSampleDataHandle); + fseek(gFileHandleSampleData, 0, SEEK_END); + _nSampleDataEndOffset = ftell(gFileHandleSampleData); + rewind(gFileHandleSampleData); - fread(m_aSamples, sizeof(tSample), TOTAL_AUDIO_SAMPLES, fpSampleDescHandle); + fread(m_aSampleDataTable, sizeof(tSample), TOTAL_AUDIO_SAMPLES, gFileHandleSampleDesc); - fclose(fpSampleDescHandle); - fpSampleDescHandle = NULL; + fclose(gFileHandleSampleDesc); + gFileHandleSampleDesc = NULL; for ( int32 i = 0; i < TOTAL_AUDIO_SAMPLES; i++ ) { #ifdef FIX_BUGS if (nBank >= MAX_SFX_BANKS) break; #endif - if ( BankStartOffset[nBank] == BankStartOffset[SFX_BANK_0] + i ) + if ( gBankStartOffset[nBank] == gBankStartOffset[SFX_BANK_0] + i ) { - nSampleBankDiscStartOffset[nBank] = m_aSamples[i].nOffset; + gSampleBankDiscStartOffset[nBank] = m_aSampleDataTable[i].nOffset; nBank++; } } - nSampleBankSize[SFX_BANK_0] = nSampleBankDiscStartOffset[SFX_BANK_PED_COMMENTS] - nSampleBankDiscStartOffset[SFX_BANK_0]; - nSampleBankSize[SFX_BANK_PED_COMMENTS] = _nSampleDataEndOffset - nSampleBankDiscStartOffset[SFX_BANK_PED_COMMENTS]; + gSampleBankSize[SFX_BANK_0] = gSampleBankDiscStartOffset[SFX_BANK_PED_COMMENTS] - gSampleBankDiscStartOffset[SFX_BANK_0]; + gSampleBankSize[SFX_BANK_PED_COMMENTS] = _nSampleDataEndOffset - gSampleBankDiscStartOffset[SFX_BANK_PED_COMMENTS]; return TRUE; } diff --git a/src/audio/sampman_null.cpp b/src/audio/sampman_null.cpp index 95603c72..8478d534 100644 --- a/src/audio/sampman_null.cpp +++ b/src/audio/sampman_null.cpp @@ -6,7 +6,7 @@ cSampleManager SampleManager; bool8 _bSampmanInitialised = FALSE; -uint32 BankStartOffset[MAX_SFX_BANKS]; +uint32 gBankStartOffset[MAX_SFX_BANKS]; uint32 nNumMP3s; cSampleManager::cSampleManager(void) diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp index f2771885..90f098ed 100644 --- a/src/audio/sampman_oal.cpp +++ b/src/audio/sampman_oal.cpp @@ -47,9 +47,9 @@ //TODO: fix eax3 reverb cSampleManager SampleManager; -bool8 _bSampmanInitialised = FALSE; +bool8 gInitialised = FALSE; -uint32 BankStartOffset[MAX_SFX_BANKS]; +uint32 gBankStartOffset[MAX_SFX_BANKS]; int prevprovider=-1; int curprovider=-1; @@ -79,26 +79,26 @@ int defaultProvider; char SampleBankDescFilename[] = "audio/sfx.SDT"; char SampleBankDataFilename[] = "audio/sfx.RAW"; -FILE *fpSampleDescHandle; +FILE *gFileHandleSampleDesc; #ifdef OPUS_SFX -OggOpusFile *fpSampleDataHandle; +OggOpusFile *gFileHandleSampleData; #else -FILE *fpSampleDataHandle; +FILE *gFileHandleSampleData; #endif -bool8 bSampleBankLoaded [MAX_SFX_BANKS]; -int32 nSampleBankDiscStartOffset [MAX_SFX_BANKS]; -int32 nSampleBankSize [MAX_SFX_BANKS]; -uintptr nSampleBankMemoryStartAddress[MAX_SFX_BANKS]; +bool8 gBankLoaded [MAX_SFX_BANKS]; +int32 gSampleBankDiscStartOffset [MAX_SFX_BANKS]; +int32 gSampleBankSize [MAX_SFX_BANKS]; +uintptr gSampleBankMemoryStartAddress[MAX_SFX_BANKS]; int32 _nSampleDataEndOffset; -int32 nPedSlotSfx [MAX_PEDSFX]; -int32 nPedSlotSfxAddr[MAX_PEDSFX]; -uint8 nCurrentPedSlot; +int32 gPedSfx [MAX_PEDSFX]; +int32 gPedSfxAddr[MAX_PEDSFX]; +uint8 gCurPedIndex; CChannel aChannel[NUM_CHANNELS]; -uint8 nChannelVolume[NUM_CHANNELS]; +uint8 gChannelVolume[NUM_CHANNELS]; -uint32 nStreamLength[TOTAL_STREAMED_SOUNDS]; +uint32 gStreamLength[TOTAL_STREAMED_SOUNDS]; ALuint ALStreamSources[MAX_STREAMS][2]; ALuint ALStreamBuffers[MAX_STREAMS][NUM_STREAMBUFFERS]; @@ -779,7 +779,7 @@ void cSampleManager::ReacquireDigitalHandle(void) bool8 cSampleManager::Initialise(void) { - if ( _bSampmanInitialised ) + if ( gInitialised ) return TRUE; EFXInit(); @@ -788,11 +788,11 @@ cSampleManager::Initialise(void) { for ( int32 i = 0; i < TOTAL_AUDIO_SAMPLES; i++ ) { - m_aSamples[i].nOffset = 0; - m_aSamples[i].nSize = 0; - m_aSamples[i].nFrequency = 22050; - m_aSamples[i].nLoopStart = 0; - m_aSamples[i].nLoopEnd = -1; + m_aSampleDataTable[i].nOffset = 0; + m_aSampleDataTable[i].nSize = 0; + m_aSampleDataTable[i].nFrequency = 22050; + m_aSampleDataTable[i].nLoopStart = 0; + m_aSampleDataTable[i].nLoopEnd = -1; } m_nEffectsVolume = MAX_VOLUME; @@ -820,31 +820,31 @@ cSampleManager::Initialise(void) } { - fpSampleDescHandle = NULL; - fpSampleDataHandle = NULL; + gFileHandleSampleDesc = NULL; + gFileHandleSampleData = NULL; for ( int32 i = 0; i < MAX_SFX_BANKS; i++ ) { - bSampleBankLoaded[i] = FALSE; - nSampleBankDiscStartOffset[i] = 0; - nSampleBankSize[i] = 0; - nSampleBankMemoryStartAddress[i] = 0; + gBankLoaded[i] = FALSE; + gSampleBankDiscStartOffset[i] = 0; + gSampleBankSize[i] = 0; + gSampleBankMemoryStartAddress[i] = 0; } } { for ( int32 i = 0; i < MAX_PEDSFX; i++ ) { - nPedSlotSfx[i] = NO_SAMPLE; - nPedSlotSfxAddr[i] = 0; + gPedSfx[i] = NO_SAMPLE; + gPedSfxAddr[i] = 0; } - nCurrentPedSlot = 0; + gCurPedIndex = 0; } { for ( int32 i = 0; i < NUM_CHANNELS; i++ ) - nChannelVolume[i] = 0; + gChannelVolume[i] = 0; } add_providers(); @@ -922,14 +922,14 @@ cSampleManager::Initialise(void) { for ( int32 i = 0; i < TOTAL_STREAMED_SOUNDS; i++ ) - nStreamLength[i] = 0; + gStreamLength[i] = 0; } #ifdef AUDIO_CACHE FILE *cacheFile = fcaseopen("audio\\sound.cache", "rb"); if (cacheFile) { debug("Loadind audio cache (If game crashes around here, then your cache is corrupted, remove audio/sound.cache)\n"); - fread(nStreamLength, sizeof(uint32), TOTAL_STREAMED_SOUNDS, cacheFile); + fread(gStreamLength, sizeof(uint32), TOTAL_STREAMED_SOUNDS, cacheFile); fclose(cacheFile); } else { @@ -944,7 +944,7 @@ cSampleManager::Initialise(void) delete aStream[0]; aStream[0] = NULL; - nStreamLength[i] = tatalms; + gStreamLength[i] = tatalms; } else USERERROR("Can't open '%s'\n", StreamedNameTable[i]); } @@ -952,7 +952,7 @@ cSampleManager::Initialise(void) cacheFile = fcaseopen("audio\\sound.cache", "wb"); if(cacheFile) { debug("Saving audio cache\n"); - fwrite(nStreamLength, sizeof(uint32), TOTAL_STREAMED_SOUNDS, cacheFile); + fwrite(gStreamLength, sizeof(uint32), TOTAL_STREAMED_SOUNDS, cacheFile); fclose(cacheFile); } else { debug("Cannot save audio cache\n"); @@ -967,17 +967,17 @@ cSampleManager::Initialise(void) return FALSE; } - nSampleBankMemoryStartAddress[SFX_BANK_0] = (uintptr)malloc(nSampleBankSize[SFX_BANK_0]); - ASSERT(nSampleBankMemoryStartAddress[SFX_BANK_0] != 0); + gSampleBankMemoryStartAddress[SFX_BANK_0] = (uintptr)malloc(gSampleBankSize[SFX_BANK_0]); + ASSERT(gSampleBankMemoryStartAddress[SFX_BANK_0] != 0); - if ( nSampleBankMemoryStartAddress[SFX_BANK_0] == 0 ) + if ( gSampleBankMemoryStartAddress[SFX_BANK_0] == 0 ) { Terminate(); return FALSE; } - nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = (uintptr)malloc(PED_BLOCKSIZE*MAX_PEDSFX); - ASSERT(nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] != 0); + gSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = (uintptr)malloc(PED_BUFFERSIZE*MAX_PEDSFX); + ASSERT(gSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] != 0); LoadSampleBank(SFX_BANK_0); } @@ -992,7 +992,7 @@ cSampleManager::Initialise(void) } { - _bSampmanInitialised = TRUE; + gInitialised = TRUE; if ( defaultProvider >= 0 && defaultProvider < m_nNumberOfProviders ) { @@ -1014,12 +1014,12 @@ cSampleManager::Initialise(void) if ( nNumMP3s != 0 ) { - nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] = 0; + gStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] = 0; for ( tMP3Entry *e = _pMP3List; e != NULL; e = e->pNext ) { - e->nTrackStreamPos = nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER]; - nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] += e->nTrackLength; + e->nTrackStreamPos = gStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER]; + gStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] += e->nTrackLength; } time_t t = time(NULL); @@ -1130,19 +1130,19 @@ cSampleManager::Terminate(void) CStream::Terminate(); - if ( nSampleBankMemoryStartAddress[SFX_BANK_0] != 0 ) + if ( gSampleBankMemoryStartAddress[SFX_BANK_0] != 0 ) { - free((void *)nSampleBankMemoryStartAddress[SFX_BANK_0]); - nSampleBankMemoryStartAddress[SFX_BANK_0] = 0; + free((void *)gSampleBankMemoryStartAddress[SFX_BANK_0]); + gSampleBankMemoryStartAddress[SFX_BANK_0] = 0; } - if ( nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] != 0 ) + if ( gSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] != 0 ) { - free((void *)nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS]); - nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = 0; + free((void *)gSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS]); + gSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = 0; } - _bSampmanInitialised = FALSE; + gInitialised = FALSE; } bool8 cSampleManager::CheckForAnAudioFileOnCD(void) @@ -1158,14 +1158,14 @@ char cSampleManager::GetCDAudioDriveLetter(void) void cSampleManager::UpdateEffectsVolume(void) { - if ( _bSampmanInitialised ) + if ( gInitialised ) { for ( int32 i = 0; i < NUM_CHANNELS; i++ ) { if ( GetChannelUsedFlag(i) ) { - if ( nChannelVolume[i] != 0 ) - aChannel[i].SetVolume(m_nEffectsFadeVolume*nChannelVolume[i]*m_nEffectsVolume >> 14); + if ( gChannelVolume[i] != 0 ) + aChannel[i].SetVolume(m_nEffectsFadeVolume*gChannelVolume[i]*m_nEffectsVolume >> 14); } } } @@ -1220,10 +1220,10 @@ cSampleManager::LoadSampleBank(uint8 nBank) #ifdef OPUS_SFX int samplesRead = 0; - int samplesSize = nSampleBankSize[nBank] / 2; - op_pcm_seek(fpSampleDataHandle, 0); + int samplesSize = gSampleBankSize[nBank] / 2; + op_pcm_seek(gFileHandleSampleData, 0); while (samplesSize > 0) { - int size = op_read(fpSampleDataHandle, (opus_int16 *)(nSampleBankMemoryStartAddress[nBank] + samplesRead), samplesSize, NULL); + int size = op_read(gFileHandleSampleData, (opus_int16 *)(gSampleBankMemoryStartAddress[nBank] + samplesRead), samplesSize, NULL); if (size <= 0) { // huh? //assert(0); @@ -1233,13 +1233,13 @@ cSampleManager::LoadSampleBank(uint8 nBank) samplesSize -= size; } #else - if ( fseek(fpSampleDataHandle, nSampleBankDiscStartOffset[nBank], SEEK_SET) != 0 ) + if ( fseek(gFileHandleSampleData, gSampleBankDiscStartOffset[nBank], SEEK_SET) != 0 ) return FALSE; - if ( fread((void *)nSampleBankMemoryStartAddress[nBank], 1, nSampleBankSize[nBank], fpSampleDataHandle) != nSampleBankSize[nBank] ) + if ( fread((void *)gSampleBankMemoryStartAddress[nBank], 1, gSampleBankSize[nBank], gFileHandleSampleData) != gSampleBankSize[nBank] ) return FALSE; #endif - bSampleBankLoaded[nBank] = TRUE; + gBankLoaded[nBank] = TRUE; return TRUE; } @@ -1249,7 +1249,7 @@ cSampleManager::UnloadSampleBank(uint8 nBank) { ASSERT( nBank < MAX_SFX_BANKS); - bSampleBankLoaded[nBank] = FALSE; + gBankLoaded[nBank] = FALSE; } bool8 @@ -1257,7 +1257,7 @@ cSampleManager::IsSampleBankLoaded(uint8 nBank) { ASSERT( nBank < MAX_SFX_BANKS); - return bSampleBankLoaded[nBank]; + return gBankLoaded[nBank]; } bool8 @@ -1269,12 +1269,12 @@ cSampleManager::IsPedCommentLoaded(uint32 nComment) for ( int32 i = 0; i < _TODOCONST(3); i++ ) { - slot = nCurrentPedSlot - i - 1; + slot = gCurPedIndex - i - 1; #ifdef FIX_BUGS if (slot < 0) - slot += ARRAY_SIZE(nPedSlotSfx); + slot += ARRAY_SIZE(gPedSfx); #endif - if ( nComment == nPedSlotSfx[slot] ) + if ( nComment == gPedSfx[slot] ) return TRUE; } @@ -1289,12 +1289,12 @@ cSampleManager::_GetPedCommentSlot(uint32 nComment) for (int32 i = 0; i < _TODOCONST(3); i++) { - slot = nCurrentPedSlot - i - 1; + slot = gCurPedIndex - i - 1; #ifdef FIX_BUGS if (slot < 0) - slot += ARRAY_SIZE(nPedSlotSfx); + slot += ARRAY_SIZE(gPedSfx); #endif - if (nComment == nPedSlotSfx[slot]) + if (nComment == gPedSfx[slot]) return slot; } @@ -1333,10 +1333,10 @@ cSampleManager::LoadPedComment(uint32 nComment) #ifdef OPUS_SFX int samplesRead = 0; - int samplesSize = m_aSamples[nComment].nSize / 2; - op_pcm_seek(fpSampleDataHandle, m_aSamples[nComment].nOffset / 2); + int samplesSize = m_aSampleDataTable[nComment].nSize / 2; + op_pcm_seek(gFileHandleSampleData, m_aSampleDataTable[nComment].nOffset / 2); while (samplesSize > 0) { - int size = op_read(fpSampleDataHandle, (opus_int16 *)(nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BLOCKSIZE * nCurrentPedSlot + samplesRead), + int size = op_read(gFileHandleSampleData, (opus_int16 *)(gSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BUFFERSIZE * gCurPedIndex + samplesRead), samplesSize, NULL); if (size <= 0) { return FALSE; @@ -1345,17 +1345,17 @@ cSampleManager::LoadPedComment(uint32 nComment) samplesSize -= size; } #else - if ( fseek(fpSampleDataHandle, m_aSamples[nComment].nOffset, SEEK_SET) != 0 ) + if ( fseek(gFileHandleSampleData, m_aSampleDataTable[nComment].nOffset, SEEK_SET) != 0 ) return FALSE; - if ( fread((void *)(nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BLOCKSIZE*nCurrentPedSlot), 1, m_aSamples[nComment].nSize, fpSampleDataHandle) != m_aSamples[nComment].nSize ) + if ( fread((void *)(gSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BUFFERSIZE*gCurPedIndex), 1, m_aSampleDataTable[nComment].nSize, gFileHandleSampleData) != m_aSampleDataTable[nComment].nSize ) return FALSE; #endif - nPedSlotSfx[nCurrentPedSlot] = nComment; + gPedSfx[gCurPedIndex] = nComment; - if ( ++nCurrentPedSlot >= MAX_PEDSFX ) - nCurrentPedSlot = 0; + if ( ++gCurPedIndex >= MAX_PEDSFX ) + gCurPedIndex = 0; return TRUE; } @@ -1363,10 +1363,10 @@ cSampleManager::LoadPedComment(uint32 nComment) int32 cSampleManager::GetBankContainingSound(uint32 offset) { - if ( offset >= BankStartOffset[SFX_BANK_PED_COMMENTS] ) + if ( offset >= gBankStartOffset[SFX_BANK_PED_COMMENTS] ) return SFX_BANK_PED_COMMENTS; - if ( offset >= BankStartOffset[SFX_BANK_0] ) + if ( offset >= gBankStartOffset[SFX_BANK_0] ) return SFX_BANK_0; return INVALID_SFX_BANK; @@ -1376,28 +1376,28 @@ int32 cSampleManager::GetSampleBaseFrequency(uint32 nSample) { ASSERT( nSample < TOTAL_AUDIO_SAMPLES ); - return m_aSamples[nSample].nFrequency; + return m_aSampleDataTable[nSample].nFrequency; } int32 cSampleManager::GetSampleLoopStartOffset(uint32 nSample) { ASSERT( nSample < TOTAL_AUDIO_SAMPLES ); - return m_aSamples[nSample].nLoopStart; + return m_aSampleDataTable[nSample].nLoopStart; } int32 cSampleManager::GetSampleLoopEndOffset(uint32 nSample) { ASSERT( nSample < TOTAL_AUDIO_SAMPLES ); - return m_aSamples[nSample].nLoopEnd; + return m_aSampleDataTable[nSample].nLoopEnd; } uint32 cSampleManager::GetSampleLength(uint32 nSample) { ASSERT( nSample < TOTAL_AUDIO_SAMPLES ); - return m_aSamples[nSample].nSize / sizeof(uint16); + return m_aSampleDataTable[nSample].nSize / sizeof(uint16); } bool8 cSampleManager::UpdateReverb(void) @@ -1496,7 +1496,7 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank) if ( !IsSampleBankLoaded(nBank) ) return FALSE; - addr = nSampleBankMemoryStartAddress[nBank] + m_aSamples[nSfx].nOffset - m_aSamples[BankStartOffset[nBank]].nOffset; + addr = gSampleBankMemoryStartAddress[nBank] + m_aSampleDataTable[nSfx].nOffset - m_aSampleDataTable[gBankStartOffset[nBank]].nOffset; } else { @@ -1504,7 +1504,7 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank) return FALSE; int32 slot = _GetPedCommentSlot(nSfx); - addr = (nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BLOCKSIZE * slot); + addr = (gSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BUFFERSIZE * slot); } if ( GetChannelUsedFlag(nChannel) ) @@ -1516,7 +1516,7 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank) aChannel[nChannel].Reset(); if ( aChannel[nChannel].HasSource() ) { - aChannel[nChannel].SetSampleData ((void*)addr, m_aSamples[nSfx].nSize, m_aSamples[nSfx].nFrequency); + aChannel[nChannel].SetSampleData ((void*)addr, m_aSampleDataTable[nSfx].nSize, m_aSampleDataTable[nSfx].nFrequency); aChannel[nChannel].SetLoopPoints (0, -1); aChannel[nChannel].SetPitch (1.0f); return TRUE; @@ -1533,18 +1533,18 @@ cSampleManager::SetChannelEmittingVolume(uint32 nChannel, uint32 nVolume) uint32 vol = nVolume; if ( vol > MAX_VOLUME ) vol = MAX_VOLUME; - nChannelVolume[nChannel] = vol; + gChannelVolume[nChannel] = vol; // reduce channel volume when JB.MP3 or S4_BDBD.MP3 playing if ( MusicManager.GetMusicMode() == MUSICMODE_CUTSCENE && MusicManager.GetNextTrack() != STREAMED_SOUND_NEWS_INTRO && MusicManager.GetNextTrack() != STREAMED_SOUND_CUTSCENE_SAL4_BDBD ) { - nChannelVolume[nChannel] = vol / 4; + gChannelVolume[nChannel] = vol / 4; } // no idea, does this one looks like a bug or it's SetChannelVolume ? - aChannel[nChannel].SetVolume(m_nEffectsFadeVolume*nChannelVolume[nChannel]*m_nEffectsVolume >> 14); + aChannel[nChannel].SetVolume(m_nEffectsFadeVolume*gChannelVolume[nChannel]*m_nEffectsVolume >> 14); } void @@ -1573,14 +1573,14 @@ cSampleManager::SetChannelVolume(uint32 nChannel, uint32 nVolume) uint32 vol = nVolume; if ( vol > MAX_VOLUME ) vol = MAX_VOLUME; - nChannelVolume[nChannel] = vol; + gChannelVolume[nChannel] = vol; // reduce the volume for JB.MP3 and S4_BDBD.MP3 if ( MusicManager.GetMusicMode() == MUSICMODE_CUTSCENE && MusicManager.GetNextTrack() != STREAMED_SOUND_NEWS_INTRO && MusicManager.GetNextTrack() != STREAMED_SOUND_CUTSCENE_SAL4_BDBD ) { - nChannelVolume[nChannel] = vol / 4; + gChannelVolume[nChannel] = vol / 4; } aChannel[nChannel].SetVolume(m_nEffectsFadeVolume*vol*m_nEffectsVolume >> 14); @@ -1727,7 +1727,7 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) // Switched to MP3 player just now if ( !_bIsMp3Active && i == 0 ) { - if ( nPos > nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] ) + if ( nPos > gStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] ) position = 0; tMP3Entry *e = _pMP3List; @@ -1935,7 +1935,7 @@ cSampleManager::GetStreamedFileLength(uint8 nStream) { ASSERT( nStream < TOTAL_STREAMED_SOUNDS ); - return nStreamLength[nStream]; + return gStreamLength[nStream]; } bool8 @@ -1977,47 +1977,47 @@ cSampleManager::InitialiseSampleBanks(void) { int32 nBank = SFX_BANK_0; - fpSampleDescHandle = fcaseopen(SampleBankDescFilename, "rb"); - if ( fpSampleDescHandle == NULL ) + gFileHandleSampleDesc = fcaseopen(SampleBankDescFilename, "rb"); + if ( gFileHandleSampleDesc == NULL ) return FALSE; #ifndef OPUS_SFX - fpSampleDataHandle = fcaseopen(SampleBankDataFilename, "rb"); - if ( fpSampleDataHandle == NULL ) + gFileHandleSampleData = fcaseopen(SampleBankDataFilename, "rb"); + if ( gFileHandleSampleData == NULL ) { - fclose(fpSampleDescHandle); - fpSampleDescHandle = NULL; + fclose(gFileHandleSampleDesc); + gFileHandleSampleDesc = NULL; return FALSE; } - fseek(fpSampleDataHandle, 0, SEEK_END); - int32 _nSampleDataEndOffset = ftell(fpSampleDataHandle); - rewind(fpSampleDataHandle); + fseek(gFileHandleSampleData, 0, SEEK_END); + int32 _nSampleDataEndOffset = ftell(gFileHandleSampleData); + rewind(gFileHandleSampleData); #else int e; - fpSampleDataHandle = op_open_file(SampleBankDataFilename, &e); + gFileHandleSampleData = op_open_file(SampleBankDataFilename, &e); #endif - fread(m_aSamples, sizeof(tSample), TOTAL_AUDIO_SAMPLES, fpSampleDescHandle); + fread(m_aSampleDataTable, sizeof(tSample), TOTAL_AUDIO_SAMPLES, gFileHandleSampleDesc); #ifdef OPUS_SFX - int32 _nSampleDataEndOffset = m_aSamples[TOTAL_AUDIO_SAMPLES - 1].nOffset + m_aSamples[TOTAL_AUDIO_SAMPLES - 1].nSize; + int32 _nSampleDataEndOffset = m_aSampleDataTable[TOTAL_AUDIO_SAMPLES - 1].nOffset + m_aSampleDataTable[TOTAL_AUDIO_SAMPLES - 1].nSize; #endif - fclose(fpSampleDescHandle); - fpSampleDescHandle = NULL; + fclose(gFileHandleSampleDesc); + gFileHandleSampleDesc = NULL; for ( int32 i = 0; i < TOTAL_AUDIO_SAMPLES; i++ ) { #ifdef FIX_BUGS if (nBank >= MAX_SFX_BANKS) break; #endif - if ( BankStartOffset[nBank] == BankStartOffset[SFX_BANK_0] + i ) + if ( gBankStartOffset[nBank] == gBankStartOffset[SFX_BANK_0] + i ) { - nSampleBankDiscStartOffset[nBank] = m_aSamples[i].nOffset; + gSampleBankDiscStartOffset[nBank] = m_aSampleDataTable[i].nOffset; nBank++; } } - nSampleBankSize[SFX_BANK_0] = nSampleBankDiscStartOffset[SFX_BANK_PED_COMMENTS] - nSampleBankDiscStartOffset[SFX_BANK_0]; - nSampleBankSize[SFX_BANK_PED_COMMENTS] = _nSampleDataEndOffset - nSampleBankDiscStartOffset[SFX_BANK_PED_COMMENTS]; + gSampleBankSize[SFX_BANK_0] = gSampleBankDiscStartOffset[SFX_BANK_PED_COMMENTS] - gSampleBankDiscStartOffset[SFX_BANK_0]; + gSampleBankSize[SFX_BANK_PED_COMMENTS] = _nSampleDataEndOffset - gSampleBankDiscStartOffset[SFX_BANK_PED_COMMENTS]; return TRUE; } -- cgit v1.2.3 From 53a4b6936be05b5920c4b66b9d30c81c8dc2f21c Mon Sep 17 00:00:00 2001 From: erorcun Date: Sun, 27 Jun 2021 17:59:43 +0300 Subject: Revert "Use PS2-y global names on SampMan" We know that they changed all those names on PC. This reverts commit 091a65996ef9eba0dfeb49508927ebb521c0f15b. --- src/audio/AudioLogic.cpp | 122 ++++++++++++------------- src/audio/oal/channel.cpp | 2 +- src/audio/sampman.h | 6 +- src/audio/sampman_miles.cpp | 196 +++++++++++++++++++-------------------- src/audio/sampman_null.cpp | 2 +- src/audio/sampman_oal.cpp | 218 ++++++++++++++++++++++---------------------- 6 files changed, 273 insertions(+), 273 deletions(-) (limited to 'src/audio') diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 7fcab57d..8472cda6 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -58,69 +58,69 @@ enum LOADING_STATUS { LOADING_STATUS_NOT_LOADED = 0, LOADING_STATUS_LOADED, LOAD void cAudioManager::PreInitialiseGameSpecificSetup() const { - gBankStartOffset[SFX_BANK_0] = SAMPLEBANK_START; + BankStartOffset[SFX_BANK_0] = SAMPLEBANK_START; #ifdef GTA_PS2 - gBankStartOffset[SFX_BANK_PACARD] = SFX_CAR_ACCEL_1; - gBankStartOffset[SFX_BANK_PATHFINDER] = SFX_CAR_ACCEL_2; - gBankStartOffset[SFX_BANK_PORSCHE] = SFX_CAR_ACCEL_3; - gBankStartOffset[SFX_BANK_SPIDER] = SFX_CAR_ACCEL_4; - gBankStartOffset[SFX_BANK_MERC] = SFX_CAR_ACCEL_5; - gBankStartOffset[SFX_BANK_TRUCK] = SFX_CAR_ACCEL_6; - gBankStartOffset[SFX_BANK_HOTROD] = SFX_CAR_ACCEL_7; - gBankStartOffset[SFX_BANK_COBRA] = SFX_CAR_ACCEL_8; - gBankStartOffset[SFX_BANK_NONE] = SFX_CAR_ACCEL_9; - gBankStartOffset[SFX_BANK_FRONT_END_MENU] = SFX_PAGE_CHANGE_AND_BACK_LEFT; - gBankStartOffset[SFX_BANK_TRAIN] = SFX_TRAIN_STATION_AMBIENCE_LOOP; - gBankStartOffset[SFX_BANK_BUILDING_CLUB_1] = SFX_CLUB_1; - gBankStartOffset[SFX_BANK_BUILDING_CLUB_2] = SFX_CLUB_2; - gBankStartOffset[SFX_BANK_BUILDING_CLUB_3] = SFX_CLUB_3; - gBankStartOffset[SFX_BANK_BUILDING_CLUB_4] = SFX_CLUB_4; - gBankStartOffset[SFX_BANK_BUILDING_CLUB_5] = SFX_CLUB_5; - gBankStartOffset[SFX_BANK_BUILDING_CLUB_6] = SFX_CLUB_6; - gBankStartOffset[SFX_BANK_BUILDING_CLUB_7] = SFX_CLUB_7; - gBankStartOffset[SFX_BANK_BUILDING_CLUB_8] = SFX_CLUB_8; - gBankStartOffset[SFX_BANK_BUILDING_CLUB_9] = SFX_CLUB_9; - gBankStartOffset[SFX_BANK_BUILDING_CLUB_10] = SFX_CLUB_10; - gBankStartOffset[SFX_BANK_BUILDING_CLUB_11] = SFX_CLUB_11; - gBankStartOffset[SFX_BANK_BUILDING_CLUB_12] = SFX_CLUB_12; - gBankStartOffset[SFX_BANK_BUILDING_CLUB_RAGGA] = SFX_CLUB_RAGGA; - gBankStartOffset[SFX_BANK_BUILDING_STRIP_CLUB_1] = SFX_STRIP_CLUB_1; - gBankStartOffset[SFX_BANK_BUILDING_STRIP_CLUB_2] = SFX_STRIP_CLUB_2; - gBankStartOffset[SFX_BANK_BUILDING_WORKSHOP] = SFX_WORKSHOP_1; - gBankStartOffset[SFX_BANK_BUILDING_PIANO_BAR] = SFX_PIANO_BAR_1; - gBankStartOffset[SFX_BANK_BUILDING_SAWMILL] = SFX_SAWMILL_LOOP; - gBankStartOffset[SFX_BANK_BUILDING_DOG_FOOD_FACTORY] = SFX_DOG_FOOD_FACTORY; - gBankStartOffset[SFX_BANK_BUILDING_LAUNDERETTE] = SFX_LAUNDERETTE_LOOP; - gBankStartOffset[SFX_BANK_BUILDING_RESTAURANT_CHINATOWN] = SFX_RESTAURANT_CHINATOWN; - gBankStartOffset[SFX_BANK_BUILDING_RESTAURANT_ITALY] = SFX_RESTAURANT_ITALY; - gBankStartOffset[SFX_BANK_BUILDING_RESTAURANT_GENERIC_1] = SFX_RESTAURANT_GENERIC_1; - gBankStartOffset[SFX_BANK_BUILDING_RESTAURANT_GENERIC_2] = SFX_RESTAURANT_GENERIC_2; - gBankStartOffset[SFX_BANK_BUILDING_AIRPORT] = SFX_AIRPORT_ANNOUNCEMENT_1; - gBankStartOffset[SFX_BANK_BUILDING_SHOP] = SFX_SHOP_LOOP; - gBankStartOffset[SFX_BANK_BUILDING_CINEMA] = SFX_CINEMA_BASS_1; - gBankStartOffset[SFX_BANK_BUILDING_DOCKS] = SFX_DOCKS_FOGHORN; - gBankStartOffset[SFX_BANK_BUILDING_HOME] = SFX_HOME_1; - gBankStartOffset[SFX_BANK_BUILDING_PORN_1] = SFX_PORN_1_LOOP; - gBankStartOffset[SFX_BANK_BUILDING_PORN_2] = SFX_PORN_2_LOOP; - gBankStartOffset[SFX_BANK_BUILDING_PORN_3] = SFX_PORN_3_LOOP; - gBankStartOffset[SFX_BANK_BUILDING_POLICE_BALL] = SFX_POLICE_BALL_1; - gBankStartOffset[SFX_BANK_BUILDING_BANK_ALARM] = SFX_BANK_ALARM_1; - gBankStartOffset[SFX_BANK_BUILDING_RAVE_INDUSTRIAL] = SFX_RAVE_INDUSTRIAL; - gBankStartOffset[SFX_BANK_BUILDING_RAVE_COMMERCIAL] = SFX_RAVE_COMMERCIAL; - gBankStartOffset[SFX_BANK_BUILDING_RAVE_SUBURBAN] = SFX_RAVE_SUBURBAN; - gBankStartOffset[SFX_BANK_BUILDING_RAVE_COMMERCIAL_2] = SFX_RAVE_COMMERCIAL_2; - gBankStartOffset[SFX_BANK_BUILDING_39] = SFX_CLUB_1_1; - gBankStartOffset[SFX_BANK_BUILDING_40] = SFX_CLUB_1_2; - gBankStartOffset[SFX_BANK_BUILDING_41] = SFX_CLUB_1_3; - gBankStartOffset[SFX_BANK_BUILDING_42] = SFX_CLUB_1_4; - gBankStartOffset[SFX_BANK_BUILDING_43] = SFX_CLUB_1_5; - gBankStartOffset[SFX_BANK_BUILDING_44] = SFX_CLUB_1_6; - gBankStartOffset[SFX_BANK_BUILDING_45] = SFX_CLUB_1_7; - gBankStartOffset[SFX_BANK_BUILDING_46] = SFX_CLUB_1_8; - gBankStartOffset[SFX_BANK_BUILDING_47] = SFX_CLUB_1_9; - gBankStartOffset[SFX_BANK_GENERIC_EXTRA] = SFX_EXPLOSION_1; + BankStartOffset[SFX_BANK_PACARD] = SFX_CAR_ACCEL_1; + BankStartOffset[SFX_BANK_PATHFINDER] = SFX_CAR_ACCEL_2; + BankStartOffset[SFX_BANK_PORSCHE] = SFX_CAR_ACCEL_3; + BankStartOffset[SFX_BANK_SPIDER] = SFX_CAR_ACCEL_4; + BankStartOffset[SFX_BANK_MERC] = SFX_CAR_ACCEL_5; + BankStartOffset[SFX_BANK_TRUCK] = SFX_CAR_ACCEL_6; + BankStartOffset[SFX_BANK_HOTROD] = SFX_CAR_ACCEL_7; + BankStartOffset[SFX_BANK_COBRA] = SFX_CAR_ACCEL_8; + BankStartOffset[SFX_BANK_NONE] = SFX_CAR_ACCEL_9; + BankStartOffset[SFX_BANK_FRONT_END_MENU] = SFX_PAGE_CHANGE_AND_BACK_LEFT; + BankStartOffset[SFX_BANK_TRAIN] = SFX_TRAIN_STATION_AMBIENCE_LOOP; + BankStartOffset[SFX_BANK_BUILDING_CLUB_1] = SFX_CLUB_1; + BankStartOffset[SFX_BANK_BUILDING_CLUB_2] = SFX_CLUB_2; + BankStartOffset[SFX_BANK_BUILDING_CLUB_3] = SFX_CLUB_3; + BankStartOffset[SFX_BANK_BUILDING_CLUB_4] = SFX_CLUB_4; + BankStartOffset[SFX_BANK_BUILDING_CLUB_5] = SFX_CLUB_5; + BankStartOffset[SFX_BANK_BUILDING_CLUB_6] = SFX_CLUB_6; + BankStartOffset[SFX_BANK_BUILDING_CLUB_7] = SFX_CLUB_7; + BankStartOffset[SFX_BANK_BUILDING_CLUB_8] = SFX_CLUB_8; + BankStartOffset[SFX_BANK_BUILDING_CLUB_9] = SFX_CLUB_9; + BankStartOffset[SFX_BANK_BUILDING_CLUB_10] = SFX_CLUB_10; + BankStartOffset[SFX_BANK_BUILDING_CLUB_11] = SFX_CLUB_11; + BankStartOffset[SFX_BANK_BUILDING_CLUB_12] = SFX_CLUB_12; + BankStartOffset[SFX_BANK_BUILDING_CLUB_RAGGA] = SFX_CLUB_RAGGA; + BankStartOffset[SFX_BANK_BUILDING_STRIP_CLUB_1] = SFX_STRIP_CLUB_1; + BankStartOffset[SFX_BANK_BUILDING_STRIP_CLUB_2] = SFX_STRIP_CLUB_2; + BankStartOffset[SFX_BANK_BUILDING_WORKSHOP] = SFX_WORKSHOP_1; + BankStartOffset[SFX_BANK_BUILDING_PIANO_BAR] = SFX_PIANO_BAR_1; + BankStartOffset[SFX_BANK_BUILDING_SAWMILL] = SFX_SAWMILL_LOOP; + BankStartOffset[SFX_BANK_BUILDING_DOG_FOOD_FACTORY] = SFX_DOG_FOOD_FACTORY; + BankStartOffset[SFX_BANK_BUILDING_LAUNDERETTE] = SFX_LAUNDERETTE_LOOP; + BankStartOffset[SFX_BANK_BUILDING_RESTAURANT_CHINATOWN] = SFX_RESTAURANT_CHINATOWN; + BankStartOffset[SFX_BANK_BUILDING_RESTAURANT_ITALY] = SFX_RESTAURANT_ITALY; + BankStartOffset[SFX_BANK_BUILDING_RESTAURANT_GENERIC_1] = SFX_RESTAURANT_GENERIC_1; + BankStartOffset[SFX_BANK_BUILDING_RESTAURANT_GENERIC_2] = SFX_RESTAURANT_GENERIC_2; + BankStartOffset[SFX_BANK_BUILDING_AIRPORT] = SFX_AIRPORT_ANNOUNCEMENT_1; + BankStartOffset[SFX_BANK_BUILDING_SHOP] = SFX_SHOP_LOOP; + BankStartOffset[SFX_BANK_BUILDING_CINEMA] = SFX_CINEMA_BASS_1; + BankStartOffset[SFX_BANK_BUILDING_DOCKS] = SFX_DOCKS_FOGHORN; + BankStartOffset[SFX_BANK_BUILDING_HOME] = SFX_HOME_1; + BankStartOffset[SFX_BANK_BUILDING_PORN_1] = SFX_PORN_1_LOOP; + BankStartOffset[SFX_BANK_BUILDING_PORN_2] = SFX_PORN_2_LOOP; + BankStartOffset[SFX_BANK_BUILDING_PORN_3] = SFX_PORN_3_LOOP; + BankStartOffset[SFX_BANK_BUILDING_POLICE_BALL] = SFX_POLICE_BALL_1; + BankStartOffset[SFX_BANK_BUILDING_BANK_ALARM] = SFX_BANK_ALARM_1; + BankStartOffset[SFX_BANK_BUILDING_RAVE_INDUSTRIAL] = SFX_RAVE_INDUSTRIAL; + BankStartOffset[SFX_BANK_BUILDING_RAVE_COMMERCIAL] = SFX_RAVE_COMMERCIAL; + BankStartOffset[SFX_BANK_BUILDING_RAVE_SUBURBAN] = SFX_RAVE_SUBURBAN; + BankStartOffset[SFX_BANK_BUILDING_RAVE_COMMERCIAL_2] = SFX_RAVE_COMMERCIAL_2; + BankStartOffset[SFX_BANK_BUILDING_39] = SFX_CLUB_1_1; + BankStartOffset[SFX_BANK_BUILDING_40] = SFX_CLUB_1_2; + BankStartOffset[SFX_BANK_BUILDING_41] = SFX_CLUB_1_3; + BankStartOffset[SFX_BANK_BUILDING_42] = SFX_CLUB_1_4; + BankStartOffset[SFX_BANK_BUILDING_43] = SFX_CLUB_1_5; + BankStartOffset[SFX_BANK_BUILDING_44] = SFX_CLUB_1_6; + BankStartOffset[SFX_BANK_BUILDING_45] = SFX_CLUB_1_7; + BankStartOffset[SFX_BANK_BUILDING_46] = SFX_CLUB_1_8; + BankStartOffset[SFX_BANK_BUILDING_47] = SFX_CLUB_1_9; + BankStartOffset[SFX_BANK_GENERIC_EXTRA] = SFX_EXPLOSION_1; #endif // GTA_PS2 - gBankStartOffset[SFX_BANK_PED_COMMENTS] = SAMPLEBANK_PED_START; + BankStartOffset[SFX_BANK_PED_COMMENTS] = SAMPLEBANK_PED_START; } void diff --git a/src/audio/oal/channel.cpp b/src/audio/oal/channel.cpp index 2ae12fcf..04e7e529 100644 --- a/src/audio/oal/channel.cpp +++ b/src/audio/oal/channel.cpp @@ -17,7 +17,7 @@ bool bChannelsCreated = false; int32 CChannel::channelsThatNeedService = 0; -uint8 tempStereoBuffer[PED_BUFFERSIZE * 2]; +uint8 tempStereoBuffer[PED_BLOCKSIZE * 2]; void CChannel::InitChannels() diff --git a/src/audio/sampman.h b/src/audio/sampman.h index 08e5dde0..d1ad9a26 100644 --- a/src/audio/sampman.h +++ b/src/audio/sampman.h @@ -96,7 +96,7 @@ enum }; #define MAX_PEDSFX 7 -#define PED_BUFFERSIZE 79000 +#define PED_BLOCKSIZE 79000 #define MAXPROVIDERS 64 @@ -130,7 +130,7 @@ class cSampleManager bool8 m_bInitialised; uint8 m_nNumberOfProviders; char *m_aAudioProviders[MAXPROVIDERS]; - tSample m_aSampleDataTable[TOTAL_AUDIO_SAMPLES]; + tSample m_aSamples[TOTAL_AUDIO_SAMPLES]; public: @@ -217,7 +217,7 @@ public: }; extern cSampleManager SampleManager; -extern uint32 gBankStartOffset[MAX_SFX_BANKS]; +extern uint32 BankStartOffset[MAX_SFX_BANKS]; #ifdef AUDIO_OAL extern int defaultProvider; diff --git a/src/audio/sampman_miles.cpp b/src/audio/sampman_miles.cpp index 3149b306..ddfaaa5f 100644 --- a/src/audio/sampman_miles.cpp +++ b/src/audio/sampman_miles.cpp @@ -20,27 +20,27 @@ #pragma comment( lib, "mss32.lib" ) cSampleManager SampleManager; -uint32 gBankStartOffset[MAX_SFX_BANKS]; +uint32 BankStartOffset[MAX_SFX_BANKS]; /////////////////////////////////////////////////////////////// char SampleBankDescFilename[] = "AUDIO\\SFX.SDT"; char SampleBankDataFilename[] = "AUDIO\\SFX.RAW"; -FILE *gFileHandleSampleDesc; -FILE *gFileHandleSampleData; -bool8 gBankLoaded [MAX_SFX_BANKS]; -int32 gSampleBankDiscStartOffset [MAX_SFX_BANKS]; -int32 gSampleBankSize [MAX_SFX_BANKS]; -int32 gSampleBankMemoryStartAddress[MAX_SFX_BANKS]; +FILE *fpSampleDescHandle; +FILE *fpSampleDataHandle; +bool8 bSampleBankLoaded [MAX_SFX_BANKS]; +int32 nSampleBankDiscStartOffset [MAX_SFX_BANKS]; +int32 nSampleBankSize [MAX_SFX_BANKS]; +int32 nSampleBankMemoryStartAddress[MAX_SFX_BANKS]; int32 _nSampleDataEndOffset; -int32 gPedSfx [MAX_PEDSFX]; -int32 gPedSfxAddr[MAX_PEDSFX]; -uint8 gCurPedIndex; +int32 nPedSlotSfx [MAX_PEDSFX]; +int32 nPedSlotSfxAddr[MAX_PEDSFX]; +uint8 nCurrentPedSlot; -uint8 gChannelVolume[MAXCHANNELS+MAX2DCHANNELS]; +uint8 nChannelVolume[MAXCHANNELS+MAX2DCHANNELS]; -uint32 gStreamLength[TOTAL_STREAMED_SOUNDS]; +uint32 nStreamLength[TOTAL_STREAMED_SOUNDS]; /////////////////////////////////////////////////////////////// struct tMP3Entry @@ -851,11 +851,11 @@ cSampleManager::Initialise(void) { for ( int32 i = 0; i < TOTAL_AUDIO_SAMPLES; i++ ) { - m_aSampleDataTable[i].nOffset = 0; - m_aSampleDataTable[i].nSize = 0; - m_aSampleDataTable[i].nFrequency = 22050; - m_aSampleDataTable[i].nLoopStart = 0; - m_aSampleDataTable[i].nLoopEnd = -1; + m_aSamples[i].nOffset = 0; + m_aSamples[i].nSize = 0; + m_aSamples[i].nFrequency = 22050; + m_aSamples[i].nLoopStart = 0; + m_aSamples[i].nLoopEnd = -1; } m_nEffectsVolume = MAX_VOLUME; @@ -890,17 +890,17 @@ cSampleManager::Initialise(void) // banks TRACE("banks"); { - gFileHandleSampleDesc = NULL; - gFileHandleSampleData = NULL; + fpSampleDescHandle = NULL; + fpSampleDataHandle = NULL; _nSampleDataEndOffset = 0; for ( int32 i = 0; i < MAX_SFX_BANKS; i++ ) { - gBankLoaded[i] = FALSE; - gSampleBankDiscStartOffset[i] = 0; - gSampleBankSize[i] = 0; - gSampleBankMemoryStartAddress[i] = 0; + bSampleBankLoaded[i] = FALSE; + nSampleBankDiscStartOffset[i] = 0; + nSampleBankSize[i] = 0; + nSampleBankMemoryStartAddress[i] = 0; } } @@ -909,18 +909,18 @@ cSampleManager::Initialise(void) { for ( int32 i = 0; i < MAX_PEDSFX; i++ ) { - gPedSfx[i] = NO_SAMPLE; - gPedSfxAddr[i] = 0; + nPedSlotSfx[i] = NO_SAMPLE; + nPedSlotSfxAddr[i] = 0; } - gCurPedIndex = 0; + nCurrentPedSlot = 0; } // channel volume TRACE("vol"); { for ( int32 i = 0; i < MAXCHANNELS+MAX2DCHANNELS; i++ ) - gChannelVolume[i] = 0; + nChannelVolume[i] = 0; } TRACE("mss"); @@ -947,14 +947,14 @@ cSampleManager::Initialise(void) return FALSE; } - gSampleBankMemoryStartAddress[SFX_BANK_0] = (int32)AIL_mem_alloc_lock(gSampleBankSize[SFX_BANK_0]); - if ( !gSampleBankMemoryStartAddress[SFX_BANK_0] ) + nSampleBankMemoryStartAddress[SFX_BANK_0] = (int32)AIL_mem_alloc_lock(nSampleBankSize[SFX_BANK_0]); + if ( !nSampleBankMemoryStartAddress[SFX_BANK_0] ) { Terminate(); return FALSE; } - gSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = (int32)AIL_mem_alloc_lock(PED_BUFFERSIZE*MAX_PEDSFX); + nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = (int32)AIL_mem_alloc_lock(PED_BLOCKSIZE*MAX_PEDSFX); } @@ -962,7 +962,7 @@ cSampleManager::Initialise(void) TRACE("cache"); FILE *cacheFile = fopen("audio\\sound.cache", "rb"); if (cacheFile) { - fread(gStreamLength, sizeof(uint32), TOTAL_STREAMED_SOUNDS, cacheFile); + fread(nStreamLength, sizeof(uint32), TOTAL_STREAMED_SOUNDS, cacheFile); fclose(cacheFile); m_bInitialised = TRUE; }else { @@ -1016,7 +1016,7 @@ cSampleManager::Initialise(void) AIL_close_stream(mp3Stream[0]); mp3Stream[0] = NULL; - gStreamLength[i] = tatalms; + nStreamLength[i] = tatalms; } else { @@ -1115,7 +1115,7 @@ cSampleManager::Initialise(void) strcpy(m_szCDRomRootPath, rootpath); for ( int32 i = 0; i < TOTAL_STREAMED_SOUNDS; i++ ) - gStreamLength[i] = streamLength[i]; + nStreamLength[i] = streamLength[i]; _bUseHDDAudio = TRUE; } @@ -1125,7 +1125,7 @@ cSampleManager::Initialise(void) #endif #ifdef AUDIO_CACHE cacheFile = fopen("audio\\sound.cache", "wb"); - fwrite(gStreamLength, sizeof(uint32), TOTAL_STREAMED_SOUNDS, cacheFile); + fwrite(nStreamLength, sizeof(uint32), TOTAL_STREAMED_SOUNDS, cacheFile); fclose(cacheFile); } #endif @@ -1188,12 +1188,12 @@ cSampleManager::Initialise(void) if ( nNumMP3s != 0 ) { - gStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] = 0; + nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] = 0; for ( tMP3Entry *e = _pMP3List; e != NULL; e = e->pNext ) { - e->nTrackStreamPos = gStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER]; - gStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] += e->nTrackLength; + e->nTrackStreamPos = nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER]; + nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] += e->nTrackLength; } time_t t = time(NULL); @@ -1270,16 +1270,16 @@ cSampleManager::Terminate(void) _DeleteMP3Entries(); - if ( gSampleBankMemoryStartAddress[SFX_BANK_0] != 0 ) + if ( nSampleBankMemoryStartAddress[SFX_BANK_0] != 0 ) { - AIL_mem_free_lock((void *)gSampleBankMemoryStartAddress[SFX_BANK_0]); - gSampleBankMemoryStartAddress[SFX_BANK_0] = 0; + AIL_mem_free_lock((void *)nSampleBankMemoryStartAddress[SFX_BANK_0]); + nSampleBankMemoryStartAddress[SFX_BANK_0] = 0; } - if ( gSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] != 0 ) + if ( nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] != 0 ) { - AIL_mem_free_lock((void *)gSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS]); - gSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = 0; + AIL_mem_free_lock((void *)nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS]); + nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = 0; } if ( DIG ) @@ -1363,10 +1363,10 @@ cSampleManager::UpdateEffectsVolume(void) //[Y], cSampleManager::UpdateSoundBuff { if ( opened_samples[i] && GetChannelUsedFlag(i) ) { - if ( gChannelVolume[i] ) + if ( nChannelVolume[i] ) { AIL_set_3D_sample_volume(opened_samples[i], - m_nEffectsFadeVolume * gChannelVolume[i] * m_nEffectsVolume >> 14); + m_nEffectsFadeVolume * nChannelVolume[i] * m_nEffectsVolume >> 14); } } } @@ -1376,10 +1376,10 @@ cSampleManager::UpdateEffectsVolume(void) //[Y], cSampleManager::UpdateSoundBuff { if ( GetChannelUsedFlag(i - MAXCHANNELS) ) { - if ( gChannelVolume[i - MAXCHANNELS] ) + if ( nChannelVolume[i - MAXCHANNELS] ) { AIL_set_sample_volume(opened_2dsamples[i - MAXCHANNELS], - m_nEffectsFadeVolume * gChannelVolume[i - MAXCHANNELS] * m_nEffectsVolume >> 14); + m_nEffectsFadeVolume * nChannelVolume[i - MAXCHANNELS] * m_nEffectsVolume >> 14); } } } @@ -1433,13 +1433,13 @@ cSampleManager::LoadSampleBank(uint8 nBank) return FALSE; } - if ( fseek(gFileHandleSampleData, gSampleBankDiscStartOffset[nBank], SEEK_SET) != 0 ) + if ( fseek(fpSampleDataHandle, nSampleBankDiscStartOffset[nBank], SEEK_SET) != 0 ) return FALSE; - if ( fread((void *)gSampleBankMemoryStartAddress[nBank], 1, gSampleBankSize[nBank],gFileHandleSampleData) != gSampleBankSize[nBank] ) + if ( fread((void *)nSampleBankMemoryStartAddress[nBank], 1, nSampleBankSize[nBank],fpSampleDataHandle) != nSampleBankSize[nBank] ) return FALSE; - gBankLoaded[nBank] = TRUE; + bSampleBankLoaded[nBank] = TRUE; return TRUE; } @@ -1447,13 +1447,13 @@ cSampleManager::LoadSampleBank(uint8 nBank) void cSampleManager::UnloadSampleBank(uint8 nBank) { - gBankLoaded[nBank] = FALSE; + bSampleBankLoaded[nBank] = FALSE; } bool8 cSampleManager::IsSampleBankLoaded(uint8 nBank) { - return gBankLoaded[nBank]; + return bSampleBankLoaded[nBank]; } bool8 @@ -1463,12 +1463,12 @@ cSampleManager::IsPedCommentLoaded(uint32 nComment) for ( int32 i = 0; i < _TODOCONST(3); i++ ) { - slot = gCurPedIndex - i - 1; + slot = nCurrentPedSlot - i - 1; #ifdef FIX_BUGS if (slot < 0) - slot += ARRAY_SIZE(gPedSfx); + slot += ARRAY_SIZE(nPedSlotSfx); #endif - if ( nComment == gPedSfx[slot] ) + if ( nComment == nPedSlotSfx[slot] ) return TRUE; } @@ -1482,12 +1482,12 @@ cSampleManager::_GetPedCommentSlot(uint32 nComment) for ( int32 i = 0; i < _TODOCONST(3); i++ ) { - slot = gCurPedIndex - i - 1; + slot = nCurrentPedSlot - i - 1; #ifdef FIX_BUGS if (slot < 0) - slot += ARRAY_SIZE(gPedSfx); + slot += ARRAY_SIZE(nPedSlotSfx); #endif - if ( nComment == gPedSfx[slot] ) + if ( nComment == nPedSlotSfx[slot] ) return slot; } @@ -1522,17 +1522,17 @@ cSampleManager::LoadPedComment(uint32 nComment) } } - if ( fseek(gFileHandleSampleData, m_aSampleDataTable[nComment].nOffset, SEEK_SET) != 0 ) + if ( fseek(fpSampleDataHandle, m_aSamples[nComment].nOffset, SEEK_SET) != 0 ) return FALSE; - if ( fread((void *)(gSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BUFFERSIZE*gCurPedIndex), 1, m_aSampleDataTable[nComment].nSize, gFileHandleSampleData) != m_aSampleDataTable[nComment].nSize ) + if ( fread((void *)(nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BLOCKSIZE*nCurrentPedSlot), 1, m_aSamples[nComment].nSize, fpSampleDataHandle) != m_aSamples[nComment].nSize ) return FALSE; - gPedSfxAddr[gCurPedIndex] = gSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BUFFERSIZE*gCurPedIndex; - gPedSfx [gCurPedIndex] = nComment; + nPedSlotSfxAddr[nCurrentPedSlot] = nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BLOCKSIZE*nCurrentPedSlot; + nPedSlotSfx [nCurrentPedSlot] = nComment; - if ( ++gCurPedIndex >= MAX_PEDSFX ) - gCurPedIndex = 0; + if ( ++nCurrentPedSlot >= MAX_PEDSFX ) + nCurrentPedSlot = 0; return TRUE; } @@ -1540,10 +1540,10 @@ cSampleManager::LoadPedComment(uint32 nComment) int32 cSampleManager::GetBankContainingSound(uint32 offset) { - if ( offset >= gBankStartOffset[SFX_BANK_PED_COMMENTS] ) + if ( offset >= BankStartOffset[SFX_BANK_PED_COMMENTS] ) return SFX_BANK_PED_COMMENTS; - if ( offset >= gBankStartOffset[SFX_BANK_0] ) + if ( offset >= BankStartOffset[SFX_BANK_0] ) return SFX_BANK_0; return INVALID_SFX_BANK; @@ -1552,25 +1552,25 @@ cSampleManager::GetBankContainingSound(uint32 offset) int32 cSampleManager::GetSampleBaseFrequency(uint32 nSample) { - return m_aSampleDataTable[nSample].nFrequency; + return m_aSamples[nSample].nFrequency; } int32 cSampleManager::GetSampleLoopStartOffset(uint32 nSample) { - return m_aSampleDataTable[nSample].nLoopStart; + return m_aSamples[nSample].nLoopStart; } int32 cSampleManager::GetSampleLoopEndOffset(uint32 nSample) { - return m_aSampleDataTable[nSample].nLoopEnd; + return m_aSamples[nSample].nLoopEnd; } uint32 cSampleManager::GetSampleLength(uint32 nSample) { - return m_aSampleDataTable[nSample].nSize >> 1; + return m_aSamples[nSample].nSize >> 1; } bool8 @@ -1700,7 +1700,7 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank) if ( !IsSampleBankLoaded(nBank) ) return FALSE; - addr = gSampleBankMemoryStartAddress[nBank] + m_aSampleDataTable[nSfx].nOffset - m_aSampleDataTable[gBankStartOffset[nBank]].nOffset; + addr = nSampleBankMemoryStartAddress[nBank] + m_aSamples[nSfx].nOffset - m_aSamples[BankStartOffset[nBank]].nOffset; } else { @@ -1709,14 +1709,14 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank) int32 slot = _GetPedCommentSlot(nSfx); - addr = gPedSfxAddr[slot]; + addr = nPedSlotSfxAddr[slot]; } if ( b2d ) { if ( opened_2dsamples[nChannel - MAXCHANNELS] ) { - AIL_set_sample_address(opened_2dsamples[nChannel - MAXCHANNELS], (void *)addr, m_aSampleDataTable[nSfx].nSize); + AIL_set_sample_address(opened_2dsamples[nChannel - MAXCHANNELS], (void *)addr, m_aSamples[nSfx].nSize); return TRUE; } else @@ -1729,8 +1729,8 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank) info.format = WAVE_FORMAT_PCM; info.data_ptr = (void *)addr; info.channels = 1; - info.data_len = m_aSampleDataTable[nSfx].nSize; - info.rate = m_aSampleDataTable[nSfx].nFrequency; + info.data_len = m_aSamples[nSfx].nSize; + info.rate = m_aSamples[nSfx].nFrequency; info.bits = 16; if ( AIL_set_3D_sample_info(opened_samples[nChannel], &info) == 0 ) @@ -1749,18 +1749,18 @@ cSampleManager::SetChannelEmittingVolume(uint32 nChannel, uint32 nVolume) uint32 vol = nVolume; if ( vol > MAX_VOLUME ) vol = MAX_VOLUME; - gChannelVolume[nChannel] = vol; + nChannelVolume[nChannel] = vol; // increase the volume for JB.MP3 and S4_BDBD.MP3 if ( MusicManager.GetMusicMode() == MUSICMODE_CUTSCENE && MusicManager.GetNextTrack() != STREAMED_SOUND_NEWS_INTRO && MusicManager.GetNextTrack() != STREAMED_SOUND_CUTSCENE_SAL4_BDBD ) { - gChannelVolume[nChannel] >>= 2; + nChannelVolume[nChannel] >>= 2; } if ( opened_samples[nChannel] ) - AIL_set_3D_sample_volume(opened_samples[nChannel], m_nEffectsFadeVolume*gChannelVolume[nChannel]*m_nEffectsVolume >> 14); + AIL_set_3D_sample_volume(opened_samples[nChannel], m_nEffectsFadeVolume*nChannelVolume[nChannel]*m_nEffectsVolume >> 14); } @@ -1788,14 +1788,14 @@ cSampleManager::SetChannelVolume(uint32 nChannel, uint32 nVolume) { case CHANNEL_POLICE_RADIO: { - gChannelVolume[nChannel] = vol; + nChannelVolume[nChannel] = vol; // increase the volume for JB.MP3 and S4_BDBD.MP3 if ( MusicManager.GetMusicMode() == MUSICMODE_CUTSCENE && MusicManager.GetNextTrack() != STREAMED_SOUND_NEWS_INTRO && MusicManager.GetNextTrack() != STREAMED_SOUND_CUTSCENE_SAL4_BDBD ) { - gChannelVolume[nChannel] >>= 2; + nChannelVolume[nChannel] >>= 2; } if ( opened_2dsamples[nChannel - MAXCHANNELS] ) @@ -2065,7 +2065,7 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) // Just switched to MP3 player if ( !_bIsMp3Active && i == 0 ) { - if ( nPos > gStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] ) + if ( nPos > nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] ) position = 0; tMP3Entry *e = _pMP3List; @@ -2253,7 +2253,7 @@ int32 cSampleManager::GetStreamedFileLength(uint8 nStream) { if ( m_bInitialised ) - return gStreamLength[nStream]; + return nStreamLength[nStream]; return 0; } @@ -2280,42 +2280,42 @@ cSampleManager::InitialiseSampleBanks(void) { int32 nBank = SFX_BANK_0; - gFileHandleSampleDesc = fopen(SampleBankDescFilename, "rb"); - if ( gFileHandleSampleDesc == NULL ) + fpSampleDescHandle = fopen(SampleBankDescFilename, "rb"); + if ( fpSampleDescHandle == NULL ) return FALSE; - gFileHandleSampleData = fopen(SampleBankDataFilename, "rb"); - if ( gFileHandleSampleData == NULL ) + fpSampleDataHandle = fopen(SampleBankDataFilename, "rb"); + if ( fpSampleDataHandle == NULL ) { - fclose(gFileHandleSampleDesc); - gFileHandleSampleDesc = NULL; + fclose(fpSampleDescHandle); + fpSampleDescHandle = NULL; return FALSE; } - fseek(gFileHandleSampleData, 0, SEEK_END); - _nSampleDataEndOffset = ftell(gFileHandleSampleData); - rewind(gFileHandleSampleData); + fseek(fpSampleDataHandle, 0, SEEK_END); + _nSampleDataEndOffset = ftell(fpSampleDataHandle); + rewind(fpSampleDataHandle); - fread(m_aSampleDataTable, sizeof(tSample), TOTAL_AUDIO_SAMPLES, gFileHandleSampleDesc); + fread(m_aSamples, sizeof(tSample), TOTAL_AUDIO_SAMPLES, fpSampleDescHandle); - fclose(gFileHandleSampleDesc); - gFileHandleSampleDesc = NULL; + fclose(fpSampleDescHandle); + fpSampleDescHandle = NULL; for ( int32 i = 0; i < TOTAL_AUDIO_SAMPLES; i++ ) { #ifdef FIX_BUGS if (nBank >= MAX_SFX_BANKS) break; #endif - if ( gBankStartOffset[nBank] == gBankStartOffset[SFX_BANK_0] + i ) + if ( BankStartOffset[nBank] == BankStartOffset[SFX_BANK_0] + i ) { - gSampleBankDiscStartOffset[nBank] = m_aSampleDataTable[i].nOffset; + nSampleBankDiscStartOffset[nBank] = m_aSamples[i].nOffset; nBank++; } } - gSampleBankSize[SFX_BANK_0] = gSampleBankDiscStartOffset[SFX_BANK_PED_COMMENTS] - gSampleBankDiscStartOffset[SFX_BANK_0]; - gSampleBankSize[SFX_BANK_PED_COMMENTS] = _nSampleDataEndOffset - gSampleBankDiscStartOffset[SFX_BANK_PED_COMMENTS]; + nSampleBankSize[SFX_BANK_0] = nSampleBankDiscStartOffset[SFX_BANK_PED_COMMENTS] - nSampleBankDiscStartOffset[SFX_BANK_0]; + nSampleBankSize[SFX_BANK_PED_COMMENTS] = _nSampleDataEndOffset - nSampleBankDiscStartOffset[SFX_BANK_PED_COMMENTS]; return TRUE; } diff --git a/src/audio/sampman_null.cpp b/src/audio/sampman_null.cpp index 8478d534..95603c72 100644 --- a/src/audio/sampman_null.cpp +++ b/src/audio/sampman_null.cpp @@ -6,7 +6,7 @@ cSampleManager SampleManager; bool8 _bSampmanInitialised = FALSE; -uint32 gBankStartOffset[MAX_SFX_BANKS]; +uint32 BankStartOffset[MAX_SFX_BANKS]; uint32 nNumMP3s; cSampleManager::cSampleManager(void) diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp index 90f098ed..f2771885 100644 --- a/src/audio/sampman_oal.cpp +++ b/src/audio/sampman_oal.cpp @@ -47,9 +47,9 @@ //TODO: fix eax3 reverb cSampleManager SampleManager; -bool8 gInitialised = FALSE; +bool8 _bSampmanInitialised = FALSE; -uint32 gBankStartOffset[MAX_SFX_BANKS]; +uint32 BankStartOffset[MAX_SFX_BANKS]; int prevprovider=-1; int curprovider=-1; @@ -79,26 +79,26 @@ int defaultProvider; char SampleBankDescFilename[] = "audio/sfx.SDT"; char SampleBankDataFilename[] = "audio/sfx.RAW"; -FILE *gFileHandleSampleDesc; +FILE *fpSampleDescHandle; #ifdef OPUS_SFX -OggOpusFile *gFileHandleSampleData; +OggOpusFile *fpSampleDataHandle; #else -FILE *gFileHandleSampleData; +FILE *fpSampleDataHandle; #endif -bool8 gBankLoaded [MAX_SFX_BANKS]; -int32 gSampleBankDiscStartOffset [MAX_SFX_BANKS]; -int32 gSampleBankSize [MAX_SFX_BANKS]; -uintptr gSampleBankMemoryStartAddress[MAX_SFX_BANKS]; +bool8 bSampleBankLoaded [MAX_SFX_BANKS]; +int32 nSampleBankDiscStartOffset [MAX_SFX_BANKS]; +int32 nSampleBankSize [MAX_SFX_BANKS]; +uintptr nSampleBankMemoryStartAddress[MAX_SFX_BANKS]; int32 _nSampleDataEndOffset; -int32 gPedSfx [MAX_PEDSFX]; -int32 gPedSfxAddr[MAX_PEDSFX]; -uint8 gCurPedIndex; +int32 nPedSlotSfx [MAX_PEDSFX]; +int32 nPedSlotSfxAddr[MAX_PEDSFX]; +uint8 nCurrentPedSlot; CChannel aChannel[NUM_CHANNELS]; -uint8 gChannelVolume[NUM_CHANNELS]; +uint8 nChannelVolume[NUM_CHANNELS]; -uint32 gStreamLength[TOTAL_STREAMED_SOUNDS]; +uint32 nStreamLength[TOTAL_STREAMED_SOUNDS]; ALuint ALStreamSources[MAX_STREAMS][2]; ALuint ALStreamBuffers[MAX_STREAMS][NUM_STREAMBUFFERS]; @@ -779,7 +779,7 @@ void cSampleManager::ReacquireDigitalHandle(void) bool8 cSampleManager::Initialise(void) { - if ( gInitialised ) + if ( _bSampmanInitialised ) return TRUE; EFXInit(); @@ -788,11 +788,11 @@ cSampleManager::Initialise(void) { for ( int32 i = 0; i < TOTAL_AUDIO_SAMPLES; i++ ) { - m_aSampleDataTable[i].nOffset = 0; - m_aSampleDataTable[i].nSize = 0; - m_aSampleDataTable[i].nFrequency = 22050; - m_aSampleDataTable[i].nLoopStart = 0; - m_aSampleDataTable[i].nLoopEnd = -1; + m_aSamples[i].nOffset = 0; + m_aSamples[i].nSize = 0; + m_aSamples[i].nFrequency = 22050; + m_aSamples[i].nLoopStart = 0; + m_aSamples[i].nLoopEnd = -1; } m_nEffectsVolume = MAX_VOLUME; @@ -820,31 +820,31 @@ cSampleManager::Initialise(void) } { - gFileHandleSampleDesc = NULL; - gFileHandleSampleData = NULL; + fpSampleDescHandle = NULL; + fpSampleDataHandle = NULL; for ( int32 i = 0; i < MAX_SFX_BANKS; i++ ) { - gBankLoaded[i] = FALSE; - gSampleBankDiscStartOffset[i] = 0; - gSampleBankSize[i] = 0; - gSampleBankMemoryStartAddress[i] = 0; + bSampleBankLoaded[i] = FALSE; + nSampleBankDiscStartOffset[i] = 0; + nSampleBankSize[i] = 0; + nSampleBankMemoryStartAddress[i] = 0; } } { for ( int32 i = 0; i < MAX_PEDSFX; i++ ) { - gPedSfx[i] = NO_SAMPLE; - gPedSfxAddr[i] = 0; + nPedSlotSfx[i] = NO_SAMPLE; + nPedSlotSfxAddr[i] = 0; } - gCurPedIndex = 0; + nCurrentPedSlot = 0; } { for ( int32 i = 0; i < NUM_CHANNELS; i++ ) - gChannelVolume[i] = 0; + nChannelVolume[i] = 0; } add_providers(); @@ -922,14 +922,14 @@ cSampleManager::Initialise(void) { for ( int32 i = 0; i < TOTAL_STREAMED_SOUNDS; i++ ) - gStreamLength[i] = 0; + nStreamLength[i] = 0; } #ifdef AUDIO_CACHE FILE *cacheFile = fcaseopen("audio\\sound.cache", "rb"); if (cacheFile) { debug("Loadind audio cache (If game crashes around here, then your cache is corrupted, remove audio/sound.cache)\n"); - fread(gStreamLength, sizeof(uint32), TOTAL_STREAMED_SOUNDS, cacheFile); + fread(nStreamLength, sizeof(uint32), TOTAL_STREAMED_SOUNDS, cacheFile); fclose(cacheFile); } else { @@ -944,7 +944,7 @@ cSampleManager::Initialise(void) delete aStream[0]; aStream[0] = NULL; - gStreamLength[i] = tatalms; + nStreamLength[i] = tatalms; } else USERERROR("Can't open '%s'\n", StreamedNameTable[i]); } @@ -952,7 +952,7 @@ cSampleManager::Initialise(void) cacheFile = fcaseopen("audio\\sound.cache", "wb"); if(cacheFile) { debug("Saving audio cache\n"); - fwrite(gStreamLength, sizeof(uint32), TOTAL_STREAMED_SOUNDS, cacheFile); + fwrite(nStreamLength, sizeof(uint32), TOTAL_STREAMED_SOUNDS, cacheFile); fclose(cacheFile); } else { debug("Cannot save audio cache\n"); @@ -967,17 +967,17 @@ cSampleManager::Initialise(void) return FALSE; } - gSampleBankMemoryStartAddress[SFX_BANK_0] = (uintptr)malloc(gSampleBankSize[SFX_BANK_0]); - ASSERT(gSampleBankMemoryStartAddress[SFX_BANK_0] != 0); + nSampleBankMemoryStartAddress[SFX_BANK_0] = (uintptr)malloc(nSampleBankSize[SFX_BANK_0]); + ASSERT(nSampleBankMemoryStartAddress[SFX_BANK_0] != 0); - if ( gSampleBankMemoryStartAddress[SFX_BANK_0] == 0 ) + if ( nSampleBankMemoryStartAddress[SFX_BANK_0] == 0 ) { Terminate(); return FALSE; } - gSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = (uintptr)malloc(PED_BUFFERSIZE*MAX_PEDSFX); - ASSERT(gSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] != 0); + nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = (uintptr)malloc(PED_BLOCKSIZE*MAX_PEDSFX); + ASSERT(nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] != 0); LoadSampleBank(SFX_BANK_0); } @@ -992,7 +992,7 @@ cSampleManager::Initialise(void) } { - gInitialised = TRUE; + _bSampmanInitialised = TRUE; if ( defaultProvider >= 0 && defaultProvider < m_nNumberOfProviders ) { @@ -1014,12 +1014,12 @@ cSampleManager::Initialise(void) if ( nNumMP3s != 0 ) { - gStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] = 0; + nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] = 0; for ( tMP3Entry *e = _pMP3List; e != NULL; e = e->pNext ) { - e->nTrackStreamPos = gStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER]; - gStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] += e->nTrackLength; + e->nTrackStreamPos = nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER]; + nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] += e->nTrackLength; } time_t t = time(NULL); @@ -1130,19 +1130,19 @@ cSampleManager::Terminate(void) CStream::Terminate(); - if ( gSampleBankMemoryStartAddress[SFX_BANK_0] != 0 ) + if ( nSampleBankMemoryStartAddress[SFX_BANK_0] != 0 ) { - free((void *)gSampleBankMemoryStartAddress[SFX_BANK_0]); - gSampleBankMemoryStartAddress[SFX_BANK_0] = 0; + free((void *)nSampleBankMemoryStartAddress[SFX_BANK_0]); + nSampleBankMemoryStartAddress[SFX_BANK_0] = 0; } - if ( gSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] != 0 ) + if ( nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] != 0 ) { - free((void *)gSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS]); - gSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = 0; + free((void *)nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS]); + nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = 0; } - gInitialised = FALSE; + _bSampmanInitialised = FALSE; } bool8 cSampleManager::CheckForAnAudioFileOnCD(void) @@ -1158,14 +1158,14 @@ char cSampleManager::GetCDAudioDriveLetter(void) void cSampleManager::UpdateEffectsVolume(void) { - if ( gInitialised ) + if ( _bSampmanInitialised ) { for ( int32 i = 0; i < NUM_CHANNELS; i++ ) { if ( GetChannelUsedFlag(i) ) { - if ( gChannelVolume[i] != 0 ) - aChannel[i].SetVolume(m_nEffectsFadeVolume*gChannelVolume[i]*m_nEffectsVolume >> 14); + if ( nChannelVolume[i] != 0 ) + aChannel[i].SetVolume(m_nEffectsFadeVolume*nChannelVolume[i]*m_nEffectsVolume >> 14); } } } @@ -1220,10 +1220,10 @@ cSampleManager::LoadSampleBank(uint8 nBank) #ifdef OPUS_SFX int samplesRead = 0; - int samplesSize = gSampleBankSize[nBank] / 2; - op_pcm_seek(gFileHandleSampleData, 0); + int samplesSize = nSampleBankSize[nBank] / 2; + op_pcm_seek(fpSampleDataHandle, 0); while (samplesSize > 0) { - int size = op_read(gFileHandleSampleData, (opus_int16 *)(gSampleBankMemoryStartAddress[nBank] + samplesRead), samplesSize, NULL); + int size = op_read(fpSampleDataHandle, (opus_int16 *)(nSampleBankMemoryStartAddress[nBank] + samplesRead), samplesSize, NULL); if (size <= 0) { // huh? //assert(0); @@ -1233,13 +1233,13 @@ cSampleManager::LoadSampleBank(uint8 nBank) samplesSize -= size; } #else - if ( fseek(gFileHandleSampleData, gSampleBankDiscStartOffset[nBank], SEEK_SET) != 0 ) + if ( fseek(fpSampleDataHandle, nSampleBankDiscStartOffset[nBank], SEEK_SET) != 0 ) return FALSE; - if ( fread((void *)gSampleBankMemoryStartAddress[nBank], 1, gSampleBankSize[nBank], gFileHandleSampleData) != gSampleBankSize[nBank] ) + if ( fread((void *)nSampleBankMemoryStartAddress[nBank], 1, nSampleBankSize[nBank], fpSampleDataHandle) != nSampleBankSize[nBank] ) return FALSE; #endif - gBankLoaded[nBank] = TRUE; + bSampleBankLoaded[nBank] = TRUE; return TRUE; } @@ -1249,7 +1249,7 @@ cSampleManager::UnloadSampleBank(uint8 nBank) { ASSERT( nBank < MAX_SFX_BANKS); - gBankLoaded[nBank] = FALSE; + bSampleBankLoaded[nBank] = FALSE; } bool8 @@ -1257,7 +1257,7 @@ cSampleManager::IsSampleBankLoaded(uint8 nBank) { ASSERT( nBank < MAX_SFX_BANKS); - return gBankLoaded[nBank]; + return bSampleBankLoaded[nBank]; } bool8 @@ -1269,12 +1269,12 @@ cSampleManager::IsPedCommentLoaded(uint32 nComment) for ( int32 i = 0; i < _TODOCONST(3); i++ ) { - slot = gCurPedIndex - i - 1; + slot = nCurrentPedSlot - i - 1; #ifdef FIX_BUGS if (slot < 0) - slot += ARRAY_SIZE(gPedSfx); + slot += ARRAY_SIZE(nPedSlotSfx); #endif - if ( nComment == gPedSfx[slot] ) + if ( nComment == nPedSlotSfx[slot] ) return TRUE; } @@ -1289,12 +1289,12 @@ cSampleManager::_GetPedCommentSlot(uint32 nComment) for (int32 i = 0; i < _TODOCONST(3); i++) { - slot = gCurPedIndex - i - 1; + slot = nCurrentPedSlot - i - 1; #ifdef FIX_BUGS if (slot < 0) - slot += ARRAY_SIZE(gPedSfx); + slot += ARRAY_SIZE(nPedSlotSfx); #endif - if (nComment == gPedSfx[slot]) + if (nComment == nPedSlotSfx[slot]) return slot; } @@ -1333,10 +1333,10 @@ cSampleManager::LoadPedComment(uint32 nComment) #ifdef OPUS_SFX int samplesRead = 0; - int samplesSize = m_aSampleDataTable[nComment].nSize / 2; - op_pcm_seek(gFileHandleSampleData, m_aSampleDataTable[nComment].nOffset / 2); + int samplesSize = m_aSamples[nComment].nSize / 2; + op_pcm_seek(fpSampleDataHandle, m_aSamples[nComment].nOffset / 2); while (samplesSize > 0) { - int size = op_read(gFileHandleSampleData, (opus_int16 *)(gSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BUFFERSIZE * gCurPedIndex + samplesRead), + int size = op_read(fpSampleDataHandle, (opus_int16 *)(nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BLOCKSIZE * nCurrentPedSlot + samplesRead), samplesSize, NULL); if (size <= 0) { return FALSE; @@ -1345,17 +1345,17 @@ cSampleManager::LoadPedComment(uint32 nComment) samplesSize -= size; } #else - if ( fseek(gFileHandleSampleData, m_aSampleDataTable[nComment].nOffset, SEEK_SET) != 0 ) + if ( fseek(fpSampleDataHandle, m_aSamples[nComment].nOffset, SEEK_SET) != 0 ) return FALSE; - if ( fread((void *)(gSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BUFFERSIZE*gCurPedIndex), 1, m_aSampleDataTable[nComment].nSize, gFileHandleSampleData) != m_aSampleDataTable[nComment].nSize ) + if ( fread((void *)(nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BLOCKSIZE*nCurrentPedSlot), 1, m_aSamples[nComment].nSize, fpSampleDataHandle) != m_aSamples[nComment].nSize ) return FALSE; #endif - gPedSfx[gCurPedIndex] = nComment; + nPedSlotSfx[nCurrentPedSlot] = nComment; - if ( ++gCurPedIndex >= MAX_PEDSFX ) - gCurPedIndex = 0; + if ( ++nCurrentPedSlot >= MAX_PEDSFX ) + nCurrentPedSlot = 0; return TRUE; } @@ -1363,10 +1363,10 @@ cSampleManager::LoadPedComment(uint32 nComment) int32 cSampleManager::GetBankContainingSound(uint32 offset) { - if ( offset >= gBankStartOffset[SFX_BANK_PED_COMMENTS] ) + if ( offset >= BankStartOffset[SFX_BANK_PED_COMMENTS] ) return SFX_BANK_PED_COMMENTS; - if ( offset >= gBankStartOffset[SFX_BANK_0] ) + if ( offset >= BankStartOffset[SFX_BANK_0] ) return SFX_BANK_0; return INVALID_SFX_BANK; @@ -1376,28 +1376,28 @@ int32 cSampleManager::GetSampleBaseFrequency(uint32 nSample) { ASSERT( nSample < TOTAL_AUDIO_SAMPLES ); - return m_aSampleDataTable[nSample].nFrequency; + return m_aSamples[nSample].nFrequency; } int32 cSampleManager::GetSampleLoopStartOffset(uint32 nSample) { ASSERT( nSample < TOTAL_AUDIO_SAMPLES ); - return m_aSampleDataTable[nSample].nLoopStart; + return m_aSamples[nSample].nLoopStart; } int32 cSampleManager::GetSampleLoopEndOffset(uint32 nSample) { ASSERT( nSample < TOTAL_AUDIO_SAMPLES ); - return m_aSampleDataTable[nSample].nLoopEnd; + return m_aSamples[nSample].nLoopEnd; } uint32 cSampleManager::GetSampleLength(uint32 nSample) { ASSERT( nSample < TOTAL_AUDIO_SAMPLES ); - return m_aSampleDataTable[nSample].nSize / sizeof(uint16); + return m_aSamples[nSample].nSize / sizeof(uint16); } bool8 cSampleManager::UpdateReverb(void) @@ -1496,7 +1496,7 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank) if ( !IsSampleBankLoaded(nBank) ) return FALSE; - addr = gSampleBankMemoryStartAddress[nBank] + m_aSampleDataTable[nSfx].nOffset - m_aSampleDataTable[gBankStartOffset[nBank]].nOffset; + addr = nSampleBankMemoryStartAddress[nBank] + m_aSamples[nSfx].nOffset - m_aSamples[BankStartOffset[nBank]].nOffset; } else { @@ -1504,7 +1504,7 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank) return FALSE; int32 slot = _GetPedCommentSlot(nSfx); - addr = (gSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BUFFERSIZE * slot); + addr = (nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BLOCKSIZE * slot); } if ( GetChannelUsedFlag(nChannel) ) @@ -1516,7 +1516,7 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank) aChannel[nChannel].Reset(); if ( aChannel[nChannel].HasSource() ) { - aChannel[nChannel].SetSampleData ((void*)addr, m_aSampleDataTable[nSfx].nSize, m_aSampleDataTable[nSfx].nFrequency); + aChannel[nChannel].SetSampleData ((void*)addr, m_aSamples[nSfx].nSize, m_aSamples[nSfx].nFrequency); aChannel[nChannel].SetLoopPoints (0, -1); aChannel[nChannel].SetPitch (1.0f); return TRUE; @@ -1533,18 +1533,18 @@ cSampleManager::SetChannelEmittingVolume(uint32 nChannel, uint32 nVolume) uint32 vol = nVolume; if ( vol > MAX_VOLUME ) vol = MAX_VOLUME; - gChannelVolume[nChannel] = vol; + nChannelVolume[nChannel] = vol; // reduce channel volume when JB.MP3 or S4_BDBD.MP3 playing if ( MusicManager.GetMusicMode() == MUSICMODE_CUTSCENE && MusicManager.GetNextTrack() != STREAMED_SOUND_NEWS_INTRO && MusicManager.GetNextTrack() != STREAMED_SOUND_CUTSCENE_SAL4_BDBD ) { - gChannelVolume[nChannel] = vol / 4; + nChannelVolume[nChannel] = vol / 4; } // no idea, does this one looks like a bug or it's SetChannelVolume ? - aChannel[nChannel].SetVolume(m_nEffectsFadeVolume*gChannelVolume[nChannel]*m_nEffectsVolume >> 14); + aChannel[nChannel].SetVolume(m_nEffectsFadeVolume*nChannelVolume[nChannel]*m_nEffectsVolume >> 14); } void @@ -1573,14 +1573,14 @@ cSampleManager::SetChannelVolume(uint32 nChannel, uint32 nVolume) uint32 vol = nVolume; if ( vol > MAX_VOLUME ) vol = MAX_VOLUME; - gChannelVolume[nChannel] = vol; + nChannelVolume[nChannel] = vol; // reduce the volume for JB.MP3 and S4_BDBD.MP3 if ( MusicManager.GetMusicMode() == MUSICMODE_CUTSCENE && MusicManager.GetNextTrack() != STREAMED_SOUND_NEWS_INTRO && MusicManager.GetNextTrack() != STREAMED_SOUND_CUTSCENE_SAL4_BDBD ) { - gChannelVolume[nChannel] = vol / 4; + nChannelVolume[nChannel] = vol / 4; } aChannel[nChannel].SetVolume(m_nEffectsFadeVolume*vol*m_nEffectsVolume >> 14); @@ -1727,7 +1727,7 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) // Switched to MP3 player just now if ( !_bIsMp3Active && i == 0 ) { - if ( nPos > gStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] ) + if ( nPos > nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] ) position = 0; tMP3Entry *e = _pMP3List; @@ -1935,7 +1935,7 @@ cSampleManager::GetStreamedFileLength(uint8 nStream) { ASSERT( nStream < TOTAL_STREAMED_SOUNDS ); - return gStreamLength[nStream]; + return nStreamLength[nStream]; } bool8 @@ -1977,47 +1977,47 @@ cSampleManager::InitialiseSampleBanks(void) { int32 nBank = SFX_BANK_0; - gFileHandleSampleDesc = fcaseopen(SampleBankDescFilename, "rb"); - if ( gFileHandleSampleDesc == NULL ) + fpSampleDescHandle = fcaseopen(SampleBankDescFilename, "rb"); + if ( fpSampleDescHandle == NULL ) return FALSE; #ifndef OPUS_SFX - gFileHandleSampleData = fcaseopen(SampleBankDataFilename, "rb"); - if ( gFileHandleSampleData == NULL ) + fpSampleDataHandle = fcaseopen(SampleBankDataFilename, "rb"); + if ( fpSampleDataHandle == NULL ) { - fclose(gFileHandleSampleDesc); - gFileHandleSampleDesc = NULL; + fclose(fpSampleDescHandle); + fpSampleDescHandle = NULL; return FALSE; } - fseek(gFileHandleSampleData, 0, SEEK_END); - int32 _nSampleDataEndOffset = ftell(gFileHandleSampleData); - rewind(gFileHandleSampleData); + fseek(fpSampleDataHandle, 0, SEEK_END); + int32 _nSampleDataEndOffset = ftell(fpSampleDataHandle); + rewind(fpSampleDataHandle); #else int e; - gFileHandleSampleData = op_open_file(SampleBankDataFilename, &e); + fpSampleDataHandle = op_open_file(SampleBankDataFilename, &e); #endif - fread(m_aSampleDataTable, sizeof(tSample), TOTAL_AUDIO_SAMPLES, gFileHandleSampleDesc); + fread(m_aSamples, sizeof(tSample), TOTAL_AUDIO_SAMPLES, fpSampleDescHandle); #ifdef OPUS_SFX - int32 _nSampleDataEndOffset = m_aSampleDataTable[TOTAL_AUDIO_SAMPLES - 1].nOffset + m_aSampleDataTable[TOTAL_AUDIO_SAMPLES - 1].nSize; + int32 _nSampleDataEndOffset = m_aSamples[TOTAL_AUDIO_SAMPLES - 1].nOffset + m_aSamples[TOTAL_AUDIO_SAMPLES - 1].nSize; #endif - fclose(gFileHandleSampleDesc); - gFileHandleSampleDesc = NULL; + fclose(fpSampleDescHandle); + fpSampleDescHandle = NULL; for ( int32 i = 0; i < TOTAL_AUDIO_SAMPLES; i++ ) { #ifdef FIX_BUGS if (nBank >= MAX_SFX_BANKS) break; #endif - if ( gBankStartOffset[nBank] == gBankStartOffset[SFX_BANK_0] + i ) + if ( BankStartOffset[nBank] == BankStartOffset[SFX_BANK_0] + i ) { - gSampleBankDiscStartOffset[nBank] = m_aSampleDataTable[i].nOffset; + nSampleBankDiscStartOffset[nBank] = m_aSamples[i].nOffset; nBank++; } } - gSampleBankSize[SFX_BANK_0] = gSampleBankDiscStartOffset[SFX_BANK_PED_COMMENTS] - gSampleBankDiscStartOffset[SFX_BANK_0]; - gSampleBankSize[SFX_BANK_PED_COMMENTS] = _nSampleDataEndOffset - gSampleBankDiscStartOffset[SFX_BANK_PED_COMMENTS]; + nSampleBankSize[SFX_BANK_0] = nSampleBankDiscStartOffset[SFX_BANK_PED_COMMENTS] - nSampleBankDiscStartOffset[SFX_BANK_0]; + nSampleBankSize[SFX_BANK_PED_COMMENTS] = _nSampleDataEndOffset - nSampleBankDiscStartOffset[SFX_BANK_PED_COMMENTS]; return TRUE; } -- cgit v1.2.3 From cb3b3855b844c14c0e943c1a7614fc29820cf666 Mon Sep 17 00:00:00 2001 From: withmorten Date: Mon, 28 Jun 2021 13:31:35 +0200 Subject: rename clamp macro to Clamp to fix compilation with g++11 --- src/audio/AudioLogic.cpp | 4 ++-- src/audio/AudioManager.cpp | 2 +- src/audio/oal/stream.cpp | 10 +++++----- src/audio/sampman_miles.cpp | 2 +- src/audio/sampman_oal.cpp | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) (limited to 'src/audio') diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 8472cda6..fdc7305b 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -1220,7 +1220,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CAutomobile * CurrentPretendGear = 1; } if (CReplay::IsPlayingBack()) - accelerateState = 255.f * clamp(automobile->m_fGasPedal, 0.0f, 1.0f); + accelerateState = 255.f * Clamp(automobile->m_fGasPedal, 0.0f, 1.0f); else accelerateState = Pads[0].GetAccelerate(); @@ -1229,7 +1229,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CAutomobile * velocityChange = params.m_fVelocityChange; relativeVelocityChange = 2.0f * velocityChange / transmission->fMaxVelocity; - accelerationMultipler = clamp(relativeVelocityChange, 0.0f, 1.0f); + accelerationMultipler = Clamp(relativeVelocityChange, 0.0f, 1.0f); gasPedalAudio = accelerationMultipler; currentGear = params.m_pVehicle->m_nCurrentGear; diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index c49ce552..a3bc6a01 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -321,7 +321,7 @@ cAudioManager::Get3DProviderName(uint8 id) const if (!m_bIsInitialised) return nil; #ifdef AUDIO_OAL - id = clamp(id, 0, SampleManager.GetNum3DProvidersAvailable() - 1); + id = Clamp(id, 0, SampleManager.GetNum3DProvidersAvailable() - 1); #else // We don't want that either since it will crash the game, but skipping for now if (id >= SampleManager.GetNum3DProvidersAvailable()) diff --git a/src/audio/oal/stream.cpp b/src/audio/oal/stream.cpp index 44cc1c93..5d3ff08e 100644 --- a/src/audio/oal/stream.cpp +++ b/src/audio/oal/stream.cpp @@ -134,7 +134,7 @@ public: else StepIndex--; - StepIndex = clamp(StepIndex, 0, 88); + StepIndex = Clamp(StepIndex, 0, 88); int delta = step >> 3; if (adpcm & 1) delta += step >> 2; @@ -143,7 +143,7 @@ public: if (adpcm & 8) delta = -delta; int newSample = Sample + delta; - Sample = clamp(newSample, -32768, 32767); + Sample = Clamp(newSample, -32768, 32767); return Sample; } }; @@ -596,7 +596,7 @@ public: static short quantize(double sample) { int a = int(sample + 0.5); - return short(clamp(a, -32768, 32767)); + return short(Clamp(a, -32768, 32767)); } void Decode(void* _inbuf, int16* _outbuf, size_t size) @@ -1086,10 +1086,10 @@ void CStream::SetVolume(uint32 nVol) void CStream::SetPan(uint8 nPan) { - m_nPan = clamp((int8)nPan - 63, 0, 63); + m_nPan = Clamp((int8)nPan - 63, 0, 63); SetPosition(0, (m_nPan - 63) / 64.0f, 0.0f, Sqrt(1.0f - SQR((m_nPan - 63) / 64.0f))); - m_nPan = clamp((int8)nPan + 64, 64, 127); + m_nPan = Clamp((int8)nPan + 64, 64, 127); SetPosition(1, (m_nPan - 63) / 64.0f, 0.0f, Sqrt(1.0f - SQR((m_nPan - 63) / 64.0f))); m_nPan = nPan; diff --git a/src/audio/sampman_miles.cpp b/src/audio/sampman_miles.cpp index ddfaaa5f..362da433 100644 --- a/src/audio/sampman_miles.cpp +++ b/src/audio/sampman_miles.cpp @@ -1624,7 +1624,7 @@ cSampleManager::UpdateReverb(void) } } - fRatio = clamp(fRatio, usingEAX3==1 ? 0.0f : 0.30f, 1.0f); + fRatio = Clamp(fRatio, usingEAX3==1 ? 0.0f : 0.30f, 1.0f); if ( fRatio == _fPrevEaxRatioDestination ) return FALSE; diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp index f2771885..31c27154 100644 --- a/src/audio/sampman_oal.cpp +++ b/src/audio/sampman_oal.cpp @@ -348,7 +348,7 @@ int8 cSampleManager::SetCurrent3DProvider(uint8 nProvider) { int savedprovider = curprovider; - nProvider = clamp(nProvider, 0, m_nNumberOfProviders - 1); + nProvider = Clamp(nProvider, 0, m_nNumberOfProviders - 1); if ( set_new_provider(nProvider) ) return curprovider; @@ -1424,7 +1424,7 @@ bool8 cSampleManager::UpdateReverb(void) #undef CALCRATIO #undef ZR - fRatio = clamp(fRatio, usingEAX3==1 ? 0.0f : 0.30f, 1.0f); + fRatio = Clamp(fRatio, usingEAX3==1 ? 0.0f : 0.30f, 1.0f); if ( fRatio == _fPrevEaxRatioDestination ) return FALSE; -- cgit v1.2.3 From 22e8e0eff8bc7444fc1d359048263cb715ca11e3 Mon Sep 17 00:00:00 2001 From: erorcun Date: Mon, 28 Jun 2021 17:11:12 +0300 Subject: Fix MP3 finding stack crash --- src/audio/sampman_oal.cpp | 145 +++++++++++++++------------------------------- 1 file changed, 47 insertions(+), 98 deletions(-) (limited to 'src/audio') diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp index 31c27154..c566893a 100644 --- a/src/audio/sampman_oal.cpp +++ b/src/audio/sampman_oal.cpp @@ -446,18 +446,32 @@ _FindMP3s(void) bool8 bInitFirstEntry; HANDLE hFind; char path[MAX_PATH]; - char filepath[MAX_PATH*2]; int total_ms; WIN32_FIND_DATA fd; + char filepath[MAX_PATH + sizeof(fd.cFileName)]; if (getcwd(_mp3DirectoryPath, MAX_PATH) == NULL) { perror("getcwd: "); return; } + + if (strlen(_mp3DirectoryPath) + 1 > MAX_PATH - 10) { + // This is not gonna end well + printf("MP3 folder path is too long, no place left for file names. MP3 finding aborted.\n"); + return; + } OutputDebugString("Finding MP3s..."); strcpy(path, _mp3DirectoryPath); strcat(path, "\\MP3\\"); + +#if !defined(_WIN32) + char *actualPath = casepath(path); + if (actualPath) { + strcpy(path, actualPath); + free(actualPath); + } +#endif strcpy(_mp3DirectoryPath, path); OutputDebugString(_mp3DirectoryPath); @@ -470,95 +484,32 @@ _FindMP3s(void) { return; } - - strcpy(filepath, _mp3DirectoryPath); - strcat(filepath, fd.cFileName); - - size_t filepathlen = strlen(filepath); - - if ( filepathlen <= 0) - { - FindClose(hFind); - return; - } - if ( _ResolveLink(filepath, filepath) ) - { - OutputDebugString("Resolving Link"); - OutputDebugString(filepath); - bShortcut = TRUE; - } else - bShortcut = FALSE; - - aStream[0] = new CStream(filepath, ALStreamSources[0], ALStreamBuffers[0]); + bShortcut = FALSE; + bInitFirstEntry = TRUE; - if (aStream[0] && aStream[0]->IsOpened()) - { - total_ms = aStream[0]->GetLengthMS(); - delete aStream[0]; - aStream[0] = NULL; - - OutputDebugString(fd.cFileName); - - _pMP3List = new tMP3Entry; - - if ( _pMP3List == NULL ) - { - FindClose(hFind); - return; - } - - nNumMP3s = 1; - - strcpy(_pMP3List->aFilename, fd.cFileName); - - _pMP3List->nTrackLength = total_ms; - - _pMP3List->pNext = NULL; - - pList = _pMP3List; - - if ( bShortcut ) - { - _pMP3List->pLinkPath = new char[MAX_PATH*2]; - strcpy(_pMP3List->pLinkPath, filepath); - } - else - { - _pMP3List->pLinkPath = NULL; - } + do + { + strcpy(filepath, _mp3DirectoryPath); + strcat(filepath, fd.cFileName); + + if (!strcmp(fd.cFileName, ".") || !strcmp(fd.cFileName, "..")) + continue; - bInitFirstEntry = FALSE; - } - else - { - strcat(filepath, " - NOT A VALID MP3"); - - OutputDebugString(filepath); + size_t filepathlen = strlen(filepath); - bInitFirstEntry = TRUE; - } - - while ( TRUE ) - { - if ( !FindNextFile(hFind, &fd) ) - break; - if ( bInitFirstEntry ) { - strcpy(filepath, _mp3DirectoryPath); - strcat(filepath, fd.cFileName); - - size_t filepathlen = strlen(filepath); - - if ( filepathlen > 0 ) + if (filepathlen > 0) { - if ( _ResolveLink(filepath, filepath) ) + if (_ResolveLink(filepath, filepath)) { OutputDebugString("Resolving Link"); OutputDebugString(filepath); bShortcut = TRUE; - } else { + } + else + { bShortcut = FALSE; if (filepathlen > MAX_PATH) { continue; @@ -571,31 +522,31 @@ _FindMP3s(void) total_ms = aStream[0]->GetLengthMS(); delete aStream[0]; aStream[0] = NULL; - + OutputDebugString(fd.cFileName); - + _pMP3List = new tMP3Entry; - - if ( _pMP3List == NULL) + + if (_pMP3List == NULL) break; - + nNumMP3s = 1; - + strcpy(_pMP3List->aFilename, fd.cFileName); - + _pMP3List->nTrackLength = total_ms; _pMP3List->pNext = NULL; - - if ( bShortcut ) + + if (bShortcut) { - _pMP3List->pLinkPath = new char [MAX_PATH*2]; + _pMP3List->pLinkPath = new char[MAX_PATH + sizeof(fd.cFileName)]; strcpy(_pMP3List->pLinkPath, filepath); } else { _pMP3List->pLinkPath = NULL; } - + pList = _pMP3List; bInitFirstEntry = FALSE; @@ -606,14 +557,11 @@ _FindMP3s(void) OutputDebugString(filepath); } } + else + break; } else { - strcpy(filepath, _mp3DirectoryPath); - strcat(filepath, fd.cFileName); - - size_t filepathlen = strlen(filepath); - if ( filepathlen > 0 ) { if ( _ResolveLink(filepath, filepath) ) @@ -621,7 +569,8 @@ _FindMP3s(void) OutputDebugString("Resolving Link"); OutputDebugString(filepath); bShortcut = TRUE; - } else + } + else bShortcut = FALSE; aStream[0] = new CStream(filepath, ALStreamSources[0], ALStreamBuffers[0]); @@ -647,7 +596,7 @@ _FindMP3s(void) if ( bShortcut ) { - e->pLinkPath = new char [MAX_PATH*2]; + e->pLinkPath = new char [MAX_PATH + sizeof(fd.cFileName)]; strcpy(e->pLinkPath, filepath); } else @@ -666,7 +615,7 @@ _FindMP3s(void) } } } - } + } while (FindNextFile(hFind, &fd)); FindClose(hFind); } -- cgit v1.2.3 From a3964dfd4a6d84aded126f0314498b0da0aaf93a Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Wed, 30 Jun 2021 21:36:11 +0300 Subject: Pause radio when game is paused --- src/audio/MusicManager.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/audio') diff --git a/src/audio/MusicManager.cpp b/src/audio/MusicManager.cpp index 957fce55..cb441622 100644 --- a/src/audio/MusicManager.cpp +++ b/src/audio/MusicManager.cpp @@ -306,7 +306,16 @@ cMusicManager::ChangeMusicMode(uint8 mode) uint8 mode2; switch (mode) { - case MUSICMODE_FRONTEND: mode2 = MUSICMODE_FRONTEND; break; + case MUSICMODE_FRONTEND: + mode2 = MUSICMODE_FRONTEND; +#ifdef PAUSE_RADIO_IN_FRONTEND + // rewind those streams we weren't listening right now + for (uint32 i = STREAMED_SOUND_RADIO_HEAD; i < STREAMED_SOUND_CUTSCENE_LUIGI1_LG; i++) { + m_aTracks[i].m_nPosition = GetTrackStartPos(i); + m_aTracks[i].m_nLastPosCheckTimer = CTimer::GetTimeInMillisecondsPauseMode(); + } +#endif + break; case MUSICMODE_GAME: mode2 = MUSICMODE_GAME; break; case MUSICMODE_CUTSCENE: mode2 = MUSICMODE_CUTSCENE; break; case MUSICMODE_DISABLE: mode2 = MUSICMODE_DISABLED; break; @@ -448,6 +457,12 @@ cMusicManager::Service() void cMusicManager::ServiceFrontEndMode() { +#ifdef PAUSE_RADIO_IN_FRONTEND + // pause radio + for (uint32 i = STREAMED_SOUND_RADIO_HEAD; i < STREAMED_SOUND_CUTSCENE_LUIGI1_LG; i++) + m_aTracks[i].m_nLastPosCheckTimer = CTimer::GetTimeInMillisecondsPauseMode(); +#endif + if (m_nNextTrack < TOTAL_STREAMED_SOUNDS) { if (m_bFrontendTrackFinished) { if (!SampleManager.IsStreamPlaying()) { -- cgit v1.2.3 From 70fa7fc239f9ec09eda218531f240e92d26d5d3a Mon Sep 17 00:00:00 2001 From: erorcun Date: Wed, 30 Jun 2021 03:31:10 +0300 Subject: Sanitizer fixes --- src/audio/sampman_oal.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/audio') diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp index c566893a..7fb84965 100644 --- a/src/audio/sampman_oal.cpp +++ b/src/audio/sampman_oal.cpp @@ -1214,14 +1214,14 @@ cSampleManager::IsPedCommentLoaded(uint32 nComment) { ASSERT( nComment < TOTAL_AUDIO_SAMPLES ); - int8 slot; - for ( int32 i = 0; i < _TODOCONST(3); i++ ) { - slot = nCurrentPedSlot - i - 1; #ifdef FIX_BUGS + int8 slot = (int8)nCurrentPedSlot - i - 1; if (slot < 0) slot += ARRAY_SIZE(nPedSlotSfx); +#else + uint8 slot = nCurrentPedSlot - i - 1; #endif if ( nComment == nPedSlotSfx[slot] ) return TRUE; @@ -1234,14 +1234,14 @@ cSampleManager::IsPedCommentLoaded(uint32 nComment) int32 cSampleManager::_GetPedCommentSlot(uint32 nComment) { - int8 slot; - for (int32 i = 0; i < _TODOCONST(3); i++) { - slot = nCurrentPedSlot - i - 1; #ifdef FIX_BUGS + int8 slot = (int8)nCurrentPedSlot - i - 1; if (slot < 0) slot += ARRAY_SIZE(nPedSlotSfx); +#else + uint8 slot = nCurrentPedSlot - i - 1; #endif if (nComment == nPedSlotSfx[slot]) return slot; -- cgit v1.2.3 From 77f31105de436108970f2041ef73013121234ba6 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 3 Jul 2021 15:57:08 +0300 Subject: Fix overflow in audio code --- src/audio/AudioManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/audio') diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index a3bc6a01..2e391349 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -977,7 +977,7 @@ void cAudioManager::AdjustSamplesVolume() { for (int i = 0; i < m_SampleRequestQueuesStatus[m_nActiveSampleQueue]; i++) { - tSound *pSample = &m_asSamples[m_nActiveSampleQueue][m_abSampleQueueIndexTable[m_nActiveSampleQueue][i] + 1]; + tSound *pSample = &m_asSamples[m_nActiveSampleQueue][m_abSampleQueueIndexTable[m_nActiveSampleQueue][i]]; if (!pSample->m_bIs2D) pSample->m_nEmittingVolume = ComputeEmittingVolume(pSample->m_nEmittingVolume, pSample->m_fSoundIntensity, pSample->m_fDistance); -- cgit v1.2.3 From dadc56ccf9c334b2c5408886a79ad4d8f8c52b1b Mon Sep 17 00:00:00 2001 From: withmorten Date: Wed, 7 Jul 2021 01:54:16 +0200 Subject: fix sampman_null build --- src/audio/sampman_null.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/audio') diff --git a/src/audio/sampman_null.cpp b/src/audio/sampman_null.cpp index 95603c72..df912a9a 100644 --- a/src/audio/sampman_null.cpp +++ b/src/audio/sampman_null.cpp @@ -226,35 +226,35 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank) void cSampleManager::SetChannelEmittingVolume(uint32 nChannel, uint32 nVolume) { - ASSERT( nChannel != CHANNEL2D ); + ASSERT( nChannel < MAXCHANNELS ); ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); } void cSampleManager::SetChannel3DPosition(uint32 nChannel, float fX, float fY, float fZ) { - ASSERT( nChannel != CHANNEL2D ); + ASSERT( nChannel < MAXCHANNELS ); ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); } void cSampleManager::SetChannel3DDistances(uint32 nChannel, float fMax, float fMin) { - ASSERT( nChannel != CHANNEL2D ); + ASSERT( nChannel < MAXCHANNELS ); ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); } void cSampleManager::SetChannelVolume(uint32 nChannel, uint32 nVolume) { - ASSERT( nChannel == CHANNEL2D ); + ASSERT( nChannel >= MAXCHANNELS ); ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); } void cSampleManager::SetChannelPan(uint32 nChannel, uint32 nPan) { - ASSERT(nChannel == CHANNEL2D); + ASSERT( nChannel >= MAXCHANNELS ); ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); } -- cgit v1.2.3 From f9a2f1daf75d5235742917359d3ec10395d46bbc Mon Sep 17 00:00:00 2001 From: withmorten Date: Thu, 8 Jul 2021 01:40:58 +0200 Subject: fix macro redefinition warnings on win-glfw build --- src/audio/sampman_miles.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/audio') diff --git a/src/audio/sampman_miles.cpp b/src/audio/sampman_miles.cpp index 362da433..e820864c 100644 --- a/src/audio/sampman_miles.cpp +++ b/src/audio/sampman_miles.cpp @@ -1,3 +1,4 @@ +#define WITHWINDOWS #include "common.h" #ifdef AUDIO_MSS -- cgit v1.2.3 From ab73c2f539bdebfd12391db6cb3af99a762e898c Mon Sep 17 00:00:00 2001 From: erorcun Date: Fri, 25 Jun 2021 05:06:38 +0300 Subject: Multi-threaded audio streams Under MULTITHREADED_AUDIO define. --- src/audio/oal/stream.cpp | 531 +++++++++++++++++++++++++++++++++++++++------- src/audio/oal/stream.h | 87 +++++++- src/audio/sampman_oal.cpp | 35 +-- 3 files changed, 558 insertions(+), 95 deletions(-) (limited to 'src/audio') diff --git a/src/audio/oal/stream.cpp b/src/audio/oal/stream.cpp index 5d3ff08e..68847906 100644 --- a/src/audio/oal/stream.cpp +++ b/src/audio/oal/stream.cpp @@ -1,8 +1,6 @@ #include "common.h" #ifdef AUDIO_OAL -#include "stream.h" -#include "sampman.h" #if defined _MSC_VER && !defined RE3_NO_AUTOLINK #ifdef AUDIO_OAL_USE_SNDFILE @@ -22,6 +20,28 @@ #include #endif +#include +#include + +#ifdef MULTITHREADED_AUDIO +#include +#include +#include +#include +#include "MusicManager.h" +#include "stream.h" + +std::thread gAudioThread; +std::mutex gAudioThreadQueueMutex; +std::condition_variable gAudioThreadCv; +bool gAudioThreadTerm = false; +std::queue gStreamsToProcess; // values are not unique, we will handle that ourself +#else +#include "stream.h" +#endif + +#include "sampman.h" + #ifndef _WIN32 #include "crossplatform.h" #endif @@ -39,6 +59,10 @@ class CSortStereoBuffer { uint16* PcmBuf; size_t BufSize; +//#ifdef MULTITHREADED_AUDIO +// std::mutex Mutex; +//#endif + public: CSortStereoBuffer() : PcmBuf(nil), BufSize(0) {} ~CSortStereoBuffer() @@ -65,6 +89,9 @@ public: void SortStereo(void* buf, size_t size) { +//#ifdef MULTITHREADED_AUDIO +// std::lock_guard lock(Mutex); +//#endif uint16* InBuf = (uint16*)buf; uint16* OutBuf = GetBuffer(size); @@ -279,6 +306,10 @@ public: #undef CLOSE_ON_ERROR } + void FileOpen() + { + } + ~CWavFile() { Close(); @@ -289,6 +320,7 @@ public: return m_bIsOpen; } + uint32 GetSampleSize() { return sizeof(uint16); @@ -405,6 +437,10 @@ public: m_pfSound = sf_open(path, SFM_READ, &m_soundInfo); } + void FileOpen() + { + } + ~CSndFile() { if ( m_pfSound ) @@ -464,8 +500,6 @@ public: #endif #ifdef AUDIO_OAL_USE_MPG123 -// fuzzy seek eliminates stutter when playing ADF but spams errors a lot (nothing breaks though) -#define MP3_USE_FUZZY_SEEK class CMP3File : public IDecoder { @@ -473,37 +507,51 @@ class CMP3File : public IDecoder bool m_bOpened; uint32 m_nRate; uint32 m_nChannels; + const char* m_pPath; + bool m_bFileNotOpenedYet; public: CMP3File(const char *path) : m_pMH(nil), m_bOpened(false), m_nRate(0), - m_nChannels(0) + m_nChannels(0), + m_pPath(path), + m_bFileNotOpenedYet(false) { m_pMH = mpg123_new(nil, nil); if ( m_pMH ) { -#ifdef MP3_USE_FUZZY_SEEK - mpg123_param(m_pMH, MPG123_FLAGS, MPG123_FUZZY | MPG123_SEEKBUFFER | MPG123_GAPLESS | MPG123_QUIET, 0.0); -#endif - long rate = 0; - int channels = 0; - int encoding = 0; - - m_bOpened = mpg123_open(m_pMH, path) == MPG123_OK - && mpg123_getformat(m_pMH, &rate, &channels, &encoding) == MPG123_OK; + mpg123_param(m_pMH, MPG123_FLAGS, MPG123_SEEKBUFFER | MPG123_GAPLESS, 0.0); - m_nRate = rate; - m_nChannels = channels; - - if ( IsOpened() ) - { - mpg123_format_none(m_pMH); - mpg123_format(m_pMH, rate, channels, encoding); - } + m_bOpened = true; + m_bFileNotOpenedYet = true; + // It's possible to move this to audioFileOpsThread(), but effect isn't noticable + probably not compatible with our current cutscene audio handling +#if 1 + FileOpen(); +#endif } } + void FileOpen() + { + if(!m_bFileNotOpenedYet) return; + + long rate = 0; + int channels = 0; + int encoding = 0; + m_bOpened = mpg123_open(m_pMH, m_pPath) == MPG123_OK + && mpg123_getformat(m_pMH, &rate, &channels, &encoding) == MPG123_OK; + + m_nRate = rate; + m_nChannels = channels; + + if(IsOpened()) { + mpg123_format_none(m_pMH); + mpg123_format(m_pMH, rate, channels, encoding); + } + m_bFileNotOpenedYet = false; + } + ~CMP3File() { if ( m_pMH ) @@ -526,7 +574,7 @@ public: uint32 GetSampleCount() { - if ( !IsOpened() ) return 0; + if ( !IsOpened() || m_bFileNotOpenedYet ) return 0; return mpg123_length(m_pMH); } @@ -542,19 +590,19 @@ public: void Seek(uint32 milliseconds) { - if ( !IsOpened() ) return; + if ( !IsOpened() || m_bFileNotOpenedYet ) return; mpg123_seek(m_pMH, ms2samples(milliseconds), SEEK_SET); } uint32 Tell() { - if ( !IsOpened() ) return 0; + if ( !IsOpened() || m_bFileNotOpenedYet ) return 0; return samples2ms(mpg123_tell(m_pMH)); } uint32 Decode(void *buffer) { - if ( !IsOpened() ) return 0; + if ( !IsOpened() || m_bFileNotOpenedYet ) return 0; size_t size; int err = mpg123_read(m_pMH, (unsigned char *)buffer, GetBufferSize(), &size); @@ -685,6 +733,10 @@ public: m_ppVagBuffers[i] = new uint8[VB_BLOCK_SIZE]; } + void FileOpen() + { + } + ~CVbFile() { if (m_pFile) @@ -837,6 +889,10 @@ public: m_bOpened = true; } } + + void FileOpen() + { + } ~COpusFile() { @@ -902,11 +958,183 @@ public: }; #endif + +// For multi-thread: Someone always acquire stream's mutex before entering here +void +CStream::BuffersShouldBeFilled() +{ +#ifdef MULTITHREADED_AUDIO + if (MusicManager.m_nMusicMode != MUSICMODE_CUTSCENE) { + std::queue> tempQueue; + for(int i = 0; i < NUM_STREAMBUFFERS / 2; i++) { + tempQueue.push(std::pair(m_alBuffers[i * 2], m_alBuffers[i * 2 + 1])); + } + m_fillBuffers.swap(tempQueue); + + FlagAsToBeProcessed(); + + m_bActive = true; // to allow Update() to queue the filled buffers & play + return; + } + std::queue>().swap(m_fillBuffers); +#endif + if ( FillBuffers() != 0 ) + { + SetPlay(true); + } +} + +// returns whether it's queued (not on multi-thread) +bool +CStream::BufferShouldBeFilledAndQueued(std::pair* bufs) +{ +#ifdef MULTITHREADED_AUDIO + if (MusicManager.m_nMusicMode != MUSICMODE_CUTSCENE) + m_fillBuffers.push(*bufs); + else +#endif + { + ALuint alBuffers[2] = {(*bufs).first, (*bufs).second}; // left - right + if (FillBuffer(alBuffers)) { + alSourceQueueBuffers(m_pAlSources[0], 1, &alBuffers[0]); + alSourceQueueBuffers(m_pAlSources[1], 1, &alBuffers[1]); + return true; + } + } + return false; +} + +#ifdef MULTITHREADED_AUDIO +void +CStream::FlagAsToBeProcessed(bool close) +{ + if (!close && MusicManager.m_nMusicMode == MUSICMODE_CUTSCENE) + return; + + gAudioThreadQueueMutex.lock(); + gStreamsToProcess.push(this); + gAudioThreadQueueMutex.unlock(); + + gAudioThreadCv.notify_one(); +} + +extern CStream *aStream[]; +void audioFileOpsThread() +{ + std::queue m_streamsToDelete; + + do + { + CStream *stream; + { + // Just a semaphore + std::unique_lock queueMutex(gAudioThreadQueueMutex); + gAudioThreadCv.wait(queueMutex, [m_streamsToDelete] { return gStreamsToProcess.size() > 0 || m_streamsToDelete.size() > 0 || gAudioThreadTerm; }); + if (gAudioThreadTerm) + return; + + if (!gStreamsToProcess.empty()) { + stream = gStreamsToProcess.front(); + gStreamsToProcess.pop(); + } else { + // End of streams. Perform deleting streams + while(!m_streamsToDelete.empty()) { + CStream *stream = m_streamsToDelete.front(); + m_streamsToDelete.pop(); + if (stream->m_pSoundFile) { + delete stream->m_pSoundFile; + stream->m_pSoundFile = nil; + } + + if (stream->m_pBuffer) { + free(stream->m_pBuffer); + stream->m_pBuffer = nil; + } + delete stream; + } + continue; + } + } + + std::unique_lock lock(stream->m_mutex); + + std::pair buffers, *lastBufAddr; + bool insertBufsAfterCheck = false; + + do { + if (stream->m_nDeleteMe == 1) { + m_streamsToDelete.push(stream); + stream->m_nDeleteMe = 2; + break; + } else if (stream->m_nDeleteMe == 2) { + break; + } + + if (!stream->IsOpened()) + break; + + if (stream->m_bReset) + break; + + // We gave up this idea for now + /* + stream->m_pSoundFile->FileOpen(); + + // Deffered allocation, do it now + if (stream->m_pBuffer == nil) { + stream->m_pBuffer = malloc(stream->m_pSoundFile->GetBufferSize()); + ASSERT(stream->m_pBuffer != nil); + } + */ + + if (stream->m_bDoSeek) { + stream->m_bDoSeek = false; + int pos = stream->m_SeekPos; + lock.unlock(); + stream->m_pSoundFile->Seek(pos); + lock.lock(); + + continue; // let's do the checks again, make sure we didn't miss anything while Seeking + } + + if (insertBufsAfterCheck) { + stream->m_queueBuffers.push(buffers); + insertBufsAfterCheck = false; + } + + if (!stream->m_fillBuffers.empty()) { + lastBufAddr = &stream->m_fillBuffers.front(); + buffers = *lastBufAddr; + lock.unlock(); + + ALuint alBuffers[2] = {buffers.first, buffers.second}; // left - right + bool filled = stream->FillBuffer(alBuffers); + + lock.lock(); + + // Make sure queue isn't touched after we released mutex + if (!stream->m_fillBuffers.empty() && lastBufAddr == &stream->m_fillBuffers.front()) { + stream->m_fillBuffers.pop(); + if (filled) + insertBufsAfterCheck = true; // Also make sure stream's properties aren't changed. So make one more pass, and push it to m_queueBuffers only if it pass checks again. + } + } else + break; + + } while (true); + + } while(true); +} +#endif + void CStream::Initialise() { #ifdef AUDIO_OAL_USE_MPG123 mpg123_init(); #endif +#ifdef MULTITHREADED_AUDIO + gAudioThread = std::thread(audioFileOpsThread); +#endif } void CStream::Terminate() @@ -914,6 +1142,14 @@ void CStream::Terminate() #ifdef AUDIO_OAL_USE_MPG123 mpg123_exit(); #endif +#ifdef MULTITHREADED_AUDIO + gAudioThreadQueueMutex.lock(); + gAudioThreadTerm = true; + gAudioThreadQueueMutex.unlock(); + + gAudioThreadCv.notify_one(); + gAudioThread.join(); +#endif } CStream::CStream(char *filename, ALuint *sources, ALuint (&buffers)[NUM_STREAMBUFFERS], uint32 overrideSampleRate) : @@ -922,6 +1158,11 @@ CStream::CStream(char *filename, ALuint *sources, ALuint (&buffers)[NUM_STREAMBU m_pBuffer(nil), m_bPaused(false), m_bActive(false), +#ifdef MULTITHREADED_AUDIO + m_nDeleteMe(false), + m_bDoSeek(false), + m_SeekPos(0), +#endif m_pSoundFile(nil), m_bReset(false), m_nVolume(0), @@ -966,42 +1207,57 @@ CStream::CStream(char *filename, ALuint *sources, ALuint (&buffers)[NUM_STREAMBU if ( IsOpened() ) { - m_pBuffer = malloc(m_pSoundFile->GetBufferSize()); - ASSERT(m_pBuffer!=nil); - - DEV("AvgSamplesPerSec: %d\n", m_pSoundFile->GetAvgSamplesPerSec()); - DEV("SampleCount: %d\n", m_pSoundFile->GetSampleCount()); - DEV("SampleRate: %d\n", m_pSoundFile->GetSampleRate()); - DEV("Channels: %d\n", m_pSoundFile->GetChannels()); - DEV("Buffer Samples: %d\n", m_pSoundFile->GetBufferSamples()); - DEV("Buffer sec: %f\n", (float(m_pSoundFile->GetBufferSamples()) / float(m_pSoundFile->GetChannels())/ float(m_pSoundFile->GetSampleRate()))); - DEV("Length MS: %02d:%02d\n", (m_pSoundFile->GetLength() / 1000) / 60, (m_pSoundFile->GetLength() / 1000) % 60); - + uint32 bufSize = m_pSoundFile->GetBufferSize(); + if(bufSize != 0) { // Otherwise it's deferred + m_pBuffer = malloc(bufSize); + ASSERT(m_pBuffer != nil); + + DEV("AvgSamplesPerSec: %d\n", m_pSoundFile->GetAvgSamplesPerSec()); + DEV("SampleCount: %d\n", m_pSoundFile->GetSampleCount()); + DEV("SampleRate: %d\n", m_pSoundFile->GetSampleRate()); + DEV("Channels: %d\n", m_pSoundFile->GetChannels()); + DEV("Buffer Samples: %d\n", m_pSoundFile->GetBufferSamples()); + DEV("Buffer sec: %f\n", (float(m_pSoundFile->GetBufferSamples()) / float(m_pSoundFile->GetChannels())/ float(m_pSoundFile->GetSampleRate()))); + DEV("Length MS: %02d:%02d\n", (m_pSoundFile->GetLength() / 1000) / 60, (m_pSoundFile->GetLength() / 1000) % 60); + } return; } } CStream::~CStream() { - Delete(); + assert(!IsOpened()); } -void CStream::Delete() +void CStream::Close() { +#ifdef MULTITHREADED_AUDIO + { + std::lock_guard lock(m_mutex); + + Stop(); + ClearBuffers(); + m_nDeleteMe = true; + // clearing buffer queues are not needed. after m_nDeleteMe set, this stream is ded + } + + FlagAsToBeProcessed(true); +#else Stop(); ClearBuffers(); - + if ( m_pSoundFile ) { delete m_pSoundFile; m_pSoundFile = nil; } - + if ( m_pBuffer ) { free(m_pBuffer); m_pBuffer = nil; } +#endif } bool CStream::HasSource() @@ -1025,6 +1281,14 @@ bool CStream::IsPlaying() alGetSourcei(m_pAlSources[1], AL_SOURCE_STATE, &sourceState[1]); if (sourceState[0] == AL_PLAYING || sourceState[1] == AL_PLAYING) return true; + +#ifdef MULTITHREADED_AUDIO + std::lock_guard lock(m_mutex); + + // Streams are designed in such a way that m_fillBuffers and m_queueBuffers will be *always* filled if audio is playing, and mutex is acquired + if (!m_fillBuffers.empty() || !m_queueBuffers.emptyNts()) + return true; +#endif } return false; @@ -1099,8 +1363,24 @@ void CStream::SetPan(uint8 nPan) void CStream::SetPosMS(uint32 nPos) { if ( !IsOpened() ) return; - m_pSoundFile->Seek(nPos); + +#ifdef MULTITHREADED_AUDIO + std::lock_guard lock(m_mutex); + + std::queue>().swap(m_fillBuffers); + tsQueue>().swapNts(m_queueBuffers); // TSness not required, second thread always access it when stream mutex acquired + + if (MusicManager.m_nMusicMode != MUSICMODE_CUTSCENE) { + m_bDoSeek = true; + m_SeekPos = nPos; + } else +#endif + { + m_pSoundFile->Seek(nPos); + } ClearBuffers(); + + // adding to gStreamsToProcess not needed, someone always calls Start() / BuffersShouldBeFilled() after SetPosMS } uint32 CStream::GetPosMS() @@ -1108,10 +1388,16 @@ uint32 CStream::GetPosMS() if ( !HasSource() ) return 0; if ( !IsOpened() ) return 0; + // Deferred init causes division by zero + if (m_pSoundFile->GetChannels() == 0) + return 0; + ALint offset; //alGetSourcei(m_alSource, AL_SAMPLE_OFFSET, &offset); alGetSourcei(m_pAlSources[0], AL_BYTE_OFFSET, &offset); + //std::lock_guard lock(m_mutex); + return m_pSoundFile->Tell() - m_pSoundFile->samples2ms(m_pSoundFile->GetBufferSamples() * (NUM_STREAMBUFFERS/2-1)) / m_pSoundFile->GetChannels() + m_pSoundFile->samples2ms(offset/m_pSoundFile->GetSampleSize()) / m_pSoundFile->GetChannels(); @@ -1125,6 +1411,7 @@ uint32 CStream::GetLengthMS() bool CStream::FillBuffer(ALuint *alBuffer) { +#ifndef MULTITHREADED_AUDIO if ( !HasSource() ) return false; if ( !IsOpened() ) @@ -1133,7 +1420,8 @@ bool CStream::FillBuffer(ALuint *alBuffer) return false; if ( !(alBuffer[1] != AL_NONE && alIsBuffer(alBuffer[1])) ) return false; - +#endif + uint32 size = m_pSoundFile->Decode(m_pBuffer); if( size == 0 ) return false; @@ -1149,6 +1437,26 @@ bool CStream::FillBuffer(ALuint *alBuffer) return true; } +#ifdef MULTITHREADED_AUDIO +bool CStream::QueueBuffers() +{ + bool buffersQueued = false; + std::pair buffers; + while (m_queueBuffers.peekPop(&buffers)) // beware: m_queueBuffers is tsQueue + { + ALuint leftBuf = buffers.first; + ALuint rightBuf = buffers.second; + + alSourceQueueBuffers(m_pAlSources[0], 1, &leftBuf); + alSourceQueueBuffers(m_pAlSources[1], 1, &rightBuf); + + buffersQueued = true; + } + return buffersQueued; +} +#endif + +// Only used in single-threaded audio or cutscene audio int32 CStream::FillBuffers() { int32 i = 0; @@ -1178,17 +1486,33 @@ void CStream::ClearBuffers() alSourceUnqueueBuffers(m_pAlSources[1], 1, &value); } -bool CStream::Setup(bool imSureQueueIsEmpty) +bool CStream::Setup(bool imSureQueueIsEmpty, bool lock) { if ( IsOpened() ) { - alSourcei(m_pAlSources[0], AL_LOOPING, AL_FALSE); - alSourcei(m_pAlSources[1], AL_LOOPING, AL_FALSE); +#ifdef MULTITHREADED_AUDIO + if (lock) + m_mutex.lock(); +#endif + if (!imSureQueueIsEmpty) { - SetPlay(false); + Stop(); ClearBuffers(); } +#ifdef MULTITHREADED_AUDIO + if (MusicManager.m_nMusicMode == MUSICMODE_CUTSCENE) { + m_pSoundFile->Seek(0); + } else { + m_bDoSeek = true; + m_SeekPos = 0; + } + + if (lock) + m_mutex.unlock(); +#else m_pSoundFile->Seek(0); +#endif + //SetPosition(0.0f, 0.0f, 0.0f); SetPitch(1.0f); //SetPan(m_nPan); @@ -1241,8 +1565,12 @@ void CStream::SetPlay(bool state) void CStream::Start() { if ( !HasSource() ) return; - if ( FillBuffers() != 0 ) - SetPlay(true); + +#ifdef MULTITHREADED_AUDIO + std::lock_guard lock(m_mutex); + tsQueue>().swapNts(m_queueBuffers); // TSness not required, second thread always access it when stream mutex acquired +#endif + BuffersShouldBeFilled(); } void CStream::Stop() @@ -1264,9 +1592,23 @@ void CStream::Update() if ( !m_bPaused ) { - ALint totalBuffers[2] = { 0, 0 }; - ALint buffersProcessed[2] = { 0, 0 }; + bool buffersQueuedAndStarted = false; + bool buffersQueuedButNotStarted = false; +#ifdef MULTITHREADED_AUDIO + // Put it in here because we need totalBuffers after queueing to decide when to loop audio + if (m_bActive) + { + buffersQueuedAndStarted = QueueBuffers(); + if(buffersQueuedAndStarted) { + SetPlay(true); + } + } +#endif + + ALint totalBuffers[2] = {0, 0}; + ALint buffersProcessed[2] = {0, 0}; + // Relying a lot on left buffer states in here do @@ -1278,44 +1620,66 @@ void CStream::Update() alGetSourcei(m_pAlSources[1], AL_BUFFERS_QUEUED, &totalBuffers[1]); alGetSourcei(m_pAlSources[1], AL_BUFFERS_PROCESSED, &buffersProcessed[1]); } while (buffersProcessed[0] != buffersProcessed[1]); - + assert(buffersProcessed[0] == buffersProcessed[1]); // Correcting OpenAL concepts here: // AL_BUFFERS_QUEUED = Number of *all* buffers in queue, including processed, processing and pending // AL_BUFFERS_PROCESSED = Index of the buffer being processing right now. Buffers coming after that(have greater index) are pending buffers. // which means: totalBuffers[0] - buffersProcessed[0] = pending buffers - - bool buffersRefilled = false; - + // We should wait queue to be cleared to loop track, because position calculation relies on queue. if (m_nLoopCount != 1 && m_bActive && totalBuffers[0] == 0) { - Setup(true); - buffersRefilled = FillBuffers() != 0; - if (m_nLoopCount != 0) - m_nLoopCount--; +#ifdef MULTITHREADED_AUDIO + std::lock_guard lock(m_mutex); + + if (m_fillBuffers.empty() && m_queueBuffers.emptyNts()) // we already acquired stream mutex, which is enough for second thread. thus Nts variant +#endif + { + Setup(true, false); + BuffersShouldBeFilled(); // will also call SetPlay(true) + if (m_nLoopCount != 0) + m_nLoopCount--; + } } else { - while( buffersProcessed[0]-- ) + static std::queue> tempFillBuffer; + + while ( buffersProcessed[0]-- ) { ALuint buffer[2]; alSourceUnqueueBuffers(m_pAlSources[0], 1, &buffer[0]); alSourceUnqueueBuffers(m_pAlSources[1], 1, &buffer[1]); - - if (m_bActive && FillBuffer(buffer)) + + if (m_bActive) { - buffersRefilled = true; - alSourceQueueBuffers(m_pAlSources[0], 1, &buffer[0]); - alSourceQueueBuffers(m_pAlSources[1], 1, &buffer[1]); + tempFillBuffer.push(std::pair(buffer[0], buffer[1])); } } + + if (m_bActive && buffersProcessed[1]) + { +#ifdef MULTITHREADED_AUDIO + m_mutex.lock(); +#endif + while (!tempFillBuffer.empty()) { + auto elem = tempFillBuffer.front(); + tempFillBuffer.pop(); + buffersQueuedButNotStarted = BufferShouldBeFilledAndQueued(&elem); + } +#ifdef MULTITHREADED_AUDIO + m_mutex.unlock(); + FlagAsToBeProcessed(); +#endif + + } } - // Two reasons: 1-Source may be starved to audio and stopped itself, 2- We're already waiting it to starve and die for looping track! - if (m_bActive && (buffersRefilled || (totalBuffers[1] - buffersProcessed[1] != 0))) + // Source may be starved to audio and stopped itself + if (m_bActive && !buffersQueuedAndStarted && (buffersQueuedButNotStarted || (totalBuffers[1] - buffersProcessed[1] != 0))) SetPlay(true); } } @@ -1324,28 +1688,45 @@ void CStream::ProviderInit() { if ( m_bReset ) { - if ( Setup(true) ) + if ( Setup(true, false) ) // lock not needed, thread can't process streams with m_bReset set { SetPan(m_nPan); SetVolume(m_nVolume); SetLoopCount(m_nLoopCount); SetPosMS(m_nPosBeforeReset); - if (m_bActive) - FillBuffers(); - SetPlay(m_bActive); - if ( m_bPaused ) +#ifdef MULTITHREADED_AUDIO + std::unique_lock lock(m_mutex); +#endif + if(m_bActive) + BuffersShouldBeFilled(); + + if (m_bPaused) Pause(); + + m_bReset = false; + + } else { +#ifdef MULTITHREADED_AUDIO + std::unique_lock lock(m_mutex); +#endif + m_bReset = false; } - - m_bReset = false; } } void CStream::ProviderTerm() { +#ifdef MULTITHREADED_AUDIO + std::lock_guard lock(m_mutex); + + // unlike Close() we will reuse this stream, so clearing queues are important. + std::queue>().swap(m_fillBuffers); + tsQueue>().swapNts(m_queueBuffers); // stream mutex is already acquired, thus Nts variant +#endif m_bReset = true; m_nPosBeforeReset = GetPosMS(); - + + Stop(); ClearBuffers(); } diff --git a/src/audio/oal/stream.h b/src/audio/oal/stream.h index 9a2a2fbe..bdbf19e0 100644 --- a/src/audio/oal/stream.h +++ b/src/audio/oal/stream.h @@ -11,6 +11,7 @@ public: virtual ~IDecoder() { } virtual bool IsOpened() = 0; + virtual void FileOpen() = 0; virtual uint32 GetSampleSize() = 0; virtual uint32 GetSampleCount() = 0; @@ -48,12 +49,70 @@ public: uint32 GetLength() { + FileOpen(); // abort deferred init, we need length now - game has to cache audio file sizes return float(GetSampleCount()) * 1000.0f / float(GetSampleRate()); } virtual uint32 Decode(void *buffer) = 0; }; +#ifdef MULTITHREADED_AUDIO +template class tsQueue +{ +public: + tsQueue() : count(0) { } + + void push(const T &value) + { + std::lock_guard lock(m_mutex); + m_queue.push(value); + count++; + } + + bool peekPop(T *retVal) + { + std::lock_guard lock(m_mutex); + if (count == 0) + return false; + + *retVal = m_queue.front(); + m_queue.pop(); + count--; + return true; + } + + void swapNts(tsQueue &replaceWith) + { + m_queue.swap(replaceWith.m_queue); + replaceWith.count = count; + } + + /* + void swapTs(tsQueue &replaceWith) + { + std::lock_guard lock(m_mutex); + std::lock_guard lock2(replaceWith.m_mutex); + swapNts(replaceWith); + } + */ + + bool emptyNts() + { + return count == 0; + } + /* + bool emptyTs() + { + std::lock_guard lock(m_mutex); + return emptyNts(); + } + */ + + std::queue m_queue; + int count; + mutable std::mutex m_mutex; +}; +#endif class CStream { char m_aFilename[128]; @@ -63,6 +122,16 @@ class CStream bool m_bPaused; bool m_bActive; +public: +#ifdef MULTITHREADED_AUDIO + std::mutex m_mutex; + std::queue> m_fillBuffers; // left and right buffer + tsQueue> m_queueBuffers; + bool m_bDoSeek; + uint32 m_SeekPos; + uint8 m_nDeleteMe; // 1: add to delete list 2: already on delete list +#endif + void *m_pBuffer; bool m_bReset; @@ -72,7 +141,14 @@ class CStream int32 m_nLoopCount; IDecoder *m_pSoundFile; - + + void BuffersShouldBeFilled(); // all + bool BufferShouldBeFilledAndQueued(std::pair*); // two (left-right) +#ifdef MULTITHREADED_AUDIO + void FlagAsToBeProcessed(bool close = false); + bool QueueBuffers(); +#endif + bool HasSource(); void SetPosition(int i, float x, float y, float z); void SetPitch(float pitch); @@ -81,15 +157,15 @@ class CStream void SetPlay(bool state); bool FillBuffer(ALuint *alBuffer); - int32 FillBuffers(); + int32 FillBuffers(); void ClearBuffers(); -public: +//public: static void Initialise(); static void Terminate(); CStream(char *filename, ALuint *sources, ALuint (&buffers)[NUM_STREAMBUFFERS], uint32 overrideSampleRate = 32000); ~CStream(); - void Delete(); + void Close(); bool IsOpened(); bool IsPlaying(); @@ -100,12 +176,11 @@ public: uint32 GetPosMS(); uint32 GetLengthMS(); - bool Setup(bool imSureQueueIsEmpty = false); + bool Setup(bool imSureQueueIsEmpty = false, bool lock = true); void Start(); void Stop(); void Update(void); void SetLoopCount(int32); - void ProviderInit(); void ProviderTerm(); diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp index 7fb84965..d546acf2 100644 --- a/src/audio/sampman_oal.cpp +++ b/src/audio/sampman_oal.cpp @@ -34,6 +34,12 @@ #include "oal/oal_utils.h" #include "oal/aldlist.h" #include "oal/channel.h" + +#include +#ifdef MULTITHREADED_AUDIO +#include +#include +#endif #include "oal/stream.h" #include "AudioManager.h" @@ -520,7 +526,7 @@ _FindMP3s(void) if (aStream[0] && aStream[0]->IsOpened()) { total_ms = aStream[0]->GetLengthMS(); - delete aStream[0]; + aStream[0]->Close(); aStream[0] = NULL; OutputDebugString(fd.cFileName); @@ -578,7 +584,7 @@ _FindMP3s(void) if (aStream[0] && aStream[0]->IsOpened()) { total_ms = aStream[0]->GetLengthMS(); - delete aStream[0]; + aStream[0]->Close(); aStream[0] = NULL; pList->pNext = new tMP3Entry; @@ -732,6 +738,7 @@ cSampleManager::Initialise(void) return TRUE; EFXInit(); + CStream::Initialise(); { @@ -890,7 +897,7 @@ cSampleManager::Initialise(void) if(aStream[0] && aStream[0]->IsOpened()) { uint32 tatalms = aStream[0]->GetLengthMS(); - delete aStream[0]; + aStream[0]->Close(); aStream[0] = NULL; nStreamLength[i] = tatalms; @@ -939,7 +946,7 @@ cSampleManager::Initialise(void) nStreamPan[i] = 63; } } - + { _bSampmanInitialised = TRUE; @@ -1025,7 +1032,7 @@ cSampleManager::Terminate(void) CStream *stream = aStream[i]; if (stream) { - delete stream; + stream->Close(); aStream[i] = NULL; } } @@ -1607,7 +1614,7 @@ cSampleManager::PreloadStreamedFile(uint8 nFile, uint8 nStream) { if ( aStream[nStream] ) { - delete aStream[nStream]; + aStream[nStream]->Close(); aStream[nStream] = NULL; } @@ -1619,7 +1626,7 @@ cSampleManager::PreloadStreamedFile(uint8 nFile, uint8 nStream) aStream[nStream] = stream; if ( !stream->Setup() ) { - delete stream; + stream->Close(); aStream[nStream] = NULL; } } @@ -1666,7 +1673,7 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) if ( aStream[nStream] ) { - delete aStream[nStream]; + aStream[nStream]->Close(); aStream[nStream] = NULL; } if ( nFile == STREAMED_SOUND_RADIO_MP3_PLAYER ) @@ -1697,7 +1704,7 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) return TRUE; } else { - delete stream; + stream->Close(); aStream[nStream] = NULL; } return FALSE; @@ -1721,7 +1728,7 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) _bIsMp3Active = TRUE; return TRUE; } else { - delete aStream[nStream]; + aStream[nStream]->Close(); aStream[nStream] = NULL; } // fall through, start playing from another song @@ -1753,7 +1760,7 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) return TRUE; } else { - delete stream; + stream->Close(); aStream[nStream] = NULL; } return FALSE; @@ -1775,7 +1782,7 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) #endif return TRUE; } else { - delete aStream[nStream]; + aStream[nStream]->Close(); aStream[nStream] = NULL; } @@ -1800,7 +1807,7 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) return TRUE; } else { - delete stream; + stream->Close(); aStream[nStream] = NULL; } return FALSE; @@ -1815,7 +1822,7 @@ cSampleManager::StopStreamedFile(uint8 nStream) if ( stream ) { - delete stream; + stream->Close(); aStream[nStream] = NULL; if ( nStream == 0 ) -- cgit v1.2.3 From 5458632c405fd81e76e625ba9dfabe8831509d1b Mon Sep 17 00:00:00 2001 From: erorcun Date: Sat, 26 Jun 2021 23:59:40 +0300 Subject: Multi-threaded audio fixes --- src/audio/oal/stream.cpp | 93 ++++++++++++++++++++------------- src/audio/oal/stream.h | 7 ++- src/audio/sampman_oal.cpp | 129 +++++++++++++++++----------------------------- 3 files changed, 111 insertions(+), 118 deletions(-) (limited to 'src/audio') diff --git a/src/audio/oal/stream.cpp b/src/audio/oal/stream.cpp index 68847906..8b627e2a 100644 --- a/src/audio/oal/stream.cpp +++ b/src/audio/oal/stream.cpp @@ -1018,42 +1018,23 @@ CStream::FlagAsToBeProcessed(bool close) gAudioThreadCv.notify_one(); } -extern CStream *aStream[]; void audioFileOpsThread() { - std::queue m_streamsToDelete; - do { CStream *stream; { // Just a semaphore std::unique_lock queueMutex(gAudioThreadQueueMutex); - gAudioThreadCv.wait(queueMutex, [m_streamsToDelete] { return gStreamsToProcess.size() > 0 || m_streamsToDelete.size() > 0 || gAudioThreadTerm; }); + gAudioThreadCv.wait(queueMutex, [] { return gStreamsToProcess.size() > 0 || gAudioThreadTerm; }); if (gAudioThreadTerm) return; if (!gStreamsToProcess.empty()) { stream = gStreamsToProcess.front(); gStreamsToProcess.pop(); - } else { - // End of streams. Perform deleting streams - while(!m_streamsToDelete.empty()) { - CStream *stream = m_streamsToDelete.front(); - m_streamsToDelete.pop(); - if (stream->m_pSoundFile) { - delete stream->m_pSoundFile; - stream->m_pSoundFile = nil; - } - - if (stream->m_pBuffer) { - free(stream->m_pBuffer); - stream->m_pBuffer = nil; - } - delete stream; - } + } else continue; - } } std::unique_lock lock(stream->m_mutex); @@ -1062,16 +1043,21 @@ void audioFileOpsThread() bool insertBufsAfterCheck = false; do { - if (stream->m_nDeleteMe == 1) { - m_streamsToDelete.push(stream); - stream->m_nDeleteMe = 2; - break; - } else if (stream->m_nDeleteMe == 2) { - break; - } + if (!stream->IsOpened()) { + // We MUST do that here, because we release mutex for m_pSoundFile->Seek() and m_pSoundFile->Decode() since they're costly + if (stream->m_pSoundFile) { + delete stream->m_pSoundFile; + stream->m_pSoundFile = nil; + } - if (!stream->IsOpened()) + if (stream->m_pBuffer) { + free(stream->m_pBuffer); + stream->m_pBuffer = nil; + } + lock.unlock(); + stream->m_closeCv.notify_one(); break; + } if (stream->m_bReset) break; @@ -1152,14 +1138,14 @@ void CStream::Terminate() #endif } -CStream::CStream(char *filename, ALuint *sources, ALuint (&buffers)[NUM_STREAMBUFFERS], uint32 overrideSampleRate) : +CStream::CStream(ALuint *sources, ALuint (&buffers)[NUM_STREAMBUFFERS]) : m_pAlSources(sources), m_alBuffers(buffers), m_pBuffer(nil), m_bPaused(false), m_bActive(false), #ifdef MULTITHREADED_AUDIO - m_nDeleteMe(false), + m_bIExist(false), m_bDoSeek(false), m_SeekPos(0), #endif @@ -1171,6 +1157,31 @@ CStream::CStream(char *filename, ALuint *sources, ALuint (&buffers)[NUM_STREAMBU m_nLoopCount(1) { +} + +bool CStream::Open(const char* filename, uint32 overrideSampleRate) +{ + if (IsOpened()) return false; + +#ifdef MULTITHREADED_AUDIO + std::unique_lock lock(m_mutex); + + CStream *stream = this; + // Wait for thread to close old one. We can't close it here, because the thread might be running Decode() or Seek(), while mutex is released + m_closeCv.wait(lock, [this] { return m_pSoundFile == nil && m_pBuffer == nil; }); + + m_bDoSeek = false; + m_SeekPos = 0; +#endif + + m_bPaused = false; + m_bActive = false; + m_bReset = false; + m_nVolume = 0; + m_nPan = 0; + m_nPosBeforeReset = 0; + m_nLoopCount = 1; + // Be case-insensitive on linux (from https://github.com/OneSadCookie/fcaseopen/) #if !defined(_WIN32) char *real = casepath(filename); @@ -1205,7 +1216,7 @@ CStream::CStream(char *filename, ALuint *sources, ALuint (&buffers)[NUM_STREAMBU else m_pSoundFile = nil; - if ( IsOpened() ) + if ( m_pSoundFile && m_pSoundFile->IsOpened() ) { uint32 bufSize = m_pSoundFile->GetBufferSize(); if(bufSize != 0) { // Otherwise it's deferred @@ -1220,8 +1231,12 @@ CStream::CStream(char *filename, ALuint *sources, ALuint (&buffers)[NUM_STREAMBU DEV("Buffer sec: %f\n", (float(m_pSoundFile->GetBufferSamples()) / float(m_pSoundFile->GetChannels())/ float(m_pSoundFile->GetSampleRate()))); DEV("Length MS: %02d:%02d\n", (m_pSoundFile->GetLength() / 1000) / 60, (m_pSoundFile->GetLength() / 1000) % 60); } - return; +#ifdef MULTITHREADED_AUDIO + m_bIExist = true; +#endif + return true; } + return false; } CStream::~CStream() @@ -1231,18 +1246,21 @@ CStream::~CStream() void CStream::Close() { + if(!IsOpened()) return; + #ifdef MULTITHREADED_AUDIO { std::lock_guard lock(m_mutex); Stop(); ClearBuffers(); - m_nDeleteMe = true; - // clearing buffer queues are not needed. after m_nDeleteMe set, this stream is ded + m_bIExist = false; + // clearing buffer queues are not needed. after m_bIExist is cleared, this stream is ded } FlagAsToBeProcessed(true); #else + Stop(); ClearBuffers(); @@ -1265,9 +1283,14 @@ bool CStream::HasSource() return (m_pAlSources[0] != AL_NONE) && (m_pAlSources[1] != AL_NONE); } +// m_bIExist only written in main thread, thus mutex is not needed on main thread bool CStream::IsOpened() { +#ifdef MULTITHREADED_AUDIO + return m_bIExist; +#else return m_pSoundFile && m_pSoundFile->IsOpened(); +#endif } bool CStream::IsPlaying() diff --git a/src/audio/oal/stream.h b/src/audio/oal/stream.h index bdbf19e0..10b595c1 100644 --- a/src/audio/oal/stream.h +++ b/src/audio/oal/stream.h @@ -127,9 +127,10 @@ public: std::mutex m_mutex; std::queue> m_fillBuffers; // left and right buffer tsQueue> m_queueBuffers; + std::condition_variable m_closeCv; bool m_bDoSeek; uint32 m_SeekPos; - uint8 m_nDeleteMe; // 1: add to delete list 2: already on delete list + bool m_bIExist; #endif void *m_pBuffer; @@ -163,8 +164,10 @@ public: static void Initialise(); static void Terminate(); - CStream(char *filename, ALuint *sources, ALuint (&buffers)[NUM_STREAMBUFFERS], uint32 overrideSampleRate = 32000); + CStream(ALuint *sources, ALuint (&buffers)[NUM_STREAMBUFFERS]); ~CStream(); + void Delete(); + bool Open(const char *filename, uint32 overrideSampleRate = 32000); void Close(); bool IsOpened(); diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp index d546acf2..6c25cf79 100644 --- a/src/audio/sampman_oal.cpp +++ b/src/audio/sampman_oal.cpp @@ -39,6 +39,7 @@ #ifdef MULTITHREADED_AUDIO #include #include +#include #endif #include "oal/stream.h" @@ -521,14 +522,10 @@ _FindMP3s(void) continue; } } - aStream[0] = new CStream(filepath, ALStreamSources[0], ALStreamBuffers[0]); - - if (aStream[0] && aStream[0]->IsOpened()) + if (aStream[0] && aStream[0]->Open(filepath)) { total_ms = aStream[0]->GetLengthMS(); aStream[0]->Close(); - aStream[0] = NULL; - OutputDebugString(fd.cFileName); _pMP3List = new tMP3Entry; @@ -579,13 +576,10 @@ _FindMP3s(void) else bShortcut = FALSE; - aStream[0] = new CStream(filepath, ALStreamSources[0], ALStreamBuffers[0]); - - if (aStream[0] && aStream[0]->IsOpened()) + if (aStream[0] && aStream[0]->Open(filepath)) { total_ms = aStream[0]->GetLengthMS(); aStream[0]->Close(); - aStream[0] = NULL; pList->pNext = new tMP3Entry; @@ -739,6 +733,9 @@ cSampleManager::Initialise(void) EFXInit(); + for(int i = 0; i < MAX_STREAMS; i++) + aStream[i] = new CStream(ALStreamSources[i], ALStreamBuffers[i]); + CStream::Initialise(); { @@ -892,14 +889,12 @@ cSampleManager::Initialise(void) debug("Cannot load audio cache\n"); #endif - for(int32 i = 0; i < TOTAL_STREAMED_SOUNDS; i++) { - aStream[0] = new CStream(StreamedNameTable[i], ALStreamSources[0], ALStreamBuffers[0], IsThisTrackAt16KHz(i) ? 16000 : 32000); - - if(aStream[0] && aStream[0]->IsOpened()) { + for ( int32 i = 0; i < TOTAL_STREAMED_SOUNDS; i++ ) + { + if ( aStream[0] && aStream[0]->Open(StreamedNameTable[i], IsThisTrackAt16KHz(i) ? 16000 : 32000) ) + { uint32 tatalms = aStream[0]->GetLengthMS(); aStream[0]->Close(); - aStream[0] = NULL; - nStreamLength[i] = tatalms; } else USERERROR("Can't open '%s'\n", StreamedNameTable[i]); @@ -941,7 +936,8 @@ cSampleManager::Initialise(void) { for ( int32 i = 0; i < MAX_STREAMS; i++ ) { - aStream[i] = NULL; + aStream[i]->Close(); + nStreamVolume[i] = 100; nStreamPan[i] = 63; } @@ -1028,15 +1024,8 @@ void cSampleManager::Terminate(void) { for (int32 i = 0; i < MAX_STREAMS; i++) - { - CStream *stream = aStream[i]; - if (stream) - { - stream->Close(); - aStream[i] = NULL; - } - } - + aStream[i]->Close(); + for ( int32 i = 0; i < NUM_CHANNELS; i++ ) aChannel[i].Term(); @@ -1086,6 +1075,9 @@ cSampleManager::Terminate(void) CStream::Terminate(); + for(int32 i = 0; i < MAX_STREAMS; i++) + delete aStream[i]; + if ( nSampleBankMemoryStartAddress[SFX_BANK_0] != 0 ) { free((void *)nSampleBankMemoryStartAddress[SFX_BANK_0]); @@ -1612,22 +1604,16 @@ cSampleManager::PreloadStreamedFile(uint8 nFile, uint8 nStream) if ( nFile < TOTAL_STREAMED_SOUNDS ) { - if ( aStream[nStream] ) - { - aStream[nStream]->Close(); - aStream[nStream] = NULL; - } - + CStream *stream = aStream[nStream]; + + stream->Close(); + strcpy(filename, StreamedNameTable[nFile]); - CStream *stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000); - ASSERT(stream != NULL); - - aStream[nStream] = stream; + stream->Open(filename, IsThisTrackAt16KHz(nFile) ? 16000 : 32000); if ( !stream->Setup() ) { stream->Close(); - aStream[nStream] = NULL; } } } @@ -1639,7 +1625,7 @@ cSampleManager::PauseStream(bool8 nPauseFlag, uint8 nStream) CStream *stream = aStream[nStream]; - if ( stream ) + if ( stream->IsOpened() ) { stream->SetPause(nPauseFlag != FALSE); } @@ -1652,12 +1638,9 @@ cSampleManager::StartPreloadedStreamedFile(uint8 nStream) CStream *stream = aStream[nStream]; - if ( stream ) + if ( stream->IsOpened() ) { - if ( stream->IsOpened() ) - { - stream->Start(); - } + stream->Start(); } } @@ -1671,11 +1654,8 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) if ( nFile >= TOTAL_STREAMED_SOUNDS ) return FALSE; - if ( aStream[nStream] ) - { - aStream[nStream]->Close(); - aStream[nStream] = NULL; - } + aStream[nStream]->Close(); + if ( nFile == STREAMED_SOUND_RADIO_MP3_PLAYER ) { do @@ -1691,12 +1671,10 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) if(!_GetMP3PosFromStreamPos(&position, &e) && !e) { nFile = 0; strcpy(filename, StreamedNameTable[nFile]); - - CStream* stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000); - aStream[nStream] = stream; - - if (stream->Setup()) { + CStream *stream = aStream[nStream]; + stream->Open(filename, IsThisTrackAt16KHz(nFile) ? 16000 : 32000); + if ( stream->Setup() ) { if (position != 0) stream->SetPosMS(position); @@ -1705,18 +1683,17 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) return TRUE; } else { stream->Close(); - aStream[nStream] = NULL; } return FALSE; } else { - if ( e->pLinkPath != NULL ) - aStream[nStream] = new CStream(e->pLinkPath, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000); + if (e->pLinkPath != NULL) + aStream[nStream]->Open(e->pLinkPath, IsThisTrackAt16KHz(nFile) ? 16000 : 32000); else { strcpy(filename, _mp3DirectoryPath); strcat(filename, e->aFilename); - - aStream[nStream] = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream]); + + aStream[nStream]->Open(filename); } if (aStream[nStream]->Setup()) { @@ -1729,7 +1706,6 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) return TRUE; } else { aStream[nStream]->Close(); - aStream[nStream] = NULL; } // fall through, start playing from another song } @@ -1748,9 +1724,8 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) _bIsMp3Active = 0; strcpy(filename, StreamedNameTable[nFile]); - CStream* stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000); - - aStream[nStream] = stream; + CStream* stream = aStream[nStream]; + stream->Open(filename, IsThisTrackAt16KHz(nFile) ? 16000 : 32000); if (stream->Setup()) { if (position != 0) @@ -1761,18 +1736,16 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) return TRUE; } else { stream->Close(); - aStream[nStream] = NULL; } return FALSE; } } - if(mp3->pLinkPath != NULL) - aStream[nStream] = new CStream(mp3->pLinkPath, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000); + if (mp3->pLinkPath != NULL) + aStream[nStream]->Open(mp3->pLinkPath, IsThisTrackAt16KHz(nFile) ? 16000 : 32000); else { strcpy(filename, _mp3DirectoryPath); strcat(filename, mp3->aFilename); - - aStream[nStream] = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream]); + aStream[nStream]->Open(filename, IsThisTrackAt16KHz(nFile) ? 16000 : 32000); } if (aStream[nStream]->Setup()) { @@ -1783,7 +1756,6 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) return TRUE; } else { aStream[nStream]->Close(); - aStream[nStream] = NULL; } } @@ -1795,9 +1767,9 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) } strcpy(filename, StreamedNameTable[nFile]); - CStream *stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000); + CStream *stream = aStream[nStream]; - aStream[nStream] = stream; + aStream[nStream]->Open(filename, IsThisTrackAt16KHz(nFile) ? 16000 : 32000); if ( stream->Setup() ) { if (position != 0) @@ -1808,7 +1780,6 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) return TRUE; } else { stream->Close(); - aStream[nStream] = NULL; } return FALSE; } @@ -1820,14 +1791,10 @@ cSampleManager::StopStreamedFile(uint8 nStream) CStream *stream = aStream[nStream]; - if ( stream ) - { - stream->Close(); - aStream[nStream] = NULL; + stream->Close(); - if ( nStream == 0 ) - _bIsMp3Active = FALSE; - } + if ( nStream == 0 ) + _bIsMp3Active = FALSE; } int32 @@ -1837,7 +1804,7 @@ cSampleManager::GetStreamedFilePosition(uint8 nStream) CStream *stream = aStream[nStream]; - if ( stream ) + if ( stream->IsOpened() ) { if ( _bIsMp3Active ) { @@ -1875,7 +1842,7 @@ cSampleManager::SetStreamedVolumeAndPan(uint8 nVolume, uint8 nPan, uint8 nEffect CStream *stream = aStream[nStream]; - if ( stream ) + if ( stream->IsOpened() ) { if ( nEffectFlag ) stream->SetVolume(m_nEffectsFadeVolume*nVolume*m_nEffectsVolume >> 14); @@ -1901,7 +1868,7 @@ cSampleManager::IsStreamPlaying(uint8 nStream) CStream *stream = aStream[nStream]; - if ( stream ) + if ( stream->IsOpened() ) { if ( stream->IsPlaying() ) return TRUE; @@ -1917,7 +1884,7 @@ cSampleManager::Service(void) { CStream *stream = aStream[i]; - if ( stream ) + if ( stream->IsOpened() ) stream->Update(); } int refCount = CChannel::channelsThatNeedService; -- cgit v1.2.3 From db4ae18e5d7a582c01c759409ba909b24d640e40 Mon Sep 17 00:00:00 2001 From: erorcun Date: Sun, 27 Jun 2021 14:42:52 +0300 Subject: Remove waiting for stream closure in multi-thread audio --- src/audio/oal/stream.cpp | 40 +++++++++++++++++++++------------------- src/audio/oal/stream.h | 2 +- src/audio/sampman_oal.cpp | 1 + 3 files changed, 23 insertions(+), 20 deletions(-) (limited to 'src/audio') diff --git a/src/audio/oal/stream.cpp b/src/audio/oal/stream.cpp index 8b627e2a..0209202a 100644 --- a/src/audio/oal/stream.cpp +++ b/src/audio/oal/stream.cpp @@ -36,6 +36,7 @@ std::mutex gAudioThreadQueueMutex; std::condition_variable gAudioThreadCv; bool gAudioThreadTerm = false; std::queue gStreamsToProcess; // values are not unique, we will handle that ourself +std::queue> gStreamsToClose; #else #include "stream.h" #endif @@ -1012,7 +1013,11 @@ CStream::FlagAsToBeProcessed(bool close) return; gAudioThreadQueueMutex.lock(); - gStreamsToProcess.push(this); + if (close) + gStreamsToClose.push(std::pair(m_pSoundFile ? m_pSoundFile : nil, m_pBuffer ? m_pBuffer : nil)); + else + gStreamsToProcess.push(this); + gAudioThreadQueueMutex.unlock(); gAudioThreadCv.notify_one(); @@ -1026,10 +1031,22 @@ void audioFileOpsThread() { // Just a semaphore std::unique_lock queueMutex(gAudioThreadQueueMutex); - gAudioThreadCv.wait(queueMutex, [] { return gStreamsToProcess.size() > 0 || gAudioThreadTerm; }); + gAudioThreadCv.wait(queueMutex, [] { return gStreamsToProcess.size() > 0 || gStreamsToClose.size() > 0 || gAudioThreadTerm; }); if (gAudioThreadTerm) return; + if (!gStreamsToClose.empty()) { + auto streamToClose = gStreamsToClose.front(); + gStreamsToClose.pop(); + if (streamToClose.first) { // pSoundFile + delete streamToClose.first; + } + + if (streamToClose.second) { // pBuffer + free(streamToClose.second); + } + } + if (!gStreamsToProcess.empty()) { stream = gStreamsToProcess.front(); gStreamsToProcess.pop(); @@ -1044,18 +1061,6 @@ void audioFileOpsThread() do { if (!stream->IsOpened()) { - // We MUST do that here, because we release mutex for m_pSoundFile->Seek() and m_pSoundFile->Decode() since they're costly - if (stream->m_pSoundFile) { - delete stream->m_pSoundFile; - stream->m_pSoundFile = nil; - } - - if (stream->m_pBuffer) { - free(stream->m_pBuffer); - stream->m_pBuffer = nil; - } - lock.unlock(); - stream->m_closeCv.notify_one(); break; } @@ -1166,10 +1171,6 @@ bool CStream::Open(const char* filename, uint32 overrideSampleRate) #ifdef MULTITHREADED_AUDIO std::unique_lock lock(m_mutex); - CStream *stream = this; - // Wait for thread to close old one. We can't close it here, because the thread might be running Decode() or Seek(), while mutex is released - m_closeCv.wait(lock, [this] { return m_pSoundFile == nil && m_pBuffer == nil; }); - m_bDoSeek = false; m_SeekPos = 0; #endif @@ -1255,7 +1256,8 @@ void CStream::Close() Stop(); ClearBuffers(); m_bIExist = false; - // clearing buffer queues are not needed. after m_bIExist is cleared, this stream is ded + std::queue>().swap(m_fillBuffers); + tsQueue>().swapNts(m_queueBuffers); // TSness not required, mutex is acquired } FlagAsToBeProcessed(true); diff --git a/src/audio/oal/stream.h b/src/audio/oal/stream.h index 10b595c1..f0456925 100644 --- a/src/audio/oal/stream.h +++ b/src/audio/oal/stream.h @@ -127,7 +127,7 @@ public: std::mutex m_mutex; std::queue> m_fillBuffers; // left and right buffer tsQueue> m_queueBuffers; - std::condition_variable m_closeCv; +// std::condition_variable m_closeCv; bool m_bDoSeek; uint32 m_SeekPos; bool m_bIExist; diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp index 6c25cf79..b96df8c4 100644 --- a/src/audio/sampman_oal.cpp +++ b/src/audio/sampman_oal.cpp @@ -526,6 +526,7 @@ _FindMP3s(void) { total_ms = aStream[0]->GetLengthMS(); aStream[0]->Close(); + OutputDebugString(fd.cFileName); _pMP3List = new tMP3Entry; -- cgit v1.2.3 From d82dbf91efc022a27853decd109f58aa54ebc1ee Mon Sep 17 00:00:00 2001 From: erorcun Date: Sat, 10 Jul 2021 23:06:36 +0300 Subject: Merge/sync fixes after threaded audio --- src/audio/sampman_oal.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/audio') diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp index b96df8c4..fdd449f7 100644 --- a/src/audio/sampman_oal.cpp +++ b/src/audio/sampman_oal.cpp @@ -582,6 +582,8 @@ _FindMP3s(void) total_ms = aStream[0]->GetLengthMS(); aStream[0]->Close(); + OutputDebugString(fd.cFileName); + pList->pNext = new tMP3Entry; tMP3Entry *e = pList->pNext; -- cgit v1.2.3 From d7ceb4870c621dedc088cd4c8eccde63ad281230 Mon Sep 17 00:00:00 2001 From: withmorten Date: Sun, 11 Jul 2021 03:26:21 +0200 Subject: tiny diff fixes --- src/audio/oal/stream.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/audio') diff --git a/src/audio/oal/stream.cpp b/src/audio/oal/stream.cpp index 0209202a..6afe8e30 100644 --- a/src/audio/oal/stream.cpp +++ b/src/audio/oal/stream.cpp @@ -2,7 +2,7 @@ #ifdef AUDIO_OAL -#if defined _MSC_VER && !defined RE3_NO_AUTOLINK +#if defined _MSC_VER && !defined CMAKE_NO_AUTOLINK #ifdef AUDIO_OAL_USE_SNDFILE #pragma comment( lib, "libsndfile-1.lib" ) #endif @@ -504,6 +504,7 @@ public: class CMP3File : public IDecoder { +protected: mpg123_handle *m_pMH; bool m_bOpened; uint32 m_nRate; -- cgit v1.2.3 From 3194fdb2c18dbff4c24a3c901ec2d4b473e4ab30 Mon Sep 17 00:00:00 2001 From: withmorten Date: Sun, 11 Jul 2021 03:34:43 +0200 Subject: fix the fix (and another fix) --- src/audio/AudioManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/audio') diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index 2e391349..a113cc93 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -993,4 +993,4 @@ cAudioManager::ComputeEmittingVolume(uint8 emittingVolume, float intensity, floa return (quatIntensity - (dist - diffIntensity)) * (float)emittingVolume / quatIntensity; return emittingVolume; } -#endif \ No newline at end of file +#endif -- cgit v1.2.3 From 2ce36a48b92a21b88a59d08856751d9adc7a062f Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Wed, 14 Jul 2021 23:07:47 +0300 Subject: Make PS2 VB files work together with PC audio files --- src/audio/sampman.h | 110 ++++++++++++++++++++++++++++++++++-- src/audio/sampman_miles.cpp | 132 ++++++++++++++++++++++++++++++++++++-------- src/audio/sampman_oal.cpp | 39 +++++++------ 3 files changed, 237 insertions(+), 44 deletions(-) (limited to 'src/audio') diff --git a/src/audio/sampman.h b/src/audio/sampman.h index d1ad9a26..dc95622b 100644 --- a/src/audio/sampman.h +++ b/src/audio/sampman.h @@ -259,8 +259,8 @@ static char StreamedNameTable[][25] = { "AUDIO\\door_2.OPUS", "AUDIO\\door_3.OPUS", "AUDIO\\door_4.OPUS", "AUDIO\\door_5.OPUS", "AUDIO\\door_6.OPUS", "AUDIO\\t3_a.OPUS", "AUDIO\\t3_b.OPUS", "AUDIO\\t3_c.OPUS", "AUDIO\\k1_b.OPUS", "AUDIO\\cat1.OPUS"}; #else -#if defined(PS2_AUDIO_PATHS) -static char StreamedNameTable[][25]= +#ifdef PS2_AUDIO_PATHS +static char PS2StreamedNameTable[][25]= { "AUDIO\\MUSIC\\HEAD.VB", "AUDIO\\MUSIC\\CLASS.VB", @@ -357,7 +357,110 @@ static char StreamedNameTable[][25]= "AUDIO\\PHONE\\MT_PH4.VB", "AUDIO\\MUSIC\\MISCOM.VB", "AUDIO\\MUSIC\\END.VB", -#else + "AUDIO\\lib_a1.WAV", + "AUDIO\\lib_a2.WAV", + "AUDIO\\lib_a.WAV", + "AUDIO\\lib_b.WAV", + "AUDIO\\lib_c.WAV", + "AUDIO\\lib_d.WAV", + "AUDIO\\l2_a.WAV", + "AUDIO\\j4t_1.WAV", + "AUDIO\\j4t_2.WAV", + "AUDIO\\j4t_3.WAV", + "AUDIO\\j4t_4.WAV", + "AUDIO\\j4_a.WAV", + "AUDIO\\j4_b.WAV", + "AUDIO\\j4_c.WAV", + "AUDIO\\j4_d.WAV", + "AUDIO\\j4_e.WAV", + "AUDIO\\j4_f.WAV", + "AUDIO\\j6_1.WAV", + "AUDIO\\j6_a.WAV", + "AUDIO\\j6_b.WAV", + "AUDIO\\j6_c.WAV", + "AUDIO\\j6_d.WAV", + "AUDIO\\t4_a.WAV", + "AUDIO\\s1_a.WAV", + "AUDIO\\s1_a1.WAV", + "AUDIO\\s1_b.WAV", + "AUDIO\\s1_c.WAV", + "AUDIO\\s1_c1.WAV", + "AUDIO\\s1_d.WAV", + "AUDIO\\s1_e.WAV", + "AUDIO\\s1_f.WAV", + "AUDIO\\s1_g.WAV", + "AUDIO\\s1_h.WAV", + "AUDIO\\s1_i.WAV", + "AUDIO\\s1_j.WAV", + "AUDIO\\s1_k.WAV", + "AUDIO\\s1_l.WAV", + "AUDIO\\s3_a.WAV", + "AUDIO\\s3_b.WAV", + "AUDIO\\el3_a.WAV", + "AUDIO\\mf1_a.WAV", + "AUDIO\\mf2_a.WAV", + "AUDIO\\mf3_a.WAV", + "AUDIO\\mf3_b.WAV", + "AUDIO\\mf3_b1.WAV", + "AUDIO\\mf3_c.WAV", + "AUDIO\\mf4_a.WAV", + "AUDIO\\mf4_b.WAV", + "AUDIO\\mf4_c.WAV", + "AUDIO\\a1_a.WAV", + "AUDIO\\a3_a.WAV", + "AUDIO\\a5_a.WAV", + "AUDIO\\a4_a.WAV", + "AUDIO\\a4_b.WAV", + "AUDIO\\a4_c.WAV", + "AUDIO\\a4_d.WAV", + "AUDIO\\k1_a.WAV", + "AUDIO\\k3_a.WAV", + "AUDIO\\r1_a.WAV", + "AUDIO\\r2_a.WAV", + "AUDIO\\r2_b.WAV", + "AUDIO\\r2_c.WAV", + "AUDIO\\r2_d.WAV", + "AUDIO\\r2_e.WAV", + "AUDIO\\r2_f.WAV", + "AUDIO\\r2_g.WAV", + "AUDIO\\r2_h.WAV", + "AUDIO\\r5_a.WAV", + "AUDIO\\r6_a.WAV", + "AUDIO\\r6_a1.WAV", + "AUDIO\\r6_b.WAV", + "AUDIO\\lo2_a.WAV", + "AUDIO\\lo6_a.WAV", + "AUDIO\\yd2_a.WAV", + "AUDIO\\yd2_b.WAV", + "AUDIO\\yd2_c.WAV", + "AUDIO\\yd2_c1.WAV", + "AUDIO\\yd2_d.WAV", + "AUDIO\\yd2_e.WAV", + "AUDIO\\yd2_f.WAV", + "AUDIO\\yd2_g.WAV", + "AUDIO\\yd2_h.WAV", + "AUDIO\\yd2_ass.WAV", + "AUDIO\\yd2_ok.WAV", + "AUDIO\\h5_a.WAV", + "AUDIO\\h5_b.WAV", + "AUDIO\\h5_c.WAV", + "AUDIO\\ammu_a.WAV", + "AUDIO\\ammu_b.WAV", + "AUDIO\\ammu_c.WAV", + "AUDIO\\door_1.WAV", + "AUDIO\\door_2.WAV", + "AUDIO\\door_3.WAV", + "AUDIO\\door_4.WAV", + "AUDIO\\door_5.WAV", + "AUDIO\\door_6.WAV", + "AUDIO\\t3_a.WAV", + "AUDIO\\t3_b.WAV", + "AUDIO\\t3_c.WAV", + "AUDIO\\k1_b.WAV", + "AUDIO\\cat1.WAV" +}; +#endif + static char StreamedNameTable[][25] = { "AUDIO\\HEAD.WAV", @@ -455,7 +558,6 @@ static char StreamedNameTable[][25] = "AUDIO\\MT_PH4.MP3", "AUDIO\\MISCOM.WAV", "AUDIO\\END.MP3", -#endif "AUDIO\\lib_a1.WAV", "AUDIO\\lib_a2.WAV", "AUDIO\\lib_a.WAV", diff --git a/src/audio/sampman_miles.cpp b/src/audio/sampman_miles.cpp index e820864c..d529513d 100644 --- a/src/audio/sampman_miles.cpp +++ b/src/audio/sampman_miles.cpp @@ -992,11 +992,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 +1014,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 +1096,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 +1111,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); @@ -1299,9 +1333,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 +1345,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.GetRandomNumber(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.GetRandomNumber(1) % TOTAL_STREAMED_SOUNDS]); + f = fopen(filepath, "rb"); + } if ( f ) { fclose(f); @@ -2007,11 +2058,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 +2132,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 +2188,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 +2238,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); diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp index fdd449f7..2d9f9e86 100644 --- a/src/audio/sampman_oal.cpp +++ b/src/audio/sampman_oal.cpp @@ -894,7 +894,11 @@ cSampleManager::Initialise(void) for ( int32 i = 0; i < TOTAL_STREAMED_SOUNDS; i++ ) { - if ( aStream[0] && aStream[0]->Open(StreamedNameTable[i], IsThisTrackAt16KHz(i) ? 16000 : 32000) ) + 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))) { uint32 tatalms = aStream[0]->GetLengthMS(); aStream[0]->Close(); @@ -1601,8 +1605,6 @@ cSampleManager::StopChannel(uint32 nChannel) void cSampleManager::PreloadStreamedFile(uint8 nFile, uint8 nStream) { - char filename[MAX_PATH]; - ASSERT( nStream < MAX_STREAMS ); if ( nFile < TOTAL_STREAMED_SOUNDS ) @@ -1611,9 +1613,10 @@ cSampleManager::PreloadStreamedFile(uint8 nFile, uint8 nStream) stream->Close(); - strcpy(filename, StreamedNameTable[nFile]); - - 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 ( !stream->Setup() ) { stream->Close(); @@ -1673,10 +1676,11 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) // Try to continue from previous song, if already started if(!_GetMP3PosFromStreamPos(&position, &e) && !e) { nFile = 0; - strcpy(filename, StreamedNameTable[nFile]); - CStream *stream = aStream[nStream]; - 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 ( stream->Setup() ) { if (position != 0) stream->SetPosMS(position); @@ -1725,10 +1729,11 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) { nFile = 0; _bIsMp3Active = 0; - strcpy(filename, StreamedNameTable[nFile]); - - CStream* stream = aStream[nStream]; - stream->Open(filename, IsThisTrackAt16KHz(nFile) ? 16000 : 32000); + 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()) { if (position != 0) @@ -1768,11 +1773,11 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) position = 0; nFile = 0; } - strcpy(filename, StreamedNameTable[nFile]); - CStream *stream = aStream[nStream]; - - aStream[nStream]->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 ( stream->Setup() ) { if (position != 0) -- cgit v1.2.3 From a064b3a687b6ba4b112eaf1e69738b27358baabf Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Mon, 26 Jul 2021 04:18:41 +0300 Subject: Audio changes: - Reorder AudioCollision.cpp functions into original order - Add missing cAudioCollision::Reset() - Move cAudioCollision ctor into .h (like original) - Fix argument types for ped comment functions and more - Fix wrong names of ped comment functions - Fix incorrect ped comments - Remove getters - Reorder declarations of cAudioManager - Wrap PC only functions around ifdef - Add cAudioManager methods from PS2 and mobile --- src/audio/AudioCollision.cpp | 409 +++++++++++++------------- src/audio/AudioCollision.h | 23 +- src/audio/AudioLogic.cpp | 663 +++++++++++++++++++++---------------------- src/audio/AudioManager.cpp | 64 +++-- src/audio/AudioManager.h | 507 +++++++++++++++++---------------- src/audio/MusicManager.cpp | 20 +- src/audio/PolRadio.cpp | 6 +- src/audio/sampman_miles.cpp | 18 +- src/audio/sampman_oal.cpp | 12 +- 9 files changed, 873 insertions(+), 849 deletions(-) (limited to 'src/audio') diff --git a/src/audio/AudioCollision.cpp b/src/audio/AudioCollision.cpp index fd819641..cfd13fb6 100644 --- a/src/audio/AudioCollision.cpp +++ b/src/audio/AudioCollision.cpp @@ -10,20 +10,39 @@ const int CollisionSoundIntensity = 60; -cAudioCollisionManager::cAudioCollisionManager() +void +cAudioManager::ReportCollision(CEntity *entity1, CEntity *entity2, uint8 surface1, uint8 surface2, float collisionPower, + float velocity) { - m_sQueue.m_pEntity1 = nil; - m_sQueue.m_pEntity2 = nil; - m_sQueue.m_bSurface1 = SURFACE_DEFAULT; - m_sQueue.m_bSurface2 = SURFACE_DEFAULT; - m_sQueue.m_fIntensity2 = 0.0f; - m_sQueue.m_fIntensity1 = 0.0f; - m_sQueue.m_vecPosition = CVector(0.0f, 0.0f, 0.0f); + float distSquared; + CVector v1; + CVector v2; - for (int i = 0; i < NUMAUDIOCOLLISIONS; i++) - m_bIndicesTable[i] = NUMAUDIOCOLLISIONS; + if(!m_bIsInitialised || m_nCollisionEntity < 0 || m_nUserPause || + (velocity < 0.0016f && collisionPower < 0.01f)) + return; - m_bCollisionsInQueue = 0; + if(entity1->IsBuilding()) { + v1 = v2 = entity2->GetPosition(); + } else if(entity2->IsBuilding()) { + v1 = v2 = entity1->GetPosition(); + } else { + v1 = entity1->GetPosition(); + v2 = entity2->GetPosition(); + } + CVector pos = (v1 + v2) * 0.5f; + distSquared = GetDistanceSquared(pos); + if(distSquared < SQR(CollisionSoundIntensity)) { + m_sCollisionManager.m_sQueue.m_pEntity1 = entity1; + m_sCollisionManager.m_sQueue.m_pEntity2 = entity2; + m_sCollisionManager.m_sQueue.m_bSurface1 = surface1; + m_sCollisionManager.m_sQueue.m_bSurface2 = surface2; + m_sCollisionManager.m_sQueue.m_fIntensity1 = collisionPower; + m_sCollisionManager.m_sQueue.m_fIntensity2 = velocity; + m_sCollisionManager.m_sQueue.m_vecPosition = pos; + m_sCollisionManager.m_sQueue.m_fDistance = distSquared; + m_sCollisionManager.AddCollisionToRequestedQueue(); + } } void @@ -55,133 +74,71 @@ cAudioCollisionManager::AddCollisionToRequestedQueue() m_bIndicesTable[i] = collisionsIndex; } -float -cAudioManager::GetCollisionLoopingRatio(uint32 a, uint32 b, float c) const -{ - return GetCollisionRatio(c, 0.0f, 0.02f, 0.02f); -} - -float -cAudioManager::GetCollisionOneShotRatio(int32 a, float b) const +void +cAudioManager::ServiceCollisions() { - float result; - - switch(a) { - case SURFACE_DEFAULT: - case SURFACE_TARMAC: - case SURFACE_PAVEMENT: - case SURFACE_STEEP_CLIFF: - case SURFACE_TRANSPARENT_STONE: result = GetCollisionRatio(b, 10.f, 60.f, 50.f); break; - case SURFACE_GRASS: - case SURFACE_CARDBOARDBOX: result = GetCollisionRatio(b, 0.f, 2.f, 2.f); break; - case SURFACE_GRAVEL: result = GetCollisionRatio(b, 0.f, 2.f, 2.f); break; - case SURFACE_MUD_DRY: result = GetCollisionRatio(b, 0.f, 2.f, 2.f); break; - case SURFACE_CAR: result = GetCollisionRatio(b, 6.f, 50.f, 44.f); break; - case SURFACE_GLASS: result = GetCollisionRatio(b, 0.1f, 10.f, 9.9f); break; - case SURFACE_TRANSPARENT_CLOTH: - case SURFACE_THICK_METAL_PLATE: result = GetCollisionRatio(b, 30.f, 130.f, 100.f); break; - case SURFACE_GARAGE_DOOR: result = GetCollisionRatio(b, 20.f, 100.f, 80.f); break; - case SURFACE_CAR_PANEL: result = GetCollisionRatio(b, 0.f, 4.f, 4.f); break; - case SURFACE_SCAFFOLD_POLE: - case SURFACE_METAL_GATE: result = GetCollisionRatio(b, 1.f, 10.f, 9.f); break; - case SURFACE_LAMP_POST: result = GetCollisionRatio(b, 1.f, 10.f, 9.f); break; - case SURFACE_FIRE_HYDRANT: result = GetCollisionRatio(b, 1.f, 15.f, 14.f); break; - case SURFACE_GIRDER: result = GetCollisionRatio(b, 8.f, 50.f, 42.f); break; - case SURFACE_METAL_CHAIN_FENCE: result = GetCollisionRatio(b, 0.1f, 10.f, 9.9f); break; - case SURFACE_PED: result = GetCollisionRatio(b, 0.f, 20.f, 20.f); break; - case SURFACE_SAND: result = GetCollisionRatio(b, 0.f, 10.f, 10.f); break; - case SURFACE_WATER: result = GetCollisionRatio(b, 0.f, 10.f, 10.f); break; - case SURFACE_WOOD_CRATES: result = GetCollisionRatio(b, 1.f, 4.f, 3.f); break; - case SURFACE_WOOD_BENCH: result = GetCollisionRatio(b, 0.1f, 5.f, 4.9f); break; - case SURFACE_WOOD_SOLID: result = GetCollisionRatio(b, 0.1f, 40.f, 39.9f); break; - case SURFACE_RUBBER: - case SURFACE_WHEELBASE: result = GetCollisionRatio(b, 0.f, 10.f, 10.f); break; - case SURFACE_PLASTIC: result = GetCollisionRatio(b, 0.1f, 4.f, 3.9f); break; - case SURFACE_HEDGE: result = GetCollisionRatio(b, 0.f, 0.5f, 0.5f); break; - case SURFACE_CONTAINER: result = GetCollisionRatio(b, 4.f, 40.f, 36.f); break; - case SURFACE_NEWS_VENDOR: result = GetCollisionRatio(b, 0.f, 5.f, 5.f); break; - default: result = 0.f; break; - } + int i, j; + bool8 abRepeatedCollision1[NUMAUDIOCOLLISIONS]; + bool8 abRepeatedCollision2[NUMAUDIOCOLLISIONS]; - return result; -} + m_sQueueSample.m_nEntityIndex = m_nCollisionEntity; -float -cAudioManager::GetCollisionRatio(float a, float b, float c, float d) const -{ - float e; - e = a; - if(a <= b) return 0.0f; - if(c <= a) e = c; - return (e - b) / d; -} + for (int i = 0; i < NUMAUDIOCOLLISIONS; i++) + abRepeatedCollision1[i] = abRepeatedCollision2[i] = FALSE; -uint32 -cAudioManager::SetLoopingCollisionRequestedSfxFreqAndGetVol(const cAudioCollision &audioCollision) -{ - uint8 surface1 = audioCollision.m_bSurface1; - uint8 surface2 = audioCollision.m_bSurface2; - int32 vol; - float ratio; + for (i = 0; i < m_sCollisionManager.m_bCollisionsInQueue; i++) { + for (j = 0; j < NUMAUDIOCOLLISIONS; j++) { + int index = m_sCollisionManager.m_bIndicesTable[i]; + if ((m_sCollisionManager.m_asCollisions1[index].m_pEntity1 == m_sCollisionManager.m_asCollisions2[j].m_pEntity1) + && (m_sCollisionManager.m_asCollisions1[index].m_pEntity2 == m_sCollisionManager.m_asCollisions2[j].m_pEntity2) + && (m_sCollisionManager.m_asCollisions1[index].m_bSurface1 == m_sCollisionManager.m_asCollisions2[j].m_bSurface1) + && (m_sCollisionManager.m_asCollisions1[index].m_bSurface2 == m_sCollisionManager.m_asCollisions2[j].m_bSurface2) + ) { + abRepeatedCollision1[index] = TRUE; + abRepeatedCollision2[j] = TRUE; + m_sCollisionManager.m_asCollisions1[index].m_nBaseVolume = ++m_sCollisionManager.m_asCollisions2[j].m_nBaseVolume; + SetUpLoopingCollisionSound(m_sCollisionManager.m_asCollisions1[index], j); + break; + } + } + } - if(surface1 == SURFACE_GRASS || surface2 == SURFACE_GRASS || surface1 == SURFACE_HEDGE || - surface2 == SURFACE_HEDGE) { - ratio = GetCollisionRatio(audioCollision.m_fIntensity2, 0.0001f, 0.09f, 0.0899f); - m_sQueueSample.m_nSampleIndex = SFX_RAIN; - m_sQueueSample.m_nFrequency = 13000.f * ratio + 35000; - vol = 50.f * ratio; - } else if(surface1 == SURFACE_WATER || surface2 == SURFACE_WATER) { - ratio = GetCollisionRatio(audioCollision.m_fIntensity2, 0.0001f, 0.09f, 0.0899f); - m_sQueueSample.m_nSampleIndex = SFX_BOAT_WATER_LOOP; - m_sQueueSample.m_nFrequency = 6050.f * ratio + 16000; - vol = 30.f * ratio; - } else if(surface1 == SURFACE_GRAVEL || surface2 == SURFACE_GRAVEL || surface1 == SURFACE_MUD_DRY || - surface2 == SURFACE_MUD_DRY || surface1 == SURFACE_SAND || surface2 == SURFACE_SAND) { - ratio = GetCollisionRatio(audioCollision.m_fIntensity2, 0.0001f, 0.09f, 0.0899f); - m_sQueueSample.m_nSampleIndex = SFX_GRAVEL_SKID; - m_sQueueSample.m_nFrequency = 6000.f * ratio + 10000; - vol = 50.f * ratio; - } else if(surface1 == SURFACE_PED || surface2 == SURFACE_PED) { - return 0; - } else { - ratio = GetCollisionRatio(audioCollision.m_fIntensity2, 0.0001f, 0.09f, 0.0899f); - m_sQueueSample.m_nSampleIndex = SFX_SCRAPE_CAR_1; - m_sQueueSample.m_nFrequency = 10000.f * ratio + 10000; - vol = 40.f * ratio; + for (i = 0; i < NUMAUDIOCOLLISIONS; i++) { + if (!abRepeatedCollision2[i]) { + m_sCollisionManager.m_asCollisions2[i].m_pEntity1 = nil; + m_sCollisionManager.m_asCollisions2[i].m_pEntity2 = nil; + m_sCollisionManager.m_asCollisions2[i].m_bSurface1 = SURFACE_DEFAULT; + m_sCollisionManager.m_asCollisions2[i].m_bSurface2 = SURFACE_DEFAULT; + m_sCollisionManager.m_asCollisions2[i].m_fIntensity2 = 0.0f; + m_sCollisionManager.m_asCollisions2[i].m_fIntensity1 = 0.0f; + m_sCollisionManager.m_asCollisions2[i].m_vecPosition = CVector(0.0f, 0.0f, 0.0f); + m_sCollisionManager.m_asCollisions2[i].m_fDistance = 0.0f; + } } - if(audioCollision.m_nBaseVolume < 2) vol = audioCollision.m_nBaseVolume * vol / 2; - return vol; -} -void -cAudioManager::SetUpLoopingCollisionSound(const cAudioCollision &col, uint8 counter) -{ - if(col.m_fIntensity2 > 0.0016f) { - uint8 emittingVol = SetLoopingCollisionRequestedSfxFreqAndGetVol(col); - if(emittingVol) { - m_sQueueSample.m_fDistance = Sqrt(col.m_fDistance); - m_sQueueSample.m_nVolume = - ComputeVolume(emittingVol, CollisionSoundIntensity, m_sQueueSample.m_fDistance); - if(m_sQueueSample.m_nVolume) { - m_sQueueSample.m_nCounter = counter; - m_sQueueSample.m_vecPos = col.m_vecPosition; - m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = FALSE; - m_sQueueSample.m_nReleasingVolumeModificator = 7; - m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = emittingVol; - SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_fSpeedMultiplier = 4.0f; - m_sQueueSample.m_fSoundIntensity = CollisionSoundIntensity; - m_sQueueSample.m_bReleasingSoundFlag = FALSE; - m_sQueueSample.m_nReleasingVolumeDivider = 5; - m_sQueueSample.m_bReverbFlag = TRUE; - m_sQueueSample.m_bRequireReflection = FALSE; - AddSampleToRequestedQueue(); + for (i = 0; i < m_sCollisionManager.m_bCollisionsInQueue; i++) { + int index = m_sCollisionManager.m_bIndicesTable[i]; + if (!abRepeatedCollision1[index]) { + for (j = 0; j < NUMAUDIOCOLLISIONS; j++) { + if (!abRepeatedCollision2[j]) { + m_sCollisionManager.m_asCollisions2[j].m_nBaseVolume = 1; + m_sCollisionManager.m_asCollisions2[j].m_pEntity1 = m_sCollisionManager.m_asCollisions1[index].m_pEntity1; + m_sCollisionManager.m_asCollisions2[j].m_pEntity2 = m_sCollisionManager.m_asCollisions1[index].m_pEntity2; + m_sCollisionManager.m_asCollisions2[j].m_bSurface1 = m_sCollisionManager.m_asCollisions1[index].m_bSurface1; + m_sCollisionManager.m_asCollisions2[j].m_bSurface2 = m_sCollisionManager.m_asCollisions1[index].m_bSurface2; + break; + } } + SetUpOneShotCollisionSound(m_sCollisionManager.m_asCollisions1[index]); + SetUpLoopingCollisionSound(m_sCollisionManager.m_asCollisions1[index], j); } } + + for (int i = 0; i < NUMAUDIOCOLLISIONS; i++) + m_sCollisionManager.m_bIndicesTable[i] = NUMAUDIOCOLLISIONS; + m_sCollisionManager.m_bCollisionsInQueue = 0; } + static const int32 gOneShotCol[] = {SFX_COL_TARMAC_1, SFX_COL_TARMAC_1, SFX_COL_GRASS_1, @@ -219,9 +176,8 @@ static const int32 gOneShotCol[] = {SFX_COL_TARMAC_1, void cAudioManager::SetUpOneShotCollisionSound(const cAudioCollision &col) { - - int16 s1; - int16 s2; + uint16 s1; + uint16 s2; int32 emittingVol; float ratio; @@ -321,101 +277,126 @@ cAudioManager::SetUpOneShotCollisionSound(const cAudioCollision &col) } void -cAudioManager::ServiceCollisions() +cAudioManager::SetUpLoopingCollisionSound(const cAudioCollision &col, uint8 counter) { - int i, j; - bool8 abRepeatedCollision1[NUMAUDIOCOLLISIONS]; - bool8 abRepeatedCollision2[NUMAUDIOCOLLISIONS]; - - m_sQueueSample.m_nEntityIndex = m_nCollisionEntity; - - for (int i = 0; i < NUMAUDIOCOLLISIONS; i++) - abRepeatedCollision1[i] = abRepeatedCollision2[i] = FALSE; - - for (i = 0; i < m_sCollisionManager.m_bCollisionsInQueue; i++) { - for (j = 0; j < NUMAUDIOCOLLISIONS; j++) { - int index = m_sCollisionManager.m_bIndicesTable[i]; - if ((m_sCollisionManager.m_asCollisions1[index].m_pEntity1 == m_sCollisionManager.m_asCollisions2[j].m_pEntity1) - && (m_sCollisionManager.m_asCollisions1[index].m_pEntity2 == m_sCollisionManager.m_asCollisions2[j].m_pEntity2) - && (m_sCollisionManager.m_asCollisions1[index].m_bSurface1 == m_sCollisionManager.m_asCollisions2[j].m_bSurface1) - && (m_sCollisionManager.m_asCollisions1[index].m_bSurface2 == m_sCollisionManager.m_asCollisions2[j].m_bSurface2) - ) { - abRepeatedCollision1[index] = TRUE; - abRepeatedCollision2[j] = TRUE; - m_sCollisionManager.m_asCollisions1[index].m_nBaseVolume = ++m_sCollisionManager.m_asCollisions2[j].m_nBaseVolume; - SetUpLoopingCollisionSound(m_sCollisionManager.m_asCollisions1[index], j); - break; + if(col.m_fIntensity2 > 0.0016f) { + uint8 emittingVol = SetLoopingCollisionRequestedSfxFreqAndGetVol(col); + if(emittingVol) { + m_sQueueSample.m_fDistance = Sqrt(col.m_fDistance); + m_sQueueSample.m_nVolume = + ComputeVolume(emittingVol, CollisionSoundIntensity, m_sQueueSample.m_fDistance); + if(m_sQueueSample.m_nVolume) { + m_sQueueSample.m_nCounter = counter; + m_sQueueSample.m_vecPos = col.m_vecPosition; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_bIs2D = FALSE; + m_sQueueSample.m_nReleasingVolumeModificator = 7; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = emittingVol; + SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_fSpeedMultiplier = 4.0f; + m_sQueueSample.m_fSoundIntensity = CollisionSoundIntensity; + m_sQueueSample.m_bReleasingSoundFlag = FALSE; + m_sQueueSample.m_nReleasingVolumeDivider = 5; + m_sQueueSample.m_bReverbFlag = TRUE; + m_sQueueSample.m_bRequireReflection = FALSE; + AddSampleToRequestedQueue(); } } } +} - for (i = 0; i < NUMAUDIOCOLLISIONS; i++) { - if (!abRepeatedCollision2[i]) { - m_sCollisionManager.m_asCollisions2[i].m_pEntity1 = nil; - m_sCollisionManager.m_asCollisions2[i].m_pEntity2 = nil; - m_sCollisionManager.m_asCollisions2[i].m_bSurface1 = SURFACE_DEFAULT; - m_sCollisionManager.m_asCollisions2[i].m_bSurface2 = SURFACE_DEFAULT; - m_sCollisionManager.m_asCollisions2[i].m_fIntensity2 = 0.0f; - m_sCollisionManager.m_asCollisions2[i].m_fIntensity1 = 0.0f; - m_sCollisionManager.m_asCollisions2[i].m_vecPosition = CVector(0.0f, 0.0f, 0.0f); - m_sCollisionManager.m_asCollisions2[i].m_fDistance = 0.0f; - } +uint32 +cAudioManager::SetLoopingCollisionRequestedSfxFreqAndGetVol(const cAudioCollision &audioCollision) +{ + uint8 surface1 = audioCollision.m_bSurface1; + uint8 surface2 = audioCollision.m_bSurface2; + int32 vol; + float ratio; + + if(surface1 == SURFACE_GRASS || surface2 == SURFACE_GRASS || surface1 == SURFACE_HEDGE || + surface2 == SURFACE_HEDGE) { + ratio = GetCollisionRatio(audioCollision.m_fIntensity2, 0.0001f, 0.09f, 0.0899f); + m_sQueueSample.m_nSampleIndex = SFX_RAIN; + m_sQueueSample.m_nFrequency = 13000.f * ratio + 35000; + vol = 50.f * ratio; + } else if(surface1 == SURFACE_WATER || surface2 == SURFACE_WATER) { + ratio = GetCollisionRatio(audioCollision.m_fIntensity2, 0.0001f, 0.09f, 0.0899f); + m_sQueueSample.m_nSampleIndex = SFX_BOAT_WATER_LOOP; + m_sQueueSample.m_nFrequency = 6050.f * ratio + 16000; + vol = 30.f * ratio; + } else if(surface1 == SURFACE_GRAVEL || surface2 == SURFACE_GRAVEL || surface1 == SURFACE_MUD_DRY || + surface2 == SURFACE_MUD_DRY || surface1 == SURFACE_SAND || surface2 == SURFACE_SAND) { + ratio = GetCollisionRatio(audioCollision.m_fIntensity2, 0.0001f, 0.09f, 0.0899f); + m_sQueueSample.m_nSampleIndex = SFX_GRAVEL_SKID; + m_sQueueSample.m_nFrequency = 6000.f * ratio + 10000; + vol = 50.f * ratio; + } else if(surface1 == SURFACE_PED || surface2 == SURFACE_PED) { + return 0; + } else { + ratio = GetCollisionRatio(audioCollision.m_fIntensity2, 0.0001f, 0.09f, 0.0899f); + m_sQueueSample.m_nSampleIndex = SFX_SCRAPE_CAR_1; + m_sQueueSample.m_nFrequency = 10000.f * ratio + 10000; + vol = 40.f * ratio; } + if(audioCollision.m_nBaseVolume < 2) vol = audioCollision.m_nBaseVolume * vol / 2; + return vol; +} - for (i = 0; i < m_sCollisionManager.m_bCollisionsInQueue; i++) { - int index = m_sCollisionManager.m_bIndicesTable[i]; - if (!abRepeatedCollision1[index]) { - for (j = 0; j < NUMAUDIOCOLLISIONS; j++) { - if (!abRepeatedCollision2[j]) { - m_sCollisionManager.m_asCollisions2[j].m_nBaseVolume = 1; - m_sCollisionManager.m_asCollisions2[j].m_pEntity1 = m_sCollisionManager.m_asCollisions1[index].m_pEntity1; - m_sCollisionManager.m_asCollisions2[j].m_pEntity2 = m_sCollisionManager.m_asCollisions1[index].m_pEntity2; - m_sCollisionManager.m_asCollisions2[j].m_bSurface1 = m_sCollisionManager.m_asCollisions1[index].m_bSurface1; - m_sCollisionManager.m_asCollisions2[j].m_bSurface2 = m_sCollisionManager.m_asCollisions1[index].m_bSurface2; - break; - } - } - SetUpOneShotCollisionSound(m_sCollisionManager.m_asCollisions1[index]); - SetUpLoopingCollisionSound(m_sCollisionManager.m_asCollisions1[index], j); - } +float +cAudioManager::GetCollisionOneShotRatio(uint32 a, float b) +{ + switch(a) { + case SURFACE_DEFAULT: + case SURFACE_TARMAC: + case SURFACE_PAVEMENT: + case SURFACE_STEEP_CLIFF: + case SURFACE_TRANSPARENT_STONE: return GetCollisionRatio(b, 10.f, 60.f, 50.f); + case SURFACE_GRASS: + case SURFACE_CARDBOARDBOX: return GetCollisionRatio(b, 0.f, 2.f, 2.f); + case SURFACE_GRAVEL: return GetCollisionRatio(b, 0.f, 2.f, 2.f); + case SURFACE_MUD_DRY: return GetCollisionRatio(b, 0.f, 2.f, 2.f); + case SURFACE_CAR: return GetCollisionRatio(b, 6.f, 50.f, 44.f); + case SURFACE_GLASS: return GetCollisionRatio(b, 0.1f, 10.f, 9.9f); + case SURFACE_TRANSPARENT_CLOTH: + case SURFACE_THICK_METAL_PLATE: return GetCollisionRatio(b, 30.f, 130.f, 100.f); + case SURFACE_GARAGE_DOOR: return GetCollisionRatio(b, 20.f, 100.f, 80.f); + case SURFACE_CAR_PANEL: return GetCollisionRatio(b, 0.f, 4.f, 4.f); + case SURFACE_SCAFFOLD_POLE: + case SURFACE_METAL_GATE: return GetCollisionRatio(b, 1.f, 10.f, 9.f); + case SURFACE_LAMP_POST: return GetCollisionRatio(b, 1.f, 10.f, 9.f); + case SURFACE_FIRE_HYDRANT: return GetCollisionRatio(b, 1.f, 15.f, 14.f); + case SURFACE_GIRDER: return GetCollisionRatio(b, 8.f, 50.f, 42.f); + case SURFACE_METAL_CHAIN_FENCE: return GetCollisionRatio(b, 0.1f, 10.f, 9.9f); + case SURFACE_PED: return GetCollisionRatio(b, 0.f, 20.f, 20.f); + case SURFACE_SAND: return GetCollisionRatio(b, 0.f, 10.f, 10.f); + case SURFACE_WATER: return GetCollisionRatio(b, 0.f, 10.f, 10.f); + case SURFACE_WOOD_CRATES: return GetCollisionRatio(b, 1.f, 4.f, 3.f); + case SURFACE_WOOD_BENCH: return GetCollisionRatio(b, 0.1f, 5.f, 4.9f); + case SURFACE_WOOD_SOLID: return GetCollisionRatio(b, 0.1f, 40.f, 39.9f); + case SURFACE_RUBBER: + case SURFACE_WHEELBASE: return GetCollisionRatio(b, 0.f, 10.f, 10.f); + case SURFACE_PLASTIC: return GetCollisionRatio(b, 0.1f, 4.f, 3.9f); + case SURFACE_HEDGE: return GetCollisionRatio(b, 0.f, 0.5f, 0.5f); + case SURFACE_CONTAINER: return GetCollisionRatio(b, 4.f, 40.f, 36.f); + case SURFACE_NEWS_VENDOR: return GetCollisionRatio(b, 0.f, 5.f, 5.f); } - for (int i = 0; i < NUMAUDIOCOLLISIONS; i++) - m_sCollisionManager.m_bIndicesTable[i] = NUMAUDIOCOLLISIONS; - m_sCollisionManager.m_bCollisionsInQueue = 0; + return 0.f; } -void -cAudioManager::ReportCollision(CEntity *entity1, CEntity *entity2, uint8 surface1, uint8 surface2, float collisionPower, - float velocity) +float +cAudioManager::GetCollisionLoopingRatio(uint32 a, uint32 b, float c) { - float distSquared; - CVector v1; - CVector v2; - - if(!m_bIsInitialised || m_nCollisionEntity < 0 || m_nUserPause || - (velocity < 0.0016f && collisionPower < 0.01f)) - return; + return GetCollisionRatio(c, 0.0f, 0.02f, 0.02f); +} - if(entity1->IsBuilding()) { - v1 = v2 = entity2->GetPosition(); - } else if(entity2->IsBuilding()) { - v1 = v2 = entity1->GetPosition(); - } else { - v1 = entity1->GetPosition(); - v2 = entity2->GetPosition(); - } - CVector pos = (v1 + v2) * 0.5f; - distSquared = GetDistanceSquared(pos); - if(distSquared < SQR(CollisionSoundIntensity)) { - m_sCollisionManager.m_sQueue.m_pEntity1 = entity1; - m_sCollisionManager.m_sQueue.m_pEntity2 = entity2; - m_sCollisionManager.m_sQueue.m_bSurface1 = surface1; - m_sCollisionManager.m_sQueue.m_bSurface2 = surface2; - m_sCollisionManager.m_sQueue.m_fIntensity1 = collisionPower; - m_sCollisionManager.m_sQueue.m_fIntensity2 = velocity; - m_sCollisionManager.m_sQueue.m_vecPosition = pos; - m_sCollisionManager.m_sQueue.m_fDistance = distSquared; - m_sCollisionManager.AddCollisionToRequestedQueue(); - } +float +cAudioManager::GetCollisionRatio(float a, float b, float c, float d) +{ + float e; + e = a; + if(a <= b) return 0.0f; + if(c <= a) e = c; + return (e - b) / d; } diff --git a/src/audio/AudioCollision.h b/src/audio/AudioCollision.h index 0a058916..a201d500 100644 --- a/src/audio/AudioCollision.h +++ b/src/audio/AudioCollision.h @@ -17,7 +17,18 @@ public: float m_fDistance; int32 m_nBaseVolume; - // no methods + cAudioCollision() { Reset(); } + + void Reset() + { + m_pEntity1 = nil; + m_pEntity2 = nil; + m_bSurface1 = 0; + m_bSurface2 = 0; + m_fIntensity1 = m_fIntensity2 = 0.0f; + m_vecPosition = CVector(0.0f, 0.0f, 0.0f); + m_fDistance = 0.0f; + } }; VALIDATE_SIZE(cAudioCollision, 40); @@ -31,7 +42,15 @@ public: uint8 m_bCollisionsInQueue; cAudioCollision m_sQueue; - cAudioCollisionManager(); + cAudioCollisionManager() + { + m_sQueue.Reset(); + + for(int i = 0; i < NUMAUDIOCOLLISIONS; i++) + m_bIndicesTable[i] = NUMAUDIOCOLLISIONS; + + m_bCollisionsInQueue = 0; + } void AddCollisionToRequestedQueue(); }; diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index fdc7305b..44664f8a 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -52,11 +52,8 @@ uint32 gHomeNextTime; uint32 gCellNextTime; uint32 gNextCryTime; -enum PLAY_STATUS { PLAY_STATUS_STOPPED = 0, PLAY_STATUS_PLAYING, PLAY_STATUS_FINISHED }; -enum LOADING_STATUS { LOADING_STATUS_NOT_LOADED = 0, LOADING_STATUS_LOADED, LOADING_STATUS_FAILED }; - void -cAudioManager::PreInitialiseGameSpecificSetup() const +cAudioManager::PreInitialiseGameSpecificSetup() { BankStartOffset[SFX_BANK_0] = SAMPLEBANK_START; #ifdef GTA_PS2 @@ -163,6 +160,7 @@ cAudioManager::PostInitialiseGameSpecificSetup() m_sMissionAudio.m_nMissionAudioCounter = 0; ResetAudioLogicTimers(CTimer::GetTimeInMilliseconds()); } + void cAudioManager::PreTerminateGameSpecificShutdown() { @@ -228,7 +226,7 @@ cAudioManager::ResetAudioLogicTimers(uint32 timer) } void -cAudioManager::ProcessReverb() const +cAudioManager::ProcessReverb() { if (SampleManager.UpdateReverb() && m_bDynamicAcousticModelingStatus) { #ifndef GTA_PS2 @@ -248,7 +246,7 @@ cAudioManager::ProcessReverb() const } float -cAudioManager::GetDistanceSquared(const CVector &v) const +cAudioManager::GetDistanceSquared(const CVector &v) { const CVector &c = TheCamera.GetPosition(); return sq(v.x - c.x) + sq(v.y - c.y) + sq((v.z - c.z) * 0.2f); @@ -801,8 +799,6 @@ cAudioManager::ProcessModelCarEngine(cVehicleParams& params) } } - - bool8 cAudioManager::ProcessVehicleRoadNoise(cVehicleParams& params) { @@ -1063,20 +1059,20 @@ cAudioManager::UpdateGasPedalAudio(CAutomobile *automobile) } void -cAudioManager::PlayerJustGotInCar() const +cAudioManager::PlayerJustGotInCar() { if (m_bIsInitialised) bPlayerJustEnteredCar = TRUE; } void -cAudioManager::PlayerJustLeftCar(void) const +cAudioManager::PlayerJustLeftCar(void) { // UNUSED: This is a perfectly empty function. } void -cAudioManager::AddPlayerCarSample(uint8 emittingVolume, int32 freq, uint32 sample, uint8 bank, uint8 counter, bool8 notLooping) +cAudioManager::AddPlayerCarSample(uint8 emittingVolume, uint32 freq, uint32 sample, uint8 bank, uint8 counter, bool8 notLooping) { m_sQueueSample.m_nVolume = ComputeVolume(emittingVolume, 50.f, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { @@ -1581,7 +1577,7 @@ cAudioManager::ProcessVehicleHorn(cVehicleParams& params) } bool8 -cAudioManager::UsesSiren(int32 model) const +cAudioManager::UsesSiren(uint32 model) { switch (model) { case FIRETRUK: @@ -1597,7 +1593,7 @@ cAudioManager::UsesSiren(int32 model) const } bool8 -cAudioManager::UsesSirenSwitching(int32 model) const +cAudioManager::UsesSirenSwitching(uint32 model) { switch (model) { case AMBULAN: @@ -1663,7 +1659,7 @@ cAudioManager::ProcessVehicleSirenOrAlarm(cVehicleParams& params) } bool8 -cAudioManager::UsesReverseWarning(int32 model) const +cAudioManager::UsesReverseWarning(uint32 model) { return model == LINERUN || model == FIRETRUK || model == TRASH || model == BUS || model == COACH; } @@ -1792,7 +1788,7 @@ cAudioManager::ProcessAirBrakes(cVehicleParams& params) } bool8 -cAudioManager::HasAirBrakes(int32 model) const +cAudioManager::HasAirBrakes(uint32 model) { return model == LINERUN || model == FIRETRUK || model == TRASH || model == BUS || model == COACH; } @@ -2631,8 +2627,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 @@ -2910,7 +2906,7 @@ cAudioManager::SetupJumboRumbleSound(uint8 emittingVol) } int32 -cAudioManager::GetJumboTaxiFreq() const +cAudioManager::GetJumboTaxiFreq() { return (60.833f * m_sQueueSample.m_fDistance) + 22050; } @@ -3565,23 +3561,23 @@ 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_29); + pedComment.m_nSampleIndex = m_anRandomTable[m_sQueueSample.m_nEntityIndex % 4] % 29 + SFX_POLICE_HELI_1; break; case SOUND_PED_BODYCAST_HIT: if (CTimer::GetTimeInMilliseconds() <= gNextCryTime) return; soundIntensity = 50.0f; gNextCryTime = CTimer::GetTimeInMilliseconds() + 500; - pedComment.m_nSampleIndex = GetRandomNumberInRange(m_sQueueSample.m_nEntityIndex % 4, SFX_PLASTER_BLOKE_1, SFX_PLASTER_BLOKE_4); + pedComment.m_nSampleIndex = m_anRandomTable[m_sQueueSample.m_nEntityIndex % 4] % 4 + SFX_PLASTER_BLOKE_1; break; case SOUND_INJURED_PED_MALE_OUCH: case SOUND_INJURED_PED_MALE_PRISON: soundIntensity = 50.0f; - pedComment.m_nSampleIndex = GetRandomNumberInRange(m_sQueueSample.m_nEntityIndex % 4, SFX_GENERIC_MALE_GRUNT_1, SFX_GENERIC_MALE_GRUNT_15); + pedComment.m_nSampleIndex = m_anRandomTable[m_sQueueSample.m_nEntityIndex % 4] % 15 + SFX_GENERIC_MALE_GRUNT_1; break; case SOUND_INJURED_PED_FEMALE: soundIntensity = 50.0f; - pedComment.m_nSampleIndex = GetRandomNumberInRange(m_sQueueSample.m_nEntityIndex % 4, SFX_GENERIC_FEMALE_GRUNT_1, SFX_GENERIC_FEMALE_GRUNT_11); + pedComment.m_nSampleIndex = m_anRandomTable[m_sQueueSample.m_nEntityIndex % 4] % 11 + SFX_GENERIC_FEMALE_GRUNT_1; break; default: return; @@ -3618,7 +3614,7 @@ cAudioManager::SetupPedComments(cPedParams ¶ms, uint16 sound) } int32 -cAudioManager::GetPedCommentSfx(CPed *ped, int32 sound) +cAudioManager::GetPedCommentSfx(CPed *ped, uint16 sound) { if (ped->IsPlayer()) return GetPlayerTalkSfx(sound); @@ -3639,7 +3635,7 @@ cAudioManager::GetPedCommentSfx(CPed *ped, int32 sound) case MI_MALE01: return GetNormalMaleTalkSfx(sound); case MI_TAXI_D: - return GetTaxiDriverTalkSfx(sound); + return GetAsianTaxiDriverTalkSfx(sound); case MI_PIMP: return GetPimpTalkSfx(sound); case MI_GANG01: @@ -3673,7 +3669,7 @@ cAudioManager::GetPedCommentSfx(CPed *ped, int32 sound) case MI_SPECIAL04: return GetSpecialCharacterTalkSfx(ped->GetModelIndex(), sound); case MI_MALE02: - return GetMaleNo2TalkSfx(sound); + return GetCasualMaleOldTalkSfx(sound); case MI_MALE03: case MI_P_MAN1: case MI_P_MAN2: @@ -3768,14 +3764,14 @@ cAudioManager::GetPedCommentSfx(CPed *ped, int32 sound) case MI_STUD_WOM: return GetStudentFemaleTalkSfx(sound); case MI_CAS_MAN: - return GetCasualMaleOldTalkSfx(sound); + return GetCasualMaleYoungTalkSfx(sound); default: return GetGenericMaleTalkSfx(sound); } } void -cAudioManager::GetPhrase(uint32 &phrase, uint32 &prevPhrase, uint32 sample, uint32 maxOffset) const +cAudioManager::GetPhrase(uint32 &phrase, uint32 &prevPhrase, uint32 sample, uint32 maxOffset) { phrase = sample + m_anRandomTable[m_sQueueSample.m_nEntityIndex & 3] % maxOffset; @@ -3789,7 +3785,7 @@ cAudioManager::GetPhrase(uint32 &phrase, uint32 &prevPhrase, uint32 sample, uint #pragma region PED_COMMENTS uint32 -cAudioManager::GetPlayerTalkSfx(int16 sound) +cAudioManager::GetPlayerTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -3812,7 +3808,7 @@ cAudioManager::GetPlayerTalkSfx(int16 sound) } uint32 -cAudioManager::GetCopTalkSfx(int16 sound) +cAudioManager::GetCopTalkSfx(uint16 sound) { uint32 sfx; PedState pedState; @@ -3836,7 +3832,7 @@ cAudioManager::GetCopTalkSfx(int16 sound) } uint32 -cAudioManager::GetSwatTalkSfx(int16 sound) +cAudioManager::GetSwatTalkSfx(uint16 sound) { uint32 sfx; PedState pedState; @@ -3860,7 +3856,7 @@ cAudioManager::GetSwatTalkSfx(int16 sound) } uint32 -cAudioManager::GetFBITalkSfx(int16 sound) +cAudioManager::GetFBITalkSfx(uint16 sound) { uint32 sfx; PedState pedState; @@ -3884,7 +3880,7 @@ cAudioManager::GetFBITalkSfx(int16 sound) } uint32 -cAudioManager::GetArmyTalkSfx(int16 sound) +cAudioManager::GetArmyTalkSfx(uint16 sound) { uint32 sfx; PedState pedState; @@ -3903,7 +3899,7 @@ cAudioManager::GetArmyTalkSfx(int16 sound) } uint32 -cAudioManager::GetMedicTalkSfx(int16 sound) +cAudioManager::GetMedicTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -3931,41 +3927,41 @@ cAudioManager::GetMedicTalkSfx(int16 sound) } uint32 -cAudioManager::GetFiremanTalkSfx(int16 sound) +cAudioManager::GetFiremanTalkSfx(uint16 sound) { return GetGenericMaleTalkSfx(sound); } uint32 -cAudioManager::GetNormalMaleTalkSfx(int16 sound) +cAudioManager::GetBusinessMaleOldTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; switch (sound) { case SOUND_PED_HANDS_COWER: - GetPhrase(sfx, lastSfx, SFX_NORMAL_MALE_GUN_PANIC_1, 7); + GetPhrase(sfx, lastSfx, SFX_BUSINESS_MALE_OLD_VOICE_1_GUN_PANIC_1, 3); break; case SOUND_PED_CAR_JACKED: - GetPhrase(sfx, lastSfx, SFX_NORMAL_MALE_CARJACKED_1, 7); + GetPhrase(sfx, lastSfx, SFX_BUSINESS_MALE_OLD_VOICE_1_CARJACKED_1, 2); + break; + case SOUND_PED_ROBBED: + GetPhrase(sfx, lastSfx, SFX_BUSINESS_MALE_OLD_VOICE_1_MUGGED_1, 2); + break; + case SOUND_PED_ATTACK: + GetPhrase(sfx, lastSfx, SFX_BUSINESS_MALE_OLD_VOICE_1_FIGHT_1, 5); break; case SOUND_PED_EVADE: - GetPhrase(sfx, lastSfx, SFX_NORMAL_MALE_DODGE_1, 9); + GetPhrase(sfx, lastSfx, SFX_BUSINESS_MALE_OLD_VOICE_1_DODGE_1, 4); break; case SOUND_PED_FLEE_RUN: - GetPhrase(sfx, lastSfx, SFX_NORMAL_MALE_RUN_FROM_FIGHT_1, 5); + GetPhrase(sfx, lastSfx, SFX_BUSINESS_MALE_OLD_VOICE_1_MRUN_FROM_FIGHT_1, 5); break; case SOUND_PED_ANNOYED_DRIVER: - GetPhrase(sfx, lastSfx, SFX_NORMAL_MALE_DRIVER_ABUSE_1, 12); - break; - case SOUND_PED_CHAT_SEXY: - GetPhrase(sfx, lastSfx, SFX_NORMAL_MALE_EYING_1, 8); - break; - case SOUND_PED_CHAT_EVENT: - GetPhrase(sfx, lastSfx, SFX_NORMAL_MALE_SHOCKED_1, 10); + GetPhrase(sfx, lastSfx, SFX_BUSINESS_MALE_OLD_VOICE_1_DRIVER_ABUSE_1, 5); break; case SOUND_PED_CHAT: - GetPhrase(sfx, lastSfx, SFX_NORMAL_MALE_CHAT_1, 25); + GetPhrase(sfx, lastSfx, SFX_BUSINESS_MALE_OLD_VOICE_1_CHAT_1, 5); break; default: return GetGenericMaleTalkSfx(sound); @@ -3974,61 +3970,47 @@ cAudioManager::GetNormalMaleTalkSfx(int16 sound) } uint32 -cAudioManager::GetTaxiDriverTalkSfx(int16 sound) +cAudioManager::GetBusinessMaleYoungTalkSfx(uint16 sound, uint32 model) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; switch (sound) { - case SOUND_PED_CAR_JACKED: - GetPhrase(sfx, lastSfx, SFX_ASIAN_TAXI_DRIVER_VOICE_1_CARJACKED_1, 7); - break; - case SOUND_PED_ANNOYED_DRIVER: - GetPhrase(sfx, lastSfx, SFX_ASIAN_TAXI_DRIVER_VOICE_1_DRIVER_ABUSE_1, 6); - break; - default: - return GetGenericMaleTalkSfx(sound); - } - - return (SFX_ASIAN_TAXI_DRIVER_VOICE_2_DRIVER_ABUSE_1 - SFX_ASIAN_TAXI_DRIVER_VOICE_1_DRIVER_ABUSE_1) * (m_sQueueSample.m_nEntityIndex % 2) + sfx; -} - -uint32 -cAudioManager::GetPimpTalkSfx(int16 sound) -{ - uint32 sfx; - static uint32 lastSfx = NO_SAMPLE; - - switch (sound) { - case SOUND_PED_HANDS_UP: - GetPhrase(sfx, lastSfx, SFX_PIMP_GUN_COOL_1, 7); + case SOUND_PED_HANDS_COWER: + GetPhrase(sfx, lastSfx, SFX_BUSINESS_MALE_YOUNG_VOICE_1_GUN_PANIC_1, 3); break; case SOUND_PED_CAR_JACKED: - GetPhrase(sfx, lastSfx, SFX_PIMP_CARJACKED_1, 4); + GetPhrase(sfx, lastSfx, SFX_BUSINESS_MALE_YOUNG_VOICE_1_CARJACKED_1, 2); break; - case SOUND_PED_DEFEND: - GetPhrase(sfx, lastSfx, SFX_PIMP_FIGHT_1, 9); + case SOUND_PED_ROBBED: + GetPhrase(sfx, lastSfx, SFX_BUSINESS_MALE_YOUNG_VOICE_1_MUGGED_1, 2); + break; + case SOUND_PED_ATTACK: + GetPhrase(sfx, lastSfx, SFX_BUSINESS_MALE_YOUNG_VOICE_1_FIGHT_1, 4); break; case SOUND_PED_EVADE: - GetPhrase(sfx, lastSfx, SFX_PIMP_DODGE_1, 6); + GetPhrase(sfx, lastSfx, SFX_BUSINESS_MALE_YOUNG_VOICE_1_DODGE_1, 4); break; - case SOUND_PED_ANNOYED_DRIVER: - GetPhrase(sfx, lastSfx, SFX_PIMP_DRIVER_ABUSE_1, 5); + case SOUND_PED_FLEE_RUN: + GetPhrase(sfx, lastSfx, SFX_BUSINESS_MALE_YOUNG_VOICE_1_RUN_FROM_FIGHT_1, 5); break; - case SOUND_PED_CHAT_EVENT: - GetPhrase(sfx, lastSfx, SFX_PIMP_SHOCKED_1, 2); + case SOUND_PED_ANNOYED_DRIVER: + GetPhrase(sfx, lastSfx, SFX_BUSINESS_MALE_YOUNG_VOICE_1_DRIVER_ABUSE_1, 6); break; case SOUND_PED_CHAT: - GetPhrase(sfx, lastSfx, SFX_PIMP_CHAT_1, 17); + GetPhrase(sfx, lastSfx, SFX_BUSINESS_MALE_YOUNG_VOICE_1_CHAT_1, 6); break; default: return GetGenericMaleTalkSfx(sound); } + + if (model == MI_B_MAN3) + sfx += (SFX_BUSINESS_MALE_YOUNG_VOICE_2_DRIVER_ABUSE_1 - SFX_BUSINESS_MALE_YOUNG_VOICE_1_DRIVER_ABUSE_1); return sfx; } uint32 -cAudioManager::GetMafiaTalkSfx(int16 sound) +cAudioManager::GetMafiaTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -4062,7 +4044,7 @@ cAudioManager::GetMafiaTalkSfx(int16 sound) } uint32 -cAudioManager::GetTriadTalkSfx(int16 sound) +cAudioManager::GetTriadTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -4099,7 +4081,7 @@ cAudioManager::GetTriadTalkSfx(int16 sound) } uint32 -cAudioManager::GetDiabloTalkSfx(int16 sound) +cAudioManager::GetDiabloTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -4140,7 +4122,7 @@ cAudioManager::GetDiabloTalkSfx(int16 sound) } uint32 -cAudioManager::GetYakuzaTalkSfx(int16 sound) +cAudioManager::GetYakuzaTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -4171,7 +4153,7 @@ cAudioManager::GetYakuzaTalkSfx(int16 sound) } uint32 -cAudioManager::GetYardieTalkSfx(int16 sound) +cAudioManager::GetYardieTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -4208,7 +4190,7 @@ cAudioManager::GetYardieTalkSfx(int16 sound) } uint32 -cAudioManager::GetColumbianTalkSfx(int16 sound) +cAudioManager::GetColumbianTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -4242,7 +4224,7 @@ cAudioManager::GetColumbianTalkSfx(int16 sound) } uint32 -cAudioManager::GetHoodTalkSfx(int16 sound) +cAudioManager::GetHoodTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -4281,7 +4263,7 @@ cAudioManager::GetHoodTalkSfx(int16 sound) } uint32 -cAudioManager::GetBlackCriminalTalkSfx(int16 sound) +cAudioManager::GetBlackCriminalTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -4313,7 +4295,7 @@ cAudioManager::GetBlackCriminalTalkSfx(int16 sound) } uint32 -cAudioManager::GetWhiteCriminalTalkSfx(int16 sound) +cAudioManager::GetWhiteCriminalTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -4345,7 +4327,7 @@ cAudioManager::GetWhiteCriminalTalkSfx(int16 sound) } uint32 -cAudioManager::GetMaleNo2TalkSfx(int16 sound) +cAudioManager::GetCasualMaleOldTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -4379,79 +4361,13 @@ cAudioManager::GetMaleNo2TalkSfx(int16 sound) } uint32 -cAudioManager::GetBlackProjectMaleTalkSfx(int16 sound, int32 model) -{ - uint32 sfx; - static uint32 lastSfx = NO_SAMPLE; - - switch(sound) { - case SOUND_PED_HANDS_UP: GetPhrase(sfx, lastSfx, SFX_BLACK_PROJECT_MALE_VOICE_1_GUN_COOL_1, 3); break; - case SOUND_PED_CAR_JACKED: GetPhrase(sfx, lastSfx, SFX_BLACK_PROJECT_MALE_VOICE_1_CARJACKED_1, 2); break; - case SOUND_PED_ROBBED: GetPhrase(sfx, lastSfx, SFX_BLACK_PROJECT_MALE_VOICE_1_MUGGED_1, 2); break; - case SOUND_PED_ATTACK: GetPhrase(sfx, lastSfx, SFX_BLACK_PROJECT_MALE_VOICE_1_FIGHT_1, 6); break; - case SOUND_PED_EVADE: GetPhrase(sfx, lastSfx, SFX_BLACK_PROJECT_MALE_VOICE_1_DODGE_1, 5); break; - case SOUND_PED_ANNOYED_DRIVER: GetPhrase(sfx, lastSfx, SFX_BLACK_PROJECT_MALE_VOICE_1_DRIVER_ABUSE_1, 7); break; - case SOUND_PED_CHAT_SEXY: GetPhrase(sfx, lastSfx, SFX_BLACK_PROJECT_MALE_VOICE_1_EYING_1, 3); break; - case SOUND_PED_CHAT: GetPhrase(sfx, lastSfx, SFX_BLACK_PROJECT_MALE_VOICE_1_CHAT_1, 6); break; - default: return GetGenericMaleTalkSfx(sound); - } - - if (model == MI_P_MAN2) - sfx += (SFX_BLACK_PROJECT_MALE_VOICE_2_DRIVER_ABUSE_1 - SFX_BLACK_PROJECT_MALE_VOICE_1_DRIVER_ABUSE_1); - return sfx; -} - -uint32 -cAudioManager::GetWhiteFatMaleTalkSfx(int16 sound) -{ - uint32 sfx; - static uint32 lastSfx = NO_SAMPLE; - - switch(sound) { - case SOUND_PED_CAR_JACKED: GetPhrase(sfx, lastSfx, SFX_WHITE_FAT_MALE_VOICE_1_CARJACKED_1, 3); break; - case SOUND_PED_ROBBED: GetPhrase(sfx, lastSfx, SFX_WHITE_FAT_MALE_VOICE_1_MUGGED_1, 3); break; - case SOUND_PED_EVADE: GetPhrase(sfx, lastSfx, SFX_WHITE_FAT_MALE_VOICE_1_DODGE_1, 9); break; - case SOUND_PED_ANNOYED_DRIVER: GetPhrase(sfx, lastSfx, SFX_WHITE_FAT_MALE_VOICE_1_DRIVER_ABUSE_1, 9); break; - case SOUND_PED_WAIT_DOUBLEBACK: GetPhrase(sfx, lastSfx, SFX_WHITE_FAT_MALE_VOICE_1_LOST_1, 2); break; - case SOUND_PED_CHAT: GetPhrase(sfx, lastSfx, SFX_WHITE_FAT_MALE_VOICE_1_CHAT_1, 9); break; - default: return GetGenericMaleTalkSfx(sound); - } - return sfx; -} - -uint32 -cAudioManager::GetBlackFatMaleTalkSfx(int16 sound) +cAudioManager::GetCasualMaleYoungTalkSfx(uint16 sound) { - uint32 sfx; - static uint32 lastSfx = NO_SAMPLE; - - switch (sound) { - case SOUND_PED_CAR_JACKED: - GetPhrase(sfx, lastSfx, SFX_BLACK_FAT_MALE_VOICE_1_CARJACKED_1, 4); - break; - case SOUND_PED_ROBBED: - GetPhrase(sfx, lastSfx, SFX_BLACK_FAT_MALE_VOICE_1_MUGGED_1, 3); - break; - case SOUND_PED_EVADE: - GetPhrase(sfx, lastSfx, SFX_BLACK_FAT_MALE_VOICE_1_DODGE_1, 7); - break; - case SOUND_PED_ANNOYED_DRIVER: - GetPhrase(sfx, lastSfx, SFX_BLACK_FAT_MALE_VOICE_1_DRIVER_ABUSE_1, 6); - break; - case SOUND_PED_WAIT_DOUBLEBACK: - GetPhrase(sfx, lastSfx, SFX_BLACK_FAT_MALE_VOICE_1_LOST_1, 3); - break; - case SOUND_PED_CHAT: - GetPhrase(sfx, lastSfx, SFX_BLACK_FAT_MALE_VOICE_1_CHAT_1, 8); - break; - default: - return GetGenericMaleTalkSfx(sound); - } - return sfx; + return GetGenericMaleTalkSfx(sound); } uint32 -cAudioManager::GetBlackCasualFemaleTalkSfx(int16 sound) +cAudioManager::GetBlackCasualFemaleTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -4488,7 +4404,7 @@ cAudioManager::GetBlackCasualFemaleTalkSfx(int16 sound) } uint32 -cAudioManager::GetWhiteCasualFemaleTalkSfx(int16 sound) +cAudioManager::GetWhiteCasualFemaleTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -4525,7 +4441,7 @@ cAudioManager::GetWhiteCasualFemaleTalkSfx(int16 sound) } uint32 -cAudioManager::GetFemaleNo3TalkSfx(int16 sound) +cAudioManager::GetFemaleNo3TalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -4562,7 +4478,47 @@ cAudioManager::GetFemaleNo3TalkSfx(int16 sound) } uint32 -cAudioManager::GetBlackFatFemaleTalkSfx(int16 sound) +cAudioManager::GetWhiteBusinessFemaleTalkSfx(uint16 sound, uint32 model) +{ + uint32 sfx; + static uint32 lastSfx = NO_SAMPLE; + + switch (sound) { + case SOUND_PED_HANDS_COWER: + GetPhrase(sfx, lastSfx, SFX_WHITE_BUSINESS_FEMALE_VOICE_1_GUN_PANIC_1, 4); + break; + case SOUND_PED_CAR_JACKED: + GetPhrase(sfx, lastSfx, SFX_WHITE_BUSINESS_FEMALE_VOICE_1_CARJACKED_1, 2); + break; + case SOUND_PED_ROBBED: + GetPhrase(sfx, lastSfx, SFX_WHITE_BUSINESS_FEMALE_VOICE_1_MUGGED_1, 2); + break; + case SOUND_PED_EVADE: + GetPhrase(sfx, lastSfx, SFX_WHITE_BUSINESS_FEMALE_VOICE_1_DODGE_1, 6); + break; + case SOUND_PED_FLEE_RUN: + GetPhrase(sfx, lastSfx, SFX_WHITE_BUSINESS_FEMALE_VOICE_1_RUN_FROM_FIGHT_1, 4); + break; + case SOUND_PED_ANNOYED_DRIVER: + GetPhrase(sfx, lastSfx, SFX_WHITE_BUSINESS_FEMALE_VOICE_1_DRIVER_ABUSE_1, 5); + break; + case SOUND_PED_CHAT_EVENT: + GetPhrase(sfx, lastSfx, SFX_WHITE_BUSINESS_FEMALE_VOICE_1_SHOCKED_1, 4); + break; + case SOUND_PED_CHAT: + GetPhrase(sfx, lastSfx, SFX_WHITE_BUSINESS_FEMALE_VOICE_1_CHAT_1, 7); + break; + default: + return GetGenericFemaleTalkSfx(sound); + } + + if (model == MI_B_WOM2) + sfx += (SFX_WHITE_BUSINESS_FEMALE_VOICE_2_DRIVER_ABUSE_1 - SFX_WHITE_BUSINESS_FEMALE_VOICE_1_DRIVER_ABUSE_1); + return sfx; +} + +uint32 +cAudioManager::GetBlackFatFemaleTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -4596,7 +4552,56 @@ cAudioManager::GetBlackFatFemaleTalkSfx(int16 sound) } uint32 -cAudioManager::GetWhiteFatFemaleTalkSfx(int16 sound) +cAudioManager::GetWhiteFatMaleTalkSfx(uint16 sound) +{ + uint32 sfx; + static uint32 lastSfx = NO_SAMPLE; + + switch(sound) { + case SOUND_PED_CAR_JACKED: GetPhrase(sfx, lastSfx, SFX_WHITE_FAT_MALE_VOICE_1_CARJACKED_1, 3); break; + case SOUND_PED_ROBBED: GetPhrase(sfx, lastSfx, SFX_WHITE_FAT_MALE_VOICE_1_MUGGED_1, 3); break; + case SOUND_PED_EVADE: GetPhrase(sfx, lastSfx, SFX_WHITE_FAT_MALE_VOICE_1_DODGE_1, 9); break; + case SOUND_PED_ANNOYED_DRIVER: GetPhrase(sfx, lastSfx, SFX_WHITE_FAT_MALE_VOICE_1_DRIVER_ABUSE_1, 9); break; + case SOUND_PED_WAIT_DOUBLEBACK: GetPhrase(sfx, lastSfx, SFX_WHITE_FAT_MALE_VOICE_1_LOST_1, 2); break; + case SOUND_PED_CHAT: GetPhrase(sfx, lastSfx, SFX_WHITE_FAT_MALE_VOICE_1_CHAT_1, 9); break; + default: return GetGenericMaleTalkSfx(sound); + } + return sfx; +} + +uint32 +cAudioManager::GetBlackFatMaleTalkSfx(uint16 sound) +{ + uint32 sfx; + static uint32 lastSfx = NO_SAMPLE; + + switch (sound) { + case SOUND_PED_CAR_JACKED: + GetPhrase(sfx, lastSfx, SFX_BLACK_FAT_MALE_VOICE_1_CARJACKED_1, 4); + break; + case SOUND_PED_ROBBED: + GetPhrase(sfx, lastSfx, SFX_BLACK_FAT_MALE_VOICE_1_MUGGED_1, 3); + break; + case SOUND_PED_EVADE: + GetPhrase(sfx, lastSfx, SFX_BLACK_FAT_MALE_VOICE_1_DODGE_1, 7); + break; + case SOUND_PED_ANNOYED_DRIVER: + GetPhrase(sfx, lastSfx, SFX_BLACK_FAT_MALE_VOICE_1_DRIVER_ABUSE_1, 6); + break; + case SOUND_PED_WAIT_DOUBLEBACK: + GetPhrase(sfx, lastSfx, SFX_BLACK_FAT_MALE_VOICE_1_LOST_1, 3); + break; + case SOUND_PED_CHAT: + GetPhrase(sfx, lastSfx, SFX_BLACK_FAT_MALE_VOICE_1_CHAT_1, 8); + break; + default: + return GetGenericMaleTalkSfx(sound); + } + return sfx; +} + +uint32 +cAudioManager::GetWhiteFatFemaleTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -4630,7 +4635,7 @@ cAudioManager::GetWhiteFatFemaleTalkSfx(int16 sound) } uint32 -cAudioManager::GetBlackFemaleProstituteTalkSfx(int16 sound) +cAudioManager::GetBlackFemaleProstituteTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -4664,7 +4669,7 @@ cAudioManager::GetBlackFemaleProstituteTalkSfx(int16 sound) } uint32 -cAudioManager::GetWhiteFemaleProstituteTalkSfx(int16 sound) +cAudioManager::GetWhiteFemaleProstituteTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -4695,7 +4700,30 @@ cAudioManager::GetWhiteFemaleProstituteTalkSfx(int16 sound) } uint32 -cAudioManager::GetBlackProjectFemaleOldTalkSfx(int16 sound) +cAudioManager::GetBlackProjectMaleTalkSfx(uint16 sound, uint32 model) +{ + uint32 sfx; + static uint32 lastSfx = NO_SAMPLE; + + switch(sound) { + case SOUND_PED_HANDS_UP: GetPhrase(sfx, lastSfx, SFX_BLACK_PROJECT_MALE_VOICE_1_GUN_COOL_1, 3); break; + case SOUND_PED_CAR_JACKED: GetPhrase(sfx, lastSfx, SFX_BLACK_PROJECT_MALE_VOICE_1_CARJACKED_1, 2); break; + case SOUND_PED_ROBBED: GetPhrase(sfx, lastSfx, SFX_BLACK_PROJECT_MALE_VOICE_1_MUGGED_1, 2); break; + case SOUND_PED_ATTACK: GetPhrase(sfx, lastSfx, SFX_BLACK_PROJECT_MALE_VOICE_1_FIGHT_1, 6); break; + case SOUND_PED_EVADE: GetPhrase(sfx, lastSfx, SFX_BLACK_PROJECT_MALE_VOICE_1_DODGE_1, 5); break; + case SOUND_PED_ANNOYED_DRIVER: GetPhrase(sfx, lastSfx, SFX_BLACK_PROJECT_MALE_VOICE_1_DRIVER_ABUSE_1, 7); break; + case SOUND_PED_CHAT_SEXY: GetPhrase(sfx, lastSfx, SFX_BLACK_PROJECT_MALE_VOICE_1_EYING_1, 3); break; + case SOUND_PED_CHAT: GetPhrase(sfx, lastSfx, SFX_BLACK_PROJECT_MALE_VOICE_1_CHAT_1, 6); break; + default: return GetGenericMaleTalkSfx(sound); + } + + if (model == MI_P_MAN2) + sfx += (SFX_BLACK_PROJECT_MALE_VOICE_2_DRIVER_ABUSE_1 - SFX_BLACK_PROJECT_MALE_VOICE_1_DRIVER_ABUSE_1); + return sfx; +} + +uint32 +cAudioManager::GetBlackProjectFemaleOldTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -4729,7 +4757,7 @@ cAudioManager::GetBlackProjectFemaleOldTalkSfx(int16 sound) } uint32 -cAudioManager::GetBlackProjectFemaleYoungTalkSfx(int16 sound) +cAudioManager::GetBlackProjectFemaleYoungTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -4763,7 +4791,7 @@ cAudioManager::GetBlackProjectFemaleYoungTalkSfx(int16 sound) } uint32 -cAudioManager::GetChinatownMaleOldTalkSfx(int16 sound) +cAudioManager::GetChinatownMaleOldTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -4797,7 +4825,7 @@ cAudioManager::GetChinatownMaleOldTalkSfx(int16 sound) } uint32 -cAudioManager::GetChinatownMaleYoungTalkSfx(int16 sound) +cAudioManager::GetChinatownMaleYoungTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -4831,7 +4859,7 @@ cAudioManager::GetChinatownMaleYoungTalkSfx(int16 sound) } uint32 -cAudioManager::GetChinatownFemaleOldTalkSfx(int16 sound) +cAudioManager::GetChinatownFemaleOldTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -4862,7 +4890,7 @@ cAudioManager::GetChinatownFemaleOldTalkSfx(int16 sound) } uint32 -cAudioManager::GetChinatownFemaleYoungTalkSfx(int16 sound) +cAudioManager::GetChinatownFemaleYoungTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -4893,7 +4921,7 @@ cAudioManager::GetChinatownFemaleYoungTalkSfx(int16 sound) } uint32 -cAudioManager::GetLittleItalyMaleTalkSfx(int16 sound) +cAudioManager::GetLittleItalyMaleTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -4927,7 +4955,7 @@ cAudioManager::GetLittleItalyMaleTalkSfx(int16 sound) } uint32 -cAudioManager::GetLittleItalyFemaleOldTalkSfx(int16 sound) +cAudioManager::GetLittleItalyFemaleOldTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -4958,7 +4986,7 @@ cAudioManager::GetLittleItalyFemaleOldTalkSfx(int16 sound) } uint32 -cAudioManager::GetLittleItalyFemaleYoungTalkSfx(int16 sound) +cAudioManager::GetLittleItalyFemaleYoungTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -4989,7 +5017,7 @@ cAudioManager::GetLittleItalyFemaleYoungTalkSfx(int16 sound) } uint32 -cAudioManager::GetWhiteDockerMaleTalkSfx(int16 sound) +cAudioManager::GetWhiteDockerMaleTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -5020,7 +5048,7 @@ cAudioManager::GetWhiteDockerMaleTalkSfx(int16 sound) } uint32 -cAudioManager::GetBlackDockerMaleTalkSfx(int16 sound) +cAudioManager::GetBlackDockerMaleTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -5051,7 +5079,7 @@ cAudioManager::GetBlackDockerMaleTalkSfx(int16 sound) } uint32 -cAudioManager::GetScumMaleTalkSfx(int16 sound) +cAudioManager::GetScumMaleTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -5088,7 +5116,7 @@ cAudioManager::GetScumMaleTalkSfx(int16 sound) } uint32 -cAudioManager::GetScumFemaleTalkSfx(int16 sound) +cAudioManager::GetScumFemaleTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -5119,7 +5147,7 @@ cAudioManager::GetScumFemaleTalkSfx(int16 sound) } uint32 -cAudioManager::GetWhiteWorkerMaleTalkSfx(int16 sound) +cAudioManager::GetWhiteWorkerMaleTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -5150,7 +5178,7 @@ cAudioManager::GetWhiteWorkerMaleTalkSfx(int16 sound) } uint32 -cAudioManager::GetBlackWorkerMaleTalkSfx(int16 sound) +cAudioManager::GetBlackWorkerMaleTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -5181,124 +5209,7 @@ cAudioManager::GetBlackWorkerMaleTalkSfx(int16 sound) } uint32 -cAudioManager::GetBusinessMaleYoungTalkSfx(int16 sound, int32 model) -{ - uint32 sfx; - static uint32 lastSfx = NO_SAMPLE; - - switch (sound) { - case SOUND_PED_HANDS_COWER: - GetPhrase(sfx, lastSfx, SFX_BUSINESS_MALE_YOUNG_VOICE_1_GUN_PANIC_1, 3); - break; - case SOUND_PED_CAR_JACKED: - GetPhrase(sfx, lastSfx, SFX_BUSINESS_MALE_YOUNG_VOICE_1_CARJACKED_1, 2); - break; - case SOUND_PED_ROBBED: - GetPhrase(sfx, lastSfx, SFX_BUSINESS_MALE_YOUNG_VOICE_1_MUGGED_1, 2); - break; - case SOUND_PED_ATTACK: - GetPhrase(sfx, lastSfx, SFX_BUSINESS_MALE_YOUNG_VOICE_1_FIGHT_1, 4); - break; - case SOUND_PED_EVADE: - GetPhrase(sfx, lastSfx, SFX_BUSINESS_MALE_YOUNG_VOICE_1_DODGE_1, 4); - break; - case SOUND_PED_FLEE_RUN: - GetPhrase(sfx, lastSfx, SFX_BUSINESS_MALE_YOUNG_VOICE_1_RUN_FROM_FIGHT_1, 5); - break; - case SOUND_PED_ANNOYED_DRIVER: - GetPhrase(sfx, lastSfx, SFX_BUSINESS_MALE_YOUNG_VOICE_1_DRIVER_ABUSE_1, 6); - break; - case SOUND_PED_CHAT: - GetPhrase(sfx, lastSfx, SFX_BUSINESS_MALE_YOUNG_VOICE_1_CHAT_1, 6); - break; - default: - return GetGenericMaleTalkSfx(sound); - } - - if (model == MI_B_MAN3) - sfx += (SFX_BUSINESS_MALE_YOUNG_VOICE_2_DRIVER_ABUSE_1 - SFX_BUSINESS_MALE_YOUNG_VOICE_1_DRIVER_ABUSE_1); - return sfx; -} - -uint32 -cAudioManager::GetBusinessMaleOldTalkSfx(int16 sound) -{ - uint32 sfx; - static uint32 lastSfx = NO_SAMPLE; - - switch (sound) { - case SOUND_PED_HANDS_COWER: - GetPhrase(sfx, lastSfx, SFX_BUSINESS_MALE_OLD_VOICE_1_GUN_PANIC_1, 3); - break; - case SOUND_PED_CAR_JACKED: - GetPhrase(sfx, lastSfx, SFX_BUSINESS_MALE_OLD_VOICE_1_CARJACKED_1, 2); - break; - case SOUND_PED_ROBBED: - GetPhrase(sfx, lastSfx, SFX_BUSINESS_MALE_OLD_VOICE_1_MUGGED_1, 2); - break; - case SOUND_PED_ATTACK: - GetPhrase(sfx, lastSfx, SFX_BUSINESS_MALE_OLD_VOICE_1_FIGHT_1, 5); - break; - case SOUND_PED_EVADE: - GetPhrase(sfx, lastSfx, SFX_BUSINESS_MALE_OLD_VOICE_1_DODGE_1, 4); - break; - case SOUND_PED_FLEE_RUN: - GetPhrase(sfx, lastSfx, SFX_BUSINESS_MALE_OLD_VOICE_1_MRUN_FROM_FIGHT_1, 5); - break; - case SOUND_PED_ANNOYED_DRIVER: - GetPhrase(sfx, lastSfx, SFX_BUSINESS_MALE_OLD_VOICE_1_DRIVER_ABUSE_1, 5); - break; - case SOUND_PED_CHAT: - GetPhrase(sfx, lastSfx, SFX_BUSINESS_MALE_OLD_VOICE_1_CHAT_1, 5); - break; - default: - return GetGenericMaleTalkSfx(sound); - } - return sfx; -} - -uint32 -cAudioManager::GetWhiteBusinessFemaleTalkSfx(int16 sound, int32 model) -{ - uint32 sfx; - static uint32 lastSfx = NO_SAMPLE; - - switch (sound) { - case SOUND_PED_HANDS_COWER: - GetPhrase(sfx, lastSfx, SFX_WHITE_BUSINESS_FEMALE_VOICE_1_GUN_PANIC_1, 4); - break; - case SOUND_PED_CAR_JACKED: - GetPhrase(sfx, lastSfx, SFX_WHITE_BUSINESS_FEMALE_VOICE_1_CARJACKED_1, 2); - break; - case SOUND_PED_ROBBED: - GetPhrase(sfx, lastSfx, SFX_WHITE_BUSINESS_FEMALE_VOICE_1_MUGGED_1, 2); - break; - case SOUND_PED_EVADE: - GetPhrase(sfx, lastSfx, SFX_WHITE_BUSINESS_FEMALE_VOICE_1_DODGE_1, 6); - break; - case SOUND_PED_FLEE_RUN: - GetPhrase(sfx, lastSfx, SFX_WHITE_BUSINESS_FEMALE_VOICE_1_RUN_FROM_FIGHT_1, 4); - break; - case SOUND_PED_ANNOYED_DRIVER: - GetPhrase(sfx, lastSfx, SFX_WHITE_BUSINESS_FEMALE_VOICE_1_DRIVER_ABUSE_1, 5); - break; - case SOUND_PED_CHAT_EVENT: - GetPhrase(sfx, lastSfx, SFX_WHITE_BUSINESS_FEMALE_VOICE_1_SHOCKED_1, 4); - break; - case SOUND_PED_CHAT: - GetPhrase(sfx, lastSfx, SFX_WHITE_BUSINESS_FEMALE_VOICE_1_CHAT_1, 7); - break; - default: - return GetGenericFemaleTalkSfx(sound); - } - - if (model == MI_B_WOM2) - sfx += (SFX_WHITE_BUSINESS_FEMALE_VOICE_2_DRIVER_ABUSE_1 - SFX_WHITE_BUSINESS_FEMALE_VOICE_1_DRIVER_ABUSE_1); - return sfx; -} - -uint32 -cAudioManager::GetBlackBusinessFemaleTalkSfx(int16 sound) +cAudioManager::GetBlackBusinessFemaleTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -5335,7 +5246,7 @@ cAudioManager::GetBlackBusinessFemaleTalkSfx(int16 sound) } uint32 -cAudioManager::GetSupermodelMaleTalkSfx(int16 sound) +cAudioManager::GetSupermodelMaleTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -5369,7 +5280,7 @@ cAudioManager::GetSupermodelMaleTalkSfx(int16 sound) } uint32 -cAudioManager::GetSupermodelFemaleTalkSfx(int16 sound) +cAudioManager::GetSupermodelFemaleTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -5400,7 +5311,7 @@ cAudioManager::GetSupermodelFemaleTalkSfx(int16 sound) } uint32 -cAudioManager::GetStewardMaleTalkSfx(int16 sound) +cAudioManager::GetStewardMaleTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -5428,7 +5339,7 @@ cAudioManager::GetStewardMaleTalkSfx(int16 sound) } uint32 -cAudioManager::GetStewardFemaleTalkSfx(int16 sound) +cAudioManager::GetStewardFemaleTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -5453,7 +5364,7 @@ cAudioManager::GetStewardFemaleTalkSfx(int16 sound) } uint32 -cAudioManager::GetFanMaleTalkSfx(int16 sound, int32 model) +cAudioManager::GetFanMaleTalkSfx(uint16 sound, uint32 model) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -5484,7 +5395,7 @@ cAudioManager::GetFanMaleTalkSfx(int16 sound, int32 model) } uint32 -cAudioManager::GetFanFemaleTalkSfx(int16 sound) +cAudioManager::GetFanFemaleTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -5512,7 +5423,7 @@ cAudioManager::GetFanFemaleTalkSfx(int16 sound) } uint32 -cAudioManager::GetHospitalMaleTalkSfx(int16 sound) +cAudioManager::GetHospitalMaleTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -5540,7 +5451,7 @@ cAudioManager::GetHospitalMaleTalkSfx(int16 sound) } uint32 -cAudioManager::GetHospitalFemaleTalkSfx(int16 sound) +cAudioManager::GetHospitalFemaleTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -5562,7 +5473,7 @@ cAudioManager::GetHospitalFemaleTalkSfx(int16 sound) } uint32 -cAudioManager::GetWhiteConstructionWorkerTalkSfx(int16 sound) +cAudioManager::GetWhiteConstructionWorkerTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -5596,7 +5507,7 @@ cAudioManager::GetWhiteConstructionWorkerTalkSfx(int16 sound) } uint32 -cAudioManager::GetBlackConstructionWorkerTalkSfx(int16 sound) +cAudioManager::GetBlackConstructionWorkerTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -5630,7 +5541,7 @@ cAudioManager::GetBlackConstructionWorkerTalkSfx(int16 sound) } uint32 -cAudioManager::GetShopperFemaleTalkSfx(int16 sound, int32 model) +cAudioManager::GetShopperFemaleTalkSfx(uint16 sound, uint32 model) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -5667,7 +5578,7 @@ cAudioManager::GetShopperFemaleTalkSfx(int16 sound, int32 model) } uint32 -cAudioManager::GetStudentMaleTalkSfx(int16 sound) +cAudioManager::GetStudentMaleTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -5701,7 +5612,7 @@ cAudioManager::GetStudentMaleTalkSfx(int16 sound) } uint32 -cAudioManager::GetStudentFemaleTalkSfx(int16 sound) +cAudioManager::GetStudentFemaleTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -5735,29 +5646,23 @@ cAudioManager::GetStudentFemaleTalkSfx(int16 sound) } uint32 -cAudioManager::GetCasualMaleOldTalkSfx(int16 sound) -{ - return GetGenericMaleTalkSfx(sound); -} - -uint32 -cAudioManager::GetSpecialCharacterTalkSfx(int32 modelIndex, int32 sound) +cAudioManager::GetSpecialCharacterTalkSfx(uint32 modelIndex, uint16 sound) { char *modelName = CModelInfo::GetModelInfo(modelIndex)->GetModelName(); if (!CGeneral::faststricmp(modelName, "eight") || !CGeneral::faststricmp(modelName, "eight2")) { - return GetEightTalkSfx(sound); + return GetEightBallTalkSfx(sound); } if (!CGeneral::faststricmp(modelName, "frankie")) { - return GetFrankieTalkSfx(sound); + return GetSalvatoreTalkSfx(sound); } if (!CGeneral::faststricmp(modelName, "misty")) { return GetMistyTalkSfx(sound); } if (!CGeneral::faststricmp(modelName, "ojg") || !CGeneral::faststricmp(modelName, "ojg_p")) { - return GetOJGTalkSfx(sound); + return GetOldJapTalkSfx(sound); } if (!CGeneral::faststricmp(modelName, "cat")) { - return GetCatatalinaTalkSfx(sound); + return GetCatalinaTalkSfx(sound); } if (!CGeneral::faststricmp(modelName, "bomber")) { return GetBomberTalkSfx(sound); @@ -5777,8 +5682,9 @@ cAudioManager::GetSpecialCharacterTalkSfx(int32 modelIndex, int32 sound) return GetGenericMaleTalkSfx(sound); } + uint32 -cAudioManager::GetEightTalkSfx(int16 sound) +cAudioManager::GetEightBallTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -5803,7 +5709,7 @@ cAudioManager::GetEightTalkSfx(int16 sound) } uint32 -cAudioManager::GetFrankieTalkSfx(int16 sound) +cAudioManager::GetSalvatoreTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -5828,7 +5734,7 @@ cAudioManager::GetFrankieTalkSfx(int16 sound) } uint32 -cAudioManager::GetMistyTalkSfx(int16 sound) +cAudioManager::GetMistyTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -5857,19 +5763,19 @@ cAudioManager::GetMistyTalkSfx(int16 sound) } uint32 -cAudioManager::GetOJGTalkSfx(int16 sound) +cAudioManager::GetOldJapTalkSfx(uint16 sound) { return GetGenericMaleTalkSfx(sound); } uint32 -cAudioManager::GetCatatalinaTalkSfx(int16 sound) +cAudioManager::GetCatalinaTalkSfx(uint16 sound) { return GetGenericFemaleTalkSfx(sound); } uint32 -cAudioManager::GetBomberTalkSfx(int16 sound) +cAudioManager::GetBomberTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -5886,7 +5792,7 @@ cAudioManager::GetBomberTalkSfx(int16 sound) } uint32 -cAudioManager::GetSecurityGuardTalkSfx(int16 sound) +cAudioManager::GetSecurityGuardTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -5919,7 +5825,7 @@ cAudioManager::GetSecurityGuardTalkSfx(int16 sound) } uint32 -cAudioManager::GetChunkyTalkSfx(int16 sound) +cAudioManager::GetChunkyTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -5939,7 +5845,98 @@ cAudioManager::GetChunkyTalkSfx(int16 sound) } uint32 -cAudioManager::GetGenericMaleTalkSfx(int16 sound) +cAudioManager::GetAsianTaxiDriverTalkSfx(uint16 sound) +{ + uint32 sfx; + static uint32 lastSfx = NO_SAMPLE; + + switch (sound) { + case SOUND_PED_CAR_JACKED: + GetPhrase(sfx, lastSfx, SFX_ASIAN_TAXI_DRIVER_VOICE_1_CARJACKED_1, 7); + break; + case SOUND_PED_ANNOYED_DRIVER: + GetPhrase(sfx, lastSfx, SFX_ASIAN_TAXI_DRIVER_VOICE_1_DRIVER_ABUSE_1, 6); + break; + default: + return GetGenericMaleTalkSfx(sound); + } + + return (SFX_ASIAN_TAXI_DRIVER_VOICE_2_DRIVER_ABUSE_1 - SFX_ASIAN_TAXI_DRIVER_VOICE_1_DRIVER_ABUSE_1) * (m_sQueueSample.m_nEntityIndex % 2) + sfx; +} + +uint32 +cAudioManager::GetPimpTalkSfx(uint16 sound) +{ + uint32 sfx; + static uint32 lastSfx = NO_SAMPLE; + + switch (sound) { + case SOUND_PED_HANDS_UP: + GetPhrase(sfx, lastSfx, SFX_PIMP_GUN_COOL_1, 7); + break; + case SOUND_PED_CAR_JACKED: + GetPhrase(sfx, lastSfx, SFX_PIMP_CARJACKED_1, 4); + break; + case SOUND_PED_DEFEND: + GetPhrase(sfx, lastSfx, SFX_PIMP_FIGHT_1, 9); + break; + case SOUND_PED_EVADE: + GetPhrase(sfx, lastSfx, SFX_PIMP_DODGE_1, 6); + break; + case SOUND_PED_ANNOYED_DRIVER: + GetPhrase(sfx, lastSfx, SFX_PIMP_DRIVER_ABUSE_1, 5); + break; + case SOUND_PED_CHAT_EVENT: + GetPhrase(sfx, lastSfx, SFX_PIMP_SHOCKED_1, 2); + break; + case SOUND_PED_CHAT: + GetPhrase(sfx, lastSfx, SFX_PIMP_CHAT_1, 17); + break; + default: + return GetGenericMaleTalkSfx(sound); + } + return sfx; +} + +uint32 +cAudioManager::GetNormalMaleTalkSfx(uint16 sound) +{ + uint32 sfx; + static uint32 lastSfx = NO_SAMPLE; + + switch (sound) { + case SOUND_PED_HANDS_COWER: + GetPhrase(sfx, lastSfx, SFX_NORMAL_MALE_GUN_PANIC_1, 7); + break; + case SOUND_PED_CAR_JACKED: + GetPhrase(sfx, lastSfx, SFX_NORMAL_MALE_CARJACKED_1, 7); + break; + case SOUND_PED_EVADE: + GetPhrase(sfx, lastSfx, SFX_NORMAL_MALE_DODGE_1, 9); + break; + case SOUND_PED_FLEE_RUN: + GetPhrase(sfx, lastSfx, SFX_NORMAL_MALE_RUN_FROM_FIGHT_1, 5); + break; + case SOUND_PED_ANNOYED_DRIVER: + GetPhrase(sfx, lastSfx, SFX_NORMAL_MALE_DRIVER_ABUSE_1, 12); + break; + case SOUND_PED_CHAT_SEXY: + GetPhrase(sfx, lastSfx, SFX_NORMAL_MALE_EYING_1, 8); + break; + case SOUND_PED_CHAT_EVENT: + GetPhrase(sfx, lastSfx, SFX_NORMAL_MALE_SHOCKED_1, 10); + break; + case SOUND_PED_CHAT: + GetPhrase(sfx, lastSfx, SFX_NORMAL_MALE_CHAT_1, 25); + break; + default: + return GetGenericMaleTalkSfx(sound); + } + return sfx; +} + +uint32 +cAudioManager::GetGenericMaleTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -5965,7 +5962,7 @@ cAudioManager::GetGenericMaleTalkSfx(int16 sound) } uint32 -cAudioManager::GetGenericFemaleTalkSfx(int16 sound) +cAudioManager::GetGenericFemaleTalkSfx(uint16 sound) { uint32 sfx; static uint32 lastSfx = NO_SAMPLE; @@ -8353,7 +8350,7 @@ FindMissionAudioSfx(const char *name) } bool8 -cAudioManager::MissionScriptAudioUsesPoliceChannel(int32 soundMission) const +cAudioManager::MissionScriptAudioUsesPoliceChannel(uint32 soundMission) { switch (soundMission) { case STREAMED_SOUND_MISSION_J6_D: @@ -8394,7 +8391,7 @@ cAudioManager::PreloadMissionAudio(Const char *name) } uint8 -cAudioManager::GetMissionAudioLoadingStatus() const +cAudioManager::GetMissionAudioLoadingStatus() { if (m_bIsInitialised) return m_sMissionAudio.m_nLoadingStatus; diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index a113cc93..c3565828 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -109,7 +109,9 @@ cAudioManager::Service() if (m_bIsInitialised) { m_nPreviousUserPause = m_nUserPause; m_nUserPause = CTimer::GetIsUserPaused(); +#ifdef GTA_PC UpdateReflections(); +#endif ServiceSoundEffects(); MusicManager.Service(); } @@ -216,33 +218,33 @@ cAudioManager::PlayOneShot(int32 index, uint16 sound, float vol) } void -cAudioManager::SetEffectsMasterVolume(uint8 volume) const +cAudioManager::SetEffectsMasterVolume(uint8 volume) { SampleManager.SetEffectsMasterVolume(volume); } void -cAudioManager::SetMusicMasterVolume(uint8 volume) const +cAudioManager::SetMusicMasterVolume(uint8 volume) { SampleManager.SetMusicMasterVolume(volume); } void -cAudioManager::SetEffectsFadeVol(uint8 volume) const +cAudioManager::SetEffectsFadeVol(uint8 volume) { SampleManager.SetEffectsFadeVolume(volume); } void -cAudioManager::SetMonoMode(bool8 mono) +cAudioManager::SetMusicFadeVol(uint8 volume) { - SampleManager.SetMonoMode(mono); + SampleManager.SetMusicFadeVolume(volume); } void -cAudioManager::SetMusicFadeVol(uint8 volume) const +cAudioManager::SetMonoMode(bool8 mono) { - SampleManager.SetMusicFadeVolume(volume); + SampleManager.SetMonoMode(mono); } void @@ -307,8 +309,10 @@ cAudioManager::DestroyAllGameCreatedEntities() } } +#ifdef GTA_PC + uint8 -cAudioManager::GetNum3DProvidersAvailable() const +cAudioManager::GetNum3DProvidersAvailable() { if (m_bIsInitialised) return SampleManager.GetNum3DProvidersAvailable(); @@ -316,7 +320,7 @@ cAudioManager::GetNum3DProvidersAvailable() const } char * -cAudioManager::Get3DProviderName(uint8 id) const +cAudioManager::Get3DProviderName(uint8 id) { if (!m_bIsInitialised) return nil; @@ -331,7 +335,7 @@ cAudioManager::Get3DProviderName(uint8 id) const } int8 -cAudioManager::GetCurrent3DProviderIndex() const +cAudioManager::GetCurrent3DProviderIndex() { if (m_bIsInitialised) return SampleManager.GetCurrent3DProviderIndex(); @@ -363,13 +367,13 @@ cAudioManager::SetCurrent3DProvider(uint8 which) } void -cAudioManager::SetSpeakerConfig(int32 conf) const +cAudioManager::SetSpeakerConfig(int32 conf) { SampleManager.SetSpeakerConfig(conf); } bool8 -cAudioManager::IsMP3RadioChannelAvailable() const +cAudioManager::IsMP3RadioChannelAvailable() { if (m_bIsInitialised) return SampleManager.IsMP3RadioChannelAvailable(); @@ -378,7 +382,7 @@ cAudioManager::IsMP3RadioChannelAvailable() const } void -cAudioManager::ReleaseDigitalHandle() const +cAudioManager::ReleaseDigitalHandle() { if (m_bIsInitialised) { SampleManager.ReleaseDigitalHandle(); @@ -386,7 +390,7 @@ cAudioManager::ReleaseDigitalHandle() const } void -cAudioManager::ReacquireDigitalHandle() const +cAudioManager::ReacquireDigitalHandle() { if (m_bIsInitialised) { SampleManager.ReacquireDigitalHandle(); @@ -400,13 +404,13 @@ cAudioManager::SetDynamicAcousticModelingStatus(bool8 status) } bool8 -cAudioManager::CheckForAnAudioFileOnCD() const +cAudioManager::CheckForAnAudioFileOnCD() { return SampleManager.CheckForAnAudioFileOnCD(); } char -cAudioManager::GetCDAudioDriveLetter() const +cAudioManager::GetCDAudioDriveLetter() { if (m_bIsInitialised) return SampleManager.GetCDAudioDriveLetter(); @@ -415,11 +419,13 @@ cAudioManager::GetCDAudioDriveLetter() const } bool8 -cAudioManager::IsAudioInitialised() const +cAudioManager::IsAudioInitialised() { return m_bIsInitialised; } +#endif // GTA_PC + void cAudioManager::ServiceSoundEffects() { @@ -469,8 +475,14 @@ cAudioManager::ServiceSoundEffects() m_sAudioScriptObjectManager.m_nScriptObjectEntityTotal = 0; } +uint32 +cAudioManager::FL(float f) +{ + return SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex) * f; +} + uint8 -cAudioManager::ComputeVolume(uint8 emittingVolume, float soundIntensity, float distance) const +cAudioManager::ComputeVolume(uint8 emittingVolume, float soundIntensity, float distance) { float newSoundIntensity; if (soundIntensity <= 0.0f) @@ -482,7 +494,7 @@ cAudioManager::ComputeVolume(uint8 emittingVolume, float soundIntensity, float d } void -cAudioManager::TranslateEntity(Const CVector *in, CVector *out) const +cAudioManager::TranslateEntity(Const CVector *in, CVector *out) { *out = MultiplyInverse(TheCamera.GetMatrix(), *in); } @@ -501,7 +513,7 @@ cAudioManager::ComputePan(float dist, CVector *vec) } int32 -cAudioManager::ComputeDopplerEffectedFrequency(uint32 oldFreq, float position1, float position2, float speedMultiplier) const +cAudioManager::ComputeDopplerEffectedFrequency(uint32 oldFreq, float position1, float position2, float speedMultiplier) { uint32 newFreq = oldFreq; if (!TheCamera.Get_Just_Switched_Status() && speedMultiplier != 0.0f) { @@ -522,7 +534,7 @@ cAudioManager::ComputeDopplerEffectedFrequency(uint32 oldFreq, float position1, } int32 -cAudioManager::RandomDisplacement(uint32 seed) const +cAudioManager::RandomDisplacement(uint32 seed) { int32 value; @@ -593,6 +605,7 @@ cAudioManager::AddSampleToRequestedQueue() AddReflectionsToRequestedQueue(); } } + void cAudioManager::AddDetailsToRequestedOrderList(uint8 sample) { @@ -610,6 +623,7 @@ cAudioManager::AddDetailsToRequestedOrderList(uint8 sample) m_abSampleQueueIndexTable[m_nActiveSampleQueue][i] = sample; } +#ifdef GTA_PC void cAudioManager::AddReflectionsToRequestedQueue() { @@ -687,6 +701,7 @@ cAudioManager::UpdateReflections() m_afReflectionsDistances[4] = 50.0f; } } +#endif // GTA_PC void cAudioManager::AddReleasingSounds() @@ -964,6 +979,13 @@ cAudioManager::ClearActiveSamples() } } +void +cAudioManager::LoadBankIfNecessary(uint8 bank) +{ + if(!SampleManager.IsSampleBankLoaded(bank)) + SampleManager.LoadSampleBank(bank); +} + void cAudioManager::GenerateIntegerRandomNumberTable() { diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index 70302745..7c591a1e 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -20,8 +20,8 @@ public: #ifndef GTA_PS2 int32 m_nLoopStart; int32 m_nLoopEnd; -#endif uint8 m_nEmittingVolume; +#endif float m_fSpeedMultiplier; float m_fSoundIntensity; bool8 m_bReleasingSoundFlag; @@ -183,6 +183,9 @@ enum { MAX_REFLECTIONS, }; +enum PLAY_STATUS { PLAY_STATUS_STOPPED = 0, PLAY_STATUS_PLAYING, PLAY_STATUS_FINISHED }; +enum LOADING_STATUS { LOADING_STATUS_NOT_LOADED = 0, LOADING_STATUS_LOADED, LOADING_STATUS_FAILED }; + class cAudioManager { public: @@ -204,8 +207,10 @@ public: tAudioEntity m_asAudioEntities[NUM_AUDIOENTITIES]; int32 m_anAudioEntityIndices[NUM_AUDIOENTITIES]; int32 m_nAudioEntitiesTotal; +#ifdef GTA_PC CVector m_avecReflectionsPos[NUM_AUDIO_REFLECTIONS]; float m_afReflectionsDistances[NUM_AUDIO_REFLECTIONS]; +#endif cAudioScriptObjectManager m_sAudioScriptObjectManager; cPedComments m_sPedComments; int32 m_nFireAudioEntity; @@ -227,277 +232,279 @@ public: cAudioManager(); ~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 ShouldDuckMissionAudio() const { return m_sMissionAudio.m_nPlayStatus == 1; } - - // "Should" be in alphabetic order, except "getXTalkSfx" - void AddDetailsToRequestedOrderList(uint8 sample); - void AddPlayerCarSample(uint8 emittingVolume, int32 freq, uint32 sample, uint8 bank, - uint8 counter, bool8 notLooping); - void AddReflectionsToRequestedQueue(); - void AddReleasingSounds(); - void AddSampleToRequestedQueue(); - void AgeCrimes(); - - void CalculateDistance(bool8 &condition, float dist); - bool8 CheckForAnAudioFileOnCD() const; - void ClearActiveSamples(); - void ClearMissionAudio(); - void ClearRequestedQueue(); - int32 ComputeDopplerEffectedFrequency(uint32 oldFreq, float position1, float position2, - float speedMultiplier) const; - int32 ComputePan(float, CVector *); - uint8 ComputeVolume(uint8 emittingVolume, float soundIntensity, float distance) const; + void Initialise(); + void Terminate(); + void Service(); int32 CreateEntity(eAudioType type, void *entity); - - void DestroyAllGameCreatedEntities(); void DestroyEntity(int32 id); - void DoPoliceRadioCrackle(); + void SetEntityStatus(int32 id, bool8 status); + void PlayOneShot(int32 index, uint16 sound, float vol); + void SetEffectsMasterVolume(uint8 volume); + void SetMusicMasterVolume(uint8 volume); + void SetEffectsFadeVol(uint8 volume); + void SetMusicFadeVol(uint8 volume); + void SetMonoMode(bool8 mono); + void ResetTimers(uint32 time); + void DestroyAllGameCreatedEntities(); - // functions returning talk sfx, - // order from GetPedCommentSfx - uint32 GetPlayerTalkSfx(int16 sound); - uint32 GetCopTalkSfx(int16 sound); - uint32 GetSwatTalkSfx(int16 sound); - uint32 GetFBITalkSfx(int16 sound); - uint32 GetArmyTalkSfx(int16 sound); - uint32 GetMedicTalkSfx(int16 sound); - uint32 GetFiremanTalkSfx(int16 sound); - uint32 GetNormalMaleTalkSfx(int16 sound); - uint32 GetTaxiDriverTalkSfx(int16 sound); - uint32 GetPimpTalkSfx(int16 sound); - uint32 GetMafiaTalkSfx(int16 sound); - uint32 GetTriadTalkSfx(int16 sound); - uint32 GetDiabloTalkSfx(int16 sound); - uint32 GetYakuzaTalkSfx(int16 sound); - uint32 GetYardieTalkSfx(int16 sound); - uint32 GetColumbianTalkSfx(int16 sound); - uint32 GetHoodTalkSfx(int16 sound); - uint32 GetBlackCriminalTalkSfx(int16 sound); - uint32 GetWhiteCriminalTalkSfx(int16 sound); - uint32 GetMaleNo2TalkSfx(int16 sound); - uint32 GetBlackProjectMaleTalkSfx(int16 sound, int32 model); - uint32 GetWhiteFatMaleTalkSfx(int16 sound); - uint32 GetBlackFatMaleTalkSfx(int16 sound); - uint32 GetBlackCasualFemaleTalkSfx(int16 sound); - uint32 GetWhiteCasualFemaleTalkSfx(int16 sound); - uint32 GetFemaleNo3TalkSfx(int16 sound); - uint32 GetBlackFatFemaleTalkSfx(int16 sound); - uint32 GetWhiteFatFemaleTalkSfx(int16 sound); - uint32 GetBlackFemaleProstituteTalkSfx(int16 sound); - uint32 GetWhiteFemaleProstituteTalkSfx(int16 sound); - uint32 GetBlackProjectFemaleOldTalkSfx(int16 sound); - uint32 GetBlackProjectFemaleYoungTalkSfx(int16 sound); - uint32 GetChinatownMaleOldTalkSfx(int16 sound); - uint32 GetChinatownMaleYoungTalkSfx(int16 sound); - uint32 GetChinatownFemaleOldTalkSfx(int16 sound); - uint32 GetChinatownFemaleYoungTalkSfx(int16 sound); - uint32 GetLittleItalyMaleTalkSfx(int16 sound); - uint32 GetLittleItalyFemaleOldTalkSfx(int16 sound); - uint32 GetLittleItalyFemaleYoungTalkSfx(int16 sound); - uint32 GetWhiteDockerMaleTalkSfx(int16 sound); - uint32 GetBlackDockerMaleTalkSfx(int16 sound); - uint32 GetScumMaleTalkSfx(int16 sound); - uint32 GetScumFemaleTalkSfx(int16 sound); - uint32 GetWhiteWorkerMaleTalkSfx(int16 sound); - uint32 GetBlackWorkerMaleTalkSfx(int16 sound); - uint32 GetBusinessMaleYoungTalkSfx(int16 sound, int32 model); - uint32 GetBusinessMaleOldTalkSfx(int16 sound); - uint32 GetWhiteBusinessFemaleTalkSfx(int16 sound, int32 model); - uint32 GetBlackBusinessFemaleTalkSfx(int16 sound); - uint32 GetSupermodelMaleTalkSfx(int16 sound); - uint32 GetSupermodelFemaleTalkSfx(int16 sound); - uint32 GetStewardMaleTalkSfx(int16 sound); - uint32 GetStewardFemaleTalkSfx(int16 sound); - uint32 GetFanMaleTalkSfx(int16 sound, int32 model); - uint32 GetFanFemaleTalkSfx(int16 sound); - uint32 GetHospitalMaleTalkSfx(int16 sound); - uint32 GetHospitalFemaleTalkSfx(int16 sound); - uint32 GetWhiteConstructionWorkerTalkSfx(int16 sound); - uint32 GetBlackConstructionWorkerTalkSfx(int16 sound); - uint32 GetShopperFemaleTalkSfx(int16 sound, int32 model); - uint32 GetStudentMaleTalkSfx(int16 sound); - uint32 GetStudentFemaleTalkSfx(int16 sound); - uint32 GetCasualMaleOldTalkSfx(int16 sound); - - uint32 GetSpecialCharacterTalkSfx(int32 modelIndex, int32 sound); - uint32 GetEightTalkSfx(int16 sound); - uint32 GetFrankieTalkSfx(int16 sound); - uint32 GetMistyTalkSfx(int16 sound); - uint32 GetOJGTalkSfx(int16 sound); - uint32 GetCatatalinaTalkSfx(int16 sound); - uint32 GetBomberTalkSfx(int16 sound); - uint32 GetSecurityGuardTalkSfx(int16 sound); - uint32 GetChunkyTalkSfx(int16 sound); - - uint32 GetGenericMaleTalkSfx(int16 sound); - uint32 GetGenericFemaleTalkSfx(int16 sound); - // end of functions returning talk sfx - - void GenerateIntegerRandomNumberTable(); - char *Get3DProviderName(uint8 id) const; - char GetCDAudioDriveLetter() const; - int8 GetCurrent3DProviderIndex() const; - float GetCollisionLoopingRatio(uint32 a, uint32 b, float c) const; // not used - float GetCollisionOneShotRatio(int32 a, float b) const; - float GetCollisionRatio(float a, float b, float c, float d) const; - float GetDistanceSquared(const CVector &v) const; - int32 GetJumboTaxiFreq() const; - uint8 GetMissionAudioLoadingStatus() const; - int8 GetMissionScriptPoliceAudioPlayingStatus() const; - uint8 GetNum3DProvidersAvailable() const; - int32 GetPedCommentSfx(CPed *ped, int32 sound); - void GetPhrase(uint32 &phrase, uint32 &prevPhrase, uint32 sample, uint32 maxOffset) const; - float GetVehicleDriveWheelSkidValue(uint8 wheel, CAutomobile *automobile, - cTransmission *transmission, float velocityChange); - float GetVehicleNonDriveWheelSkidValue(uint8 wheel, CAutomobile *automobile, - cTransmission *transmission, float velocityChange); - - bool8 HasAirBrakes(int32 model) const; +#ifdef GTA_PC + uint8 GetNum3DProvidersAvailable(); + char *Get3DProviderName(uint8 id); + int8 GetCurrent3DProviderIndex(); + int8 SetCurrent3DProvider(uint8 which); + void SetSpeakerConfig(int32 conf); + bool8 IsMP3RadioChannelAvailable(); + void ReleaseDigitalHandle(); + void ReacquireDigitalHandle(); + void SetDynamicAcousticModelingStatus(bool8 status); + bool8 CheckForAnAudioFileOnCD(); + char GetCDAudioDriveLetter(); + bool8 IsAudioInitialised(); +#endif - void Initialise(); - void InitialisePoliceRadio(); - void InitialisePoliceRadioZones(); - void InterrogateAudioEntities(); - bool8 IsAudioInitialised() const; - bool8 IsMissionAudioSampleFinished(); - bool8 IsMP3RadioChannelAvailable() const; + void ServiceSoundEffects(); + uint32 FL(float f); // not used + uint8 ComputeVolume(uint8 emittingVolume, float soundIntensity, float distance); + void TranslateEntity(Const CVector *v1, CVector *v2); + int32 ComputePan(float, CVector *); + int32 ComputeDopplerEffectedFrequency(uint32 oldFreq, float position1, float position2, float speedMultiplier); // inlined on PS2 + int32 RandomDisplacement(uint32 seed); + void InterrogateAudioEntities(); // inlined on PS2 + void AddSampleToRequestedQueue(); + void AddDetailsToRequestedOrderList(uint8 sample); // inlined on PS2 +#ifdef GTA_PC + void AddReflectionsToRequestedQueue(); + void UpdateReflections(); +#endif + void AddReleasingSounds(); + void ProcessActiveQueues(); + void ClearRequestedQueue(); // inlined on PS2 + void ClearActiveSamples(); + void GenerateIntegerRandomNumberTable(); // inlined on PS2 + void LoadBankIfNecessary(uint8 bank); // this is used only on PS2 but technically not a platform code - bool8 MissionScriptAudioUsesPoliceChannel(int32 soundMission) const; +#ifdef GTA_PC + void AdjustSamplesVolume(); + uint8 ComputeEmittingVolume(uint8 emittingVolume, float intensity, float dist); +#endif - void PlayLoadedMissionAudio(); - void PlayOneShot(int32 index, uint16 sound, float vol); - void PlaySuspectLastSeen(float x, float y, float z); - void PlayerJustGotInCar() const; - void PlayerJustLeftCar() const; + // audio logic + void PreInitialiseGameSpecificSetup(); void PostInitialiseGameSpecificSetup(); - void PostTerminateGameSpecificShutdown(); - void PreInitialiseGameSpecificSetup() const; - void PreloadMissionAudio(Const char *name); void PreTerminateGameSpecificShutdown(); - /// processX - main logic of adding new sounds - void ProcessActiveQueues(); - bool8 ProcessAirBrakes(cVehicleParams& params); - void ProcessAirportScriptObject(uint8 sound); - bool8 ProcessBoatEngine(cVehicleParams& params); - bool8 ProcessBoatMovingOverWater(cVehicleParams& params); - void ProcessBridge(); - void ProcessBridgeMotor(); - void ProcessBridgeOneShots(); - void ProcessBridgeWarning(); - bool8 ProcessCarBombTick(cVehicleParams& params); - void ProcessCesna(cVehicleParams& params); - void ProcessCinemaScriptObject(uint8 sound); - void ProcessCrane(); - void ProcessDocksScriptObject(uint8 sound); - bool8 ProcessEngineDamage(cVehicleParams& params); + void PostTerminateGameSpecificShutdown(); + void ResetAudioLogicTimers(uint32 timer); + void ProcessReverb(); + float GetDistanceSquared(const CVector &v); + void CalculateDistance(bool8 &condition, float dist); + void ProcessSpecial(); void ProcessEntity(int32 sound); - void ProcessExplosions(int32 explosion); - void ProcessFireHydrant(); - void ProcessFires(int32 entity); - void ProcessFrontEnd(); - void ProcessGarages(); - bool8 ProcessHelicopter(cVehicleParams& params); - void ProcessHomeScriptObject(uint8 sound); - void ProcessJumbo(cVehicleParams& params); + void ProcessPhysical(int32 id); + void ProcessVehicle(CVehicle *vehicle); + void ProcessRainOnVehicle(cVehicleParams ¶ms); + bool8 ProcessReverseGear(cVehicleParams ¶ms); + void ProcessModelCarEngine(cVehicleParams ¶ms); + bool8 ProcessVehicleRoadNoise(cVehicleParams ¶ms); + bool8 ProcessWetRoadNoise(cVehicleParams ¶ms); + + // vehicles + void ProcessVehicleEngine(cVehicleParams ¶ms); + void UpdateGasPedalAudio(CAutomobile *automobile); // inlined on PS2 + void PlayerJustGotInCar(); + void PlayerJustLeftCar(); + void AddPlayerCarSample(uint8 emittingVolume, uint32 freq, uint32 sample, uint8 bank, uint8 counter, bool8 notLooping); + void ProcessCesna(cVehicleParams ¶ms); + void ProcessPlayersVehicleEngine(cVehicleParams ¶ms, CAutomobile *automobile); + bool8 ProcessVehicleSkidding(cVehicleParams ¶ms); + float GetVehicleDriveWheelSkidValue(uint8 wheel, CAutomobile *automobile, cTransmission *transmission, float velocityChange); + float GetVehicleNonDriveWheelSkidValue(uint8 wheel, CAutomobile *automobile, cTransmission *transmission, float velocityChange); // was in .h on PS2 + void ProcessVehicleHorn(cVehicleParams ¶ms); + bool8 UsesSiren(uint32 model); // inlined on PS2 + bool8 UsesSirenSwitching(uint32 model); // inlined on PS2 + bool8 ProcessVehicleSirenOrAlarm(cVehicleParams ¶ms); + bool8 UsesReverseWarning(uint32 model); // inlined on PS2 + bool8 ProcessVehicleReverseWarning(cVehicleParams ¶ms); + bool8 ProcessVehicleDoors(cVehicleParams ¶ms); + bool8 ProcessAirBrakes(cVehicleParams ¶ms); + bool8 HasAirBrakes(uint32 model); // inlined on PS2 + bool8 ProcessEngineDamage(cVehicleParams ¶ms); + bool8 ProcessCarBombTick(cVehicleParams ¶ms); + void ProcessVehicleOneShots(cVehicleParams ¶ms); + bool8 ProcessTrainNoise(cVehicleParams ¶ms); + bool8 ProcessBoatEngine(cVehicleParams ¶ms); + bool8 ProcessBoatMovingOverWater(cVehicleParams ¶ms); + bool8 ProcessHelicopter(cVehicleParams ¶ms); + void ProcessPlane(cVehicleParams ¶ms); // inlined on PS2 + void ProcessJumbo(cVehicleParams ¶ms); + void ProcessJumboTaxi(); // inlined on PS2 void ProcessJumboAccel(CPlane *plane); - void ProcessJumboDecel(CPlane *plane); - void ProcessJumboFlying(); - void ProcessJumboLanding(CPlane *plane); - void ProcessJumboTakeOff(CPlane *plane); - void ProcessJumboTaxi(); - void ProcessLaunderetteScriptObject(uint8 sound); - void ProcessLoopingScriptObject(uint8 sound); - void ProcessMissionAudio(); - void ProcessModelCarEngine(cVehicleParams& params); - void ProcessOneShotScriptObject(uint8 sound); - void ProcessPed(CPhysical *ped); + void ProcessJumboTakeOff(CPlane *plane); // inlined on PS2 + void ProcessJumboFlying(); // inlined on PS2 + void ProcessJumboLanding(CPlane *plane); // inlined on PS2 + void ProcessJumboDecel(CPlane *plane); // inlined on PS2 + bool8 SetupJumboTaxiSound(uint8 vol); + bool8 SetupJumboWhineSound(uint8 emittingVol, uint32 freq); + bool8 SetupJumboEngineSound(uint8 vol, uint32 freq); + bool8 SetupJumboFlySound(uint8 emittingVol); + bool8 SetupJumboRumbleSound(uint8 emittingVol); + int32 GetJumboTaxiFreq(); // inlined on PS2 + + // peds + void ProcessPed(CPhysical *ped); // inlined on PS2 void ProcessPedHeadphones(cPedParams ¶ms); void ProcessPedOneShots(cPedParams ¶ms); - void ProcessPhysical(int32 id); - void ProcessPlane(cVehicleParams& params); - void ProcessPlayersVehicleEngine(cVehicleParams& params, CAutomobile *automobile); - void ProcessPoliceCellBeatingScriptObject(uint8 sound); + + // ped comments + void SetupPedComments(cPedParams ¶ms, uint16 sound); + int32 GetPedCommentSfx(CPed *ped, uint16 sound); + void GetPhrase(uint32 &phrase, uint32 &prevPhrase, uint32 sample, uint32 maxOffset); // inlined on PS2 + uint32 GetPlayerTalkSfx(uint16 sound); // inlined on PS2 + uint32 GetCopTalkSfx(uint16 sound); + uint32 GetSwatTalkSfx(uint16 sound); + uint32 GetFBITalkSfx(uint16 sound); + uint32 GetArmyTalkSfx(uint16 sound); + uint32 GetMedicTalkSfx(uint16 sound); + uint32 GetFiremanTalkSfx(uint16 sound); // inlined on PS2 + uint32 GetBusinessMaleOldTalkSfx(uint16 sound); + uint32 GetBusinessMaleYoungTalkSfx(uint16 sound, uint32 model); + uint32 GetMafiaTalkSfx(uint16 sound); + uint32 GetTriadTalkSfx(uint16 sound); + uint32 GetDiabloTalkSfx(uint16 sound); + uint32 GetYakuzaTalkSfx(uint16 sound); + uint32 GetYardieTalkSfx(uint16 sound); + uint32 GetColumbianTalkSfx(uint16 sound); + uint32 GetHoodTalkSfx(uint16 sound); + uint32 GetBlackCriminalTalkSfx(uint16 sound); + uint32 GetWhiteCriminalTalkSfx(uint16 sound); + uint32 GetCasualMaleOldTalkSfx(uint16 sound); + uint32 GetCasualMaleYoungTalkSfx(uint16 sound); + uint32 GetBlackCasualFemaleTalkSfx(uint16 sound); + uint32 GetWhiteCasualFemaleTalkSfx(uint16 sound); + uint32 GetFemaleNo3TalkSfx(uint16 sound); + uint32 GetWhiteBusinessFemaleTalkSfx(uint16 sound, uint32 model); + uint32 GetBlackFatFemaleTalkSfx(uint16 sound); + uint32 GetWhiteFatMaleTalkSfx(uint16 sound); + uint32 GetBlackFatMaleTalkSfx(uint16 sound); + uint32 GetWhiteFatFemaleTalkSfx(uint16 sound); + uint32 GetBlackFemaleProstituteTalkSfx(uint16 sound); + uint32 GetWhiteFemaleProstituteTalkSfx(uint16 sound); + uint32 GetBlackProjectMaleTalkSfx(uint16 sound, uint32 model); + uint32 GetBlackProjectFemaleOldTalkSfx(uint16 sound); + uint32 GetBlackProjectFemaleYoungTalkSfx(uint16 sound); + uint32 GetChinatownMaleOldTalkSfx(uint16 sound); + uint32 GetChinatownMaleYoungTalkSfx(uint16 sound); + uint32 GetChinatownFemaleOldTalkSfx(uint16 sound); + uint32 GetChinatownFemaleYoungTalkSfx(uint16 sound); + uint32 GetLittleItalyMaleTalkSfx(uint16 sound); + uint32 GetLittleItalyFemaleOldTalkSfx(uint16 sound); + uint32 GetLittleItalyFemaleYoungTalkSfx(uint16 sound); + uint32 GetWhiteDockerMaleTalkSfx(uint16 sound); + uint32 GetBlackDockerMaleTalkSfx(uint16 sound); + uint32 GetScumMaleTalkSfx(uint16 sound); + uint32 GetScumFemaleTalkSfx(uint16 sound); + uint32 GetWhiteWorkerMaleTalkSfx(uint16 sound); + uint32 GetBlackWorkerMaleTalkSfx(uint16 sound); + uint32 GetBlackBusinessFemaleTalkSfx(uint16 sound); + uint32 GetSupermodelMaleTalkSfx(uint16 sound); + uint32 GetSupermodelFemaleTalkSfx(uint16 sound); + uint32 GetStewardMaleTalkSfx(uint16 sound); + uint32 GetStewardFemaleTalkSfx(uint16 sound); + uint32 GetFanMaleTalkSfx(uint16 sound, uint32 model); + uint32 GetFanFemaleTalkSfx(uint16 sound); + uint32 GetHospitalMaleTalkSfx(uint16 sound); + uint32 GetHospitalFemaleTalkSfx(uint16 sound); // inlined on PS2 + uint32 GetWhiteConstructionWorkerTalkSfx(uint16 sound); + uint32 GetBlackConstructionWorkerTalkSfx(uint16 sound); + uint32 GetShopperFemaleTalkSfx(uint16 sound, uint32 model); + uint32 GetStudentMaleTalkSfx(uint16 sound); + uint32 GetStudentFemaleTalkSfx(uint16 sound); + + uint32 GetSpecialCharacterTalkSfx(uint32 modelIndex, uint16 sound); + uint32 GetEightBallTalkSfx(uint16 sound); // inlined on PS2 + uint32 GetSalvatoreTalkSfx(uint16 sound); // inlined on PS2 + uint32 GetMistyTalkSfx(uint16 sound); + uint32 GetOldJapTalkSfx(uint16 sound); // inlined on PS2 + uint32 GetCatalinaTalkSfx(uint16 sound); // inlined on PS2 + uint32 GetBomberTalkSfx(uint16 sound); // inlined on PS2 + uint32 GetSecurityGuardTalkSfx(uint16 sound); + uint32 GetChunkyTalkSfx(uint16 sound); // inlined on PS2 + + uint32 GetAsianTaxiDriverTalkSfx(uint16 sound); // inlined on PS2 + uint32 GetPimpTalkSfx(uint16 sound); + uint32 GetNormalMaleTalkSfx(uint16 sound); + uint32 GetGenericMaleTalkSfx(uint16 sound); + uint32 GetGenericFemaleTalkSfx(uint16 sound); + + // particles + void ProcessExplosions(int32 explosion); + void ProcessFires(int32 entity); + void ProcessWaterCannon(int32); + + // script objects + void ProcessScriptObject(int32 id); // inlined on PS2 + void ProcessOneShotScriptObject(uint8 sound); + void ProcessLoopingScriptObject(uint8 sound); void ProcessPornCinema(uint8 sound); - void ProcessProjectiles(); - void ProcessRainOnVehicle(cVehicleParams& params); - void ProcessReverb() const; - bool8 ProcessReverseGear(cVehicleParams& params); + void ProcessWorkShopScriptObject(uint8 sound); void ProcessSawMillScriptObject(uint8 sound); - void ProcessScriptObject(int32 id); + void ProcessLaunderetteScriptObject(uint8 sound); void ProcessShopScriptObject(uint8 sound); - void ProcessSpecial(); - bool8 ProcessTrainNoise(cVehicleParams& params); - void ProcessVehicle(CVehicle *vehicle); - bool8 ProcessVehicleDoors(cVehicleParams& params); - void ProcessVehicleEngine(cVehicleParams& params); - void ProcessVehicleHorn(cVehicleParams& params); - void ProcessVehicleOneShots(cVehicleParams& params); - bool8 ProcessVehicleReverseWarning(cVehicleParams& params); - bool8 ProcessVehicleRoadNoise(cVehicleParams& params); - bool8 ProcessVehicleSirenOrAlarm(cVehicleParams& params); - bool8 ProcessVehicleSkidding(cVehicleParams& params); - void ProcessWaterCannon(int32); + void ProcessAirportScriptObject(uint8 sound); + void ProcessCinemaScriptObject(uint8 sound); + void ProcessDocksScriptObject(uint8 sound); + void ProcessHomeScriptObject(uint8 sound); + void ProcessPoliceCellBeatingScriptObject(uint8 sound); + + // misc void ProcessWeather(int32 id); - bool8 ProcessWetRoadNoise(cVehicleParams& params); - void ProcessWorkShopScriptObject(uint8 sound); + void ProcessFrontEnd(); + void ProcessCrane(); + void ProcessProjectiles(); + void ProcessGarages(); + void ProcessFireHydrant(); - int32 RandomDisplacement(uint32 seed) const; - void ReacquireDigitalHandle() const; - void ReleaseDigitalHandle() const; - void ReportCollision(CEntity *entity1, CEntity *entity2, uint8 surface1, uint8 surface2, - float collisionPower, float intensity2); - void ReportCrime(eCrimeType crime, const CVector &pos); - void ResetAudioLogicTimers(uint32 timer); - void ResetPoliceRadio(); - void ResetTimers(uint32 time); + // bridge + void ProcessBridge(); // inlined on PS2 + void ProcessBridgeWarning(); + void ProcessBridgeMotor(); + void ProcessBridgeOneShots(); - void Service(); - void ServiceCollisions(); + // mission audio + bool8 MissionScriptAudioUsesPoliceChannel(uint32 soundMission); + void PreloadMissionAudio(Const char *name); + uint8 GetMissionAudioLoadingStatus(); + void SetMissionAudioLocation(float x, float y, float z); + void PlayLoadedMissionAudio(); + bool8 IsMissionAudioSampleFinished(); + bool8 IsMissionAudioSamplePlaying() { return m_sMissionAudio.m_nPlayStatus == PLAY_STATUS_PLAYING; } + bool8 ShouldDuckMissionAudio() { return IsMissionAudioSamplePlaying(); } + void ClearMissionAudio(); + void ProcessMissionAudio(); + + // police radio + void InitialisePoliceRadioZones(); + void InitialisePoliceRadio(); + void ResetPoliceRadio(); + void SetMissionScriptPoliceAudio(int32 sfx); + int8 GetMissionScriptPoliceAudioPlayingStatus(); + void DoPoliceRadioCrackle(); void ServicePoliceRadio(); void ServicePoliceRadioChannel(uint8 wantedLevel); - void ServiceSoundEffects(); - int8 SetCurrent3DProvider(uint8 which); - void SetDynamicAcousticModelingStatus(bool8 status); - void SetEffectsFadeVol(uint8 volume) const; - void SetEffectsMasterVolume(uint8 volume) const; - void SetEntityStatus(int32 id, bool8 status); - uint32 SetLoopingCollisionRequestedSfxFreqAndGetVol(const cAudioCollision &audioCollision); - void SetMissionAudioLocation(float x, float y, float z); - void SetMissionScriptPoliceAudio(int32 sfx) const; - void SetMonoMode(bool8 mono); - void SetMusicFadeVol(uint8 volume) const; - void SetMusicMasterVolume(uint8 volume) const; - void SetSpeakerConfig(int32 conf) const; - void SetUpLoopingCollisionSound(const cAudioCollision &col, uint8 counter); - void SetUpOneShotCollisionSound(const cAudioCollision &col); bool8 SetupCrimeReport(); - bool8 SetupJumboEngineSound(uint8 vol, uint32 freq); - bool8 SetupJumboFlySound(uint8 emittingVol); - bool8 SetupJumboRumbleSound(uint8 emittingVol); - bool8 SetupJumboTaxiSound(uint8 vol); - bool8 SetupJumboWhineSound(uint8 emittingVol, uint32 freq); - void SetupPedComments(cPedParams ¶ms, uint16 sound); void SetupSuspectLastSeenReport(); - - void Terminate(); - void TranslateEntity(Const CVector *v1, CVector *v2) const; - - void UpdateGasPedalAudio(CAutomobile *automobile); - void UpdateReflections(); - bool8 UsesReverseWarning(int32 model) const; - bool8 UsesSiren(int32 model) const; - bool8 UsesSirenSwitching(int32 model) const; - -#ifdef GTA_PC - // only used in pc - void AdjustSamplesVolume(); - uint8 ComputeEmittingVolume(uint8 emittingVolume, float intensity, float dist); -#endif + void ReportCrime(eCrimeType crime, const CVector &pos); + void PlaySuspectLastSeen(float x, float y, float z); + void AgeCrimes(); // inlined on PS2 + + // collision stuff + void ReportCollision(CEntity *entity1, CEntity *entity2, uint8 surface1, uint8 surface2, float collisionPower, float intensity2); + void ServiceCollisions(); + void SetUpOneShotCollisionSound(const cAudioCollision &col); + void SetUpLoopingCollisionSound(const cAudioCollision &col, uint8 counter); + uint32 SetLoopingCollisionRequestedSfxFreqAndGetVol(const cAudioCollision &audioCollision); + float GetCollisionOneShotRatio(uint32 a, float b); + float GetCollisionLoopingRatio(uint32 a, uint32 b, float c); // not used + float GetCollisionRatio(float a, float b, float c, float d); // inlined on PS2 }; /* diff --git a/src/audio/MusicManager.cpp b/src/audio/MusicManager.cpp index cb441622..815e55f2 100644 --- a/src/audio/MusicManager.cpp +++ b/src/audio/MusicManager.cpp @@ -236,23 +236,23 @@ cMusicManager::Initialise() 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 @@ -265,7 +265,7 @@ cMusicManager::Initialise() for (int i = 0; i < TOTAL_STREAMED_SOUNDS; i++) { m_aTracks[i].m_nLength = SampleManager.GetStreamedFileLength(i); - 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; m_aTracks[i].m_nLastPosCheckTimer = CTimer::GetTimeInMillisecondsPauseMode(); } @@ -949,7 +949,7 @@ cMusicManager::GetCarTuning() if (veh == nil) return RADIO_OFF; if (UsesPoliceRadio(veh)) return POLICE_RADIO; 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/PolRadio.cpp b/src/audio/PolRadio.cpp index 235a53d3..9a98de35 100644 --- a/src/audio/PolRadio.cpp +++ b/src/audio/PolRadio.cpp @@ -106,7 +106,7 @@ cAudioManager::ResetPoliceRadio() } void -cAudioManager::SetMissionScriptPoliceAudio(int32 sfx) const +cAudioManager::SetMissionScriptPoliceAudio(int32 sfx) { if (!m_bIsInitialised) return; if (g_nMissionAudioPlayingStatus != 1) { @@ -116,7 +116,7 @@ cAudioManager::SetMissionScriptPoliceAudio(int32 sfx) const } int8 -cAudioManager::GetMissionScriptPoliceAudioPlayingStatus() const +cAudioManager::GetMissionScriptPoliceAudioPlayingStatus() { return g_nMissionAudioPlayingStatus; } @@ -677,8 +677,6 @@ cAudioManager::SetupSuspectLastSeenReport() } } - - void cAudioManager::ReportCrime(eCrimeType type, const CVector &pos) { diff --git a/src/audio/sampman_miles.cpp b/src/audio/sampman_miles.cpp index d529513d..7c40d15d 100644 --- a/src/audio/sampman_miles.cpp +++ b/src/audio/sampman_miles.cpp @@ -1245,7 +1245,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; @@ -1256,7 +1256,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 ) @@ -1265,7 +1265,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 @@ -1345,7 +1345,7 @@ cSampleManager::CheckForAnAudioFileOnCD(void) strcpy(filepath, m_szCDRomRootPath); #endif // #if GTA_VERSION >= GTA3_PC_11 - strcat(filepath, PS2StreamedNameTable[AudioManager.GetRandomNumber(1) % TOTAL_STREAMED_SOUNDS]); + strcat(filepath, PS2StreamedNameTable[AudioManager.m_anRandomTable[1] % TOTAL_STREAMED_SOUNDS]); f = fopen(filepath, "rb"); if ( !f ) @@ -1360,7 +1360,7 @@ cSampleManager::CheckForAnAudioFileOnCD(void) strcpy(filepath, m_szCDRomRootPath); #endif // #if GTA_VERSION >= GTA3_PC_11 - strcat(filepath, StreamedNameTable[AudioManager.GetRandomNumber(1) % TOTAL_STREAMED_SOUNDS]); + strcat(filepath, StreamedNameTable[AudioManager.m_anRandomTable[1] % TOTAL_STREAMED_SOUNDS]); f = fopen(filepath, "rb"); } @@ -1631,12 +1631,12 @@ cSampleManager::UpdateReverb(void) 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); diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp index 2d9f9e86..74b352a1 100644 --- a/src/audio/sampman_oal.cpp +++ b/src/audio/sampman_oal.cpp @@ -995,7 +995,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; @@ -1006,7 +1006,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 ) @@ -1015,7 +1015,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 @@ -1363,9 +1363,9 @@ bool8 cSampleManager::UpdateReverb(void) if ( AudioManager.GetFrameCounter() & 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); -- cgit v1.2.3 From 6a94299eac3357ca4d1d13648df625b4a9d286fb Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Mon, 26 Jul 2021 04:42:15 +0300 Subject: Fix --- src/audio/sampman_oal.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/audio') diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp index 74b352a1..17776347 100644 --- a/src/audio/sampman_oal.cpp +++ b/src/audio/sampman_oal.cpp @@ -1360,7 +1360,7 @@ bool8 cSampleManager::UpdateReverb(void) if ( !usingEAX && !_usingEFX ) return FALSE; - if ( AudioManager.GetFrameCounter() & 15 ) + if ( AudioManager.m_FrameCounter & 15 ) return FALSE; float y = AudioManager.m_afReflectionsDistances[REFLECTION_TOP] + AudioManager.m_afReflectionsDistances[REFLECTION_BOTTOM]; -- cgit v1.2.3 From 5240dce01882804d5f68766cf75b33b81f14cdb4 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Tue, 27 Jul 2021 22:01:17 +0300 Subject: cAudioManager::GetCollisionOneShotRatio cleanup --- src/audio/AudioCollision.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src/audio') diff --git a/src/audio/AudioCollision.cpp b/src/audio/AudioCollision.cpp index cfd13fb6..bc470c49 100644 --- a/src/audio/AudioCollision.cpp +++ b/src/audio/AudioCollision.cpp @@ -353,33 +353,34 @@ cAudioManager::GetCollisionOneShotRatio(uint32 a, float b) case SURFACE_STEEP_CLIFF: case SURFACE_TRANSPARENT_STONE: return GetCollisionRatio(b, 10.f, 60.f, 50.f); case SURFACE_GRASS: - case SURFACE_CARDBOARDBOX: return GetCollisionRatio(b, 0.f, 2.f, 2.f); - case SURFACE_GRAVEL: return GetCollisionRatio(b, 0.f, 2.f, 2.f); + case SURFACE_CARDBOARDBOX: + case SURFACE_GRAVEL: case SURFACE_MUD_DRY: return GetCollisionRatio(b, 0.f, 2.f, 2.f); case SURFACE_CAR: return GetCollisionRatio(b, 6.f, 50.f, 44.f); - case SURFACE_GLASS: return GetCollisionRatio(b, 0.1f, 10.f, 9.9f); + case SURFACE_GLASS: + case SURFACE_METAL_CHAIN_FENCE: return GetCollisionRatio(b, 0.1f, 10.f, 9.9f); case SURFACE_TRANSPARENT_CLOTH: case SURFACE_THICK_METAL_PLATE: return GetCollisionRatio(b, 30.f, 130.f, 100.f); case SURFACE_GARAGE_DOOR: return GetCollisionRatio(b, 20.f, 100.f, 80.f); case SURFACE_CAR_PANEL: return GetCollisionRatio(b, 0.f, 4.f, 4.f); case SURFACE_SCAFFOLD_POLE: - case SURFACE_METAL_GATE: return GetCollisionRatio(b, 1.f, 10.f, 9.f); + case SURFACE_METAL_GATE: case SURFACE_LAMP_POST: return GetCollisionRatio(b, 1.f, 10.f, 9.f); case SURFACE_FIRE_HYDRANT: return GetCollisionRatio(b, 1.f, 15.f, 14.f); case SURFACE_GIRDER: return GetCollisionRatio(b, 8.f, 50.f, 42.f); - case SURFACE_METAL_CHAIN_FENCE: return GetCollisionRatio(b, 0.1f, 10.f, 9.9f); case SURFACE_PED: return GetCollisionRatio(b, 0.f, 20.f, 20.f); - case SURFACE_SAND: return GetCollisionRatio(b, 0.f, 10.f, 10.f); - case SURFACE_WATER: return GetCollisionRatio(b, 0.f, 10.f, 10.f); + case SURFACE_SAND: + case SURFACE_WATER: + case SURFACE_RUBBER: + case SURFACE_WHEELBASE: return GetCollisionRatio(b, 0.f, 10.f, 10.f); case SURFACE_WOOD_CRATES: return GetCollisionRatio(b, 1.f, 4.f, 3.f); case SURFACE_WOOD_BENCH: return GetCollisionRatio(b, 0.1f, 5.f, 4.9f); case SURFACE_WOOD_SOLID: return GetCollisionRatio(b, 0.1f, 40.f, 39.9f); - case SURFACE_RUBBER: - case SURFACE_WHEELBASE: return GetCollisionRatio(b, 0.f, 10.f, 10.f); case SURFACE_PLASTIC: return GetCollisionRatio(b, 0.1f, 4.f, 3.9f); case SURFACE_HEDGE: return GetCollisionRatio(b, 0.f, 0.5f, 0.5f); case SURFACE_CONTAINER: return GetCollisionRatio(b, 4.f, 40.f, 36.f); case SURFACE_NEWS_VENDOR: return GetCollisionRatio(b, 0.f, 5.f, 5.f); + default: break; } return 0.f; -- cgit v1.2.3 From 16e2e3d0913b5454b51c1300a6b6e1ae4012441a Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Tue, 27 Jul 2021 22:32:47 +0300 Subject: Type fix --- src/audio/AudioManager.h | 2 +- src/audio/PolRadio.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/audio') diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index 7c591a1e..b836f221 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -485,7 +485,7 @@ public: void InitialisePoliceRadioZones(); void InitialisePoliceRadio(); void ResetPoliceRadio(); - void SetMissionScriptPoliceAudio(int32 sfx); + void SetMissionScriptPoliceAudio(uint32 sfx); int8 GetMissionScriptPoliceAudioPlayingStatus(); void DoPoliceRadioCrackle(); void ServicePoliceRadio(); diff --git a/src/audio/PolRadio.cpp b/src/audio/PolRadio.cpp index 9a98de35..6fc1ceef 100644 --- a/src/audio/PolRadio.cpp +++ b/src/audio/PolRadio.cpp @@ -106,7 +106,7 @@ cAudioManager::ResetPoliceRadio() } void -cAudioManager::SetMissionScriptPoliceAudio(int32 sfx) +cAudioManager::SetMissionScriptPoliceAudio(uint32 sfx) { if (!m_bIsInitialised) return; if (g_nMissionAudioPlayingStatus != 1) { -- cgit v1.2.3 From d0666a8702ab3dff7c054474c7b0e833cc479501 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Tue, 27 Jul 2021 22:38:35 +0300 Subject: One more type fix --- src/audio/PolRadio.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/audio') diff --git a/src/audio/PolRadio.cpp b/src/audio/PolRadio.cpp index 6fc1ceef..d6079191 100644 --- a/src/audio/PolRadio.cpp +++ b/src/audio/PolRadio.cpp @@ -25,7 +25,7 @@ tPoliceRadioZone ZoneSfx[NUMAUDIOZONES]; char SubZo2Label[8]; char SubZo3Label[8]; -int32 g_nMissionAudioSfx = TOTAL_AUDIO_SAMPLES; +uint32 g_nMissionAudioSfx = TOTAL_AUDIO_SAMPLES; int8 g_nMissionAudioPlayingStatus = 2; uint8 gSpecialSuspectLastSeenReport; uint32 gMinTimeToNextReport[NUM_CRIME_TYPES]; -- cgit v1.2.3 From 81673ab304bbe0816785e95acd91c03c14674064 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Wed, 28 Jul 2021 10:36:18 +0300 Subject: Fix comments --- src/audio/AudioManager.cpp | 2 +- src/audio/AudioManager.h | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/audio') diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index c3565828..4f703c82 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -512,7 +512,7 @@ cAudioManager::ComputePan(float dist, CVector *vec) return Min(107, PanTable[index] + 63); } -int32 +uint32 cAudioManager::ComputeDopplerEffectedFrequency(uint32 oldFreq, float position1, float position2, float speedMultiplier) { uint32 newFreq = oldFreq; diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index b836f221..5757a873 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -267,7 +267,7 @@ public: uint8 ComputeVolume(uint8 emittingVolume, float soundIntensity, float distance); void TranslateEntity(Const CVector *v1, CVector *v2); int32 ComputePan(float, CVector *); - int32 ComputeDopplerEffectedFrequency(uint32 oldFreq, float position1, float position2, float speedMultiplier); // inlined on PS2 + uint32 ComputeDopplerEffectedFrequency(uint32 oldFreq, float position1, float position2, float speedMultiplier); // inlined on PS2 int32 RandomDisplacement(uint32 seed); void InterrogateAudioEntities(); // inlined on PS2 void AddSampleToRequestedQueue(); @@ -300,14 +300,14 @@ public: void ProcessSpecial(); void ProcessEntity(int32 sound); void ProcessPhysical(int32 id); + + // vehicles void ProcessVehicle(CVehicle *vehicle); void ProcessRainOnVehicle(cVehicleParams ¶ms); bool8 ProcessReverseGear(cVehicleParams ¶ms); void ProcessModelCarEngine(cVehicleParams ¶ms); bool8 ProcessVehicleRoadNoise(cVehicleParams ¶ms); bool8 ProcessWetRoadNoise(cVehicleParams ¶ms); - - // vehicles void ProcessVehicleEngine(cVehicleParams ¶ms); void UpdateGasPedalAudio(CAutomobile *automobile); // inlined on PS2 void PlayerJustGotInCar(); @@ -317,7 +317,7 @@ public: void ProcessPlayersVehicleEngine(cVehicleParams ¶ms, CAutomobile *automobile); bool8 ProcessVehicleSkidding(cVehicleParams ¶ms); float GetVehicleDriveWheelSkidValue(uint8 wheel, CAutomobile *automobile, cTransmission *transmission, float velocityChange); - float GetVehicleNonDriveWheelSkidValue(uint8 wheel, CAutomobile *automobile, cTransmission *transmission, float velocityChange); // was in .h on PS2 + float GetVehicleNonDriveWheelSkidValue(uint8 wheel, CAutomobile *automobile, cTransmission *transmission, float velocityChange); // inlined on PS2 void ProcessVehicleHorn(cVehicleParams ¶ms); bool8 UsesSiren(uint32 model); // inlined on PS2 bool8 UsesSirenSwitching(uint32 model); // inlined on PS2 -- cgit v1.2.3 From 6cea1de9e6062195f19b7fe5f1beeafe1432376c Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Thu, 29 Jul 2021 00:40:32 +0300 Subject: Reverse unused audio functions from mobile --- src/audio/AudioManager.cpp | 16 ++++++++++++++++ src/audio/AudioManager.h | 4 +++- src/audio/DMAudio.cpp | 12 ++++++++++++ src/audio/DMAudio.h | 4 +++- 4 files changed, 34 insertions(+), 2 deletions(-) (limited to 'src/audio') diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index 4f703c82..22415e76 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -160,6 +160,14 @@ cAudioManager::DestroyEntity(int32 id) } } +bool8 +cAudioManager::GetEntityStatus(int32 id) +{ + if (m_bIsInitialised && id >= 0 && id < NUM_AUDIOENTITIES && m_asAudioEntities[id].m_bIsUsed) + return m_asAudioEntities[id].m_bStatus; + return FALSE; +} + void cAudioManager::SetEntityStatus(int32 id, bool8 status) { @@ -167,6 +175,14 @@ cAudioManager::SetEntityStatus(int32 id, bool8 status) m_asAudioEntities[id].m_bStatus = status; } +void * +cAudioManager::GetEntityPointer(int32 id) +{ + if (m_bIsInitialised && id >= 0 && id < NUM_AUDIOENTITIES && m_asAudioEntities[id].m_bIsUsed) + return m_asAudioEntities[id].m_pEntity; + return NULL; +} + void cAudioManager::PlayOneShot(int32 index, uint16 sound, float vol) { diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index 5757a873..187a71a8 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -48,7 +48,7 @@ public: eAudioType m_nType; void *m_pEntity; bool8 m_bIsUsed; - uint8 m_bStatus; + bool8 m_bStatus; int16 m_awAudioEvent[NUM_AUDIOENTITY_EVENTS]; float m_afVolume[NUM_AUDIOENTITY_EVENTS]; uint8 m_AudioEvents; @@ -237,7 +237,9 @@ public: void Service(); int32 CreateEntity(eAudioType type, void *entity); void DestroyEntity(int32 id); + bool8 GetEntityStatus(int32 id); void SetEntityStatus(int32 id, bool8 status); + void *GetEntityPointer(int32 id); void PlayOneShot(int32 index, uint16 sound, float vol); void SetEffectsMasterVolume(uint8 volume); void SetMusicMasterVolume(uint8 volume); diff --git a/src/audio/DMAudio.cpp b/src/audio/DMAudio.cpp index eea91bd1..688da201 100644 --- a/src/audio/DMAudio.cpp +++ b/src/audio/DMAudio.cpp @@ -38,6 +38,12 @@ cDMAudio::DestroyEntity(int32 audioEntity) AudioManager.DestroyEntity(audioEntity); } +bool8 +cDMAudio::GetEntityStatus(int32 audioEntity) +{ + return AudioManager.GetEntityStatus(audioEntity); +} + void cDMAudio::SetEntityStatus(int32 audioEntity, bool8 status) { @@ -170,6 +176,12 @@ cDMAudio::IsAudioInitialised(void) return AudioManager.IsAudioInitialised(); } +void +cDMAudio::ResetPoliceRadio() +{ + AudioManager.ResetPoliceRadio(); +} + void cDMAudio::ReportCrime(eCrimeType crime, const CVector &pos) { diff --git a/src/audio/DMAudio.h b/src/audio/DMAudio.h index 19689fab..9f427272 100644 --- a/src/audio/DMAudio.h +++ b/src/audio/DMAudio.h @@ -22,6 +22,7 @@ public: int32 CreateEntity(eAudioType type, void *UID); void DestroyEntity(int32 audioEntity); + bool8 GetEntityStatus(int32 audioEntity); void SetEntityStatus(int32 audioEntity, bool8 status); void PlayOneShot(int32 audioEntity, uint16 oneShot, float volume); void DestroyAllGameCreatedEntities(void); @@ -51,7 +52,8 @@ public: char GetCDAudioDriveLetter(void); bool8 IsAudioInitialised(void); - + + void ResetPoliceRadio(); void ReportCrime(eCrimeType crime, CVector const &pos); int32 CreateLoopingScriptObject(cAudioScriptObject *scriptObject); -- cgit v1.2.3 From 0542b1bd4d8a08c39904a43c6104b27594c0a259 Mon Sep 17 00:00:00 2001 From: erorcun Date: Sat, 31 Jul 2021 23:03:59 +0300 Subject: Fix radio scroll when player controls disabled --- src/audio/MusicManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/audio') diff --git a/src/audio/MusicManager.cpp b/src/audio/MusicManager.cpp index 815e55f2..9872589a 100644 --- a/src/audio/MusicManager.cpp +++ b/src/audio/MusicManager.cpp @@ -527,7 +527,7 @@ cMusicManager::ServiceGameMode() #endif } #ifdef RADIO_SCROLL_TO_PREV_STATION - else if(CPad::GetPad(0)->GetMouseWheelDownJustDown() || CPad::GetPad(0)->GetMouseWheelUpJustDown()) { + else if(!CPad::GetPad(0)->ArePlayerControlsDisabled() && (CPad::GetPad(0)->GetMouseWheelDownJustDown() || CPad::GetPad(0)->GetMouseWheelUpJustDown())) { int scrollNext = ControlsManager.GetControllerKeyAssociatedWithAction(VEHICLE_CHANGE_RADIO_STATION, MOUSE); int scrollPrev = scrollNext == rsMOUSEWHEELUPBUTTON ? rsMOUSEWHEELDOWNBUTTON : scrollNext == rsMOUSEWHEELDOWNBUTTON ? rsMOUSEWHEELUPBUTTON : -1; -- cgit v1.2.3