Class DtmfConfig
DtmfConfig has two tiers. The common tier, expressed via
the four static factories (defaults(), forTelephony(),
forVoip(), forNoisyAudio()), covers the scenarios that
most callers reach for: 8 kHz mono telephony, Q.24 Standard_Twist
tolerances, conservative minimum-tone and minimum-gap durations, and a
pre-picked number of confirmation frames. The advanced tier, via
advanced(), adds explicit control over the window function, twist
thresholds, confirmation-frame count, and the broader sample-rate domain
[4000, 192000] Hz (Requirement 3.4 vs 3.2 vs 3.3).
The ten knobs exactly mirror Requirements 8.1 and 8.2. Six common knobs are: sample rate, analysis block size, minimum tone duration, minimum gap duration, detection threshold, channel mode. Four advanced knobs are: window function, forward twist in dB, reverse twist in dB, and confirmation frames.
Validation happens at construction time (Requirement 17): every numeric
field is checked against its documented domain, every reference field is
null-checked with Objects.requireNonNull(Object, String), and the
standard factories enforce the narrow sample-rate set
{8000, 16000, 44100, 48000} (Requirement 3.3). The
Advanced.build() path enforces the wider domain. The
analysisBlockSize is auto-derived via
BlockSizer.blockSizeFor(sampleRate) when the caller does not set
it explicitly.
Instances are immutable: every accessor returns the value that was
baked in at construction time, and there is no setter on DtmfConfig
itself. The nested Advanced builder is mutable, but exposes only
fluent setters that return this and a terminal build()
method.
- Since:
- 2.0.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classFluent builder forDtmfConfig, exposing every knob and the wider[4000, 192000]sample-rate domain. -
Method Summary
Modifier and TypeMethodDescriptionstatic DtmfConfig.Advancedadvanced()Returns a newDtmfConfig.Advancedbuilder seeded with the values fromforTelephony().intReturns the analysis block size in samples.Returns the channel mode.intReturns the number of consecutive analysis blocks required to confirm a tone.static DtmfConfigdefaults()Returns a configuration suitable for 8 kHz mono telephony audio with Standard_Twist tolerances.doubleReturns the detection-confidence threshold in [0.0, 1.0].static DtmfConfigReturns a configuration tuned for noisy audio.static DtmfConfigReturns a configuration tuned for ITU-T Q.24 telephony audio.static DtmfConfigforVoip()Returns a configuration tuned for VoIP audio.doubleReturns the forward-twist tolerance in dB.Returns the minimum inter-tone gap duration.Returns the minimum tone duration.doubleReturns the reverse-twist tolerance in dB.intReturns the sample rate in Hz.Returns the window function applied to each analysis block.
-
Method Details
-
sampleRate
public int sampleRate()Returns the sample rate in Hz..- Returns:
- the sample rate in Hz
-
analysisBlockSize
public int analysisBlockSize()Returns the analysis block size in samples..- Returns:
- the analysis block size in samples
-
minimumToneDuration
Returns the minimum tone duration..- Returns:
- the minimum tone duration
-
minimumGapDuration
Returns the minimum inter-tone gap duration..- Returns:
- the minimum inter-tone gap duration
-
detectionThreshold
public double detectionThreshold()Returns the detection-confidence threshold in [0.0, 1.0]..- Returns:
- the detection-confidence threshold in [0.0, 1.0]
-
channelMode
Returns the channel mode..- Returns:
- the channel mode
-
windowFunction
Returns the window function applied to each analysis block..- Returns:
- the window function applied to each analysis block
-
forwardTwistDb
public double forwardTwistDb()Returns the forward-twist tolerance in dB..- Returns:
- the forward-twist tolerance in dB
-
reverseTwistDb
public double reverseTwistDb()Returns the reverse-twist tolerance in dB..- Returns:
- the reverse-twist tolerance in dB
-
confirmationFrames
public int confirmationFrames()Returns the number of consecutive analysis blocks required to confirm a tone..- Returns:
- the number of consecutive analysis blocks required to confirm a tone
-
defaults
Returns a configuration suitable for 8 kHz mono telephony audio with Standard_Twist tolerances..Delegates to
forTelephony().- Returns:
- a configuration suitable for 8 kHz mono telephony audio with Standard_Twist tolerances
-
forTelephony
Returns a configuration tuned for ITU-T Q.24 telephony audio..Values:
- sample rate: 8000 Hz
- analysis block size: auto (160 samples at 8 kHz, 50 Hz bin)
- minimum tone duration: 40 ms
- minimum gap duration: 40 ms
- detection threshold: 0.25
- channel mode:
MONO - window:
RECTANGULAR - forward twist: +4 dB (Standard_Twist)
- reverse twist: −8 dB (Standard_Twist)
- confirmation frames: 2
- Returns:
- a configuration tuned for ITU-T Q.24 telephony audio
-
forVoip
Returns a configuration tuned for VoIP audio..Identical to
forTelephony()except forconfirmationFrames = 3, chosen to absorb packet-loss concealment artifacts that briefly disrupt the active tone.- Returns:
- a configuration tuned for VoIP audio
-
forNoisyAudio
Returns a configuration tuned for noisy audio..Differs from
forTelephony()as follows: minimum tone duration is 50 ms, detection threshold is 0.35, andconfirmationFrames = 4. Other knobs matchforTelephony.- Returns:
- a configuration tuned for noisy audio
-
advanced
Returns a newDtmfConfig.Advancedbuilder seeded with the values fromforTelephony()..The returned builder accepts any integer sample rate in
[4000, 192000]Hz (Requirement 3.4) and exposes every one of the ten knobs for override.- Returns:
- a new
DtmfConfig.Advancedbuilder seeded with the values fromforTelephony()
-