From 6cd8db7b28b675f75ab22c2073832980d9f8d6a4 Mon Sep 17 00:00:00 2001 From: ehofman Date: Tue, 17 Nov 2009 13:06:32 +0000 Subject: [PATCH] Set to default distance attenuation function but change the parameters a but for better sound effects (and most of all quieter sounds at greta distance --- simgear/sound/sample_group.cxx | 2 +- simgear/sound/soundmgr_openal.cxx | 10 +++------- simgear/sound/xmlsound.cxx | 7 ++++--- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/simgear/sound/sample_group.cxx b/simgear/sound/sample_group.cxx index dfe8d756..bd1bf485 100644 --- a/simgear/sound/sample_group.cxx +++ b/simgear/sound/sample_group.cxx @@ -144,7 +144,7 @@ void SGSampleGroup::update( double dt ) { ALboolean looping = sample->is_looping() ? AL_TRUE : AL_FALSE; alSourcei( source, AL_LOOPING, looping ); - alSourcef( source, AL_ROLLOFF_FACTOR, 1.0 ); + alSourcef( source, AL_ROLLOFF_FACTOR, 0.3 ); alSourcei( source, AL_SOURCE_RELATIVE, AL_FALSE ); alSourcePlay( source ); testForALError("sample play"); diff --git a/simgear/sound/soundmgr_openal.cxx b/simgear/sound/soundmgr_openal.cxx index ef4a8f15..b9e86488 100644 --- a/simgear/sound/soundmgr_openal.cxx +++ b/simgear/sound/soundmgr_openal.cxx @@ -133,13 +133,9 @@ void SGSoundMgr::init() { alDopplerFactor(1.0); alDopplerVelocity(340.3); // speed of sound in meters per second. -#if 0 - if ( alIsExtensionPresent((const ALchar*)"EXT_exponent_distance") ) { - alDistanceModel(AL_EXPONENT_DISTANCE); - } else { - alDistanceModel(AL_INVERSE_DISTANCE); - } -#endif + // gain = AL_REFERENCE_DISTANCE / (AL_REFERENCE_DISTANCE + + // AL_ROLLOFF_FACTOR * (distance - AL_REFERENCE_DISTANCE)); + alDistanceModel(AL_INVERSE_DISTANCE_CLAMPED); testForALError("listener initialization"); diff --git a/simgear/sound/xmlsound.cxx b/simgear/sound/xmlsound.cxx index 79a57c7f..479e3123 100644 --- a/simgear/sound/xmlsound.cxx +++ b/simgear/sound/xmlsound.cxx @@ -174,9 +174,10 @@ SGXmlSound::init(SGPropertyNode *root, SGPropertyNode *node, } - float reference_dist = node->getDoubleValue("reference-dist", 500.0); - float max_dist = node->getDoubleValue("max-dist", 3000.0); - + // rule of thumb: make reference distance a 100th of the maximum distance. + float reference_dist = node->getDoubleValue("reference-dist", 60.0); + float max_dist = node->getDoubleValue("max-dist", 6000.0); + // // set pitch properties // -- 2.39.5