//! Analysis configuration: toggles for which analysis modules to run on a batch. /// Configuration for which analyses to run on a batch. #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] pub struct AnalysisConfig { /// Compute peak, RMS, and LUFS loudness pub loudness: bool, /// Detect BPM via stratum-dsp pub bpm: bool, /// Detect musical key via stratum-dsp pub key: bool, /// Compute spectral features (centroid, flatness, rolloff, ZCR) pub spectral: bool, /// Classify sample type (requires spectral) pub classify: bool, /// Detect if sample is a loop pub loop_detect: bool, /// Generate tag suggestions from results pub auto_suggest_tags: bool, /// Compute peak envelope fingerprint for near-duplicate detection pub fingerprint: bool, /// Maximum seconds of audio to use for expensive analyses (STFT, BPM/key). /// `None` means use the full signal. Default: `Some(30.0)`. /// Fingerprint and peak/RMS always use the full signal. pub max_analysis_seconds: Option, /// Skip BPM/key/loop for sample types where they don't apply. /// Uses the classification result to decide: drums, impacts, noise, foley, /// ambience, and textures skip BPM/key/loop since those concepts don't apply. /// Requires `classify = true` to have any effect. Default: `true`. pub smart_skip: bool, } impl Default for AnalysisConfig { fn default() -> Self { Self { loudness: true, bpm: true, key: true, spectral: true, classify: true, loop_detect: true, auto_suggest_tags: true, fingerprint: true, max_analysis_seconds: Some(30.0), smart_skip: true, } } } #[cfg(test)] mod tests { use super::*; #[test] fn default_enables_all_features() { let config = AnalysisConfig::default(); assert!(config.loudness); assert!(config.bpm); assert!(config.key); assert!(config.spectral); assert!(config.classify); assert!(config.loop_detect); assert!(config.auto_suggest_tags); assert!(config.fingerprint); assert_eq!(config.max_analysis_seconds, Some(30.0)); assert!(config.smart_skip); } #[test] fn custom_config_with_specific_toggles() { let config = AnalysisConfig { loudness: true, bpm: false, key: false, spectral: true, classify: false, loop_detect: false, auto_suggest_tags: false, fingerprint: false, max_analysis_seconds: None, smart_skip: false, }; assert!(config.loudness); assert!(!config.bpm); assert!(!config.key); assert!(config.spectral); assert!(!config.classify); assert!(!config.loop_detect); assert!(!config.auto_suggest_tags); assert!(!config.fingerprint); assert!(config.max_analysis_seconds.is_none()); assert!(!config.smart_skip); } }