summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/audio/sampman.cpp54
-rw-r--r--src/audio/sampman.h37
2 files changed, 47 insertions, 44 deletions
diff --git a/src/audio/sampman.cpp b/src/audio/sampman.cpp
index c758fc9f..abda71aa 100644
--- a/src/audio/sampman.cpp
+++ b/src/audio/sampman.cpp
@@ -18,7 +18,7 @@
#pragma comment( lib, "mss32.lib" )
cSampleManager &SampleManager = *(cSampleManager *)0x7341E0;
-int32 (&BankStartOffset)[2] = *(int32 (*)[2])*(int *)0x6FAB70;
+int32 (&BankStartOffset)[MAX_SAMPLEBANKS] = *(int32 (*)[MAX_SAMPLEBANKS])*(int *)0x6FAB70;
///////////////////////////////////////////////////////////////
@@ -289,7 +289,7 @@ cSampleManager::SetSpeakerConfig(int32 which)
}
uint32
-cSampleManager::GetMaximumSupportedChannels(void) //[Y]
+cSampleManager::GetMaximumSupportedChannels(void)
{
if ( _maxSamples > MAXCHANNELS )
return MAXCHANNELS;
@@ -857,10 +857,10 @@ cSampleManager::Initialise(void)
m_aSamples[i].nLoopEnd = -1;
}
- m_nEffectsVolume = 127;
- m_nMusicVolume = 127;
- m_nEffectsFadeVolume = 127;
- m_nMusicFadeVolume = 127;
+ m_nEffectsVolume = MAX_VOLUME;
+ m_nMusicVolume = MAX_VOLUME;
+ m_nEffectsFadeVolume = MAX_VOLUME;
+ m_nMusicFadeVolume = MAX_VOLUME;
m_nMonoMode = 0;
}
@@ -946,14 +946,14 @@ cSampleManager::Initialise(void)
return false;
}
- nSampleBankMemoryStartAddress[0] = (int32)AIL_mem_alloc_lock(nSampleBankSize[0]);
- if ( !nSampleBankMemoryStartAddress[0] )
+ nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN] = (int32)AIL_mem_alloc_lock(nSampleBankSize[SAMPLEBANK_MAIN]);
+ if ( !nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN] )
{
Terminate();
return false;
}
- nSampleBankMemoryStartAddress[1] = (int32)AIL_mem_alloc_lock(PED_BLOCKSIZE*MAX_PEDSFX);
+ nSampleBankMemoryStartAddress[SAMPLEBANK_PED] = (int32)AIL_mem_alloc_lock(PED_BLOCKSIZE*MAX_PEDSFX);
}
@@ -1159,7 +1159,7 @@ cSampleManager::Initialise(void)
TRACE("bank");
- LoadSampleBank(0);
+ LoadSampleBank(SAMPLEBANK_MAIN);
// mp3
TRACE("mp3");
@@ -1188,7 +1188,7 @@ cSampleManager::Initialise(void)
bUseRandomTable = true;
else
{
- bUseRandomTable = 0;
+ bUseRandomTable = false;
localtm = localtime(&t);
}
@@ -1254,16 +1254,16 @@ cSampleManager::Terminate(void)
_DeleteMP3Entries();
- if ( nSampleBankMemoryStartAddress[0] != 0 )
+ if ( nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN] != 0 )
{
- AIL_mem_free_lock((void *)nSampleBankMemoryStartAddress[0]);
- nSampleBankMemoryStartAddress[0] = 0;
+ AIL_mem_free_lock((void *)nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN]);
+ nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN] = 0;
}
- if ( nSampleBankMemoryStartAddress[1] != 0 )
+ if ( nSampleBankMemoryStartAddress[SAMPLEBANK_PED] != 0 )
{
- AIL_mem_free_lock((void *)nSampleBankMemoryStartAddress[1]);
- nSampleBankMemoryStartAddress[1] = 0;
+ AIL_mem_free_lock((void *)nSampleBankMemoryStartAddress[SAMPLEBANK_PED]);
+ nSampleBankMemoryStartAddress[SAMPLEBANK_PED] = 0;
}
if ( DIG )
@@ -1407,7 +1407,7 @@ cSampleManager::LoadSampleBank(uint8 nBank)
if ( MusicManager.IsInitialised()
&& MusicManager.GetMusicMode() == MUSICMODE_CUTSCENE
- && nBank != 0 )
+ && nBank != SAMPLEBANK_MAIN )
{
return false;
}
@@ -1496,10 +1496,10 @@ cSampleManager::LoadPedComment(uint32 nComment)
if ( fseek(fpSampleDataHandle, m_aSamples[nComment].nOffset, SEEK_SET) != 0 )
return false;
- if ( fread((void *)(nSampleBankMemoryStartAddress[1] + PED_BLOCKSIZE*nCurrentPedSlot), 1, m_aSamples[nComment].nSize, fpSampleDataHandle) != m_aSamples[nComment].nSize )
+ if ( fread((void *)(nSampleBankMemoryStartAddress[SAMPLEBANK_PED] + PED_BLOCKSIZE*nCurrentPedSlot), 1, m_aSamples[nComment].nSize, fpSampleDataHandle) != m_aSamples[nComment].nSize )
return false;
- nPedSlotSfxAddr[nCurrentPedSlot] = nSampleBankMemoryStartAddress[1] + PED_BLOCKSIZE*nCurrentPedSlot;
+ nPedSlotSfxAddr[nCurrentPedSlot] = nSampleBankMemoryStartAddress[SAMPLEBANK_PED] + PED_BLOCKSIZE*nCurrentPedSlot;
nPedSlotSfx [nCurrentPedSlot] = nComment;
if ( ++nCurrentPedSlot >= MAX_PEDSFX )
@@ -1706,7 +1706,7 @@ void
cSampleManager::SetChannelEmittingVolume(uint32 nChannel, uint32 nVolume)
{
uint32 vol = nVolume;
- if ( vol > 127 ) vol = 127;
+ if ( vol > MAX_VOLUME ) vol = MAX_VOLUME;
nChannelVolume[nChannel] = vol;
@@ -1741,7 +1741,7 @@ void
cSampleManager::SetChannelVolume(uint32 nChannel, uint32 nVolume)
{
uint32 vol = nVolume;
- if ( vol > 127 ) vol = 127;
+ if ( vol > MAX_VOLUME ) vol = MAX_VOLUME;
switch ( nChannel )
{
@@ -2181,8 +2181,8 @@ cSampleManager::SetStreamedVolumeAndPan(uint8 nVolume, uint8 nPan, uint8 nEffect
if ( m_bInitialised )
{
- if ( vol > 127 ) vol = 127;
- if ( vol > 127 ) vol = 127;
+ if ( vol > MAX_VOLUME ) vol = MAX_VOLUME;
+ if ( vol > MAX_VOLUME ) vol = MAX_VOLUME;
nStreamVolume[nStream] = vol;
nStreamPan[nStream] = nPan;
@@ -2228,7 +2228,7 @@ cSampleManager::IsStreamPlaying(uint8 nStream)
bool
cSampleManager::InitialiseSampleBanks(void)
{
- int32 nBank = 0;
+ int32 nBank = SAMPLEBANK_MAIN;
fpSampleDescHandle = fopen(SampleBankDescFilename, "rb");
if ( fpSampleDescHandle == NULL )
@@ -2261,8 +2261,8 @@ cSampleManager::InitialiseSampleBanks(void)
}
}
- nSampleBankSize[0] = nSampleBankDiscStartOffset[1] - nSampleBankDiscStartOffset[0];
- nSampleBankSize[1] = _nSampleDataEndOffset - nSampleBankDiscStartOffset[1];
+ nSampleBankSize[SAMPLEBANK_MAIN] = nSampleBankDiscStartOffset[SAMPLEBANK_PED] - nSampleBankDiscStartOffset[SAMPLEBANK_MAIN];
+ nSampleBankSize[SAMPLEBANK_PED] = _nSampleDataEndOffset - nSampleBankDiscStartOffset[SAMPLEBANK_PED];
return true;
}
diff --git a/src/audio/sampman.h b/src/audio/sampman.h
index ba2381b5..def4853f 100644
--- a/src/audio/sampman.h
+++ b/src/audio/sampman.h
@@ -2,6 +2,8 @@
#include "common.h"
#include "AudioSamples.h"
+#define MAX_VOLUME 127
+
struct tSample {
int32 nOffset;
uint32 nSize;
@@ -10,30 +12,31 @@ struct tSample {
int32 nLoopEnd;
};
-#define MAXPROVIDERS 64
-
-#define MAXCHANNELS 28
-#define MAXCHANNELS_SURROUND 24
-#define MAX2DCHANNELS 1
-#define CHANNEL2D MAXCHANNELS
+enum
+{
+ SAMPLEBANK_MAIN,
+ SAMPLEBANK_PED,
+ MAX_SAMPLEBANKS,
+};
+#define MAX_PEDSFX 7
+#define PED_BLOCKSIZE 79000
-#define MAX_MP3STREAMS 2
+#define MAXPROVIDERS 64
+#define MAXCHANNELS 28
+#define MAXCHANNELS_SURROUND 24
+#define MAX2DCHANNELS 1
+#define CHANNEL2D MAXCHANNELS
-#define MAX_SAMPLEBANKS 2
-#define MAX_PEDSFX 7
-#define PED_BLOCKSIZE 79000
+#define MAX_MP3STREAMS 2
+#define DIGITALRATE 32000
+#define DIGITALBITS 16
+#define DIGITALCHANNELS 2
#define MAX_DIGITAL_MIXER_CHANNELS 32
-#define DIGITALRATE 32000
-#define DIGITALBITS 16
-#define DIGITALCHANNELS 2
-
-
-
class cSampleManager
{
uint8 m_nEffectsVolume;
@@ -98,7 +101,7 @@ public:
int32 _GetPedCommentSlot(uint32 nComment);
- int32 GetSampleBaseFrequency (uint32 nSample);
+ int32 GetSampleBaseFrequency (uint32 nSample);
int32 GetSampleLoopStartOffset(uint32 nSample);
int32 GetSampleLoopEndOffset (uint32 nSample);
uint32 GetSampleLength (uint32 nSample);