Package com.tino1b2be.dtmf
Enum Class WindowFunction
- All Implemented Interfaces:
Serializable,Comparable<WindowFunction>,Constable
Window function applied to each analysis block before the Goertzel bank
computes magnitudes.
DTMF detection at a bin width of 40–60 Hz already separates
the eight DTMF frequencies by at least 100 Hz, so windowing is a
precision knob rather than a necessity. The production defaults
(defaults, forTelephony, forVoip,
forNoisyAudio) all use RECTANGULAR; the advanced builder
can override to HAMMING or HANN when sidelobe leakage
from a nearby non-DTMF tone is a concern.
Formulas (for a window of length N, n = 0..N-1):
RECTANGULAR— identity; leaves samples unchanged.HAMMING—0.54 - 0.46 · cos(2π · n / (N - 1)).HANN—0.5 · (1 - cos(2π · n / (N - 1))). At the endpoints the coefficient is exactly0.
The single-sample window (N == 1) is treated as a pass-through
for every shape: the textbook formulas have a zero-width denominator in
that case, and the only sensible coefficient is 1.0.
- Since:
- 2.0.0
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionHamming window:0.54 - 0.46 · cos(2π · n / (N - 1)).Hann window:0.5 · (1 - cos(2π · n / (N - 1))).No window; samples pass through unchanged. -
Method Summary
Modifier and TypeMethodDescriptionabstract voidapplyInPlace(double[] samples, int offset, int length) Multiply each sample insamples[offset .. offset + length)by the corresponding window coefficient, in place.static WindowFunctionReturns the enum constant of this class with the specified name.static WindowFunction[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
RECTANGULAR
No window; samples pass through unchanged. -
HAMMING
Hamming window:0.54 - 0.46 · cos(2π · n / (N - 1)). -
HANN
Hann window:0.5 · (1 - cos(2π · n / (N - 1))).
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
applyInPlace
public abstract void applyInPlace(double[] samples, int offset, int length) Multiply each sample insamples[offset .. offset + length)by the corresponding window coefficient, in place.- Parameters:
samples- destination buffer; must be non-nulloffset- index of the first sample to window; must be non-negativelength- number of samples to window; the window length- Throws:
NullPointerException- ifsamplesisnullIndexOutOfBoundsException- ifoffsetorlengthdescribes a range outsidesamples
-