129#define TONE_OUTLIER_PCT 45u
131#define TONE_BEEP_QUEUE 16u
138#define TONE_WINDOW_US_MAX 100000u
139#define TONE_GAP_US_MAX 1000000u
140#define TONE_GLITCH_NS_MAX 10000u
141#define TONE_HOLD_NS_MAX 100000u
242 uint64_t win_ticks, per_min, per_max, car_max, glitch, gap;
266 uint64_t burst_start, burst_e_before;
271 uint32_t b_n, b_bursts;
277 uint64_t w_index, w_end, w_sum;
278 uint32_t w_n, w_bursts;
283 uint32_t q_head, q_len;
One beep as the page reported it.
Definition tone_link.h:193
uint8_t flags
Definition tone_link.h:200
float carrier_hz
The carrier its run was chopped at; 0 when no rise came at the carrier rate.
Definition tone.h:211
uint32_t periods
Definition tone.h:213
uint16_t bursts
Definition tone_link.h:198
uint64_t start
Definition tone.h:204
float freq_hz
Definition tone.h:206
uint64_t end
Definition tone.h:205
Detector settings, as given to tone_init().
Definition tone.h:144
uint32_t min_periods
Definition tone.h:176
uint32_t window_min_periods
Definition tone.h:177
uint32_t f_min_hz
Definition tone.h:147
uint32_t glitch_ns
A low shorter than this, ns, is no low; 1 to 10000.
Definition tone.h:157
uint32_t split_pct
TONE_BLOCK periods this far from the beep's mean, in percent, start a new beep; 0 splits only on sile...
Definition tone.h:175
uint32_t window_us
Definition tone.h:146
uint32_t gap_us
No edge for this long ends a beep, us, at most TONE_GAP_US_MAX; at least the period of f_min_hz,...
Definition tone.h:170
uint32_t hold_ns
The capture's hold-off (tone_holdoff_t), ns, 0 to TONE_HOLD_NS_MAX; 0 none.
Definition tone.h:164
uint32_t f_max_hz
Definition tone.h:148
uint32_t carrier_min_hz
Rise intervals up to this carrier's period are chopping inside a burst.
Definition tone.h:155
uint32_t tick_hz
Definition tone.h:145
One edge: the tick it happened at and the level after it.
Definition tone.h:182
The capture's hold-off: the rule the PIO program applies before an edge reaches the detector,...
Definition tone.h:437
uint64_t fall
Definition tone.h:441
bool line
Definition tone.h:439
uint64_t hold
Definition tone.h:438
bool pending
Definition tone.h:440
uint64_t out_t
Definition tone.h:442
A period waiting for the pitch check.
Definition tone.h:232
uint64_t s_open
Definition tone.h:234
bool good
Definition tone.h:236
uint64_t p
Definition tone.h:233
uint64_t e_before
Definition tone.h:235
Counters of the detector, read with tone_stats().
Definition tone.h:218
uint32_t edges
Definition tone.h:219
uint32_t lost
Definition tone.h:228
uint32_t beeps
Definition tone.h:222
uint32_t glitches
Definition tone.h:220
uint32_t rejected
Runs that made no beep: too few periods, or a mean outside the tone range.
Definition tone.h:227
uint32_t out_of_order
Definition tone.h:221
Detector state. The fields belong to tone.c.
Definition tone.h:240
bool have_edge
Definition tone.h:253
bool seen
Definition tone.h:251
uint64_t last_fall
Definition tone.h:257
uint64_t car_rise
Definition tone.h:263
bool rise_started
Definition tone.h:265
uint64_t start_low
Definition tone.h:243
uint64_t spacing
The shortest time between two burst starts that makes a counted period, ticks: the most of half the s...
Definition tone.h:249
uint64_t car_low
Definition tone.h:261
uint64_t car_high
Definition tone.h:262
uint64_t now
Definition tone.h:252
uint64_t last_edge
Definition tone.h:254
uint64_t last_rise
Definition tone.h:256
bool high
Definition tone.h:255
One window of window_us.
Definition tone.h:188
float freq_hz
Definition tone.h:191
uint32_t periods
Definition tone.h:192
bool present
Definition tone.h:190
uint64_t index
Definition tone.h:189
uint32_t bursts
Definition tone.h:193
uint64_t tone_ns_ticks(uint64_t tick_hz, uint64_t ns)
ns as ticks of a tick_hz clock, rounded up: the conversion of every time setting.
Definition tone.c:49
uint64_t tone_ticks_us(const tone_t *d, uint64_t ticks)
ticks of the detector's clock in microseconds, rounded down.
Definition tone.c:701
#define TONE_BEEP_QUEUE
Beeps held until the caller takes them.
Definition tone.h:131
void tone_edge(tone_t *d, uint64_t t, bool level)
One edge at tick t, level after it.
Definition tone.c:619
size_t tone_holdoff_edge(tone_holdoff_t *h, uint64_t t, bool level, tone_edge_t out[2])
One edge at t; the edges reported, 0 to 2, into out in time order: a held fall whose low lasted the h...
Definition tone.c:721
size_t tone_holdoff_advance(tone_holdoff_t *h, uint64_t now, tone_edge_t out[1])
No edge up to now: a held fall whose low has lasted the hold-off by then, into out; 0 or 1.
Definition tone.c:757
void tone_flush(tone_t *d)
End the beep under way at its last edge, as a silence would, and forget the line's level,...
Definition tone.c:656
#define TONE_BLOCK
Periods compared at once for a pitch change.
Definition tone.h:124
void tone_advance(tone_t *d, uint64_t now)
No edge up to tick now: a silence ends a beep, a window closes.
Definition tone.c:648
tone_beep_flag_t
Definition tone.h:196
@ TONE_BEEP_BEFORE_CHANGE
Ended at a pitch change, with no silence after it.
Definition tone.h:200
@ TONE_BEEP_AFTER_CHANGE
Began at a pitch change, with no silence before it.
Definition tone.h:198
void tone_feed(tone_t *d, const tone_edge_t *e, size_t n)
n edges in time order.
Definition tone.c:638
bool tone_next_beep(tone_t *d, tone_beep_t *b)
Take the oldest beep reported; false with none waiting.
Definition tone.c:680
bool tone_busy(const tone_t *d)
A run of bursts is under way.
Definition tone.c:691
const tone_stats_t * tone_stats(const tone_t *d)
The counters of the detector.
Definition tone.c:696
void tone_cfg_defaults(tone_cfg_t *c, uint32_t tick_hz)
Defaults for a clock of tick_hz: 8000us windows, 400 to 6500Hz, carrier from 7kHz,...
Definition tone.c:16
uint64_t tone_holdoff_horizon(const tone_holdoff_t *h, uint64_t now)
now less the hold-off, at least 0, and never before the latest edge handed out: every edge before it ...
Definition tone.c:771
bool tone_window(const tone_t *d, tone_window_t *w)
The last window finished; false before the first.
Definition tone.c:671
void tone_holdoff_init(tone_holdoff_t *h, uint32_t tick_hz, uint32_t hold_ns)
hold_ns of a clock of tick_hz, rounded up to whole ticks; the line starts low.
Definition tone.c:712
bool tone_init(tone_t *d, const tone_cfg_t *c)
Start from nothing.
Definition tone.c:71