Struct sample::rms::Rms[][src]

pub struct Rms<F, S> where
    F: Frame,
    S: Slice<Element = F::Float>, 
{ /* fields omitted */ }

Iteratively extracts the RMS (root mean square) envelope from a window over a signal of sample Frames.

Methods

impl<F, S> Rms<F, S> where
    F: Frame,
    S: Slice<Element = F::Float>, 
[src]

Construct a new Rms that uses the given ring buffer as its window.

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

extern crate sample;

use sample::ring_buffer;
use sample::rms::Rms;

fn main() {
    let window = ring_buffer::Fixed::from([[0.0]; 4]);
    let mut rms = Rms::new(window);
    rms.next([0.5]);
}

Zeroes the square_sum and the buffer of the window.

extern crate sample;

use sample::ring_buffer;
use sample::rms::Rms;

fn main() {
    let window = ring_buffer::Fixed::from([[0.0]; 4]);
    let mut rms = Rms::new(window);
    rms.next([0.6]);
    rms.next([0.9]);
    rms.reset();
    assert_eq!(rms.current(), [0.0]);
}

The length of the window as a number of frames.

extern crate sample;

use sample::ring_buffer;
use sample::rms::Rms;

fn main() {
    let window = ring_buffer::Fixed::from([[0.0]; 4]);
    let mut rms = Rms::new(window);
    assert_eq!(rms.window_frames(), 4);
    rms.next([0.5]);
    assert_eq!(rms.window_frames(), 4);
}

The next RMS given the new frame in the sequence.

The Rms pops its front frame and adds the new frame to the back.

The yielded RMS is the RMS of all frame squares in the window after the new frame is added.

This method uses Rms::next_squared internally and then calculates the square root.

extern crate sample;

use sample::ring_buffer;
use sample::rms::Rms;

fn main() {
    let window = ring_buffer::Fixed::from([[0.0]; 4]);
    let mut rms = Rms::new(window);
    assert_eq!(rms.next([1.0]), [0.5]);
    assert_eq!(rms.next([-1.0]), [0.7071067811865476]);
    assert_eq!(rms.next([1.0]), [0.8660254037844386]);
    assert_eq!(rms.next([-1.0]), [1.0]);
}

The same as Rms::next, but does not calculate the final square root required to determine the RMS.

Consumes the Rms and returns its inner ring buffer of squared frames along with a frame representing the sum of all frame squares contained within the ring buffer.

Calculates the RMS of all frames currently stored within the inner window.

extern crate sample;

use sample::ring_buffer;
use sample::rms::Rms;

fn main() {
    let window = ring_buffer::Fixed::from([[0.0]; 4]);
    let mut rms = Rms::new(window);
    assert_eq!(rms.current(), [0.0]);
    rms.next([1.0]);
    rms.next([1.0]);
    rms.next([1.0]);
    rms.next([1.0]);
    assert_eq!(rms.current(), [1.0]);
}

Trait Implementations

impl<F, S> Detect<F> for Rms<F, S> where
    F: Frame,
    S: Slice<Element = F::Float> + SliceMut
[src]

The result of detection.

Given some frame, return the detected envelope over each channel.

impl<F: Clone, S: Clone> Clone for Rms<F, S> where
    F: Frame,
    S: Slice<Element = F::Float>,
    F::Float: Clone
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<F, S> Debug for Rms<F, S> where
    F: Frame,
    F::Float: Debug,
    S: Debug + Slice<Element = F::Float>, 
[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl<F, S> Send for Rms<F, S> where
    F: Send,
    S: Send,
    <F as Frame>::Float: Send

impl<F, S> Sync for Rms<F, S> where
    F: Sync,
    S: Sync,
    <F as Frame>::Float: Sync