Class BlockSizer
The detector picks a block length N such that the effective
Goertzel bin width sampleRate / N lands in the closed range
[40, 60] Hz, with a target of 50 Hz in the middle of the
band. That range is wide enough that every one of the Supported_Sample_Rate
values (8 kHz, 16 kHz, 44.1 kHz, 48 kHz) lands on an
integer N producing exactly 50 Hz bin width (Requirement 3.5),
and comfortably satisfies Requirement 3.4 for any integer sample rate in
[4000, 192000] Hz.
The algorithm is a rounded divide plus a clamp: start from
N = round(sampleRate / 50), then nudge N up or down until
sampleRate / N lands back inside [40, 60]. At any positive
integer sample rate in the supported range this terminates in at most two
steps because the 1 / N spacing between candidate bin widths is
strictly narrower than the 20 Hz tolerance band.
Although the type is public so DtmfConfig in the sibling
package com.tino1b2be.dtmf can call it, the convention is that
com.tino1b2be.dtmf.internal.* is not part of the published API:
callers go through DtmfConfig.Advanced rather than constructing
this type directly. There is no constructor to call; every entry point is
a static method.
-
Method Summary
Modifier and TypeMethodDescriptionstatic intblockSizeFor(int sampleRate) Compute the analysis block size for the given sample rate so that the effective Goertzel bin width lies in[40, 60]Hz.
-
Method Details
-
blockSizeFor
public static int blockSizeFor(int sampleRate) Compute the analysis block size for the given sample rate so that the effective Goertzel bin width lies in[40, 60]Hz.- Parameters:
sampleRate- sample rate in Hz; must be> 0- Returns:
- a positive
int Nsuch thatsampleRate / Nis in[40.0, 60.0] - Throws:
IllegalArgumentException- ifsampleRate <= 0
-