[Openal] Re: Source gain issue
Anthony Thibault
anthonythibault at yahoo.com
Fri Apr 4 18:39:13 PDT 2008
I put together a test program which exhibits the problem.
Here's the main function:
OpenALInit();
// use linear distance model & disable doppler.
alDistanceModel(AL_LINEAR_DISTANCE_CLAMPED);
alDopplerFactor(0.0f);
ALuint buffer = GenBufferFromWAVFile("SD5010.WAV");
ALuint source;
alGenSources(1,&source);
alSourcei(source, AL_BUFFER, buffer);
alSourcef(source, AL_GAIN, 1.0f);
alSourcefv(source, AL_POSITION, close);
// set falloff constants.
const float kRefDistance = 2.0f;
const float kMaxDistance = 30.0f;
const float kRolloffFactor = 1.0f;
alSourcef(source, AL_REFERENCE_DISTANCE, kRefDistance);
alSourcef(source, AL_MAX_DISTANCE, kMaxDistance);
alSourcef(source, AL_ROLLOFF_FACTOR, kRolloffFactor);
// attack transients are cut off.
printf("Play it close!\n");
alSourcePlay(source);
WaitForSound(source);
// can hear attack transients fine.
printf("Play it close, AGAIN!\n");
alSourcePlay(source);
WaitForSound(source);
alSourcefv(source, AL_POSITION, far);
// beginning of sound is audible, even tho it's outside of the max distance range!
printf("Play it far away!\n");
alSourcePlay(source);
WaitForSound(source);
// sound is now not audible.
printf("Play it far away, AGAIN!\n");
alSourcePlay(source);
WaitForSound(source);
OpenALShutdown();
Perhaps part of the problem is that I'm reusing the same source. I've tried all sorts of ways to reset the source, including deleting and re generating it. However the problem still persists.
Full source at:
www.hyperlogic.org/openaltest.tar.gz
Anthony Thibault
----- Original Message ----
From: Anthony Thibault <anthonythibault at yahoo.com>
To: openal at opensource.creative.com
Sent: Friday, April 4, 2008 4:56:56 PM
Subject: Source gain issue
Hello all, I'm having a problem with how sounds are rendered with OpenAL 1.1 on Mac OS 10.5.2 (leopard).
Whenever I play a freshly created source, near the listener, the volume of the sound ramps up quickly from 0 to 1. The initial part of the sample is clipped off, almost as if it had an ADSR envelope on it with a 100ms attack time.
I also have a similar problem that occurs with sources that are far outside the linear falloff distance. The volume ramps down from 1 to 0. This causes the initial part of the sound to be audible, when it should be completely silent.
Has anyone heard this behavior before, or know any workarounds?
Anthony Thibault
____________________________________________________________________________________
You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost.
http://tc.deals.yahoo.com/tc/blockbuster/text5.com
____________________________________________________________________________________
You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost.
http://tc.deals.yahoo.com/tc/blockbuster/text5.com
More information about the Openal
mailing list