[][src]Trait dasp_signal::envelope::SignalEnvelope

pub trait SignalEnvelope: Signal {
    fn detect_envelope<D>(
        self,
        detector: Detector<Self::Frame, D>
    ) -> DetectEnvelope<Self, D>
    where
        Self: Sized,
        D: Detect<Self::Frame>
, { ... } }

An extension to the Signal trait that enables envelope detection.

Required Features

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

Provided methods

fn detect_envelope<D>(
    self,
    detector: Detector<Self::Frame, D>
) -> DetectEnvelope<Self, D> where
    Self: Sized,
    D: Detect<Self::Frame>, 

An adaptor that detects and yields the envelope of the signal.

Example

use dasp_envelope as envelope;
use dasp_signal::{self as signal, Signal};
use dasp_signal::envelope::SignalEnvelope;

fn main() {
    let signal = signal::rate(4.0).const_hz(1.0).sine();
    let attack = 1.0;
    let release = 1.0;
    let detector = envelope::Detector::peak(attack, release);
    let mut envelope = signal.detect_envelope(detector);
    assert_eq!(
        envelope.take(4).collect::<Vec<_>>(),
        vec![0.0, 0.6321205496788025, 0.23254416035257117, 0.7176687675647109]
    );
}

Required Features

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

Implementors

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

Loading content...