akiomik / akiomik/oxtt

effectkit: flush and DENORMAL_FLOOR are public for a caller that does not exist

Offen
#6 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
rust
Vorherrschende Sprache
Rust
Sterne
1
Forks
0
Ø Merge
8 Std. 2 Min.
Gemergte PRs (30 T.)
1

Beschreibung

## What

`effectkit::filter::flush` and `effectkit::filter::DENORMAL_FLOOR` are `pub`,
and `flush`'s documentation gives the reason:

> Public because the constant it compares against is a decision, and an
> effect building a filter of its own should reach for the decision rather
> than for the number. Two copies of `1e-20` in two crates is one copy that
> will be revised.

**No such caller exists.** Every use is inside `filter.rs` itself:

```
crates/effectkit/src/filter.rs:131 self.y1 = flush(y0); // Biquad
crates/effectkit/src/filter.rs:316 self.ic1eq = flush(...); // Svf
crates/effectkit/src/filter.rs:317 self.ic2eq = flush(...); // Svf
```

Nothing outside the crate references either name, and the reason is
structural rather than an oversight: no effect builds a filter of its own.
`hyperglare-dsp` reaches for `effectkit::filter::{Biquad, biquad_coeffs}` in
`bands.rs` and `processor.rs`, and `{Svf, SvfCoeffs}` in `bank.rs`, all of
which already flush internally. The scenario the doc guards against — two
copies of `1e-20` in two crates — has not arisen and has no route to.

The one place that does flush by hand is `hyperglare-dsp`'s
`exciter::envelope_floor`, and it is deliberately *not* this decision: it uses
`effectkit::decibels::FLOOR_DB` and its comment explains why a denormal-scale
floor would be the wrong answer to "what counts as silence". So it is not the
duplication this API was made public to prevent.

## Why it matters

A public item with a rationale written in the perfect tense reads as though
the integration happened. It is also surface that has to keep working across
versions for no caller's benefit — `flush` is `#[inline]` and trivial, but
`DENORMAL_FLOOR` is a number whose value is now part of the crate's API.

## Options

1. **Make both private.** `Biquad` and `Svf` are the crate's filters and they
flush themselves; an effect that needed its own would be the reason to
export them again, and that reason would arrive with a caller.
2. **Keep them public and correct the doc** to say they are offered rather
than relied upon, so the next reader does not go looking for the consumer.

(1) is the smaller surface and (2) is the smaller change. Either settles it;
what should not stay is a justification that describes a caller that is not
there.

## Out of scope

This is `effectkit`, so it is deliberately not being folded into the
`hyperglare` work that surfaced it.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.