Enum Class WindowFunction

java.lang.Object
java.lang.Enum<WindowFunction>
com.tino1b2be.dtmf.WindowFunction
All Implemented Interfaces:
Serializable, Comparable<WindowFunction>, Constable

public enum WindowFunction extends Enum<WindowFunction>
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.
  • HAMMING0.54 - 0.46 · cos(2π · n / (N - 1)).
  • HANN0.5 · (1 - cos(2π · n / (N - 1))). At the endpoints the coefficient is exactly 0.

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
  • Enum Constant Details

    • RECTANGULAR

      public static final WindowFunction RECTANGULAR
      No window; samples pass through unchanged.
    • HAMMING

      public static final WindowFunction HAMMING
      Hamming window: 0.54 - 0.46 · cos(2π · n / (N - 1)).
    • HANN

      public static final WindowFunction HANN
      Hann window: 0.5 · (1 - cos(2π · n / (N - 1))).
  • Method Details

    • values

      public static WindowFunction[] 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

      public static WindowFunction valueOf(String name)
      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 name
      NullPointerException - if the argument is null
    • applyInPlace

      public abstract void applyInPlace(double[] samples, int offset, int length)
      Multiply each sample in samples[offset .. offset + length) by the corresponding window coefficient, in place.
      Parameters:
      samples - destination buffer; must be non-null
      offset - index of the first sample to window; must be non-negative
      length - number of samples to window; the window length
      Throws:
      NullPointerException - if samples is null
      IndexOutOfBoundsException - if offset or length describes a range outside samples