mirror of
https://github.com/ZDoom/qzdoom.git
synced 2025-02-06 15:51:02 +00:00
Fix compilation with OpenAL
This commit is contained in:
parent
18597a93a7
commit
b31a729ab8
2 changed files with 36 additions and 16 deletions
|
@ -1817,7 +1817,7 @@ void OpenALSoundRenderer::SetSfxVolume(float volume)
|
||||||
alSourcef(source, AL_MAX_GAIN, volume);
|
alSourcef(source, AL_MAX_GAIN, volume);
|
||||||
if(schan->ManualGain)
|
if(schan->ManualGain)
|
||||||
volume *= GetRolloff(&schan->Rolloff, sqrt(schan->DistanceSqr));
|
volume *= GetRolloff(&schan->Rolloff, sqrt(schan->DistanceSqr));
|
||||||
alSourcef(source, AL_GAIN, volume);
|
alSourcef(source, AL_GAIN, volume * ((FSoundChan*)schan)->Volume);
|
||||||
}
|
}
|
||||||
schan = schan->NextChan;
|
schan = schan->NextChan;
|
||||||
}
|
}
|
||||||
|
@ -1866,7 +1866,7 @@ float OpenALSoundRenderer::GetOutputRate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SoundHandle OpenALSoundRenderer::LoadSoundRaw(BYTE *sfxdata, int length, int frequency, int channels, int bits, int loopstart)
|
SoundHandle OpenALSoundRenderer::LoadSoundRaw(BYTE *sfxdata, int length, int frequency, int channels, int bits, int loopstart, int loopend)
|
||||||
{
|
{
|
||||||
SoundHandle retval = { NULL };
|
SoundHandle retval = { NULL };
|
||||||
|
|
||||||
|
@ -1911,17 +1911,19 @@ SoundHandle OpenALSoundRenderer::LoadSoundRaw(BYTE *sfxdata, int length, int fre
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(loopstart > 0 && LoopPoints)
|
if((loopstart > 0 || loopend > 0) && LoopPoints)
|
||||||
{
|
{
|
||||||
ALint loops[2] = {
|
if(loopstart < 0)
|
||||||
loopstart,
|
loopstart = 0;
|
||||||
length / (channels*bits/8)
|
if(loopend < loopstart)
|
||||||
};
|
loopend = length / (channels*bits/8);
|
||||||
|
|
||||||
|
ALint loops[2] = { loopstart, loopend };
|
||||||
Printf("Setting loop points %d -> %d\n", loops[0], loops[1]);
|
Printf("Setting loop points %d -> %d\n", loops[0], loops[1]);
|
||||||
alBufferiv(buffer, AL_LOOP_POINTS, loops);
|
alBufferiv(buffer, AL_LOOP_POINTS, loops);
|
||||||
getALError();
|
getALError();
|
||||||
}
|
}
|
||||||
else if(loopstart > 0)
|
else if(loopstart > 0 || loopend > 0)
|
||||||
{
|
{
|
||||||
static bool warned = false;
|
static bool warned = false;
|
||||||
if(!warned)
|
if(!warned)
|
||||||
|
@ -2170,11 +2172,11 @@ FISoundChannel *OpenALSoundRenderer::StartSound(SoundHandle sfx, float vol, int
|
||||||
else chan->SysChannel = &source;
|
else chan->SysChannel = &source;
|
||||||
|
|
||||||
chan->Rolloff.RolloffType = ROLLOFF_Linear;
|
chan->Rolloff.RolloffType = ROLLOFF_Linear;
|
||||||
chan->Rolloff.MaxDistance = 2.f;
|
chan->Rolloff.MaxDistance = 1000.f;
|
||||||
chan->Rolloff.MinDistance = 1.f;
|
chan->Rolloff.MinDistance = 1.f;
|
||||||
chan->DistanceScale = 1.f;
|
chan->DistanceScale = 1.f;
|
||||||
chan->DistanceSqr = (2.f-vol)*(2.f-vol);
|
chan->DistanceSqr = 1.f;
|
||||||
chan->ManualGain = true;
|
chan->ManualGain = false;
|
||||||
|
|
||||||
return chan;
|
return chan;
|
||||||
}
|
}
|
||||||
|
@ -2321,6 +2323,20 @@ FISoundChannel *OpenALSoundRenderer::StartSound3D(SoundHandle sfx, SoundListener
|
||||||
return chan;
|
return chan;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OpenALSoundRenderer::ChannelVolume(FISoundChannel *chan, float volume)
|
||||||
|
{
|
||||||
|
if(chan == NULL || chan->SysChannel == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
alcSuspendContext(Context);
|
||||||
|
|
||||||
|
ALuint source = *((ALuint*)chan->SysChannel);
|
||||||
|
|
||||||
|
if(chan->ManualGain)
|
||||||
|
volume *= GetRolloff(&chan->Rolloff, sqrt(chan->DistanceSqr));
|
||||||
|
alSourcef(source, AL_GAIN, SfxVolume * volume);
|
||||||
|
}
|
||||||
|
|
||||||
void OpenALSoundRenderer::StopChannel(FISoundChannel *chan)
|
void OpenALSoundRenderer::StopChannel(FISoundChannel *chan)
|
||||||
{
|
{
|
||||||
if(chan == NULL || chan->SysChannel == NULL)
|
if(chan == NULL || chan->SysChannel == NULL)
|
||||||
|
@ -2384,7 +2400,7 @@ void OpenALSoundRenderer::SetSfxPaused(bool paused, int slot)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenALSoundRenderer::SetInactive(bool inactive)
|
void OpenALSoundRenderer::SetInactive(EInactiveState)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2443,7 +2459,7 @@ void OpenALSoundRenderer::UpdateSoundParams3D(SoundListener *listener, FISoundCh
|
||||||
if(chan->ManualGain)
|
if(chan->ManualGain)
|
||||||
{
|
{
|
||||||
float gain = GetRolloff(&chan->Rolloff, sqrt(chan->DistanceSqr));
|
float gain = GetRolloff(&chan->Rolloff, sqrt(chan->DistanceSqr));
|
||||||
alSourcef(source, AL_GAIN, SfxVolume*gain);
|
alSourcef(source, AL_GAIN, SfxVolume*gain*((FSoundChan*)chan)->Volume);
|
||||||
}
|
}
|
||||||
|
|
||||||
getALError();
|
getALError();
|
||||||
|
@ -2604,7 +2620,8 @@ float OpenALSoundRenderer::GetAudibility(FISoundChannel *chan)
|
||||||
ALfloat volume = 0.f;
|
ALfloat volume = 0.f;
|
||||||
|
|
||||||
if(!chan->ManualGain)
|
if(!chan->ManualGain)
|
||||||
volume = SfxVolume * GetRolloff(&chan->Rolloff, sqrt(chan->DistanceSqr));
|
volume = SfxVolume * ((FSoundChan*)chan)->Volume *
|
||||||
|
GetRolloff(&chan->Rolloff, sqrt(chan->DistanceSqr));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
alGetSourcef(source, AL_GAIN, &volume);
|
alGetSourcef(source, AL_GAIN, &volume);
|
||||||
|
|
|
@ -82,7 +82,7 @@ public:
|
||||||
virtual void SetSfxVolume(float volume);
|
virtual void SetSfxVolume(float volume);
|
||||||
virtual void SetMusicVolume(float volume);
|
virtual void SetMusicVolume(float volume);
|
||||||
virtual SoundHandle LoadSound(BYTE *sfxdata, int length);
|
virtual SoundHandle LoadSound(BYTE *sfxdata, int length);
|
||||||
virtual SoundHandle LoadSoundRaw(BYTE *sfxdata, int length, int frequency, int channels, int bits, int loopstart);
|
virtual SoundHandle LoadSoundRaw(BYTE *sfxdata, int length, int frequency, int channels, int bits, int loopstart, int loopend);
|
||||||
virtual void UnloadSound(SoundHandle sfx);
|
virtual void UnloadSound(SoundHandle sfx);
|
||||||
virtual unsigned int GetMSLength(SoundHandle sfx);
|
virtual unsigned int GetMSLength(SoundHandle sfx);
|
||||||
virtual unsigned int GetSampleLength(SoundHandle sfx);
|
virtual unsigned int GetSampleLength(SoundHandle sfx);
|
||||||
|
@ -96,6 +96,9 @@ public:
|
||||||
virtual FISoundChannel *StartSound(SoundHandle sfx, float vol, int pitch, int chanflags, FISoundChannel *reuse_chan);
|
virtual FISoundChannel *StartSound(SoundHandle sfx, float vol, int pitch, int chanflags, FISoundChannel *reuse_chan);
|
||||||
virtual FISoundChannel *StartSound3D(SoundHandle sfx, SoundListener *listener, float vol, FRolloffInfo *rolloff, float distscale, int pitch, int priority, const FVector3 &pos, const FVector3 &vel, int channum, int chanflags, FISoundChannel *reuse_chan);
|
virtual FISoundChannel *StartSound3D(SoundHandle sfx, SoundListener *listener, float vol, FRolloffInfo *rolloff, float distscale, int pitch, int priority, const FVector3 &pos, const FVector3 &vel, int channum, int chanflags, FISoundChannel *reuse_chan);
|
||||||
|
|
||||||
|
// Changes a channel's volume.
|
||||||
|
virtual void ChannelVolume(FISoundChannel *chan, float volume);
|
||||||
|
|
||||||
// Stops a sound channel.
|
// Stops a sound channel.
|
||||||
virtual void StopChannel(FISoundChannel *chan);
|
virtual void StopChannel(FISoundChannel *chan);
|
||||||
|
|
||||||
|
@ -109,7 +112,7 @@ public:
|
||||||
virtual void SetSfxPaused(bool paused, int slot);
|
virtual void SetSfxPaused(bool paused, int slot);
|
||||||
|
|
||||||
// Pauses or resumes *every* channel, including environmental reverb.
|
// Pauses or resumes *every* channel, including environmental reverb.
|
||||||
virtual void SetInactive(bool inactive);
|
virtual void SetInactive(EInactiveState state);
|
||||||
|
|
||||||
// Updates the volume, separation, and pitch of a sound channel.
|
// Updates the volume, separation, and pitch of a sound channel.
|
||||||
virtual void UpdateSoundParams3D(SoundListener *listener, FISoundChannel *chan, bool areasound, const FVector3 &pos, const FVector3 &vel);
|
virtual void UpdateSoundParams3D(SoundListener *listener, FISoundChannel *chan, bool areasound, const FVector3 &pos, const FVector3 &vel);
|
||||||
|
|
Loading…
Reference in a new issue