From 5dd974f5acbc37dfd1ff05039b4a965885c23b47 Mon Sep 17 00:00:00 2001 From: VoidX Date: Sun, 23 Jun 2024 14:56:02 +0200 Subject: [PATCH] Delay filter interface stability --- Cavern/Filters/Delay.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Cavern/Filters/Delay.cs b/Cavern/Filters/Delay.cs index a6bf383..a9b4876 100644 --- a/Cavern/Filters/Delay.cs +++ b/Cavern/Filters/Delay.cs @@ -63,7 +63,7 @@ public double DelayMs { /// /// If the filter was set up with a time delay, this is the sample rate that was used for it. /// - readonly int sampleRate; + int sampleRate; /// /// The used cache (0 or 1). @@ -108,7 +108,9 @@ public static Delay FromEqualizerAPO(string[] splitLine, int sampleRate) { } return splitLine[2].ToLowerInvariant() switch { "ms" => new Delay(delay, sampleRate), - "samples" => new Delay((int)delay), + "samples" => new Delay((int)delay) { + sampleRate = sampleRate + }, _ => throw new ArgumentOutOfRangeException(splitLine[0]), }; } @@ -146,7 +148,7 @@ public override void Process(float[] samples) { /// public override string ToString() { - if (sampleRate == 0) { + if (double.IsNaN(delayMs)) { return $"Delay: {DelaySamples} samples"; } else { string delay = DelayMs.ToString(CultureInfo.InvariantCulture); @@ -156,7 +158,7 @@ public override string ToString() { /// public string ToString(CultureInfo culture) => culture.Name switch { - "hu-HU" => sampleRate == 0 ? $"Késleltetés: {DelaySamples} minta" : $"Késleltetés: {DelayMs} ms", + "hu-HU" => double.IsNaN(delayMs) ? $"Késleltetés: {DelaySamples} minta" : $"Késleltetés: {DelayMs} ms", _ => ToString() };