changed listener orientation to match openal handedness.

This commit is contained in:
Steven Fuller 2003-08-10 02:38:08 +00:00 committed by Patryk Obara
parent 638b22362e
commit 6ddf7d5a9a

View file

@ -37,12 +37,9 @@ static int SoundActivated = 0;
/* /*
openal.c TODO: openal.c TODO:
1. AL_PITCH seems to work, but laststand is still a bit weird. 1. There is no EAX/Reverb. But there's probably not much I can do...
2. Panning somewhat works now. Need someone to verify. 2. Restarting sound system may or may not work.
3. There is no EAX/Reverb. But there's probably not much I can do... 3. Better Error Handling (device not avail, etc).
4. Restarting sound system may or may not work.
5. Doppler (if it was originally used) isn't currently used.
6. Better Error Handling (device not avail, etc).
*/ */
int PlatStartSoundSys() int PlatStartSoundSys()
{ {
@ -84,8 +81,7 @@ int PlatStartSoundSys()
alListenerfv(AL_VELOCITY, vel); alListenerfv(AL_VELOCITY, vel);
alListenerfv(AL_ORIENTATION, or); alListenerfv(AL_ORIENTATION, or);
/* alDistanceModel(AL_NONE); */ alDistanceModel(AL_NONE);
alDistanceModel(AL_INVERSE_DISTANCE);
if (alGetError() != AL_NO_ERROR) { if (alGetError() != AL_NO_ERROR) {
fprintf(stderr, "alListenerfv() error = ...\n"); fprintf(stderr, "alListenerfv() error = ...\n");
@ -459,26 +455,25 @@ void PlatStopSound(int activeIndex)
} }
/* table generated by: /* table generated by:
c = -600.0 / log10(.5); vol_to_gain_table[volume] = (float) pow(10.0, (double) vol_to_atten_table[volume] / 2000.0);
x = pow(10, (double)vol_to_atten_table[volume]/c);
*/ */
static const float vol_to_gain_table[] = { static const float vol_to_gain_table[] = {
0.000000f, 0.000011f, 0.000054f, 0.000142f, 0.000279f, 0.000474f, 0.000730f, 0.001052f, 0.000010f, 0.000011f, 0.000056f, 0.000146f, 0.000287f, 0.000486f, 0.000748f, 0.001076f,
0.001441f, 0.001904f, 0.002444f, 0.003061f, 0.003764f, 0.004544f, 0.005417f, 0.006382f, 0.001474f, 0.001945f, 0.002495f, 0.003122f, 0.003837f, 0.004629f, 0.005514f, 0.006494f,
0.007434f, 0.008579f, 0.009820f, 0.011164f, 0.012604f, 0.014147f, 0.015788f, 0.017538f, 0.007560f, 0.008720f, 0.009977f, 0.011337f, 0.012794f, 0.014355f, 0.016014f, 0.017783f,
0.019393f, 0.021369f, 0.023438f, 0.025619f, 0.027937f, 0.030360f, 0.032880f, 0.035526f, 0.019656f, 0.021652f, 0.023741f, 0.025942f, 0.028281f, 0.030726f, 0.033266f, 0.035934f,
0.038296f, 0.041187f, 0.044194f, 0.047366f, 0.050649f, 0.054034f, 0.057512f, 0.061143f, 0.038726f, 0.041639f, 0.044668f, 0.047863f, 0.051168f, 0.054576f, 0.058076f, 0.061731f,
0.064929f, 0.068869f, 0.072880f, 0.077035f, 0.081428f, 0.085872f, 0.090454f, 0.095171f, 0.065539f, 0.069502f, 0.073536f, 0.077714f, 0.082130f, 0.086596f, 0.091201f, 0.095940f,
0.100018f, 0.104991f, 0.110083f, 0.115423f, 0.120882f, 0.126452f, 0.132127f, 0.138057f, 0.100809f, 0.105803f, 0.110917f, 0.116279f, 0.121759f, 0.127350f, 0.133045f, 0.138995f,
0.143919f, 0.150205f, 0.156402f, 0.162856f, 0.169576f, 0.176369f, 0.183222f, 0.190342f, 0.144877f, 0.151182f, 0.157398f, 0.163870f, 0.170608f, 0.177419f, 0.184289f, 0.191426f,
0.197510f, 0.204948f, 0.212421f, 0.220166f, 0.227931f, 0.235969f, 0.244008f, 0.252613f, 0.198609f, 0.206063f, 0.213550f, 0.221309f, 0.229087f, 0.237137f, 0.245188f, 0.253805f,
0.260918f, 0.269496f, 0.278355f, 0.287507f, 0.296616f, 0.306013f, 0.315344f, 0.324960f, 0.262120f, 0.270707f, 0.279576f, 0.288735f, 0.297852f, 0.307256f, 0.316592f, 0.326212f,
0.334869f, 0.344681f, 0.355191f, 0.365177f, 0.375877f, 0.386445f, 0.397309f, 0.408479f, 0.336124f, 0.345939f, 0.356451f, 0.366438f, 0.377138f, 0.387704f, 0.398566f, 0.409732f,
0.419478f, 0.430773f, 0.442372f, 0.454284f, 0.465978f, 0.477973f, 0.490276f, 0.502896f, 0.420727f, 0.432016f, 0.443609f, 0.455512f, 0.467197f, 0.479181f, 0.491473f, 0.504081f,
0.515246f, 0.528509f, 0.541488f, 0.554144f, 0.567752f, 0.581023f, 0.595291f, 0.609205f, 0.516416f, 0.529663f, 0.542625f, 0.555265f, 0.568853f, 0.582103f, 0.596348f, 0.610239f,
0.622725f, 0.637280f, 0.651423f, 0.666649f, 0.681444f, 0.695762f, 0.711203f, 0.726986f, 0.623735f, 0.638263f, 0.652379f, 0.667575f, 0.682339f, 0.696626f, 0.712033f, 0.727780f,
0.742262f, 0.757858f, 0.773782f, 0.790041f, 0.806642f, 0.823591f, 0.839926f, 0.856584f, 0.743019f, 0.758578f, 0.774462f, 0.790679f, 0.807235f, 0.824138f, 0.840427f, 0.857038f,
0.873573f, 0.890899f, 0.908568f, 0.926588f, 0.944965f, 0.962594f, 0.980552f, 1.000000f 0.873977f, 0.891251f, 0.908866f, 0.926830f, 0.945148f, 0.962720f, 0.980618f, 1.000000f
}; };
int PlatChangeGlobalVolume(int volume) int PlatChangeGlobalVolume(int volume)
@ -523,6 +518,10 @@ int PlatChangeSoundPitch(int activeIndex, int pitch)
frequency = frequency / (float)GameSounds[gsi].dsFrequency; frequency = frequency / (float)GameSounds[gsi].dsFrequency;
if (frequency > 2.0) { if (frequency > 2.0) {
#ifdef OPENAL_DEBUG
fprintf(stderr, "OPENAL: freq clamp = %f\n", frequency);
#endif
alSourceStop(ActiveSounds[activeIndex].ds3DBufferP); alSourceStop(ActiveSounds[activeIndex].ds3DBufferP);
return 0; return 0;
} }
@ -683,15 +682,15 @@ void PlatUpdatePlayer()
or[1] = 0.0; or[1] = 0.0;
or[2] = (float) ((Global_VDB_Ptr->VDB_Mat.mat33) / 65536.0F); or[2] = (float) ((Global_VDB_Ptr->VDB_Mat.mat33) / 65536.0F);
or[3] = 0.0; or[3] = 0.0;
or[4] = 1.0; or[4] = -1.0; /* negated for openal */
or[5] = 0.0; or[5] = 0.0;
} else { } else {
or[0] = (float) ((Global_VDB_Ptr->VDB_Mat.mat13) / 65536.0F); or[0] = (float) ((Global_VDB_Ptr->VDB_Mat.mat13) / 65536.0F);
or[1] = (float) ((Global_VDB_Ptr->VDB_Mat.mat23) / 65536.0F); or[1] = (float) ((Global_VDB_Ptr->VDB_Mat.mat23) / 65536.0F);
or[2] = (float) ((Global_VDB_Ptr->VDB_Mat.mat33) / 65536.0F); or[2] = (float) ((Global_VDB_Ptr->VDB_Mat.mat33) / 65536.0F);
or[3] = (float) ((Global_VDB_Ptr->VDB_Mat.mat12) / 65536.0F); or[3] = -(float) ((Global_VDB_Ptr->VDB_Mat.mat12) / 65536.0F);
or[4] = (float) ((Global_VDB_Ptr->VDB_Mat.mat22) / 65536.0F); or[4] = -(float) ((Global_VDB_Ptr->VDB_Mat.mat22) / 65536.0F); /* negated for openal */
or[5] = (float) ((Global_VDB_Ptr->VDB_Mat.mat32) / 65536.0F); or[5] = -(float) ((Global_VDB_Ptr->VDB_Mat.mat32) / 65536.0F);
} }
if ((AvP.PlayerType == I_Alien && DopplerShiftIsOn && NormalFrameTime)) { if ((AvP.PlayerType == I_Alien && DopplerShiftIsOn && NormalFrameTime)) {
@ -775,7 +774,10 @@ void InitialiseBaseFrequency(SOUNDINDEX soundNum)
frequency = ToneToFrequency(GameSounds[soundNum].dsFrequency, frequency = ToneToFrequency(GameSounds[soundNum].dsFrequency,
PITCH_DEFAULTPLAT, GameSounds[soundNum].pitch); PITCH_DEFAULTPLAT, GameSounds[soundNum].pitch);
#ifdef OPENAL_DEBUG
fprintf(stderr, "OPENAL: old=%d,new=%d\n", GameSounds[soundNum].dsFrequency, frequency); fprintf(stderr, "OPENAL: old=%d,new=%d\n", GameSounds[soundNum].dsFrequency, frequency);
#endif
GameSounds[soundNum].dsFrequency = frequency; GameSounds[soundNum].dsFrequency = frequency;
} }