Skip to main content

MetricsAccumulator

Struct MetricsAccumulator 

pub struct MetricsAccumulator { /* private fields */ }
Expand description

Accumulates per-sample statistics and reduces them to UiMetrics every block.

Used by the audio thread to compute RMS, peak, and tap tube/transformer state. Call accumulate() every sample, then reduce() every block_size samples.

Implementations§

§

impl MetricsAccumulator

pub fn new(block_size: usize) -> MetricsAccumulator

Create a new accumulator with the given block size.

pub fn set_nominal_supply(&mut self, voltage: f32)

Set the nominal supply voltage for sag calculation.

pub fn accumulate_levels(&mut self, input: f64, output: f64)

Accumulate input/output levels for one sample.

pub fn accumulate_stage(&mut self, stage_idx: usize, level: f64)

Record a stage level (call after each WDF stage processes).

pub fn record_stage_solver( &mut self, stage_idx: usize, iterations: u32, residual: f64, converged: bool, )

Record one nonlinear/coupled solver call for a stage.

pub fn record_signal_fault(&mut self, value: f64)

Record a runtime signal fault caught outside normal level metering.

pub fn record_tube(&mut self, tube_idx: usize, plate_current_ma: f32, vpk: f32)

Record tube state (call once per sample or per block).

pub fn record_supply(&mut self, voltage: f32)

Record supply voltage (for sag visualization).

pub fn record_lfo_phase(&mut self, phase: f32)

Record LFO phase (for pulse indicator).

pub fn record_gain_reduction(&mut self, gr_db: f32)

Record gain reduction (for compressor meters).

pub fn is_block_complete(&self) -> bool

Check if a block is complete and ready for reduction.

pub fn reduce(&mut self) -> UiMetrics

Reduce accumulated statistics to UiMetrics and reset for next block.

Call this every block_size samples. Returns the reduced metrics.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more