Christophe Weblog Wiki Code Publications Music
simplify squeeze-mixer-compute-bar a bit
authorChristophe Rhodes <csr21@cantab.net>
Sun, 10 Aug 2014 07:25:59 +0000 (08:25 +0100)
committerChristophe Rhodes <csr21@cantab.net>
Sun, 10 Aug 2014 07:25:59 +0000 (08:25 +0100)
compute a quotient rather than repeated comparisons with fractional
part

squeeze.el

index c6f10d9feae79bc4be5bbd6e6117cee07ab87dd4..6e4f4da4c35371d6b677382a768b0fb3f3b83a42 100644 (file)
          (nblank (floor (- width exact))))
     (format "%s%s%s"
             (make-string nfull ?█)
-            (cond ((= width (+ nfull nblank)) "")
-                  ((< frac 0.0625) " ")
-                  ((< frac 0.1875) "▏")
-                  ((< frac 0.3125) "▎")
-                  ((< frac 0.4375) "▍")
-                  ((< frac 0.5625) "▌")
-                  ((< frac 0.6875) "▋")
-                  ((< frac 0.8125) "▊")
-                  ((< frac 0.9375) "▉")
-                  (t "█"))
+            (if (= width (+ nfull nblank))
+                ""
+              (aref " ▏▎▍▌▋▊▉█" (floor (+ frac 0.0625) 0.125)))
             (make-string nblank ? ))))
 
 (defun squeeze-mixer-make-bar (vol width)