{
const float min_level = 9.0f; // y=0 is top of screen, so “min” is the loudest level.
const float max_level = -18.0f;
+
+ // Handle -inf.
+ if (level_lu < max_level) {
+ return height - 1;
+ }
+
int y = lrintf(height * (level_lu - min_level) / (max_level - min_level));
y = std::max(y, 0);
y = std::min(y, height - 1);
{
const float min_level = 9.0f; // y=0 is top of screen, so “min” is the loudest level.
const float max_level = -18.0f;
+
+ // Handle -inf.
+ if (level_lu < max_level) {
+ return height - 1;
+ }
+
int y = lrintf(height * (level_lu - min_level) / (max_level - min_level));
y = std::max(y, 0);
y = std::min(y, height - 1);