Class DtmfDecoder

java.lang.Object
com.tino1b2be.dtmf.DtmfDecoder

public final class DtmfDecoder extends Object
Batch DTMF decoder: turn a buffer of PCM samples into a list of detected DtmfTone instances.

DtmfDecoder is the batch half of the public API. Every overload is a thin wrapper around DtmfDetector:

  1. null-check the inputs (Requirement 4.8, 17.1);
  2. normalise the sample format to double via SampleConverter (Requirements 4.5, 4.6, 4.7);
  3. instantiate a fresh DtmfDetector, wire an ArrayList.add(E, java.lang.Object[], int) callback, feed the normalised samples, and flush;
  4. return the list in non-decreasing startSample order (Requirement 5.2).

Running batch decoding through the same push pipeline is how chunk invariance (Requirement 6.7) becomes structural rather than tested-after- the-fact: decode(B, cfg) and any chunking of B fed into a fresh detector produce the same tones by construction.

The class is final with a private constructor; all entry points are static.

Since:
2.0.0
  • Method Details

    • decode

      public static List<DtmfTone> decode(double[] samples, DtmfConfig config)
      Decode a double[] buffer of normalised PCM samples in [-1.0, 1.0].
      Parameters:
      samples - PCM samples; non-null
      config - detection configuration; non-null
      Returns:
      the list of detected tones, in non-decreasing startSample order
      Throws:
      NullPointerException - if either argument is null
    • decode

      public static List<DtmfTone> decode(short[] samples, DtmfConfig config)
      Decode a short[] buffer of signed PCM16 samples. Samples are normalised to double via division by 32768.0 (Requirement 4.5).
      Parameters:
      samples - PCM16 samples; non-null
      config - detection configuration; non-null
      Returns:
      the list of detected tones, in non-decreasing startSample order
      Throws:
      NullPointerException - if either argument is null
    • decode

      public static List<DtmfTone> decode(float[] samples, DtmfConfig config)
      Decode a float[] buffer of normalised samples in [-1.0, 1.0]. Samples are widened to double without scaling (Requirement 4.6).
      Parameters:
      samples - float samples; non-null
      config - detection configuration; non-null
      Returns:
      the list of detected tones, in non-decreasing startSample order
      Throws:
      NullPointerException - if either argument is null
    • decode

      public static List<DtmfTone> decode(int[] samples, DtmfConfig config)
      Decode an int[] buffer of signed PCM32 samples. Samples are normalised via division by 2^31 (Requirement 4.7).
      Parameters:
      samples - PCM32 samples; non-null
      config - detection configuration; non-null
      Returns:
      the list of detected tones, in non-decreasing startSample order
      Throws:
      NullPointerException - if either argument is null
    • decodePcm24

      public static List<DtmfTone> decodePcm24(int[] samples, DtmfConfig config)
      Decode an int[] buffer where each entry carries a signed PCM24 value in its low 24 bits. Helper for callers supplying packed PCM24 (Requirement 4.4).
      Parameters:
      samples - PCM24-in-int samples; non-null
      config - detection configuration; non-null
      Returns:
      the list of detected tones, in non-decreasing startSample order
      Throws:
      NullPointerException - if either argument is null