mirror of
https://github.com/vsariola/sointu.git
synced 2026-02-23 08:33:17 -05:00
drafting
This commit is contained in:
parent
179ebb7cc3
commit
fcb9a06249
@ -68,10 +68,8 @@ func (s *SpectrumState) Layout(gtx C) D {
|
||||
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
|
||||
layout.Flexed(1, func(gtx C) D {
|
||||
data := func(chn int, xr plotRange) (yr plotRange) {
|
||||
xr.a = softplus(xr.a*10) / 10
|
||||
xr.b = softplus(xr.b*10) / 10
|
||||
xr.a = float32(math.Log(float64(xr.a))) + 1
|
||||
xr.b = float32(math.Log(float64(xr.b))) + 1
|
||||
xr.a = float32(math.Exp2(float64(xr.a-1) * 8))
|
||||
xr.b = float32(math.Exp2(float64(xr.b-1) * 8))
|
||||
w1, f1 := math.Modf(float64(xr.a) * float64(speclen))
|
||||
w2, f2 := math.Modf(float64(xr.b) * float64(speclen))
|
||||
x1 := max(int(w1), 0)
|
||||
@ -104,13 +102,33 @@ func (s *SpectrumState) Layout(gtx C) D {
|
||||
|
||||
return plotRange{-y1, -y2}
|
||||
}
|
||||
type pair struct {
|
||||
freq float64
|
||||
label string
|
||||
}
|
||||
xticks := func(r plotRange, yield func(pos float32, label string)) {
|
||||
yield(0, "")
|
||||
yield(1, "")
|
||||
for _, p := range []pair{
|
||||
{freq: 10, label: "10 Hz"},
|
||||
{freq: 20, label: "20 Hz"},
|
||||
{freq: 50, label: "50 Hz"},
|
||||
{freq: 100, label: "100 Hz"},
|
||||
{freq: 200, label: "200 Hz"},
|
||||
{freq: 500, label: "500 Hz"},
|
||||
{freq: 1e3, label: "1 kHz"},
|
||||
{freq: 2e3, label: "2 kHz"},
|
||||
{freq: 5e3, label: "5 kHz"},
|
||||
{freq: 1e4, label: "10 kHz"},
|
||||
{freq: 2e4, label: "20 kHz"},
|
||||
} {
|
||||
x := float32(math.Log2((p.freq/22050))/8 + 1)
|
||||
if x >= r.a && x <= r.b {
|
||||
yield(x, p.label)
|
||||
}
|
||||
}
|
||||
}
|
||||
yticks := func(r plotRange, yield func(pos float32, label string)) {
|
||||
yield(-1, "")
|
||||
yield(0, "")
|
||||
yield(-1, "0 dB")
|
||||
yield(0, "-Inf dB")
|
||||
}
|
||||
return s.plot.Layout(gtx, data, xticks, yticks, 0, numchns)
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user