[][src]Struct dsp::signals::Signal

pub struct Signal {
    pub sample_rate: usize,
    // some fields omitted
}

Discrete Time Signal

  • data - Data points
  • sample_rate - how many points per second

Fields

sample_rate: usize

Methods

impl Signal[src]

pub fn new(data: Vec<Complex64>) -> Signal[src]

Create new signal from 1 second of samples

pub fn sample_rate(&self) -> usize[src]

Returns the sample_rate of this signal

pub fn from_samples(data: Vec<Complex64>, sample_rate: usize) -> Signal[src]

Create new signal from samples with given sample rate

pub fn from_reals(data: Vec<f64>, sample_rate: usize) -> Signal[src]

Create new signal from vector of real numbers

pub fn len(&self) -> usize[src]

Signal length() in number of samples

pub fn duration(&self) -> f64[src]

Signal duration in time units

pub fn get(&self, i: isize) -> Complex64[src]

This function will return 0 if index out of bound

pub fn to_vec(&self) -> Vec<Complex64>[src]

Copy data into new vector

pub fn shift(&self, k: isize) -> Signal[src]

Shift signal by given integer y[n] = x[n-k] This function will not change the signal length

pub fn integrate(&self) -> Signal[src]

Integrate signal y[n] = Sum x[k] For all k <= n

pub fn differentiate(&self) -> Signal[src]

Differentiate the signal y[n] = x[n] - x[n-1]

pub fn energy(&self) -> f64[src]

Calculate energy E = Sum x[n]^2 For all n

pub fn power(&self) -> f64[src]

Calculate power P = 1/N Sum x[n]^2 For all n

pub fn modulate(&self, carrier: &Signal) -> Signal[src]

Modulate signal by given carrier

pub fn sum(&self, s2: &Signal) -> Signal[src]

Sum 2 signals

pub fn slice(&self, start: usize, end: usize) -> Signal[src]

Sliced signal. Return copy.

pub fn reverse(&self) -> Signal[src]

Reverse the signal. Last value will be first

pub fn convolve(&self, h: &Signal) -> Signal[src]

Convolve signals

Important traits for Frames<'a>
pub fn frames<'a>(&'a self, length: usize, shift: usize) -> Frames<'a>[src]

Build an iterator over frames of this signal. The frames have the specified length and they are spaced shift samples center to center

Trait Implementations

impl PartialEq<Signal> for Signal[src]

impl Clone for Signal[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for Signal[src]

Auto Trait Implementations

impl Send for Signal

impl Sync for Signal

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]