pub struct ChromaExtractor { /* private fields */ }Expand description
Chroma feature extractor with configurable STFT and tuning parameters.
§Examples
use resonant_analysis::chroma::ChromaExtractor;
let extractor = ChromaExtractor::new(44100.0);
let samples = vec![0.0_f32; 8192];
let chroma = extractor.extract(&samples).unwrap();
for cv in &chroma {
assert_eq!(cv.bins.len(), 12);
}Implementations§
Source§impl ChromaExtractor
impl ChromaExtractor
Sourcepub fn new(sample_rate: f32) -> Self
pub fn new(sample_rate: f32) -> Self
Creates an extractor with default parameters.
Defaults: window 4096, hop 2048, A4 = 440 Hz tuning.
Sourcepub fn with_window_size(self, size: usize) -> Self
pub fn with_window_size(self, size: usize) -> Self
Sets the STFT window size (should be a power of two).
Sourcepub fn with_hop_size(self, hop: usize) -> Self
pub fn with_hop_size(self, hop: usize) -> Self
Sets the STFT hop size.
Sourcepub fn with_tuning(self, hz: f32) -> Self
pub fn with_tuning(self, hz: f32) -> Self
Sets the tuning reference frequency for A4 (default 440 Hz).
Sourcepub fn extract(
&self,
samples: &[f32],
) -> Result<Vec<ChromaVector>, AnalysisError>
pub fn extract( &self, samples: &[f32], ) -> Result<Vec<ChromaVector>, AnalysisError>
Extracts chroma vectors from mono audio samples.
Returns one ChromaVector per STFT frame.
§Errors
Returns AnalysisError::EmptyInput if samples is empty.
Trait Implementations§
Source§impl Clone for ChromaExtractor
impl Clone for ChromaExtractor
Source§fn clone(&self) -> ChromaExtractor
fn clone(&self) -> ChromaExtractor
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 moreAuto Trait Implementations§
impl Freeze for ChromaExtractor
impl RefUnwindSafe for ChromaExtractor
impl Send for ChromaExtractor
impl Sync for ChromaExtractor
impl Unpin for ChromaExtractor
impl UnsafeUnpin for ChromaExtractor
impl UnwindSafe for ChromaExtractor
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