Skip to content

Commit ed4af6d

Browse files
committed
docs: add note on f32 vs f64 precision
1 parent 20c0765 commit ed4af6d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/common.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,21 @@ pub type ChannelCount = NonZero<u16>;
1010
/// Number of bits per sample. Can never be zero.
1111
pub type BitDepth = NonZero<u32>;
1212

13+
// NOTE on numeric precision:
14+
//
15+
// While `f32` is transparent for typical playback use cases, it does not guarantee preservation of
16+
// full 24-bit source fidelity across arbitrary processing chains. Each floating-point operation
17+
// rounds its result to `f32` precision (~24-bit significand). In DSP pipelines (filters, mixing,
18+
// modulation), many operations are applied per sample and over time, so rounding noise accumulates
19+
// and long-running state (e.g. oscillator phase) can drift.
20+
//
21+
// For use cases where numerical accuracy must be preserved through extended processing (recording,
22+
// editing, analysis, long-running generators, or complex DSP graphs), enabling 64-bit processing
23+
// reduces accumulated rounding error and drift.
24+
//
25+
// This mirrors common practice in professional audio software and DSP libraries, which often use
26+
// 64-bit internal processing even when the final output is 16- or 24-bit.
27+
1328
/// Floating point type used for internal calculations. Can be configured to be
1429
/// either `f32` (default) or `f64` using the `64bit` feature flag.
1530
#[cfg(not(feature = "64bit"))]

0 commit comments

Comments
 (0)