test for implementations with 'bad' doppler effects and adjust for it.

This commit is contained in:
ehofman
2009-11-24 14:17:54 +01:00
committed by Tim Moore
parent 5b28b024ae
commit 406cdf8d16
3 changed files with 20 additions and 1 deletions
+4
View File
@@ -359,6 +359,10 @@ void SGSampleGroup::update_sample_config( SGSoundSample *sample ) {
velocity = sample->get_velocity(); velocity = sample->get_velocity();
} }
if (_smgr->bad_doppler_effect()) {
velocity *= 100.0f;
}
#if 0 #if 0
if (length(position) > 20000) if (length(position) > 20000)
printf("%s source and listener distance greater than 20km!\n", printf("%s source and listener distance greater than 20km!\n",
+7 -1
View File
@@ -69,7 +69,8 @@ SGSoundMgr::SGSoundMgr() :
_geod_pos(SGGeod::fromCart(SGVec3d::zeros())), _geod_pos(SGGeod::fromCart(SGVec3d::zeros())),
_velocity(SGVec3d::zeros()), _velocity(SGVec3d::zeros()),
_orientation(SGQuatd::zeros()), _orientation(SGQuatd::zeros()),
_devname(NULL) _devname(NULL),
_bad_doppler(false)
{ {
#if defined(ALUT_API_MAJOR_VERSION) && ALUT_API_MAJOR_VERSION >= 1 #if defined(ALUT_API_MAJOR_VERSION) && ALUT_API_MAJOR_VERSION >= 1
if (_alut_init == 0) { if (_alut_init == 0) {
@@ -155,6 +156,11 @@ void SGSoundMgr::init() {
else break; else break;
} }
const char *renderer = (char *)alGetString(AL_RENDERER);
if ( strcmp(renderer, "OpenAL Sample Implementation") ) {
_bad_doppler = true;
}
if (_free_sources.size() == 0) { if (_free_sources.size() == 0) {
SG_LOG(SG_GENERAL, SG_ALERT, "Unable to grab any OpenAL sources!"); SG_LOG(SG_GENERAL, SG_ALERT, "Unable to grab any OpenAL sources!");
} }
+9
View File
@@ -260,6 +260,14 @@ public:
*/ */
inline bool has_changed() { return _changed; } inline bool has_changed() { return _changed; }
/**
* Some implementations seem to need the velocity miltyplied by a
* factor of 100 to make them distinct. I've not found if this is
* a problem in the implementation or in out code. Until then
* this function is used to detect the problematic implementations.
*/
inline bool bad_doppler_effect() { return _bad_doppler; }
/** /**
* Load a sample file and return it's configuration and data. * Load a sample file and return it's configuration and data.
* @param samplepath Path to the file to load * @param samplepath Path to the file to load
@@ -304,6 +312,7 @@ private:
vector<ALuint> _sources_in_use; vector<ALuint> _sources_in_use;
char *_devname; char *_devname;
bool _bad_doppler;
bool testForALError(string s); bool testForALError(string s);
bool testForALCError(string s); bool testForALCError(string s);