[][src]Trait dasp::signal::rms::SignalRms

pub trait SignalRms: Signal {
    fn rms<S>(self, ring_buffer: Fixed<S>) -> Rms<Self, S>
    where
        S: Slice<Element = <Self::Frame as Frame>::Float> + SliceMut
, { ... } }

An extension to the Signal trait that monitors the RMS of a signal.

Required Features

  • When using dasp_signal, this item requires the rms feature to be enabled.
  • When using dasp, this item requires the signal-rms feature to be enabled.

Provided methods

fn rms<S>(self, ring_buffer: Fixed<S>) -> Rms<Self, S> where
    S: Slice<Element = <Self::Frame as Frame>::Float> + SliceMut

An adaptor that yields the RMS of the signal.

The window size of the RMS detector is equal to the given ring buffer length.

Example

use dasp_ring_buffer as ring_buffer;
use dasp_signal::{self as signal, Signal};
use dasp_signal::rms::SignalRms;

fn main() {
    let frames = [[0.9], [-0.8], [0.6], [-0.9]];
    let signal = signal::from_iter(frames.iter().cloned());
    let ring_buffer = ring_buffer::Fixed::from([[0.0]; 2]);
    let mut rms_signal = signal.rms(ring_buffer);
    assert_eq!(
        [rms_signal.next(), rms_signal.next(), rms_signal.next()],
        [[0.6363961030678927], [0.8514693182963201], [0.7071067811865476]]
    );
}

Required Features

  • When using dasp_signal, this item requires the rms feature to be enabled.
  • When using dasp, this item requires the signal-rms feature to be enabled.
Loading content...

Implementors

impl<T> SignalRms for T where
    T: Signal
[src]

Loading content...