Package com.tino1b2be.dtmf
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>= 0endSample- last sample index (exclusive) of the tone; must be> startSamplesampleRate- sample rate the indices are expressed in, in Hz; must be> 0confidence- detection confidence in[0.0, 1.0]channel- channel tag:0for mono or left,1for 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 ≥ 0endSample > startSamplesampleRate > 0confidencein 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
ConstructorsConstructorDescriptionDtmfTone(char key, long startSample, long endSample, int sampleRate, double confidence, int channel) Compact constructor validating every field. -
Method Summary
Modifier and TypeMethodDescriptionintchannel()Returns the value of thechannelrecord component.doubleReturns the value of theconfidencerecord component.duration()Returns the duration of this tone, equal toendTime().minus(startTime()).longReturns the value of theendSamplerecord component.endTime()Returns the end position of this tone as aDuration.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.charkey()Returns the value of thekeyrecord component.intReturns the value of thesampleRaterecord component.longReturns the value of thestartSamplerecord component.Returns the start position of this tone as aDuration.final StringtoString()Returns a string representation of this record class.
-
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
Returns the start position of this tone as aDuration. computed fromstartSample()andsampleRate()(Requirement 14.1).- Returns:
- the start position of this tone as a
Duration
-
endTime
Returns the end position of this tone as aDuration. computed fromendSample()andsampleRate()(Requirement 14.2).- Returns:
- the end position of this tone as a
Duration
-
duration
Returns the duration of this tone, equal toendTime().minus(startTime()). (Requirement 14.3).- Returns:
- the duration of this tone, equal to
endTime().minus(startTime())
-
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. -
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. -
equals
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 '=='. -
key
public char key()Returns the value of thekeyrecord component.- Returns:
- the value of the
keyrecord component
-
startSample
public long startSample()Returns the value of thestartSamplerecord component.- Returns:
- the value of the
startSamplerecord component
-
endSample
public long endSample()Returns the value of theendSamplerecord component.- Returns:
- the value of the
endSamplerecord component
-
sampleRate
public int sampleRate()Returns the value of thesampleRaterecord component.- Returns:
- the value of the
sampleRaterecord component
-
confidence
public double confidence()Returns the value of theconfidencerecord component.- Returns:
- the value of the
confidencerecord component
-
channel
public int channel()Returns the value of thechannelrecord component.- Returns:
- the value of the
channelrecord component
-