Reported: pegging the TRAX fader changes nothing audible, the ladder never reaches red, and the ladder does not scale with the fader. Cause (two defects in the same setters): - UserGain wrote the OUTPUT DEVICE's volume. NAudio's WaveOut ignores that, so the fader was inert. - LocalGain (the desktop-mute follow) recomputed the sample-chain volume WITHOUT the user gain, so every duck/mute silently discarded whatever the creator had set. Fix: one `EffectiveVolume(user, local)` = MusicVolume × user × local, applied to the sample chain by both setters. The meter sits AFTER that stage, so the ladder now scales with the fader and can reach the peak band on a loud track — exactly what pegging should look like. Max user gain is +6 dB, so "pegged" means the file at unity, not a magic boost. Guard: MusicLevelTests pins the arithmetic (default half, pegged double, mute multiplies to zero), that the user gain survives the mute follow, and that nothing may drive the output device's volume again — the no-op that made this invisible.
36 lines
1.6 KiB
C#
36 lines
1.6 KiB
C#
using Xunit;
|
|
using ytLive.Services.Audio;
|
|
|
|
namespace ytLive.Tests;
|
|
|
|
/// <summary>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.
|
|
/// </summary>
|
|
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);
|
|
}
|
|
}
|