From fd90dbb123adf798d0769e2572c8ed5a9924d05f Mon Sep 17 00:00:00 2001 From: ehofman Date: Sun, 1 Nov 2009 17:34:25 +0000 Subject: [PATCH] silently clip pitch and gain to their maximum values --- simgear/sound/sample_openal.hxx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/simgear/sound/sample_openal.hxx b/simgear/sound/sample_openal.hxx index 8f310233..a0fb812e 100644 --- a/simgear/sound/sample_openal.hxx +++ b/simgear/sound/sample_openal.hxx @@ -230,7 +230,10 @@ public: * Should be between 0.0 and 2.0 for maximum compatibility. * @param p Pitch */ - inline void set_pitch( float p ) { _pitch = p; _changed = true; } + inline void set_pitch( float p ) { + if (p > 2.0) p = 2.0; else if (p < 0.01) p = 0.01; + _pitch = p; _changed = true; + } /** * Get the current pitch value of this audio sample. @@ -245,6 +248,7 @@ public: * @param v Volume */ inline void set_master_volume( float v ) { + if (v > 1.0) v = 1.0; else if (v < 0.0) v = 0.0; _master_volume = v; _changed = true; } @@ -254,7 +258,10 @@ public: * volume. * @param v Volume */ - inline void set_volume( float v ) { _volume = v; _changed = true; } + inline void set_volume( float v ) { + if (v > 1.0) v = 1.0; else if (v < 0.0) v = 0.0; + _volume = v; _changed = true; + } /** * Get the final volume value of this audio sample. -- 2.39.5