-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implements HammingPeriodic and HanningPeriodic
- Loading branch information
Showing
5 changed files
with
88 additions
and
6 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
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
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,29 @@ | ||
using System; | ||
|
||
namespace FftSharp.Windows | ||
{ | ||
public class HammingPeriodic : Window, IWindow | ||
{ | ||
public override string Name => "HammingPeriodic"; | ||
public override string Description => | ||
"The Hamming window has a sinusoidal shape does NOT touch zero at the edges (unlike the similar Hanning window). " + | ||
"It is similar to the Hanning window but its abrupt edges are designed to cancel the largest side lobe. " + | ||
"It may be a good choice for low-quality (8-bit) auto where side lobes lie beyond the quantization noise floor." + | ||
"A periodic window, for use in spectral analysis."; | ||
|
||
public override double[] Create(int size, bool normalize = false) | ||
{ | ||
double[] window = new double[size]; | ||
|
||
double phaseStep = (2.0 * Math.PI) / size; | ||
|
||
for (int i = 0; i < size; i++) | ||
window[i] = 0.54 - 0.46 * Math.Cos(i * phaseStep); | ||
|
||
if (normalize) | ||
NormalizeInPlace(window); | ||
|
||
return window; | ||
} | ||
} | ||
} |
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
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,29 @@ | ||
using System; | ||
|
||
namespace FftSharp.Windows | ||
{ | ||
public class HanningPeriodic : Window, IWindow | ||
{ | ||
public override string Name => "HanningPeriodic"; | ||
public override string Description => | ||
"The Hanning window has a sinusoidal shape which touches zero at the edges (unlike the similar Hamming window). " + | ||
"It has good frequency resolution, low spectral leakage, and is satisfactory for 95 percent of use cases. " + | ||
"If you do not know the nature of the signal but you want to apply a smoothing window, start with the Hann window." + | ||
"A periodic window, for use in spectral analysis."; | ||
|
||
public override double[] Create(int size, bool normalize = false) | ||
{ | ||
double[] window = new double[size]; | ||
|
||
double phaseStep = (2.0 * Math.PI) / size; | ||
|
||
for (int i = 0; i < size; i++) | ||
window[i] = 0.5 - 0.5 * Math.Cos(i * phaseStep); | ||
|
||
if (normalize) | ||
NormalizeInPlace(window); | ||
|
||
return window; | ||
} | ||
} | ||
} |