]> Sergey Matveev's repositories - vors.git/commitdiff
Dynamically scale RMS bar
authorSergey Matveev <stargrave@stargrave.org>
Tue, 16 Apr 2024 19:11:24 +0000 (22:11 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Tue, 16 Apr 2024 19:43:31 +0000 (22:43 +0300)
cmd/client/stats.go

index 1d44e854094c12e896b08eb3bc8508b78ecd8261cb64fb27994ff3bd924ac2bb..28fe6477bbc07f6d40e4c5a1d10e8d06fe7abf08522bda16fe1274d6bc08f95b 100644 (file)
@@ -54,6 +54,7 @@ func statsDrawer(stats *Stats, name string) {
        var now time.Time
        var v *gocui.View
        var vol, volN float64
+       var maxRMS float64
        var rep int
        for {
                select {
@@ -91,7 +92,10 @@ func statsDrawer(stats *Stats, name string) {
                                        continue
                                }
                                vol = math.Sqrt(vol / volN)
-                               rep = int(float64(GUIMaxY) * vol / 5000)
+                               if vol/4 > maxRMS {
+                                       maxRMS = vol / 4
+                               }
+                               rep = int(float64(GUIMaxY) * vol / maxRMS)
                                v.Write([]byte(strings.Repeat("▒", rep)))
                        }
                }