Class TwistEvaluator
Per ITU-T Q.24, twist is the power ratio between the high-group tone and the low-group tone of a DTMF pair, expressed in decibels:
twistDb = 10 * log10(highEnergy / lowEnergy)
A positive twist means the high group is louder (forward twist); a
negative twist means the low group is louder (reverse twist). Standard_Twist
bounds are +4 dB forward and -8 dB reverse; anything outside
those bounds is rejected by DtmfConfig.forTelephony()
and DtmfConfig.defaults() (Requirement 9.2).
The advanced builder exposes custom bounds (Requirement 9.3).
Zero-energy handling. If lowEnergy == 0.0 the
ratio is undefined and the low group contributed no signal at all; this
cannot be a valid DTMF candidate regardless of the twist configuration.
twistDb(double, double) returns Double.POSITIVE_INFINITY
in that case so withinTolerance(double, DtmfConfig) rejects under
any finite forward-twist bound (Requirement 9.4).
Although the type is public so
com.tino1b2be.dtmf.internal.AnalysisPipeline in the same package
and the dtmf-core tests in com.tino1b2be.dtmf.internal can
call it, the convention is that com.tino1b2be.dtmf.internal.* is
not part of the published API.
- Since:
- 2.0.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic doubletwistDb(double lowEnergy, double highEnergy) Compute the twist in decibels for a candidate DTMF pair.static booleanwithinTolerance(double twistDb, DtmfConfig cfg) Returns whether the given twist in dB lies within the tolerance band configured oncfg.
-
Method Details
-
twistDb
public static double twistDb(double lowEnergy, double highEnergy) Compute the twist in decibels for a candidate DTMF pair.- Parameters:
lowEnergy- magnitude-squared of the picked low-group peak; non-negativehighEnergy- magnitude-squared of the picked high-group peak; non-negative- Returns:
10 * log10(highEnergy / lowEnergy)whenlowEnergy > 0;Double.POSITIVE_INFINITYwhenlowEnergy == 0so any finite tolerance rejects
-
withinTolerance
Returns whether the given twist in dB lies within the tolerance band configured oncfg..Returns
truewhenreverseDb <= twistDb <= forwardDbwherereverseDbandforwardDbcome fromDtmfConfig.reverseTwistDb()andDtmfConfig.forwardTwistDb()respectively. ADouble.POSITIVE_INFINITYorDouble.NaNtwist is always rejected because neither comparison can evaluate to true.- Parameters:
twistDb- candidate twist in dB (may be infinite)cfg- configuration supplying the twist bounds; non-null- Returns:
- whether the given twist in dB lies within the tolerance band
configured on
cfg
-