Record Class DtmfTone

java.lang.Object
java.lang.Record
com.tino1b2be.dtmf.DtmfTone
Record Components:
key - one of '0'..'9', 'A'..'D', '*', '#'
startSample - first sample index (inclusive) of the tone; must be >= 0
endSample - last sample index (exclusive) of the tone; must be > startSample
sampleRate - sample rate the indices are expressed in, in Hz; must be > 0
confidence - detection confidence in [0.0, 1.0]
channel - channel tag: 0 for mono or left, 1 for right

public record DtmfTone(char key, long startSample, long endSample, int sampleRate, double confidence, int channel) extends Record
Immutable value object describing one detected or generated DTMF tone.

The record is populated by DtmfDecoder, DtmfDetector, and DtmfStream for every confirmed tone, and by test fixtures and the generator side when building expected vectors. All fields are public via record accessors; see the Glossary in requirements.md for the authoritative semantics.

Compact-constructor validation (Requirement 17.2) rejects illegal inputs with IllegalArgumentException:

  • startSample ≥ 0
  • endSample > startSample
  • sampleRate > 0
  • confidence in the closed range [0.0, 1.0]
  • channel ≥ 0

Time helpers (startTime(), endTime(), duration()) derive Duration values from the sample indices and the sample rate per Requirement 14. The arithmetic uses Math.round(double) on nanoseconds so a whole-second boundary reports exactly PT1S rather than PT0.999999999S.

Since:
2.0.0
  • Constructor Summary

    Constructors
    Constructor
    Description
    DtmfTone(char key, long startSample, long endSample, int sampleRate, double confidence, int channel)
    Compact constructor validating every field.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the value of the channel record component.
    double
    Returns the value of the confidence record component.
    Returns the duration of this tone, equal to endTime().minus(startTime()).
    long
    Returns the value of the endSample record component.
    Returns the end position of this tone as a Duration.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    char
    key()
    Returns the value of the key record component.
    int
    Returns the value of the sampleRate record component.
    long
    Returns the value of the startSample record component.
    Returns the start position of this tone as a Duration.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • DtmfTone

      public DtmfTone(char key, long startSample, long endSample, int sampleRate, double confidence, int channel)
      Compact constructor validating every field. Messages include the offending value so callers can diagnose misuse without reading source.
  • Method Details

    • startTime

      public Duration startTime()
      Returns the start position of this tone as a Duration. computed from startSample() and sampleRate() (Requirement 14.1).
      Returns:
      the start position of this tone as a Duration
    • endTime

      public Duration endTime()
      Returns the end position of this tone as a Duration. computed from endSample() and sampleRate() (Requirement 14.2).
      Returns:
      the end position of this tone as a Duration
    • duration

      public Duration duration()
      Returns the duration of this tone, equal to endTime().minus(startTime()). (Requirement 14.3).
      Returns:
      the duration of this tone, equal to endTime().minus(startTime())
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • key

      public char key()
      Returns the value of the key record component.
      Returns:
      the value of the key record component
    • startSample

      public long startSample()
      Returns the value of the startSample record component.
      Returns:
      the value of the startSample record component
    • endSample

      public long endSample()
      Returns the value of the endSample record component.
      Returns:
      the value of the endSample record component
    • sampleRate

      public int sampleRate()
      Returns the value of the sampleRate record component.
      Returns:
      the value of the sampleRate record component
    • confidence

      public double confidence()
      Returns the value of the confidence record component.
      Returns:
      the value of the confidence record component
    • channel

      public int channel()
      Returns the value of the channel record component.
      Returns:
      the value of the channel record component