Skip to content

Commit

Permalink
OpenAL sound: Use a simpler distance model
Browse files Browse the repository at this point in the history
In createPlayingSoundAt(), AL_ROLLOFF_FACTOR is not set, so it has
the default value of 1.0, this makes the equation of the currently
used AL_EXPONENT_DISTANCE distance model identical to the equation
of the simpler AL_INVERSE_DISTANCE distance model.

Using AL_INVERSE_DISTANCE means an exponent is not processed,
exponents are quite intensive to process.
There is no change in sound attenuation behaviour.

The commented-out AL_ROLLOFF_FACTOR value is removed as it would
now have a different effect if used.
  • Loading branch information
paramat committed Feb 9, 2017
1 parent e2ad76f commit a5ee713
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/sound_openal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ class OpenALSoundManager: public ISoundManager
return;
}

alDistanceModel(AL_EXPONENT_DISTANCE);
alDistanceModel(AL_INVERSE_DISTANCE);

infostream<<"Audio: Initialized: OpenAL "<<alGetString(AL_VERSION)
<<", using "<<alcGetString(m_device, ALC_DEVICE_SPECIFIER)
Expand Down Expand Up @@ -409,7 +409,6 @@ class OpenALSoundManager: public ISoundManager
alSourcei(sound->source_id, AL_SOURCE_RELATIVE, false);
alSource3f(sound->source_id, AL_POSITION, pos.X, pos.Y, pos.Z);
alSource3f(sound->source_id, AL_VELOCITY, 0, 0, 0);
//alSourcef(sound->source_id, AL_ROLLOFF_FACTOR, 0.7);
alSourcef(sound->source_id, AL_REFERENCE_DISTANCE, 30.0);
alSourcei(sound->source_id, AL_LOOPING, loop ? AL_TRUE : AL_FALSE);
volume = MYMAX(0.0, volume);
Expand Down

0 comments on commit a5ee713

Please sign in to comment.