Pass raw "float" volume to OpenAL

The client uses float values between 0.0 and 1.0 to represent the volume
of sound samples. This is the range required by OpenAL. But the generic
part of the sound system multiplied the raw float value with 374 and
clamped it to a full integer. That worked by luck withth the OpenAL
backend but broke at least the silencer powerup. Solve this problem by
adding a new field "float oal_vol" to the channel_t struct and use it to
pass the raw float value to OpenAL.

This fixes issue #18
This commit is contained in:
Yamagi Burmeister 2013-01-17 20:17:44 +01:00
parent 2344637ed4
commit 548bbeb129
3 changed files with 6 additions and 5 deletions

View file

@ -99,6 +99,7 @@ typedef struct
qboolean autosound; /* from an entity->sound, cleared each frame */
#if USE_OPENAL
int autoframe;
float oal_vol;
int srcnum;
#endif
} channel_t;

View file

@ -292,11 +292,10 @@ AL_PlayChannel(channel_t *ch)
qalGetError();
qalSourcei(ch->srcnum, AL_BUFFER, sc->bufnum);
qalSourcei(ch->srcnum, AL_LOOPING, ch->autosound ? AL_TRUE : AL_FALSE);
qalSourcef(ch->srcnum, AL_GAIN, ch->master_vol / 3);
qalSourcef(ch->srcnum, AL_GAIN, ch->oal_vol);
qalSourcef(ch->srcnum, AL_REFERENCE_DISTANCE, SOUND_FULLVOLUME);
qalSourcef(ch->srcnum, AL_MAX_DISTANCE, 8192);
qalSourcef(ch->srcnum, AL_ROLLOFF_FACTOR, ch->dist_mult *
(8192 - SOUND_FULLVOLUME));
qalSourcef(ch->srcnum, AL_ROLLOFF_FACTOR, ch->dist_mult * (8192 - SOUND_FULLVOLUME));
AL_Spatialize(ch);

View file

@ -689,7 +689,6 @@ S_IssuePlaysound(playsound_t *ps)
ch->dist_mult = ps->attenuation * 0.0005f;
}
ch->master_vol = (int)ps->volume;
ch->entnum = ps->entnum;
ch->entchannel = ps->entchannel;
ch->sfx = ps->sfx;
@ -699,11 +698,13 @@ S_IssuePlaysound(playsound_t *ps)
#if USE_OPENAL
if (sound_started == SS_OAL)
{
ch->oal_vol = ps->volume;
AL_PlayChannel(ch);
}
else
#endif
{
ch->master_vol = (int)ps->volume;
S_Spatialize(ch);
}
@ -870,7 +871,7 @@ S_StartSound(vec3_t origin, int entnum, int entchannel, sfx_t *sfx,
if (sound_started == SS_OAL)
{
ps->begin = paintedtime + timeofs * 1000;
ps->volume = fvol * 384;
ps->volume = fvol;
}
else
#endif