pub struct StftParams { /* private fields */ }Expand description
STFT parameters for spectrogram computation.
n_fft: Size of the FFT window.hop_size: Number of samples between successive frames.- window: Window function to apply to each frame.
- centre: Whether to pad the input signal so that frames are centered.
Implementations§
Source§impl StftParams
impl StftParams
Sourcepub fn new(
n_fft: NonZeroUsize,
hop_size: NonZeroUsize,
window: WindowType,
centre: bool,
) -> SpectrogramResult<Self>
pub fn new( n_fft: NonZeroUsize, hop_size: NonZeroUsize, window: WindowType, centre: bool, ) -> SpectrogramResult<Self>
Create new STFT parameters.
§Arguments
n_fft- Size of the FFT windowhop_size- Number of samples between successive frameswindow- Window function to apply to each framecentre- Whether to pad the input signal so that frames are centered
§Errors
Returns an error if:
hop_size>n_fft- Custom window size doesn’t match
n_fft
§Returns
New StftParams instance.
Sourcepub const fn n_fft(&self) -> NonZeroUsize
pub const fn n_fft(&self) -> NonZeroUsize
Sourcepub const fn hop_size(&self) -> NonZeroUsize
pub const fn hop_size(&self) -> NonZeroUsize
Sourcepub fn window(&self) -> WindowType
pub fn window(&self) -> WindowType
Sourcepub const fn centre(&self) -> bool
pub const fn centre(&self) -> bool
Get whether frames are centered (input signal is padded).
§Returns
true if frames are centered, false otherwise.
Sourcepub fn builder() -> StftParamsBuilder
pub fn builder() -> StftParamsBuilder
Create a builder for STFT parameters.
§Returns
A StftParamsBuilder instance.
§Examples
use spectrograms::{StftParams, WindowType, nzu};
let stft = StftParams::builder()
.n_fft(nzu!(2048))
.hop_size(nzu!(512))
.window(WindowType::Hanning)
.centre(true)
.build()?;
assert_eq!(stft.n_fft(), nzu!(2048));
assert_eq!(stft.hop_size(), nzu!(512));Trait Implementations§
Source§impl Clone for StftParams
impl Clone for StftParams
Source§fn clone(&self) -> StftParams
fn clone(&self) -> StftParams
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for StftParams
impl Debug for StftParams
Source§impl<'de> Deserialize<'de> for StftParams
impl<'de> Deserialize<'de> for StftParams
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<PyStftParams> for StftParams
impl From<PyStftParams> for StftParams
Source§fn from(val: PyStftParams) -> Self
fn from(val: PyStftParams) -> Self
Converts to this type from the input type.
Source§impl From<StftParams> for PyStftParams
impl From<StftParams> for PyStftParams
Source§fn from(inner: StftParams) -> Self
fn from(inner: StftParams) -> Self
Converts to this type from the input type.
Source§impl PartialEq for StftParams
impl PartialEq for StftParams
Source§fn eq(&self, other: &StftParams) -> bool
fn eq(&self, other: &StftParams) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for StftParams
impl Serialize for StftParams
impl StructuralPartialEq for StftParams
Auto Trait Implementations§
impl Freeze for StftParams
impl RefUnwindSafe for StftParams
impl Send for StftParams
impl Sync for StftParams
impl Unpin for StftParams
impl UnsafeUnpin for StftParams
impl UnwindSafe for StftParams
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
Mutably borrows from an owned value. Read more