MCPcopy Create free account
hub / github.com/DISTRHO/Cardinal / d_findMaxNormalizedFloat128

Function d_findMaxNormalizedFloat128

plugins/Cardinal/src/plugin.hpp:87–112  ·  view source on GitHub ↗

* Find the highest absolute and normalized value within a float array. */

Source from the content-addressed store, hash-verified

85 * Find the highest absolute and normalized value within a float array.
86 */
87static inline
88float d_findMaxNormalizedFloat128(const float floats[128])
89{
90 static constexpr const float kEmptyFloats[128] = {};
91
92 if (std::memcmp(floats, kEmptyFloats, sizeof(float)*128) == 0)
93 return 0.f;
94
95 float tmp, maxf2 = std::abs(floats[0]);
96
97 for (std::size_t i=1; i<128; ++i)
98 {
99 if (!std::isfinite(floats[i]))
100 __builtin_unreachable();
101
102 tmp = std::abs(floats[i]);
103
104 if (tmp > maxf2)
105 maxf2 = tmp;
106 }
107
108 if (maxf2 > 1.f)
109 maxf2 = 1.f;
110
111 return maxf2;
112}

Callers 2

HostAudio.cppFile · 0.85
processFunction · 0.85

Calls 1

memcmpFunction · 0.85

Tested by

no test coverage detected