Skip to content

Commit

Permalink
Window: Welch
Browse files Browse the repository at this point in the history
  • Loading branch information
swharden committed Oct 27, 2021
1 parent 62ac992 commit 0d3e807
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/FftSharp/Windows/Welch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace FftSharp.Windows
{
internal class Welch : Window, IWindow
{
public override string Name => "Welch";
public override string Description =>
"The Welch window is typically used for antialiasing and resampling. " +
"Its frequency response is better than that of the Bartlett windowed cosc function below pi, " +
"but it shows again a rather distinctive bump above.";

public override double[] Create(int size, bool normalize = false)
{
double[] window = new double[size];

double halfN = (size - 1) / 2.0;

for (int i = 0; i < size; i++)
{
double b = (i - halfN) / halfN;
window[i] = 1 - b * b;
}

if (normalize)
NormalizeInPlace(window);

return window;
}
}
}

0 comments on commit 0d3e807

Please sign in to comment.