mirror of
https://github.com/vsariola/sointu.git
synced 2025-07-18 21:14:31 -04:00
refactor(tracker): split Volume to PeakVolume and AverageVolume
This commit is contained in:
parent
1a8a317464
commit
50ccfe03da
@ -11,8 +11,9 @@ import (
|
||||
)
|
||||
|
||||
type VuMeter struct {
|
||||
Volume tracker.Volume
|
||||
Range float32
|
||||
AverageVolume tracker.Volume
|
||||
PeakVolume tracker.Volume
|
||||
Range float32
|
||||
}
|
||||
|
||||
func (v VuMeter) Layout(gtx C) D {
|
||||
@ -20,7 +21,7 @@ func (v VuMeter) Layout(gtx C) D {
|
||||
gtx.Constraints.Max.Y = gtx.Dp(unit.Dp(12))
|
||||
height := gtx.Dp(unit.Dp(6))
|
||||
for j := 0; j < 2; j++ {
|
||||
value := float32(v.Volume.Average[j]) + v.Range
|
||||
value := float32(v.AverageVolume[j]) + v.Range
|
||||
if value > 0 {
|
||||
x := int(value/v.Range*float32(gtx.Constraints.Max.X) + 0.5)
|
||||
if x > gtx.Constraints.Max.X {
|
||||
@ -28,7 +29,7 @@ func (v VuMeter) Layout(gtx C) D {
|
||||
}
|
||||
paint.FillShape(gtx.Ops, mediumEmphasisTextColor, clip.Rect(image.Rect(0, 0, x, height)).Op())
|
||||
}
|
||||
valueMax := float32(v.Volume.Peak[j]) + v.Range
|
||||
valueMax := float32(v.PeakVolume[j]) + v.Range
|
||||
if valueMax > 0 {
|
||||
color := white
|
||||
if valueMax >= v.Range {
|
||||
|
Reference in New Issue
Block a user