Files
DP44/DataPRO/FftSharp/Windows/Tukey.cs

35 lines
1.1 KiB
C#
Raw Normal View History

2026-04-17 14:55:32 -04:00
using System;
namespace FftSharp.Windows
{
public class Tukey : Window, IWindow
{
private readonly double Alpha;
public override string Name => "Tukey";
public override string Description =>
"A Tukey window has a flat center and tapers at the edges according to a cosine function. " +
"The amount of taper is defined by alpha (with low values being less taper). " +
"Tukey windows are ideal for analyzing transient data since the amplitude of transient signal " +
"in the time domain is less likely to be altered compared to using Hanning or flat top.";
public Tukey()
{
Alpha = .5;
}
public Tukey(double alpha = .5)
{
Alpha = alpha;
}
protected override double windowValue(int index, int size)
{
double m = 2 * Math.PI / (Alpha * size);
int edgeSizePoints = (int)(size * Alpha / 2);
bool isEdge = (index < edgeSizePoints) || (index > size - edgeSizePoints);
return isEdge ? (1 - Math.Cos(index * m)) / 2 : 1;
}
}
}