pub struct TraceNormalizer { /* private fields */ }Expand description
The waveform’s normalizer: one running peak of the trace’s magnitude, applied as a uniform gain to the whole trace.
One shared peak for the same reason BandNormalizer uses one — the samples
of a trace only mean anything relative to each other, and a per-sample gain
would erase the shape the trace exists to show. Two differences from that
type, both forced by the quantity:
- The peak tracks
|x|and the output stays signed. A trace is a signal, not a magnitude, so it is divided rather than rectified and clamps to-1..=1instead of0..=1. - The divisor is returned rather than discarded, because it is published
as
AnalysisFrame::waveform_gain(ADR-0139): the raw amplitude iswaveform[i] * waveform_gain, which is the escape hatch a consumer that genuinely wants absolute level reaches for.
Implementations§
Source§impl TraceNormalizer
impl TraceNormalizer
Sourcepub fn normalize(&mut self, trace: &mut [f32; 512]) -> f32
pub fn normalize(&mut self, trace: &mut [f32; 512]) -> f32
Advance one hop, normalizing trace in place, and return the divisor
removed — 0.0 while the tracked peak sits under the floor, where the
trace is zeroed rather than amplified.
Sourcepub fn normalize_pair(
&mut self,
left: &mut [f32; 512],
right: &mut [f32; 512],
) -> f32
pub fn normalize_pair( &mut self, left: &mut [f32; 512], right: &mut [f32; 512], ) -> f32
The same, over two traces at once and with one divisor tracked over the larger of their magnitudes.
One divisor rather than two, and that is the whole reason this exists
beside normalize: a hard-panned signal has a silent
side, and levelling that side against its own recent peak would amplify
whatever noise is in it up to full scale. The pair would then read as two
loud channels, and an x-y figure built from them would lose the aspect
that says where the sound is.