Skip to content

Commit

Permalink
Fix carla_findMaxNormalizedFloat call
Browse files Browse the repository at this point in the history
Signed-off-by: falkTX <falktx@falktx.com>
  • Loading branch information
falkTX committed Jan 13, 2023
1 parent 12d4d77 commit 9190d42
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions source/utils/CarlaMathUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,12 @@ void carla_fill<float>(float data[], const float& value, const std::size_t count
static inline
float carla_findMaxNormalizedFloat(const float floats[], const std::size_t count)
{
CARLA_SAFE_ASSERT_RETURN(floats != nullptr, 0.0f);
CARLA_SAFE_ASSERT_RETURN(count > 0, 0.0f);
CARLA_SAFE_ASSERT_RETURN(floats != nullptr, 0.f);
CARLA_SAFE_ASSERT_RETURN(count > 0, 0.f);

static constexpr const float kEmptyFloats[8192] = {};

if (count <= 8192 && std::memcmp(floats, kEmptyFloats, count) == 0)
if (count <= 8192 && std::memcmp(floats, kEmptyFloats, sizeof(float)*count) == 0)
return 0.0f;

float tmp, maxf2 = std::abs(floats[0]);
Expand All @@ -263,14 +263,14 @@ float carla_findMaxNormalizedFloat(const float floats[], const std::size_t count
if (!std::isfinite(floats[i]))
__builtin_unreachable();

tmp = std::abs(*floats++);
tmp = std::abs(floats[i]);

if (tmp > maxf2)
maxf2 = tmp;
}

if (maxf2 > 1.0f)
maxf2 = 1.0f;
if (maxf2 > 1.f)
maxf2 = 1.f;

return maxf2;
}
Expand Down

0 comments on commit 9190d42

Please sign in to comment.