diff --git a/simgear/sound/sample.hxx b/simgear/sound/sample.hxx index 366e4cad..a67524d7 100644 --- a/simgear/sound/sample.hxx +++ b/simgear/sound/sample.hxx @@ -181,6 +181,12 @@ public: */ inline float get_humidity() { return _humidity; } + /** + * Get the pressure at the current altitude. + * @return Pressure in kPa + */ + inline float get_pressure() { return _pressure; } + /** * Test if static data of audio sample configuration has changed. * Calling this function will reset the flag so calling it a second @@ -220,6 +226,7 @@ protected: float _reference_dist = 500.0f; float _max_dist = 3000.0f; + float _pressure = 101.325f; float _humidity = 0.5f; float _degC = 20.0f; @@ -557,12 +564,15 @@ public: /** * Set both the temperature and relative humidity at the current altitude. - * @param temp Temperature in degrees Celsius - * @param hum Percent relative humidity (0.0 to 1.0) + * @param t Temperature in degrees Celsius + * @param h Percent relative humidity (0.0 to 1.0) + * @param p Pressure in kPa; */ - inline void set_atmosphere(float temp, float hum) { - if (fabsf(_degC - temp) > 1.0f || fabsf(_humidity - hum) > 0.1f) { - _degC = temp, _humidity = hum; _static_changed = true; + inline void set_atmosphere(float t, float h, float p) { + if (fabsf(_degC - t) > 1.0f || fabsf(_humidity - h) > 0.1f || + fabsf(_pressure - p) > 1.0f) + { + _degC = t, _humidity = h; _pressure = p; _static_changed = true; } } diff --git a/simgear/sound/sample_group.cxx b/simgear/sound/sample_group.cxx index f25699d4..d303dee5 100644 --- a/simgear/sound/sample_group.cxx +++ b/simgear/sound/sample_group.cxx @@ -302,7 +302,7 @@ void SGSampleGroup::update_pos_and_orientation() { sample->set_rotation( ec2body ); sample->set_position(base_position); sample->set_velocity( velocity ); - sample->set_atmosphere( _degC, _humidity ); + sample->set_atmosphere( _degC, _humidity, _pressure ); // Test if a sample is farther away than max distance, if so // stop the sound playback and free it's source. diff --git a/simgear/sound/sample_group.hxx b/simgear/sound/sample_group.hxx index 07aabd36..be63224d 100644 --- a/simgear/sound/sample_group.hxx +++ b/simgear/sound/sample_group.hxx @@ -198,11 +198,12 @@ public: /** * Set both the temperature and relative humidity at the current altitude. - * @param temp Temperature in degrees Celsius - * @param hum Percent relative humidity (0.0 to 1.0) + * @param t Temperature in degrees Celsius + * @param h Percent relative humidity (0.0 to 1.0) + * @param p Pressure in kPa */ - void set_atmosphere(float temp, float hum ) { - _degC = temp, _humidity = hum; _changed = true; + void set_atmosphere(float t, float h, float p ) { + _degC = t, _humidity = h; _pressure = p; _changed = true; } /** @@ -223,6 +224,7 @@ private: bool _changed = false; bool _pause = false; float _volume = 1.0f; + float _pressure = 101.325f; float _humidity = 0.5f; float _degC = 20.0f;