]> git.sesse.net Git - nageru/commitdiff
Fix meter display before we have any audio.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 31 Oct 2015 11:08:27 +0000 (12:08 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 31 Oct 2015 11:08:27 +0000 (12:08 +0100)
lrameter.cpp
vumeter.cpp

index 79a702dd7ca24c4a2d11e8259bed53c3f22c7a57..da651014ec268e5a5283ae1851cbce8c6c59e11d 100644 (file)
@@ -10,6 +10,12 @@ int lufs_to_pos(float level_lu, int height)
 {
        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);
index 7254698830c4815a00942302b7612ccf85f0701e..e377211fe1371c0abb2c28bec5b65ec14985119e 100644 (file)
@@ -10,6 +10,12 @@ int lufs_to_pos(float level_lu, int height)
 {
        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);