mirror of https://github.com/ArduPilot/ardupilot
AP_HAL_SITL: fix possible divide by 0 on synth.hpp
This commit is contained in:
parent
b3954afe52
commit
d78fe1ad99
|
@ -7,6 +7,7 @@
|
||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Audio.hpp>
|
#include <SFML/Audio.hpp>
|
||||||
|
#include <cfloat>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
namespace Synth
|
namespace Synth
|
||||||
|
@ -107,7 +108,7 @@ double amplitude(double dTime, sEnvelope env)
|
||||||
else if (dTime > env.dAttackTime && dTime <= (env.dAttackTime + env.dDecayTime)) // Decay phase
|
else if (dTime > env.dAttackTime && dTime <= (env.dAttackTime + env.dDecayTime)) // Decay phase
|
||||||
dAmplitude = ((dTime - env.dAttackTime) / env.dDecayTime) * (env.dSustainAmplitude - env.dStartAmplitude) + env.dStartAmplitude;
|
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;
|
dAmplitude = (dTime / env.dAttackTime) * env.dStartAmplitude;
|
||||||
|
|
||||||
// Amplitude should not be negative, check just in case
|
// Amplitude should not be negative, check just in case
|
||||||
|
|
Loading…
Reference in New Issue