Round Voice Start Times Down To Output Samples

This commit is contained in:
copecone committed 2026-10-13 19:20:59 +09:00
1 parent 8b9c009804
commit a2e6c49d7a
1 file changed
+5 -2
+5 -2
View File
@@ -75,8 +75,11 @@ internal sealed class VoiceMixer : IDisposable
/// <summary>Voices currently mixed (started or waiting to start). Render thread only.</summary> /// <summary>Voices currently mixed (started or waiting to start). Render thread only.</summary>
public int ActiveVoiceCount => _voices.Count; public int ActiveVoiceCount => _voices.Count;
/// <summary>Output sample nearest to <paramref name="seconds"/>.</summary> /// <summary>
public static long ToSample(double seconds, int rate) => (long)Math.Round(seconds * rate, MidpointRounding.AwayFromZero); /// Output sample containing <paramref name="seconds"/> (seconds × rate rounded down), the sample at which
/// AudioSource.PlayScheduled starts a sound scheduled between two output samples.
/// </summary>
public static long ToSample(double seconds, int rate) => (long)Math.Floor(seconds * rate);
// ── Main thread ── // ── Main thread ──