Class DtmfConfig.Advanced

java.lang.Object
com.tino1b2be.dtmf.DtmfConfig.Advanced
Enclosing class:
DtmfConfig

public static final class DtmfConfig.Advanced extends Object
Fluent builder for DtmfConfig, exposing every knob and the wider [4000, 192000] sample-rate domain.

Every setter validates its argument in the same way the canonical constructor does, so misuse surfaces at the setter call site rather than at build(). The sample-rate range check and the twist relationship check are enforced in build().

Setters return this for chaining. Instances are not thread-safe; build one per caller.

  • Method Details

    • sampleRate

      public DtmfConfig.Advanced sampleRate(int hz)
      Set the sample rate.
      Parameters:
      hz - integer sample rate in Hz; must be in [4000, 192000]
      Returns:
      this
      Throws:
      IllegalArgumentException - if hz is outside [4000, 192000]
    • analysisBlockSize

      public DtmfConfig.Advanced analysisBlockSize(int samples)
      Set the analysis block size explicitly. If never called, the block size is derived at build() time from BlockSizer.blockSizeFor(sampleRate).
      Parameters:
      samples - block size in samples; must be > 0
      Returns:
      this
      Throws:
      IllegalArgumentException - if samples <= 0
    • minimumToneDuration

      public DtmfConfig.Advanced minimumToneDuration(Duration d)
      Set the minimum tone duration. Must be ≥ 10 ms (Requirement 8.8).
      Parameters:
      d - minimum tone duration; non-null
      Returns:
      this
      Throws:
      NullPointerException - if d is null
      IllegalArgumentException - if d < 10 ms
    • minimumGapDuration

      public DtmfConfig.Advanced minimumGapDuration(Duration d)
      Set the minimum inter-tone gap duration. Must be non-negative.
      Parameters:
      d - minimum gap duration; non-null
      Returns:
      this
      Throws:
      NullPointerException - if d is null
      IllegalArgumentException - if d is negative
    • detectionThreshold

      public DtmfConfig.Advanced detectionThreshold(double t)
      Set the detection-confidence threshold. Must be in [0.0, 1.0].
      Parameters:
      t - detection threshold
      Returns:
      this
      Throws:
      IllegalArgumentException - if t is NaN or outside [0, 1]
    • channelMode

      public DtmfConfig.Advanced channelMode(ChannelMode m)
      Set the channel mode.
      Parameters:
      m - channel mode; non-null
      Returns:
      this
      Throws:
      NullPointerException - if m is null
    • windowFunction

      public DtmfConfig.Advanced windowFunction(WindowFunction w)
      Set the window function.
      Parameters:
      w - window function; non-null
      Returns:
      this
      Throws:
      NullPointerException - if w is null
    • forwardTwistDb

      public DtmfConfig.Advanced forwardTwistDb(double db)
      Set the forward-twist tolerance in dB. Must be finite and strictly greater than the reverse-twist value at build() time.
      Parameters:
      db - forward-twist tolerance in dB
      Returns:
      this
      Throws:
      IllegalArgumentException - if db is not finite
    • reverseTwistDb

      public DtmfConfig.Advanced reverseTwistDb(double db)
      Set the reverse-twist tolerance in dB. Must be finite and strictly less than the forward-twist value at build() time.
      Parameters:
      db - reverse-twist tolerance in dB
      Returns:
      this
      Throws:
      IllegalArgumentException - if db is not finite
    • confirmationFrames

      public DtmfConfig.Advanced confirmationFrames(int frames)
      Set the number of consecutive analysis blocks required to confirm a tone. Must be >= 1.
      Parameters:
      frames - confirmation-frame count
      Returns:
      this
      Throws:
      IllegalArgumentException - if frames < 1
    • build

      public DtmfConfig build()
      Materialize an immutable DtmfConfig from the values set on this builder. If analysisBlockSize(int) has not been called, the block size is derived via BlockSizer.blockSizeFor(sampleRate) so the effective bin width lands in [40, 60] Hz.
      Returns:
      the new DtmfConfig
      Throws:
      IllegalArgumentException - if any inter-field constraint is violated (e.g. forward ≤ reverse)