pub struct AnalyzerConfig { /* private fields */ }Expand description
Configuration for the BPM analyzer.
Use the builder pattern to customize analyzer parameters:
§Example
use bpm_analyzer::AnalyzerConfig;
let config = AnalyzerConfig::builder()
.min_bpm(60.0)
.max_bpm(180.0)
.window_size(32768)
.build();Implementations§
Source§impl AnalyzerConfig
impl AnalyzerConfig
Sourcepub fn builder() -> AnalyzerConfigBuilder
pub fn builder() -> AnalyzerConfigBuilder
Create an instance of AnalyzerConfig using the builder syntax
Source§impl AnalyzerConfig
impl AnalyzerConfig
Sourcepub fn electronic() -> Self
pub fn electronic() -> Self
Creates a configuration preset optimized for electronic music (100-160 BPM).
Examples found in repository?
examples/beat_timing.rs (line 10)
8fn main() -> Result<(), bpm_analyzer::Error> {
9 // Configure the analyzer for electronic music
10 let config = AnalyzerConfig::electronic();
11
12 println!("Starting BPM analyzer...");
13 println!("Listening for beats and tempo...\n");
14
15 // Start the analyzer
16 let receiver = begin(config)?;
17
18 // Process detections
19 for detection in receiver.iter() {
20 // Print BPM if detected
21 if let Some(bpm) = detection.bpm() {
22 println!("🎵 Detected BPM: {:.1}", bpm);
23 }
24
25 // Print beat timings
26 if let Some(last_beat) = detection.last_beat() {
27 print!(
28 "🥁 Beat at {:.2}s (strength: {:.2})",
29 last_beat.time_seconds, last_beat.strength
30 );
31
32 // Show beat interval if we have at least 2 beats
33 if let Some(interval) = detection.last_beat_interval() {
34 let instant_bpm = 60.0 / interval;
35 print!(" | Interval: {:.3}s ({:.1} BPM)", interval, instant_bpm);
36 }
37 println!();
38 }
39
40 // Print all recent beat timings
41 let beats = detection.beat_timings();
42 if beats.len() >= 4 {
43 println!("📊 Recent beats: {} detected", beats.len());
44 for (i, beat) in beats.iter().rev().take(4).enumerate() {
45 println!(
46 " {} {:.2}s ago (strength: {:.2})",
47 if i == 0 { "•" } else { " " },
48 beats.last().unwrap().time_seconds - beat.time_seconds,
49 beat.strength
50 );
51 }
52 }
53
54 println!();
55 }
56
57 Ok(())
58}Sourcepub fn classical() -> Self
pub fn classical() -> Self
Creates a configuration preset optimized for classical music (40-100 BPM).
Sourcepub fn window_size(&self) -> usize
pub fn window_size(&self) -> usize
Returns the window size setting.
Sourcepub fn queue_size(&self) -> usize
pub fn queue_size(&self) -> usize
Returns the queue size setting.
Sourcepub fn buffer_size(&self) -> u32
pub fn buffer_size(&self) -> u32
Returns the buffer size setting.
Trait Implementations§
Source§impl Clone for AnalyzerConfig
impl Clone for AnalyzerConfig
Source§fn clone(&self) -> AnalyzerConfig
fn clone(&self) -> AnalyzerConfig
Returns a duplicate of the value. Read more
1.0.0 · 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 AnalyzerConfig
impl Debug for AnalyzerConfig
impl Copy for AnalyzerConfig
Auto Trait Implementations§
impl Freeze for AnalyzerConfig
impl RefUnwindSafe for AnalyzerConfig
impl Send for AnalyzerConfig
impl Sync for AnalyzerConfig
impl Unpin for AnalyzerConfig
impl UnwindSafe for AnalyzerConfig
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