-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |