Skip to content

Commit

Permalink
Delay filter interface stability
Browse files Browse the repository at this point in the history
  • Loading branch information
VoidXH committed Jun 23, 2024
1 parent 3e9a117 commit 5dd974f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Cavern/Filters/Delay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public double DelayMs {
/// <summary>
/// If the filter was set up with a time delay, this is the sample rate that was used for it.
/// </summary>
readonly int sampleRate;
int sampleRate;

/// <summary>
/// The used cache (0 or 1).
Expand Down Expand Up @@ -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]),
};
}
Expand Down Expand Up @@ -146,7 +148,7 @@ public override void Process(float[] samples) {

/// <inheritdoc/>
public override string ToString() {
if (sampleRate == 0) {
if (double.IsNaN(delayMs)) {
return $"Delay: {DelaySamples} samples";
} else {
string delay = DelayMs.ToString(CultureInfo.InvariantCulture);
Expand All @@ -156,7 +158,7 @@ public override string ToString() {

/// <inheritdoc/>
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()
};

Expand Down

0 comments on commit 5dd974f

Please sign in to comment.