ref: 0b6a7b46dd0afe2e2b7486c9c540180673d52961
parent: 58db468b6f94b65c20fda728e1707ce8852634f9
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Sun Dec 24 21:56:21 EST 2023
openal: add a rather dumb doppler shift
--- a/unix/snd_openal.c
+++ b/unix/snd_openal.c
@@ -306,6 +306,8 @@
stepsnd(vec3_t zp, vec3_t fw, vec3_t rt, vec3_t up)
{
vec_t fwup[6] = {fw[0], fw[1], fw[2], up[0], up[1], up[2]};
+ static vec3_t ozp;
+ vec3_t vel;
if(dev == nil)
return;
@@ -317,6 +319,9 @@
alListenerfv(AL_POSITION, zp); ALERR();
alListenerfv(AL_ORIENTATION, fwup); ALERR();
+ VectorSubtract(zp, ozp, vel);
+ VectorCopy(zp, ozp);
+ alListenerfv(AL_VELOCITY, vel); ALERR();
alListenerf(AL_GAIN, volume.value); ALERR();
ambs(zp);
@@ -469,7 +474,10 @@
ALERR();
}
alListenerf(AL_GAIN, volume.value); ALERR();
- alDistanceModel(AL_LINEAR_DISTANCE_CLAMPED);
+ alDistanceModel(AL_LINEAR_DISTANCE_CLAMPED); ALERR();
+
+ // assuming 64 Quake units is ~1.7m
+ alSpeedOfSound(343.3 * 64.0 / 1.7); ALERR();
if(alIsExtensionPresent("AL_SOFT_source_resampler")){
al_default_resampler = alGetInteger(AL_DEFAULT_RESAMPLER_SOFT);