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
+11
View File
@@ -9,6 +9,7 @@ import (
"path"
"supersonic/backend/util"
"supersonic/player"
"supersonic/sharedutil"
"github.com/20after4/configdir"
"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.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.PlaybackManager = NewPlaybackManager(a.bgrndCtx, a.ServerManager, a.Player, &a.Config.Scrobbling)
a.LibraryManager = NewLibraryManager(a.ServerManager)
+12
View File
@@ -58,6 +58,12 @@ type ScrobbleConfig struct {
ThresholdPercent int
}
type ReplayGainConfig struct {
Mode string
PreampGainDB float64
PreventClipping bool
}
type Config struct {
Application AppConfig
Servers []*ServerConfig
@@ -69,6 +75,7 @@ type Config struct {
PlaylistPage PlaylistPageConfig
LocalPlayback LocalPlaybackConfig
Scrobbling ScrobbleConfig
ReplayGain ReplayGainConfig
}
func DefaultConfig() *Config {
@@ -106,6 +113,11 @@ func DefaultConfig() *Config {
ThresholdTimeSeconds: 240,
ThresholdPercent: 50,
},
ReplayGain: ReplayGainConfig{
Mode: ReplayGainNone,
PreampGainDB: 0.0,
PreventClipping: true,
},
}
}
+6
View File
@@ -12,6 +12,12 @@ import (
"github.com/dweymouth/go-subsonic/subsonic"
)
const (
ReplayGainNone = string(player.ReplayGainNone)
ReplayGainAlbum = string(player.ReplayGainAlbum)
ReplayGainTrack = string(player.ReplayGainTrack)
)
type PlaybackManager struct {
ctx context.Context
cancelPollPos context.CancelFunc