add preamp to EQ

This commit is contained in:
Drew Weymouth
2023-06-24 13:22:11 -07:00
parent 59be258e89
commit 2d38a0712c
7 changed files with 46 additions and 9 deletions
+6
View File
@@ -10,6 +10,7 @@ import (
type Equalizer interface {
IsEnabled() bool
Preamp() float64
Curve() EqualizerCurve
Type() string
// Returns the band frequencies as strings friendly for display
@@ -18,6 +19,7 @@ type Equalizer interface {
type ISO15BandEqualizer struct {
Disabled bool
EQPreamp float64
BandGains [15]float64
}
@@ -32,6 +34,10 @@ func (i *ISO15BandEqualizer) IsEnabled() bool {
return !i.Disabled
}
func (i *ISO15BandEqualizer) Preamp() float64 {
return i.EQPreamp
}
func (i *ISO15BandEqualizer) Curve() EqualizerCurve {
fC := float64(25)
curve := make([]EqualizerBand, 0, len(i.BandGains))
+12 -1
View File
@@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"log"
"math"
"strconv"
"github.com/dweymouth/go-mpv"
@@ -507,7 +508,17 @@ func (p *Player) SetEqualizer(eq Equalizer) error {
if eq == nil || !eq.IsEnabled() {
return p.mpv.SetPropertyString("af", "")
}
return p.mpv.SetPropertyString("af", eq.Curve().String())
af := ""
if math.Abs(eq.Preamp()) > 0.01 {
af = fmt.Sprintf("volume=volume=%0.1fdB", eq.Preamp())
}
eqAF := eq.Curve().String()
if af == "" {
af = eqAF
} else if eqAF != "" {
af = fmt.Sprintf("%s,%s", af, eqAF)
}
return p.mpv.SetPropertyString("af", af)
}
func (p *Player) Equalizer() Equalizer {