reference_dist(500.0),
max_dist(3000.),
loop(AL_FALSE),
- playing(false)
+ playing(false),
+ no_Doppler_effect(true)
{
}
// constructor
-SGSoundSample::SGSoundSample( const char *path, const char *file) :
+SGSoundSample::SGSoundSample( const char *path, const char *file , bool _no_Doppler_effect ) :
buffer(0),
source(0),
pitch(1.0),
reference_dist(500.0),
max_dist(3000.),
loop(AL_FALSE),
- playing(false)
-{
+ playing(false),
+ no_Doppler_effect(_no_Doppler_effect)
+ {
SGPath samplepath( path );
if ( strlen(file) ) {
samplepath.append( file );
}
// constructor
-SGSoundSample::SGSoundSample( unsigned char *_data, int len, int _freq ) :
+SGSoundSample::SGSoundSample( unsigned char *_data, int len, int _freq , bool _no_Doppler_effect ) :
buffer(0),
source(0),
pitch(1.0),
reference_dist(500.0),
max_dist(3000.),
loop(AL_FALSE),
- playing(false)
+ playing(false),
+ no_Doppler_effect(_no_Doppler_effect)
{
SG_LOG( SG_GENERAL, SG_DEBUG, "In memory sounds sample" );
sgAddVec3( final_pos, source_pos, offset_pos );
alSourcefv( source, AL_POSITION, final_pos );
+ print_openal_error("set_source_pos");
}
}
sgAddVec3( final_pos, source_pos, offset_pos );
alSourcefv( source, AL_POSITION, final_pos );
+ print_openal_error("set_offset_pos");
}
}
}
void
-SGSoundSample::set_source_vel( ALfloat *vel ) {
- source_vel[0] = vel[0];
- source_vel[1] = vel[1];
- source_vel[2] = vel[2];
+SGSoundSample::set_source_vel( ALfloat *vel , ALfloat *listener_vel ) {
+ if (no_Doppler_effect) {
+ source_vel[0] = listener_vel[0];
+ source_vel[1] = listener_vel[1];
+ source_vel[2] = listener_vel[2];
+ } else {
+ source_vel[0] = vel[0];
+ source_vel[1] = vel[1];
+ source_vel[2] = vel[2];
+ }
if (playing) {
alSourcefv( source, AL_VELOCITY, source_vel );
}
# include <AL/alut.h>
#endif
+
SG_USING_STD(string);
/**
bool playing;
bool bind_source();
+ bool no_Doppler_effect;
public:
should usually be true unless you want to manipulate the data
later.)
*/
- SGSoundSample( const char *path, const char *file );
+ SGSoundSample( const char *path, const char *file , bool no_Doppler_effect = true );
/**
* Constructor.
should usually be true unless you want to manipulate the data
later.)
*/
- SGSoundSample( unsigned char *_data, int len, int _freq );
+ SGSoundSample( unsigned char *_data, int len, int _freq , bool no_Doppler_effect = true );
~SGSoundSample();
/**
* Set velocity of sound source (uses same coordinate system as opengl)
*/
- void set_source_vel( ALfloat *vel );
+ void set_source_vel( ALfloat *vel , ALfloat *listener_vel );
/**
// "alSource". The semantics of what is going on here seems
// confused and needs to be thought through more carefully.
_sample = new SGSoundSample( path.c_str(),
- node->getStringValue("path", "") );
+ node->getStringValue("path", ""),
+ false );
_mgr->add( _sample, _name );
}