diff --git a/libraries/AP_HAL_SITL/Synth.hpp b/libraries/AP_HAL_SITL/Synth.hpp index d4a2374681..cc96cf9f44 100644 --- a/libraries/AP_HAL_SITL/Synth.hpp +++ b/libraries/AP_HAL_SITL/Synth.hpp @@ -7,6 +7,7 @@ // Headers //////////////////////////////////////////////////////////// #include +#include #include namespace Synth @@ -107,7 +108,7 @@ double amplitude(double dTime, sEnvelope env) else if (dTime > env.dAttackTime && dTime <= (env.dAttackTime + env.dDecayTime)) // Decay phase dAmplitude = ((dTime - env.dAttackTime) / env.dDecayTime) * (env.dSustainAmplitude - env.dStartAmplitude) + env.dStartAmplitude; - else if (dTime <= env.dAttackTime) // Attack phase + else if ((env.dAttackTime >= DBL_EPSILON) && dTime <= env.dAttackTime) // Attack phase dAmplitude = (dTime / env.dAttackTime) * env.dStartAmplitude; // Amplitude should not be negative, check just in case