using Xunit; using ytLive.Services.Audio; namespace ytLive.Tests; /// The TRAX fader must actually change the level the meter measures — and it did not: /// `UserGain` wrote to the output device's volume (a no-op for NAudio's WaveOut), while the /// mute-follow rewrote the sample-chain volume WITHOUT the user gain, so pegging the fader changed /// nothing and the next desktop mute/duck silently discarded the setting. /// public class MusicLevelTests { [Fact] public void The_trax_fader_reaches_the_chain_and_survives_the_mute_follow() { // Default: the bed sits at the design volume; pegging doubles it (+6 dB). Assert.Equal(0.5f, MusicPlayer.EffectiveVolume(1f, 1f), 3); Assert.Equal(1.0f, MusicPlayer.EffectiveVolume(MusicPlayer.MaxUserGain, 1f), 3); // The mute-follow multiplies, it does not replace: the user gain survives. Assert.Equal(1.0f, MusicPlayer.EffectiveVolume(MusicPlayer.MaxUserGain, 1f), 3); Assert.Equal(0.5f, MusicPlayer.EffectiveVolume(1f, 1f), 3); // Muted (or a desktop mute) is silence whatever the fader says. Assert.Equal(0f, MusicPlayer.EffectiveVolume(MusicPlayer.MaxUserGain, 0f)); // And the floor is a real zero, not a residue. Assert.Equal(0f, MusicPlayer.EffectiveVolume(0f, 1f)); // The old defect cannot come back: nothing may drive the output device's volume. var source = SourceAssert.Text("Services", "Audio", "MusicPlayer.cs"); Assert.DoesNotContain("_output.Volume", source); Assert.Contains("EffectiveVolume(_userGain, _localGain)", source); } }