Files
Bjarne Øverli 6d056f9580
Release / build (amd64, darwin, macos-latest) (push) Has been cancelled
Release / build (amd64, linux, ubuntu-latest) (push) Has been cancelled
Release / build (amd64, windows, windows-latest) (push) Has been cancelled
Release / build (arm64, darwin, macos-latest) (push) Has been cancelled
Release / build (arm64, linux, ubuntu-latest) (push) Has been cancelled
Release / release (push) Has been cancelled
Release / update-homebrew (push) Has been cancelled
Speed up visualizer FFT and rendering pipeline
2026-04-20 18:40:53 +02:00

31 lines
728 B
Go

package ui
import "strings"
// renderBars is the default smooth spectrum with fractional Unicode blocks.
func (v *Visualizer) renderBars(bands []float64) string {
height := v.Rows
lines := make([]string, height)
bandCount := len(bands)
for row := range height {
var content strings.Builder
rowBottom := float64(height-1-row) / float64(height)
rowTop := float64(height-row) / float64(height)
for i, level := range bands {
bw := visBandWidth(bandCount, i)
block := fracBlock(level, rowBottom, rowTop)
for range bw {
content.WriteString(block)
}
if i < bandCount-1 {
content.WriteByte(' ')
}
}
lines[row] = specWrap(rowBottom, content.String())
}
return strings.Join(lines, "\n")
}