Creator: "why is there no meter for when trax is playing?" Routing answer: TRAX rides the desktop loopback, so it already moved the GAME ladder — there was no separate TRAX signal in the mix. But that ladder cannot answer the question a deaf creator actually has: "is the music producing sound at all?" The play glyph cannot either — an open file with a dead decoder still reports Playing. So the player now measures its own output: \`MusicPlayer\` wraps the volume stage in an NAudio \`MeteringSampleProvider\` and exposes \`Level\`; \`ITraxPlayer.Level\` keeps the fake honest. The VM maps it through the same display scale (\`TraxMeterFraction\`), zeroed when not playing, and the TRAX bay carries a 24-segment ladder above its fader. This reverses my earlier "no ladder, nothing honest to show" — the honest thing arrived with a real measurement. TraxBayTests flipped accordingly (it now asserts the ladder AND its source).
45 lines
2.2 KiB
C#
45 lines
2.2 KiB
C#
using Xunit;
|
|
using ytLive.Helpers;
|
|
using ytLive.Services.Audio;
|
|
using ytLive.ViewModels;
|
|
|
|
namespace ytLive.Tests;
|
|
|
|
/// <summary>The TRAX bay shows the track, plays/pauses it, and carries a level — but no meter:
|
|
/// nothing measures the bed, and a decorative ladder would be a lie. Its fader moves a gain the
|
|
/// player actually applies, separate from the desktop-mute follow.
|
|
/// </summary>
|
|
public class TraxBayTests
|
|
{
|
|
[Fact]
|
|
public void The_trax_bay_binds_the_track_level_and_play_state_without_inventing_a_meter()
|
|
{
|
|
var dock = SourceAssert.Text("Controls", "AudioDock.xaml");
|
|
Assert.Contains("Text=\"{Binding TraxTrackLabel}\"", dock);
|
|
Assert.Contains("Value=\"{Binding TraxVolumeDb, Mode=TwoWay}\"", dock);
|
|
Assert.Contains("Text=\"{Binding TraxVolumeDbLabel}\"", dock);
|
|
Assert.Contains("Binding=\"{Binding IsMusicPlaying}\" Value=\"True\"", dock);
|
|
Assert.Contains("Click=\"TraxPlayPause_Click\"", dock);
|
|
|
|
// The bay DOES carry a ladder now — the player measures its own output, so "is music making
|
|
// sound" is answerable without hearing it (a play glyph cannot answer that).
|
|
var traxBay = dock[dock.IndexOf("Text=\"TRAX\"", System.StringComparison.Ordinal)
|
|
..dock.IndexOf("Text=\"LIP-SYNC\"", System.StringComparison.Ordinal)];
|
|
Assert.Contains("TraxTrackLabel", traxBay);
|
|
Assert.Contains("SegmentMeter", traxBay);
|
|
Assert.Contains("TraxMeterFraction", traxBay);
|
|
|
|
foreach (var name in new[] { "TraxVolumeDb", "TraxVolumeDbLabel", "TraxTrackLabel", "IsTraxDucking", "TraxMeterFraction" })
|
|
Assert.NotNull(typeof(MainViewModel).GetProperty(name));
|
|
|
|
// The player gained a real user level, separate from the mute-follow LocalGain.
|
|
Assert.NotNull(typeof(ITraxPlayer).GetProperty("UserGain"));
|
|
Assert.NotNull(typeof(ITraxPlayer).GetProperty("Level"));
|
|
Assert.NotNull(typeof(MusicPlayer).GetProperty("UserGain"));
|
|
|
|
// Unity means the bed's design level, and the fader's scale is the same one as the others.
|
|
Assert.Equal(0, GainDb.ToDb(1f), 6);
|
|
Assert.Contains("∞", GainDb.Label(GainDb.FloorDb)); // true silence, not "-60.0"
|
|
}
|
|
}
|