From 825355dd546bd47d44b15b90c7c1c6592523f5c0 Mon Sep 17 00:00:00 2001 From: ivan tkachenko Date: Sat, 1 Nov 2025 21:17:45 +0200 Subject: [PATCH] Raise the default audio volume, add a configuration slider --- CHANGELOG.md | 1 + MuzikaGromche/Plugin.cs | 43 ++++++++++++++++++++++++----------------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e71617..96934f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## MuzikaGromche 1337.9001.1 +- Raised the default audio volume, and added a configuration slider. ## MuzikaGromche 1337.9001.0 - v73 Music quieter Edition diff --git a/MuzikaGromche/Plugin.cs b/MuzikaGromche/Plugin.cs index 5f8cf91..60c0e25 100644 --- a/MuzikaGromche/Plugin.cs +++ b/MuzikaGromche/Plugin.cs @@ -2177,10 +2177,13 @@ namespace MuzikaGromche public static bool ExtrapolateTime { get; private set; } = true; public static bool ShouldSkipWindingPhase { get; private set; } = false; - // Audio files are normalized to target -14 LUFS, which is too loud to communicate. Reduce by another -12 dB down to about -26 LUFS. - public static float DefaultVolume = 0.25f; -#if DEBUG + // Audio files are normalized to target -14 LUFS, which is too loud to communicate. Reduce by another -9 dB down to about -23 LUFS. + private const float VolumeDefault = 0.35f; + private const float VolumeMin = 0.2f; + private const float VolumeMax = 0.5f; + // Ranges from quiet 0.20 (-14 dB) to loud 0.5 (-6 dB) public static ConfigEntry Volume { get; private set; } = null!; +#if DEBUG // Latest set track, used for loading palette and timings. private static IAudioTrack? CurrentTrack = null; // All per-track values that can be overridden @@ -2231,6 +2234,10 @@ namespace MuzikaGromche new ConfigDescription("Display lyrics in the HUD tooltip when you hear the music.")); LethalConfigManager.AddConfigItem(new BoolCheckBoxConfigItem(DisplayLyrics, requiresRestart: false)); + Volume = configFile.Bind("General", "Volume", VolumeDefault, + new ConfigDescription("Volume of music played by this mod.", new AcceptableValueRange(VolumeMin, VolumeMax))); + LethalConfigManager.AddConfigItem(new FloatSliderConfigItem(Volume, requiresRestart: false)); + AudioOffset = configFile.Bind("General", "Audio Offset", 0f, new ConfigDescription( "Adjust audio offset (in seconds).\n\nIf you are playing with Bluetooth headphones and experiencing a visual desync, try setting this to about negative 0.2.\n\nIf your video output has high latency (like a long HDMI cable etc.), try positive values instead.", new AcceptableValueRange(-0.5f, 0.5f))); @@ -2249,7 +2256,6 @@ namespace MuzikaGromche SetupEntriesForScreenFilters(configFile); SetupEntriesForExtrapolation(configFile); SetupEntriesToSkipWinding(configFile); - SetupEntriesForVolume(configFile); SetupEntriesForPaletteOverride(configFile); SetupEntriesForTimingsOverride(configFile); #endif @@ -2333,13 +2339,6 @@ namespace MuzikaGromche } } - private void SetupEntriesForVolume(ConfigFile configFile) - { - Volume = configFile.Bind("General", "Volume", DefaultVolume, - new ConfigDescription("Volume of the music played by this mod.", new AcceptableValueRange(0f, 1f))); - LethalConfigManager.AddConfigItem(new FloatSliderConfigItem(Volume, requiresRestart: false)); - } - private void SetupEntriesForPaletteOverride(ConfigFile configFile) { const string section = "Palette"; @@ -2714,25 +2713,33 @@ namespace MuzikaGromche IntroAudioSource.maxDistance = Plugin.AudioMaxDistance; IntroAudioSource.dopplerLevel = 0; IntroAudioSource.loop = false; - IntroAudioSource.volume = Config.DefaultVolume; + IntroAudioSource.volume = Config.Volume.Value; LoopAudioSource = loopAudioGameObject.GetComponent(); LoopAudioSource.maxDistance = Plugin.AudioMaxDistance; LoopAudioSource.dopplerLevel = 0; LoopAudioSource.loop = true; - LoopAudioSource.volume = Config.DefaultVolume; + LoopAudioSource.volume = Config.Volume.Value; + + Config.Volume.SettingChanged += UpdateVolume; Debug.Log($"{nameof(MuzikaGromche)} {nameof(MuzikaGromcheJesterNetworkBehaviour)} Patched JesterEnemy"); } } -#if DEBUG - void Update() + public override void OnDestroy() { - IntroAudioSource.volume = Config.Volume.Value; - LoopAudioSource.volume = Config.Volume.Value; + Config.Volume.SettingChanged -= UpdateVolume; + } + + private void UpdateVolume(object sender, EventArgs e) + { + if (IntroAudioSource != null && LoopAudioSource != null) + { + IntroAudioSource.volume = Config.Volume.Value; + LoopAudioSource.volume = Config.Volume.Value; + } } -#endif public override void OnNetworkSpawn() {