beginning work on equalizer

This commit is contained in:
Drew Weymouth
2023-06-21 20:48:46 -07:00
parent bc10e7f3d2
commit 0e590ca8f3
+57
View File
@@ -0,0 +1,57 @@
package player
import (
"fmt"
"strings"
)
type WidthType int
const (
WidthTypeHz WidthType = iota
WidthTypeKhz
WidthTypeQ
WidthTypeOctave
WidthTypeSlope
)
type EqualizerBand struct {
Frequency int
Gain float64
Width float64
WidthType WidthType
}
type EqualizerCurve []EqualizerBand
func (e EqualizerCurve) String() string {
var sb strings.Builder
for i, band := range e {
if i > 0 {
sb.WriteString(",")
}
sb.WriteString(band.String())
}
return sb.String()
}
func (e EqualizerBand) String() string {
return fmt.Sprintf("equalizer=f=%d:g=%0.2f:t=%s:w=%0.2f",
e.Frequency, e.Gain, e.WidthType.String(), e.Width)
}
func (w WidthType) String() string {
switch w {
case WidthTypeHz:
return "h"
case WidthTypeKhz:
return "k"
case WidthTypeQ:
return "q"
case WidthTypeOctave:
return "o"
case WidthTypeSlope:
return "s"
}
return "x" // not reached
}