29 #include "../idlib/precompiled.h"
87 void PermuteList_r(
int *list,
int listLength,
int permute,
int maxPermute ) {
88 if ( listLength < 2 ) {
91 permute %= maxPermute;
92 int swap = permute * listLength / maxPermute;
97 maxPermute /= listLength;
98 PermuteList_r( list + 1, listLength - 1, permute, maxPermute );
111 for (
int i = 0 ;
i < listLength ;
i++ ) {
116 if ( listLength > 12 ) {
121 int maxPermute =
Factorial( listLength );
134 for (
int j = 0 ;
j < max * 2 ;
j++ ) {
137 for (
int k = 0 ; k <
len ; k++ ) {
182 for( j = 0; j < 6; j++ ) {
261 float *dest_p = dest;
267 if ( sampleOffset44k < 0 ) {
268 len = -sampleOffset44k;
269 if ( len > sampleCount44k ) {
270 len = sampleCount44k;
272 memset( dest_p, 0, len *
sizeof( dest_p[0] ) );
274 sampleCount44k -=
len;
275 sampleOffset44k +=
len;
280 if ( !leadin || sampleOffset44k < 0 || sampleCount44k <= 0 ) {
281 memset( dest_p, 0, sampleCount44k *
sizeof( dest_p[0] ) );
285 if ( sampleOffset44k < leadin->LengthIn44kHzSamples() ) {
287 if ( len > sampleCount44k ) {
288 len = sampleCount44k;
295 sampleCount44k -=
len;
296 sampleOffset44k +=
len;
301 memset( dest_p, 0, sampleCount44k *
sizeof( dest_p[0] ) );
309 memset( dest_p, 0, sampleCount44k *
sizeof( dest_p[0] ) );
315 while( sampleCount44k > 0 ) {
318 sampleOffset44k %= totalLen;
320 len = totalLen - sampleOffset44k;
321 if ( len > sampleCount44k ) {
322 len = sampleCount44k;
329 sampleCount44k -=
len;
330 sampleOffset44k +=
len;
515 bool hasActive =
false;
550 if ( listenerArea == -1 ) {
556 if ( soundInArea == -1 ) {
565 if ( soundInArea == listenerArea ) {
595 common->
Error(
"idSoundEmitterLocal::UpdateEmitter: NULL parms" );
613 this->parms = *
parms;
680 chanParms = shader->
parms;
684 if ( chanParms.
shakes > 0.0f ) {
711 if ( choice < 0 || choice >= shader->
numEntries ) {
718 if ( shader->
leadins[ choice ] ) {
719 sample = shader->
leadins[ choice ];
721 sample = shader->
entries[ choice ];
760 if ( channel != SCHANNEL_ANY ) {
789 if ( i == SOUND_MAX_CHANNELS ) {
800 if ( shader->
leadins[ choice ] ) {
834 chan->
parms = chanParms;
878 common->
Error(
"idSoundEmitterLocal::ModifySound: NULL parms" );
902 if ( channel != SCHANNEL_ANY && chan->
triggerChannel != channel ) {
943 if ( channel != SCHANNEL_ANY && chan->
triggerChannel != channel ) {
1005 if ( channel != SCHANNEL_ANY && chan->
triggerChannel != channel ) {
1106 memset(
this, 0,
sizeof( *
this ) );
1151 int i, neededSamples, orgTime, zeroedPos,
count = 0;
1163 neededSamples = sampleCount44k * slowmoSpeed + 4;
1164 orgTime = playPos.
time;
1168 for ( i = 0; i < neededSamples >> 1; i++ ) {
1169 spline[
i] = src[i*2];
1173 zeroedPos = playPos.
time;
1176 for ( i = 0; i < sampleCount44k >> 1; i++, count += 2 ) {
1178 val = spline[playPos.
time];
1184 float *in_p = in + 2, *out_p = out + 2;
1185 int numSamples = sampleCount44k >> 1;
1190 for (
int i = 0, count = 0; i < numSamples; i++, count += 2 ) {
1192 finalBuffer[
count] = finalBuffer[count+1] = out[
i];
1197 playPos.
time += zeroedPos;
idSlowChannel GetSlowChannel(const idSoundChannel *chan)
idSoundChannel channels[SOUND_MAX_CHANNELS]
void GetContinuitySamples(float &in1, float &in2, float &out1, float &out2)
static idSampleDecoder * Alloc(void)
const idSoundShader * soundShader
int ALint
OpenAL 32bit signed integer type.
const float METERS_TO_DOOM
virtual bool CurrentlyPlaying(void) const
void PermuteList_r(int *list, int listLength, int permute, int maxPermute)
virtual void Free(bool immediate)
const idSoundChannel * chan
float GetFloat(void) const
void GatherChannelSamples(int sampleOffset44k, int sampleCount44k, float *dest)
virtual void UpdateEmitter(const idVec3 &origin, int listenerId, const soundShaderParms_t *parms)
const int MIXBUFFER_SAMPLES
float FindAmplitude(idSoundEmitterLocal *sound, const int localTime, const idVec3 *listenerPosition, const s_channelType channel, bool shakesOnly)
void FreeOpenALSource(ALuint handle)
virtual void ProcessSample(float *in, float *out)
int Sys_Milliseconds(void)
virtual void FadeSound(const s_channelType channel, float to, float over)
int MillisecondsToSamples(int ms) const
static idCVar s_skipHelltimeFX
const char * GetName(void) const
int GetCurrent44kHzTime(void) const
virtual void ClearDecoder(void)=0
virtual void ModifySound(const s_channelType channel, const soundShaderParms_t *parms)
void ResolveOrigin(const int stackDepth, const soundPortalTrace_t *prevStack, const int soundArea, const float dist, const idVec3 &soundOrigin, idSoundEmitterLocal *def)
ALuint lastopenalStreamingBuffer[3]
#define AL_NO_ERROR
Errors: No Error.
void SetSlowChannel(const idSoundChannel *chan, idSlowChannel slow)
FracTime GetCurrentPosition()
idSoundEmitterLocal(void)
idSoundSample * leadins[SOUND_MAX_LIST_WAVS]
int LengthIn44kHzSamples() const
void SetParms(float p1=0, float p2=0, float p3=0)
void CheckForCompletion(int current44kHzTime)
void ResetSlowChannel(const idSoundChannel *chan)
GLuint GLuint GLsizei count
virtual int WriteInt(const int value)
virtual bool CheckShakesAndOgg(void) const
idSlowChannel slowChannels[SOUND_MAX_CHANNELS]
SoundFX_LowpassFast lowpass
idSampleDecoder * decoder
static idCVar s_constantAmplitude
removeStatus_t removeStatus
ALuint openalStreamingOffset
static void Free(idSampleDecoder *decoder)
virtual const char * GetName(void) const =0
const float DOOM_TO_METERS
virtual void Printf(const char *fmt,...) id_attribute((format(printf
idSoundSample * leadinSample
void AttachSoundChannel(const idSoundChannel *chan)
virtual void StopSound(const s_channelType channel)
virtual int GetLastDecodeTime(void) const =0
virtual int StartSound(const idSoundShader *shader, const s_channelType channel, float diversity=0, int shaderFlags=0, bool allowSlow=true)
idSoundSample * entries[SOUND_MAX_LIST_WAVS]
void GeneratePermutedList(int *list, int listLength, int permute)
idSoundSystemLocal soundSystemLocal
void GatherChannelSamples(int sampleOffset44k, int sampleCount44k, float *dest) const
void GenerateSlowChannel(FracTime &playPos, int sampleCount44k, float *finalBuffer)
virtual int WriteFloat(const float value)
void SetContinuitySamples(float in1, float in2, float out1, float out2)
virtual idSoundWorld * GetPlayingSoundWorld(void)
ALuint openalStreamingBuffer[3]
GLsizei const GLcharARB const GLint * length
#define AL_SOURCE_STATE
Source state information.
virtual int Index(void) const
const char * c_str(void) const
float LengthFast(void) const
const int SOUND_DECODER_FREE_DELAY
virtual void Decode(idSoundSample *sample, int sampleOffset44k, int sampleCount44k, float *dest)=0
#define AL_BUFFER
Indicate the buffer to provide sound samples.
virtual ~idSoundEmitterLocal(void)
virtual int PointInArea(const idVec3 &point) const =0
const int SOUND_MAX_LIST_WAVS
waveformatex_t objectInfo
void TestPermutations(void)
virtual void Error(const char *fmt,...) id_attribute((format(printf
virtual void TimeHitch(int msec)=0
static idCVar s_showStartSound
void OverrideParms(const soundShaderParms_t *base, const soundShaderParms_t *over, soundShaderParms_t *out)
void Sys_LeaveCriticalSection(int index)
void Sys_EnterCriticalSection(int index)
idSoundWorldLocal * soundWorld
void Spatialize(idVec3 listenerPos, int listenerArea, idRenderWorld *rw)
virtual int WriteVec3(const idVec3 &vec)
s_channelType triggerChannel
float FadeDbAt44kHz(int current44kHz)
const int SOUND_MAX_CHANNELS
virtual float CurrentAmplitude(void)
void Increment(float val)
void WriteHashString(const char *str)