hook up replaygain config file options

This commit is contained in:
Drew Weymouth
2023-03-28 18:17:45 -07:00
parent e22a16ea5a
commit fe5a6ffdf3
4 changed files with 38 additions and 4 deletions
+9 -4
View File
@@ -49,9 +49,10 @@ const (
// Replay Gain options (argument to SetReplayGainOptions).
type ReplayGainOptions struct {
Mode ReplayGainMode
FallbackGain float64
PreampGain float64
Mode ReplayGainMode
PreampGain float64
PreventClipping bool
// Fallback gain intentionally omitted
}
// Player encapsulates the mpv instance and provides functions
@@ -266,7 +267,11 @@ func (p *Player) SetReplayGainOptions(options ReplayGainOptions) error {
if err := p.mpv.SetProperty("replaygain-preamp", MPVFormatDouble, options.PreampGain); err != nil {
return err
}
if err := p.mpv.SetProperty("replaygain-fallback", MPVFormatDouble, options.FallbackGain); err != nil {
clip := "no"
if options.PreventClipping {
clip = "yes"
}
if err := p.mpv.SetPropertyString("replaygain-clip", clip); err != nil {
return err
}
}