Added standalone analyzer layout

This commit is contained in:
maze authored and maze committed 2026-10-29 17:29:54 +01:00
1 parent 0196bb3707
commit f9bc5bb3b8
5 files changed
+110 -13

No files matched your search

+28 -9
View File
@@ -64,7 +64,10 @@ func (w *Spectrum) String() string {
if w.waterfall {
variant = "waterfall"
}
return channels + " " + variant
if w.buffer != nil {
return channels + " " + variant + ":" + w.buffer.Bounds().Size().String()
}
return channels + " " + variant + ":nil"
}
func (w *Spectrum) update(channels, bins int) {
@@ -97,6 +100,21 @@ func (w *Spectrum) SetChannels(channels int) *Spectrum {
return w
}
func (w *Spectrum) SetHold(hold int) *Spectrum {
w.mu.Lock()
w.hold = hold
w.mu.Unlock()
return w
}
func (w *Spectrum) SetRange(min, max int) *Spectrum {
w.mu.Lock()
w.minFrequency = min
w.maxFrequency = max
w.mu.Unlock()
return w
}
func (w *Spectrum) SetWaterfall(on bool) *Spectrum {
w.mu.Lock()
w.waterfall = on
@@ -115,10 +133,6 @@ func (w *Spectrum) Resize(size image.Point) app.Widget {
}
func (w *Spectrum) Refresh(ctx app.Context) bool {
if !w.IsVisible() {
return false
}
bounds := w.bounds.Load()
if w.changed.CompareAndSwap(true, false) {
if w.buffer == nil {
@@ -134,7 +148,6 @@ func (w *Spectrum) Refresh(ctx app.Context) bool {
}
app.ImageCopyBounds(ctx.Display(), w.buffer, bounds.Add(w.position.Load()))
return true
}
@@ -226,14 +239,20 @@ func (w *Spectrum) refreshWaterfall(bounds image.Rectangle) {
height := bounds.Dy()
if w.channels == 1 {
for i, v := range w.bands[0] {
w.drawMonoPoint(i, v, height)
w.drawPoint(i, v, height)
}
} else {
offset := bounds.Dx() / 2
for i := range w.bands[0] {
w.drawPoint(i, w.bands[0][i], height)
w.drawPoint(offset+i, w.bands[1][i], height)
}
}
}
func (w *Spectrum) drawMonoPoint(i int, level float64, maxHeight int) {
func (w *Spectrum) drawPoint(x int, level float64, maxHeight int) {
intesity := uint8(16*level + .5)
w.buffer.Set(i, maxHeight-1, pixel.Gray4{Y: intesity})
w.buffer.Set(x, maxHeight-1, pixel.Gray4{Y: intesity})
}
func (w *Spectrum) StatusChanged(ctx app.Context, status *player.Status) {