use super::config::ViewerConfig;
use crate::Matrix;
pub struct AudioAnalysis {
pub envelope: Option<Matrix>,
pub spectrum: Option<Matrix>,
pub mel: Option<Matrix>,
}
pub fn analyze(path: &str, config: &ViewerConfig) -> crate::Result<Option<AudioAnalysis>> {
let engine = crate::Engine::new()?;
let decoded = match crate::audio::decode_file(&engine, path) {
Ok(a) => a,
Err(_) => return Ok(None),
};
let envelope = crate::audio::waveform_envelope(&decoded, config.audio_waveform_bins).ok();
Ok(Some(AudioAnalysis {
envelope,
spectrum: None,
mel: None,
}))
}