Class FrequencyBins

java.lang.Object
com.tino1b2be.dtmf.internal.FrequencyBins

public final class FrequencyBins extends Object
ITU-T Q.23 DTMF frequency tables.

This internal helper holds the eight DTMF frequencies (four in the low group, four in the high group) and the 4×4 key matrix mapping (lowIndex, highIndex) to the symbol for that tone pair.

The detector uses ALL_EIGHT to construct its GoertzelBank and indexes peaks via keyFor(int, int). The generator uses LOW_GROUP and HIGH_GROUP to look up the (lowHz, highHz) pair for a given key symbol.

The numeric values are the Q.23 nominal frequencies and are deliberately exposed as double so Goertzel coefficient computation is free of implicit int-to-double widening.

Although the type is public so the public API classes in the sibling package com.tino1b2be.dtmf (generator, detector, decoder) can reach it, the convention is that com.tino1b2be.dtmf.internal.* is not part of the published API.

Since:
2.0.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final double[]
    The eight DTMF frequencies in a single array, ordered as LOW_GROUP ∥ HIGH_GROUP.
    static final double[]
    High-group DTMF frequencies in Hz, indexed 0..3.
    static final char[][]
    The 4×4 key matrix: KEY_MATRIX[lowIndex][highIndex] is the DTMF symbol for the tone pair (LOW_GROUP[lowIndex], HIGH_GROUP[highIndex]).
    static final double[]
    Low-group DTMF frequencies in Hz, indexed 0..3.
  • Method Summary

    Modifier and Type
    Method
    Description
    static double[]
    frequenciesFor(char key)
    Look up the (lowHz, highHz) frequency pair for a DTMF key symbol.
    static char
    keyFor(int lowIndex, int highIndex)
    Look up the DTMF symbol for the given low-group / high-group peak indices.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • LOW_GROUP

      public static final double[] LOW_GROUP
      Low-group DTMF frequencies in Hz, indexed 0..3. Matches Q.23: 697, 770, 852, 941 Hz.
    • HIGH_GROUP

      public static final double[] HIGH_GROUP
      High-group DTMF frequencies in Hz, indexed 0..3. Matches Q.23: 1209, 1336, 1477, 1633 Hz.
    • ALL_EIGHT

      public static final double[] ALL_EIGHT
      The eight DTMF frequencies in a single array, ordered as LOW_GROUP ∥ HIGH_GROUP. Convenient for constructing a GoertzelBank with one filter per DTMF frequency.
    • KEY_MATRIX

      public static final char[][] KEY_MATRIX
      The 4×4 key matrix: KEY_MATRIX[lowIndex][highIndex] is the DTMF symbol for the tone pair (LOW_GROUP[lowIndex], HIGH_GROUP[highIndex]).
                1209  1336  1477  1633
         697 Hz   1     2     3     A
         770 Hz   4     5     6     B
         852 Hz   7     8     9     C
         941 Hz   *     0     #     D
       
  • Method Details

    • keyFor

      public static char keyFor(int lowIndex, int highIndex)
      Look up the DTMF symbol for the given low-group / high-group peak indices.
      Parameters:
      lowIndex - index into LOW_GROUP; must be in [0, 4)
      highIndex - index into HIGH_GROUP; must be in [0, 4)
      Returns:
      the DTMF symbol for (LOW_GROUP[lowIndex], HIGH_GROUP[highIndex])
      Throws:
      ArrayIndexOutOfBoundsException - if either index is outside [0, 4)
    • frequenciesFor

      public static double[] frequenciesFor(char key)
      Look up the (lowHz, highHz) frequency pair for a DTMF key symbol.
      Parameters:
      key - the DTMF symbol; must be one of '0'..'9', 'A'..'D', '*', or '#'
      Returns:
      a two-element array [lowHz, highHz] with the Q.23 nominal frequencies for that key
      Throws:
      IllegalArgumentException - if key is not in the accepted set