Files
LlamaCasty/ytLive.Tests/AudioFoldTests.cs
T
gramps 5889d71db6 feat(dock): master strip + MONO output (the accessibility switch)
Unit 9, the one that matters most for this creator.

MASTER STRIP (top, nearest the preview):
- one ladder fed by the MEASURED mix — `AudioMixer` now measures the buffer the encoder receives
  (`MasterLevel`, `MasterImbalanceDb`), so the master cannot show a source instead of the output
- `-12.4 dB` readout, and ONE L/R flag that appears above a 6 dB gap instead of a second ladder
- bitrate / FPS / dropped / duration from the existing health poll

MONO OUTPUT:
- `AudioFold.ToMono` averages each stereo pair into both channels, applied after the limiter and
  the sync delay, so the stream AND the recording get what was folded
- `MonoOutput` is persisted (`Audio.MonoOutput`) and restored at startup: an accessibility switch
  that resets each session is an accessibility failure
- one click in the strip, remembered forever

Guard: AudioFoldTests (hard-left reaches the right at half amplitude, hard-right — the inaudible
case — reaches the left, centred material keeps its level, mono buffers untouched) and
MasterStripTests (the strip binds the measured mix + the switch, the store round-trips it, and the
fold is the tested helper rather than new arithmetic). 33 audio tests green.
2026-10-30 13:18:23 -07:00

36 lines
1.3 KiB
C#

using Xunit;
using ytLive.Helpers;
namespace ytLive.Tests;
/// <summary>The mono output exists because single-sided audio is inaudible to this creator, not
/// merely unbalanced. The fold has to move content to BOTH sides — a "fold" that keeps a channel
/// empty would leave the exact problem in place — and it must not touch mono buffers.</summary>
public class AudioFoldTests
{
[Fact]
public void Folding_to_mono_puts_a_one_sided_signal_on_both_sides()
{
// Hard LEFT content becomes audible on the right at half amplitude.
var left = new[] { 0.5f, 0f, 0.5f, 0f };
AudioFold.ToMono(left, 2);
Assert.Equal(new[] { 0.25f, 0.25f, 0.25f, 0.25f }, left);
// Hard RIGHT — the inaudible case — becomes audible on the left.
var right = new[] { 0f, 0.6f };
AudioFold.ToMono(right, 2);
Assert.Equal(0.3f, right[0], 4);
Assert.Equal(0.3f, right[1], 4);
// Centred material keeps its level (the mic case): no quietening.
var centred = new[] { 0.4f, 0.4f };
AudioFold.ToMono(centred, 2);
Assert.Equal(0.4f, centred[0], 4);
// Mono buffers are untouched — folding is about pairs.
var mono = new[] { 0.7f, 0.2f };
AudioFold.ToMono(mono, 1);
Assert.Equal(new[] { 0.7f, 0.2f }, mono);
}
}