From: ehofman Date: Mon, 23 Nov 2009 10:32:26 +0000 (+0000) Subject: test for implementations with 'bad' doppler effects and adjust for it. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=406cdf8d1678fd470f65b2a8ea09620c060e4c36;p=simgear.git test for implementations with 'bad' doppler effects and adjust for it. --- diff --git a/simgear/sound/sample_group.cxx b/simgear/sound/sample_group.cxx index 9f486413..1c76bfa6 100644 --- a/simgear/sound/sample_group.cxx +++ b/simgear/sound/sample_group.cxx @@ -359,6 +359,10 @@ void SGSampleGroup::update_sample_config( SGSoundSample *sample ) { velocity = sample->get_velocity(); } + if (_smgr->bad_doppler_effect()) { + velocity *= 100.0f; + } + #if 0 if (length(position) > 20000) printf("%s source and listener distance greater than 20km!\n", diff --git a/simgear/sound/soundmgr_openal.cxx b/simgear/sound/soundmgr_openal.cxx index ebd3a4b4..ce415e29 100644 --- a/simgear/sound/soundmgr_openal.cxx +++ b/simgear/sound/soundmgr_openal.cxx @@ -69,7 +69,8 @@ SGSoundMgr::SGSoundMgr() : _geod_pos(SGGeod::fromCart(SGVec3d::zeros())), _velocity(SGVec3d::zeros()), _orientation(SGQuatd::zeros()), - _devname(NULL) + _devname(NULL), + _bad_doppler(false) { #if defined(ALUT_API_MAJOR_VERSION) && ALUT_API_MAJOR_VERSION >= 1 if (_alut_init == 0) { @@ -155,6 +156,11 @@ void SGSoundMgr::init() { else break; } + const char *renderer = (char *)alGetString(AL_RENDERER); + if ( strcmp(renderer, "OpenAL Sample Implementation") ) { + _bad_doppler = true; + } + if (_free_sources.size() == 0) { SG_LOG(SG_GENERAL, SG_ALERT, "Unable to grab any OpenAL sources!"); } diff --git a/simgear/sound/soundmgr_openal.hxx b/simgear/sound/soundmgr_openal.hxx index f3163018..30801665 100644 --- a/simgear/sound/soundmgr_openal.hxx +++ b/simgear/sound/soundmgr_openal.hxx @@ -260,6 +260,14 @@ public: */ 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. * @param samplepath Path to the file to load @@ -304,6 +312,7 @@ private: vector _sources_in_use; char *_devname; + bool _bad_doppler; bool testForALError(string s); bool testForALCError(string s);