29 #include "../idlib/precompiled.h"
106 if ( args.
Argc() == 2 ) {
124 const char *snd = args.
Argv( 1 );
132 int totalSamples = 0;
134 int totalPCMMemory = 0;
140 if ( snd && sample->
name.
Find( snd,
false ) < 0 ) {
146 const char *stereo = ( info.
nChannels == 2 ?
"ST" :
" " );
148 const char *defaulted = ( sample->
defaultSound ?
"(DEFAULTED)" : sample->
purged ?
"(PURGED)" :
"" );
164 common->
Printf(
"%8d total samples loaded\n", totalSamples );
165 common->
Printf(
"%8d kB total system memory used\n", totalMemory >> 10 );
177 int i,
j, numActiveDecoders, numWaitingDecoders;
180 numActiveDecoders = numWaitingDecoders = 0;
199 if ( sample !=
NULL ) {
206 numWaitingDecoders++;
227 if ( sample ==
NULL ) {
236 if ( localTime > sampleTime ) {
238 percent = ( localTime % sampleTime ) * 100 / sampleTime;
243 percent = localTime * 100 / sampleTime;
246 common->
Printf(
"%3d decoding %3d%% %s: %s\n", numActiveDecoders, percent, format, sample->
name.
c_str() );
252 common->
Printf(
"%d decoders\n", numWaitingDecoders + numActiveDecoders );
253 common->
Printf(
"%d waiting decoders\n", numWaitingDecoders );
254 common->
Printf(
"%d active decoders\n", numActiveDecoders );
266 if ( args.
Argc() != 2 ) {
287 soundSystemLocal.
InitHW();
300 common->
Printf(
"----- Initializing Sound System ------\n" );
318 for(
int i = -600;
i < 600;
i++ ) {
341 common->
Printf(
"Setup OpenAL device and context... " );
354 common->
Printf(
"OpenAL: EAX 4.0 extension not found\n" );
372 common->
Printf(
"OpenAL: disabling ( no EAX ). Using legacy mixer.\n" );
428 common->
Printf(
"--------------------------------------\n" );
601 int inTime, numSpeakers;
632 ulong dwCurrentWritePos;
633 dword dwCurrentBlock;
659 short *fBlock =
NULL;
693 if ( newSoundTime > 0x6fffffff ) {
718 short *dest = fBlock + nextWriteSamples * numSpeakers;
725 short temp = dest[j*2];
726 dest[j*2] = dest[j*2+1];
800 short temp = dest[j*2];
801 dest[j*2] = dest[j*2+1];
823 }
else if ( val <= -60.0
f ) {
825 }
else if ( val >= 60.0
f ) {
826 return powf( 2.0
f, val * ( 1.0
f / 6.0
f ) );
828 int ival = (
int)( ( val + 60.0
f ) * 10.0f );
842 memset( &ret, 0,
sizeof( ret ) );
851 memset(
graph, 0, 256*128 * 4 );
858 for( j = 0; j < numSpeakers; j++ ) {
862 if ( result > meter ) {
873 if ( numSpeakers == 6 ) {
882 for ( y = 0; y < 128; y++ ) {
883 for ( x = 0; x < xsize; x++ ) {
884 graph[(127-
y)*256 + offset + x ] = color;
889 }
else if ( y == 112 ) {
909 for( j = 0; j < numSpeakers; j++ ) {
914 if ( numSpeakers == 6 ) {
925 }
else if ( meter <= 112 ) {
930 for ( y = meter; y < 128 && y < meter + 4; y++ ) {
931 for ( x = 0; x < xsize; x++ ) {
932 graph[(127-
y)*256 + offset + x ] = color;
937 dword colors[] = { 0xff007f00, 0xff007f7f, 0xff00007f, 0xff00ff00, 0xff00ffff, 0xff0000ff };
939 for( j = 0; j < numSpeakers; j++ ) {
945 for(
int x = 0;
x < step;
x++ ) {
946 float result = accum[(i+
x)*numSpeakers+j];
947 result = result / 32768.0f;
951 if ( fmeter < -1.0
f ) {
953 }
else if ( fmeter > 1.0
f ) {
956 int meter = (fmeter * 63.0f);
957 graph[ (meter + 64) * 256 + xx ] = colors[j];
974 for( i = 0; i < 256; i++ ) {
976 for (
int y = -meter;
y < meter;
y++ ) {
977 graph[ (
y+64)*256 + i ] = colors[j];
996 int i,
j, firstEmitter, firstChannel;
1007 for ( i = firstEmitter; i < sw->
emitters.
Num(); i++ ) {
1024 if ( sample ==
NULL ) {
1039 return ( i * SOUND_MAX_CHANNELS + j );
1136 idStr efxname(
"efxs/" );
1137 idStr mapname( mapstring );
1161 int iOldestZeroVolSingleShot = -1;
1162 int iOldestZeroVolLooping = -1;
1163 int iOldestSingle = -1;
1181 if (
openalSources[i].startTime < timeOldestZeroVolSingleShot ) {
1183 iOldestZeroVolSingleShot =
i;
1186 if (
openalSources[i].startTime < timeOldestZeroVolLooping ) {
1188 iOldestZeroVolLooping =
i;
1198 if ( iUnused != -1 ) {
1200 }
else if ( iOldestZeroVolSingleShot != - 1 ) {
1201 index = iOldestZeroVolSingleShot;
1202 }
else if ( iOldestZeroVolLooping != -1 ) {
1203 index = iOldestZeroVolLooping;
1204 }
else if ( iOldestSingle != -1 ) {
1205 index = iOldestSingle;
1208 if ( index != -1 ) {
1276 float c, a1, a2, a3, b1, b2;
1285 a1 = 1.0 / ( 1.0 + resonance * c + c *
c );
1288 b1 = 2.0 * ( 1.0 - c *
c) * a1;
1289 b2 = ( 1.0 - resonance * c + c *
c ) * a1;
1292 out[0] = a1 * in[0] + a2 * in[-1] + a3 * in[-2] - b1 * out[-1] - b2 * out[-2];
1297 out[0] =
a1 * in[0] +
a2 * in[-1] +
a3 * in[-2] -
b1 * out[-1] -
b2 * out[-2];
1311 a1 = 1.0 / ( 1.0 +
res * c + c *
c );
1315 b1 = 2.0 * ( 1.0 - c *
c) *
a1;
1316 b2 = ( 1.0 -
res * c + c *
c ) *
a1;
1351 float out[10000], *out_p = out + 2;
1352 float in[10000], *in_p = in + 2;
1357 for (
int i = 0;
i < 6;
i++ ) {
1379 for (
int i = 0;
i < numSpeakers;
i++ ) {
1383 memset( in, 0, 10000 *
sizeof(
float ) );
1384 memset( out, 0, 10000 *
sizeof(
float ) );
1387 for (
int k = 0; k <
fxList.
Num(); k++ ) {
1396 for ( j = 0; j < numSamples; j++ ) {
1401 for ( j = 0; j < numSamples; j++ ) {
1406 fx->
SetContinuitySamples( in_p[numSamples-2], in_p[numSamples-3], out_p[numSamples-2], out_p[numSamples-3] );
1408 for ( j = 0; j < numSamples; j++ ) {
1409 samples[j * numSpeakers +
i] = out_p[
j];
#define EAXSOURCE_DEFAULTROOM
idSoundWorldLocal * currentSoundWorld
static idCVar s_force22kHz
idSoundChannel channels[SOUND_MAX_CHANNELS]
virtual void SetPlayingSoundWorld(idSoundWorld *soundWorld)
void GetContinuitySamples(float &in1, float &in2, float &out1, float &out2)
virtual int AsyncUpdate(int time)
void SetChannel(int chan)
virtual bool Initialize()=0
idStr & SetFileExtension(const char *extension)
virtual bool Flush(void)=0
assert(prefInfo.fullscreenBtn)
EAXGetBufferMode alEAXGetBufferMode
void ListSounds_f(const idCmdArgs &args)
static idCVar s_enviroSuitCutoffFreq
static idCVar s_meterTopTime
virtual void ClearBuffer(void)
idList< idSoundEmitterLocal * > emitters
static idCVar s_reverbTime
virtual void ProcessSample(float *in, float *out)
GLenum GLsizei GLenum format
static idCVar s_numberOfSpeakers
static float Tan16(float a)
float GetFloat(void) const
const int GetNumObjects(void)
virtual bool Lock(void **pDSLockedBuffer, ulong *dwDSLockedBufferSize)=0
const int MIXBUFFER_SAMPLES
float dB2Scale(const float val) const
void Sys_FreeOpenAL(void)
void Sys_Printf(const char *msg,...)
void FreeOpenALSource(ALuint handle)
virtual void ProcessSample(float *in, float *out)
int Sys_Milliseconds(void)
virtual idSoundSample * GetSample(void) const =0
static int GetNumUsedBlocks(void)
static idCVar s_libOpenAL
virtual cinData_t ImageForTime(const int milliseconds, const bool waveform)
int MillisecondsToSamples(int ms) const
static idCVar s_skipHelltimeFX
int GetCurrent44kHzTime(void) const
void ReloadSounds(bool force)
void DoEnviroSuit(float *samples, int numSamples, int numSpeakers)
void SoundSystemRestart_f(const idCmdArgs &args)
static idCVar s_spatializationDecay
idAudioHardware * snd_audio_hw
static idCVar s_slowAttenuate
void Sys_Sleep(const int time)
static idCVar s_muteEAXReverb
#define AL_NO_ERROR
Errors: No Error.
virtual void VPCALL Memset(void *dst, const int val, const int count)=0
virtual idSoundWorld * AllocSoundWorld(idRenderWorld *rw)
static idCVar s_decompressionLimit
virtual int GetNumberOfSpeakers(void)=0
void TestSound_f(const idCmdArgs &args)
static idCVar s_useOcclusion
static idCVar s_quadraticFalloff
void SoundReloadSounds_f(const idCmdArgs &args)
static idCVar s_playDefaultSound
virtual bool Unlock(void *pDSLockedBuffer, dword dwDSLockedBufferSize)=0
const int ROOM_SLICES_IN_BUFFER
virtual void Shutdown(void)
unsigned ALuint
OpenAL 32bit unsigned integer type.
virtual void Initialize()
int LengthIn44kHzSamples() const
void SetParms(float p1=0, float p2=0, float p3=0)
unsigned int ALsizei
OpenAL 32bit type.
#define ALC_DEVICE_SPECIFIER
static int GetUsedBlockMemory(void)
bool LoadFile(const char *filename, bool OSPath=false)
virtual void Initialize()
void ListSoundDecoders_f(const idCmdArgs &args)
void PrintMemInfo(MemInfo_t *mi)
void Init(idRenderWorld *rw)
static void Shutdown(void)
virtual int IsEAXAvailable(void)
void MixLoop(int current44kHz, int numSpeakers, float *finalMixBuffer)
static int FtoiFast(float f)
idSampleDecoder * decoder
static float Fabs(float f)
virtual void SetMute(bool mute)
static idCVar s_enviroSuitCutoffQ
static idCVar s_constantAmplitude
static idCVar s_useOpenAL
void SetInteger(const int value)
int GetInteger(void) const
static idCVar s_reverbFeedback
virtual bool GetCurrentPosition(ulong *pdwCurrentWriteCursor)=0
idList< SoundFX * > fxList
virtual bool InitHW(void)
void SetParameter(float val)
static idCVar s_drawSounds
static idCVar s_clipVolumes
int Find(const char c, int start=0, int end=-1) const
#define alcProcessContext
virtual void EndLevelLoad(const char *mapString)
static float Tan(float a)
static idCVar s_showLevelMeter
virtual void Printf(const char *fmt,...) id_attribute((format(printf
idSoundSample * leadinSample
#define alIsExtensionPresent
#define alcDestroyContext
virtual short * GetMixBuffer(void)=0
virtual void StartupVariable(const char *match, bool once)=0
virtual void ProcessSample(float *in, float *out)=0
static void ArgCompletion_SoundName(const idCmdArgs &args, void(*callback)(const char *s))
#define alcMakeContextCurrent
virtual void BeginLevelLoad(void)
static idCVar s_doorDistanceAdd
static idCVar s_useEAXReverb
EAXSetBufferMode alEAXSetBufferMode
virtual void SetMute(bool mute)=0
int Append(const type &obj)
static idCVar s_minVolume2
idSoundSystemLocal soundSystemLocal
float realAccum[6 *MIXBUFFER_SAMPLES+16]
virtual int GetMixBufferSize(void)=0
virtual void Write(bool flushing)=0
static unsigned long Ftol(float f)
static idCVar s_enviroSuitVolumeScale
static idCVar s_maxSoundsPerShader
idSoundCache * soundCache
idSoundSystem * soundSystem
bool Sys_LoadOpenAL(void)
openalSource_t openalSources[256]
void SetContinuitySamples(float in1, float in2, float out1, float out2)
#define AL_ROLLOFF_FACTOR
Indicate the rolloff factor for the source.
#define EAXPROPERTYID_EAX_Source
const idSoundSample * GetObject(const int index) const
virtual idSoundWorld * GetPlayingSoundWorld(void)
virtual void PlayShaderDirectly(const char *name, int channel=-1)
virtual void VPCALL MixedSoundToSamples(short *samples, const float *mixBuffer, const int numSamples)=0
const char * c_str(void) const
virtual bool ShutdownHW(void)
static idCVar s_globalFraction
void SetBool(const bool value)
static idCVar s_subFraction
const char * Argv(int arg) const
virtual int AsyncMix(int soundTime, float *mixBuffer)
ALsizei openalSourceCount
#define AL_BUFFER
Indicate the buffer to provide sound samples.
void * Mem_Alloc(const int size)
int SamplesToMilliseconds(int samples) const
ALuint AllocOpenALSource(idSoundChannel *chan, bool looping, bool stereo)
ALCcontext * openalContext
int GetSoundDecoderInfo(int index, soundDecoderInfo_t &decoderInfo)
static idAudioHardware * Alloc()
waveformatex_t objectInfo
static idCVar s_showStartSound
virtual int AsyncUpdateWrite(int time)
void Sys_LeaveCriticalSection(int index)
void Sys_EnterCriticalSection(int index)
virtual void ProcessSample(float *in, float *out)
static idCVar s_realTimeDecoding
virtual void AddCommand(const char *cmdName, cmdFunction_t function, int flags, const char *description, argCompletion_t argCompletion=NULL)=0
virtual void PrintMemInfo(MemInfo_t *mi)
static idCVar s_singleEmitter
#define alcSuspendContext
static idCVar s_minVolume6
const int SOUND_MAX_CHANNELS
idSIMDProcessor * SIMDProcessor
unsigned int nextWriteBlock