hook up replaygain config file options
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
|||||||
"path"
|
"path"
|
||||||
"supersonic/backend/util"
|
"supersonic/backend/util"
|
||||||
"supersonic/player"
|
"supersonic/player"
|
||||||
|
"supersonic/sharedutil"
|
||||||
|
|
||||||
"github.com/20after4/configdir"
|
"github.com/20after4/configdir"
|
||||||
"github.com/zalando/go-keyring"
|
"github.com/zalando/go-keyring"
|
||||||
@@ -51,6 +52,16 @@ func StartupApp() (*App, error) {
|
|||||||
a.Config.LocalPlayback.Volume = clamp(a.Config.LocalPlayback.Volume, 0, 100)
|
a.Config.LocalPlayback.Volume = clamp(a.Config.LocalPlayback.Volume, 0, 100)
|
||||||
a.Player.SetVolume(a.Config.LocalPlayback.Volume)
|
a.Player.SetVolume(a.Config.LocalPlayback.Volume)
|
||||||
|
|
||||||
|
rgainOpts := []string{ReplayGainNone, ReplayGainAlbum, ReplayGainTrack}
|
||||||
|
if !sharedutil.StringSliceContains(rgainOpts, a.Config.ReplayGain.Mode) {
|
||||||
|
a.Config.ReplayGain.Mode = ReplayGainNone
|
||||||
|
}
|
||||||
|
a.Player.SetReplayGainOptions(player.ReplayGainOptions{
|
||||||
|
Mode: player.ReplayGainMode(a.Config.ReplayGain.Mode),
|
||||||
|
PreventClipping: a.Config.ReplayGain.PreventClipping,
|
||||||
|
PreampGain: a.Config.ReplayGain.PreampGainDB,
|
||||||
|
})
|
||||||
|
|
||||||
a.ServerManager = NewServerManager()
|
a.ServerManager = NewServerManager()
|
||||||
a.PlaybackManager = NewPlaybackManager(a.bgrndCtx, a.ServerManager, a.Player, &a.Config.Scrobbling)
|
a.PlaybackManager = NewPlaybackManager(a.bgrndCtx, a.ServerManager, a.Player, &a.Config.Scrobbling)
|
||||||
a.LibraryManager = NewLibraryManager(a.ServerManager)
|
a.LibraryManager = NewLibraryManager(a.ServerManager)
|
||||||
|
|||||||
@@ -58,6 +58,12 @@ type ScrobbleConfig struct {
|
|||||||
ThresholdPercent int
|
ThresholdPercent int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ReplayGainConfig struct {
|
||||||
|
Mode string
|
||||||
|
PreampGainDB float64
|
||||||
|
PreventClipping bool
|
||||||
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Application AppConfig
|
Application AppConfig
|
||||||
Servers []*ServerConfig
|
Servers []*ServerConfig
|
||||||
@@ -69,6 +75,7 @@ type Config struct {
|
|||||||
PlaylistPage PlaylistPageConfig
|
PlaylistPage PlaylistPageConfig
|
||||||
LocalPlayback LocalPlaybackConfig
|
LocalPlayback LocalPlaybackConfig
|
||||||
Scrobbling ScrobbleConfig
|
Scrobbling ScrobbleConfig
|
||||||
|
ReplayGain ReplayGainConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func DefaultConfig() *Config {
|
func DefaultConfig() *Config {
|
||||||
@@ -106,6 +113,11 @@ func DefaultConfig() *Config {
|
|||||||
ThresholdTimeSeconds: 240,
|
ThresholdTimeSeconds: 240,
|
||||||
ThresholdPercent: 50,
|
ThresholdPercent: 50,
|
||||||
},
|
},
|
||||||
|
ReplayGain: ReplayGainConfig{
|
||||||
|
Mode: ReplayGainNone,
|
||||||
|
PreampGainDB: 0.0,
|
||||||
|
PreventClipping: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,12 @@ import (
|
|||||||
"github.com/dweymouth/go-subsonic/subsonic"
|
"github.com/dweymouth/go-subsonic/subsonic"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
ReplayGainNone = string(player.ReplayGainNone)
|
||||||
|
ReplayGainAlbum = string(player.ReplayGainAlbum)
|
||||||
|
ReplayGainTrack = string(player.ReplayGainTrack)
|
||||||
|
)
|
||||||
|
|
||||||
type PlaybackManager struct {
|
type PlaybackManager struct {
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
cancelPollPos context.CancelFunc
|
cancelPollPos context.CancelFunc
|
||||||
|
|||||||
+7
-2
@@ -50,8 +50,9 @@ const (
|
|||||||
// Replay Gain options (argument to SetReplayGainOptions).
|
// Replay Gain options (argument to SetReplayGainOptions).
|
||||||
type ReplayGainOptions struct {
|
type ReplayGainOptions struct {
|
||||||
Mode ReplayGainMode
|
Mode ReplayGainMode
|
||||||
FallbackGain float64
|
|
||||||
PreampGain float64
|
PreampGain float64
|
||||||
|
PreventClipping bool
|
||||||
|
// Fallback gain intentionally omitted
|
||||||
}
|
}
|
||||||
|
|
||||||
// Player encapsulates the mpv instance and provides functions
|
// 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 {
|
if err := p.mpv.SetProperty("replaygain-preamp", MPVFormatDouble, options.PreampGain); err != nil {
|
||||||
return err
|
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
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user