Skip to content

Commit

Permalink
Magnitude-only transfer function averaging
Browse files Browse the repository at this point in the history
  • Loading branch information
VoidXH committed Oct 23, 2023
1 parent 99c4d6e commit 5c93057
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Cavern/Utilities/ComplexArray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,21 @@ public static Complex[] Average(this Complex[][] sources) {
return result;
}

/// <summary>
/// Get the average of multiple frequency responses.
/// </summary>
public static float[] AverageMagnitudes(this Complex[][] sources) {
float[] result = new float[sources[0].Length >> 1];
for (int i = 0; i < sources.Length; i++) {
Complex[] source = sources[i];
for (int j = 0; j < result.Length; j++) {
result[j] += source[j].Magnitude;
}
}
WaveformUtils.Gain(result, 1f / sources.Length);
return result;
}

/// <summary>
/// Convert all elements in the <paramref name="source"/> to their conjugates.
/// </summary>
Expand Down

0 comments on commit 5c93057

Please sign in to comment.