pub struct AnalyticSignal { /* private fields */ }Expand description
The analytic signal z = x + j H{x} of a real signal.
Implementations§
Source§impl AnalyticSignal
impl AnalyticSignal
Sourcepub fn new(samples: &[f64], rate: SampleRate, pad: usize) -> Self
pub fn new(samples: &[f64], rate: SampleRate, pad: usize) -> Self
Computes the analytic signal by FFT: the negative bins are zeroed, the positive bins doubled, and the DC bin and, for an even length, the Nyquist bin keep gain 1.
The FFT wraps circularly, so pad zeros go before and after the
signal and are cut after the transform. The cut ends still carry an
error that decays as 1 / d with the distance d from an end,
about fs / (2 pi^2 f d) for a sine of frequency f: 0.1 % needs
some 4000 samples at 123 Hz and 8 kHz. Mirroring the signal instead
of zeros is worse, because a reversed partial runs backwards in phase.
It is meant for note-sized segments. The transform holds the padded signal as complex values, 16 bytes a sample, and an FFT of a length that is not a power of two needs several times that in scratch: a whole 10-minute stem at 48 kHz peaks near 2 GB. Heterodyne a long signal instead.
Sourcepub fn instantaneous_frequency(&self) -> Vec<f64>
pub fn instantaneous_frequency(&self) -> Vec<f64>
Returns the instantaneous frequency in hertz between consecutive
samples, f[n] = (fs / 2 pi) arg(z[n+1] conj(z[n])). Avoids
differentiating a noisy phase. One value fewer than samples. The
per-sample track stays bare f64 hertz: a value can be negative,
which Hz rejects.
Trait Implementations§
Source§impl Clone for AnalyticSignal
impl Clone for AnalyticSignal
Source§impl Debug for AnalyticSignal
impl Debug for AnalyticSignal
Source§impl PartialEq for AnalyticSignal
impl PartialEq for AnalyticSignal
impl StructuralPartialEq for AnalyticSignal
Auto Trait Implementations§
impl Freeze for AnalyticSignal
impl RefUnwindSafe for AnalyticSignal
impl Send for AnalyticSignal
impl Sync for AnalyticSignal
impl Unpin for AnalyticSignal
impl UnsafeUnpin for AnalyticSignal
impl UnwindSafe for AnalyticSignal
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> CloneAny for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more