Struct True Peak Bank64
pub struct TruePeakBank64 { /* private fields */ }Expand description
Prepared 1..64-channel f64 measurement bank; f32 observation widens exactly.
Each causal phase is at t-half_width+phase/factor after source step t. Negative indices are zero. Live readings have half_width frames of pending source suffix (capped at the accepted source length); explicit finish evaluates the full zero-extended finite support. Artificial tail steps never increment original source frames. Empty finish is empty, repeat finish idempotent, and later input (including empty calls) requires reset.
Entire shape/prefix/frame/count admission precedes any measurement/history mutation. Nonfinite samples are measurement silence with a flag; audio is untouched. Per-window max-absolute scaling and Neumaier summation avoid intermediate overflow and reduce alternating-weight accumulation error; genuine final amplitudes beyond f64::MAX report infinity and an overflow flag. Native underflow/rounding remains observable. No callback heap/locks/I/O or implicit Drop finalization; finish performs bounded 2*half_width steps and belongs after stopped audio ownership. No deadline or conformance guarantee.
A live interpolated_peak is not a peak bound: it can be below
sample_peak because the newest half_width source frames have not yet had
their own phase-zero coordinate evaluated. Coordinates beyond the last source
frame (for example the overshoot after a truncated near-Nyquist run) are only
measured by finish(). Coordinates far beyond the last frame only see small
window edge weights, so the peak value is not expected to discriminate a
tail much longer than half_width steps (an argument, not a proof); the
2*half_width tail is evidenced by the tail_frames, phase_observations
and last_phase_numerator() counters rather than by the peak.
Two flags have different meanings. Nonfinite input samples are replaced by
zero before measurement (also in sample_peak) and latch nonfinite_input;
amplitude_overflow is set only when the final arithmetic result of finite
samples exceeds f64::MAX. Flags and peaks are per channel; a poisoned channel
leaves its neighbours’ readings and histories unchanged. Channels share
nothing but the step counter and a recomputed scratch array.
Implementations§
§impl TruePeakBank64
impl TruePeakBank64
pub fn new(
design: &TruePeakDesign,
channels: usize,
maximum_frames: usize,
) -> Result<Self, TruePeakError>
pub fn new( design: &TruePeakDesign, channels: usize, maximum_frames: usize, ) -> Result<Self, TruePeakError>
Borrowed design survives any constructor refusal; all allocation is CONTROL.
pub fn design(&self) -> &TruePeakDesign
pub const fn channels(&self) -> usize
pub const fn maximum_frames(&self) -> usize
pub const fn source_frames(&self) -> u64
pub fn last_phase_numerator(&self) -> Option<i128>
pub fn last_phase_numerator(&self) -> Option<i128>
Latest fully evaluated phase coordinate numerator, denominator factor.
pub fn pending_source_suffix_frames(&self) -> u64
pub fn reading( &self, channel: usize, ) -> Result<TruePeakReading64, TruePeakError>
pub fn observe_frame(&mut self, input: &[f64]) -> Result<(), TruePeakError>
pub fn observe_frame_f32(&mut self, input: &[f32]) -> Result<(), TruePeakError>
pub fn observe_planar( &mut self, input: &[&[f64]], frames: usize, ) -> Result<(), TruePeakError>
pub fn observe_planar_f32( &mut self, input: &[&[f32]], frames: usize, ) -> Result<(), TruePeakError>
pub fn observe_in_place( &mut self, input: &[&mut [f64]], frames: usize, ) -> Result<(), TruePeakError>
pub fn observe_in_place_f32( &mut self, input: &[&mut [f32]], frames: usize, ) -> Result<(), TruePeakError>
pub fn finish(&mut self)
pub fn finish(&mut self)
Explicit stopped finalization; all finite support, no original-frame inflation.