using Xunit; using ytLive.Helpers; namespace ytLive.Tests; /// 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. 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); } }