data(NULL),
pitch(1.0),
volume(1.0),
+ reference_dist(500.0),
+ max_dist(3000.),
loop(AL_FALSE)
{
SGPath samplepath( path );
alSourcei( source, AL_LOOPING, loop );
alSourcei( source, AL_SOURCE_RELATIVE, AL_TRUE );
- alSourcef( source, AL_REFERENCE_DISTANCE, 500.0f );
- alSourcef( source, AL_MAX_DISTANCE, 3000.0f );
+ alSourcef( source, AL_REFERENCE_DISTANCE, reference_dist );
+ alSourcef( source, AL_MAX_DISTANCE, max_dist );
}
data(NULL),
pitch(1.0),
volume(1.0),
+ reference_dist(500.0),
+ max_dist(3000.),
loop(AL_FALSE)
{
SG_LOG( SG_GENERAL, SG_DEBUG, "In memory sounds sample" );
alSourcefv( source, AL_POSITION, source_pos );
alSourcefv( source, AL_VELOCITY, source_vel );
alSourcei( source, AL_LOOPING, loop );
+
+ alSourcei( source, AL_SOURCE_RELATIVE, AL_TRUE );
+ alSourcef( source, AL_REFERENCE_DISTANCE, reference_dist );
+ alSourcef( source, AL_MAX_DISTANCE, max_dist );
}
double pitch;
double volume;
+ double reference_dist;
+ double max_dist;
ALboolean loop;
public:
alSourcefv( source, AL_VELOCITY, source_vel );
}
+
+ /**
+ * Set reference distance of sound (the distance where the gain
+ * will be half.)
+ */
+ inline void set_reference_dist( ALfloat dist ) {
+ reference_dist = dist;
+ alSourcef( source, AL_REFERENCE_DISTANCE, reference_dist );
+ }
+
+
+ /**
+ * Set maximume distance of sound (the distance where the sound is
+ * no longer audible.
+ */
+ inline void set_max_dist( ALfloat dist ) {
+ max_dist = dist;
+ alSourcef( source, AL_MAX_DISTANCE, max_dist );
+ }
};
}
-
+ float reference_dist = node->getDoubleValue("reference-dist", 500.0);
+ float max_dist = node->getDoubleValue("max-dist", 3000.0);
+ SG_LOG(SG_GENERAL,SG_ALERT, "ref-dist = " << reference_dist );
+ SG_LOG(SG_GENERAL,SG_ALERT, "max-dist = " << max_dist );
+
//
// set pitch properties
//
_sample = new SGSoundSample( path.c_str(),
node->getStringValue("path", ""),
true );
+
_mgr->add( _sample, _name );
}
_sample->set_volume(v);
+ _sample->set_reference_dist( reference_dist );
+ _sample->set_max_dist( max_dist );
_sample->set_pitch(p);
}