Expand description
§audio-analysis-core
Shared audio frame conversion, whole-buffer clip editing primitives, windowing,
and streaming helpers for moritzbrantner-video-analysis.
§Feature flags
- No optional feature flags today.
§Example
use audio_analysis_core::{AudioClip, ConcatPolicy, FrameSpec, StreamingFrameBuffer};
use video_analysis_core::{AudioBuffer, OwnedAudioFrame, Timebase, Timestamp};
let frame = OwnedAudioFrame::new(
Timestamp::new(0, Timebase::new(1, 48_000)),
48_000,
1,
AudioBuffer::F32(vec![0.0; 4_096]),
)?;
let spec = FrameSpec::new(2_048, 512)?;
let mut windows = StreamingFrameBuffer::new(spec);
let frames = windows.push_frame(&frame.as_frame()?)?;
let clip = AudioClip::from_frames(&[frame])?;
let parts = clip.split_at_seconds(&[0.025, 0.05])?;
let joined = AudioClip::concat(&parts, ConcatPolicy::RequireSameFormat)?;
assert!(!frames.is_empty());
assert_eq!(joined.channels, 1);§Whole-Buffer Editing
AudioClip stores validated interleaved f32 audio with sample rate and channel
metadata. It supports sample/second slicing, timeline splitting, concat, and
mixing. Format-changing concat is explicit through ConcatPolicy::ResampleToFirst;
mixing still requires matching sample rate and channels.
§Package surface
Primary workflow: audio.levels.
Workflow operations:
audio.levels: Returns deterministic level metrics for normalized audio samples.audio.frames: Summarizes fixed-size analysis frames over normalized samples.audio.timestamps: Converts between seconds, samples, and timestamp ticks for a sample rate.
Debug operations:
describe: inspect package metadata and runtime support.
Runtime support: library, CLI, server, and WASM wrappers expose these operations.
Run the primary workflow through the CLI:
cargo run -p moritzbrantner-audio-analysis-core-cli -- run \
--operation audio.levels \
--json '{"channels":1,"sampleRate":48000,"samples":[0.0,0.5,-0.5]}'Successful responses use the shared package-surface shape with operation,
title, message, summary, and result. Default surface calls are
deterministic, local-first, and do not download models, write persistent files,
or execute external tools unless an operation explicitly documents native or
external-tool execution.
§Related crates
video-analysis-coreaudio-analysis-fourieraudio-analysis-processing
Modules§
- surface
- Library-owned runtime surface for
audio-analysis-core.
Structs§
- Audio
Clip - Owned interleaved f32 clip for whole-buffer editing.
- Audio
Feature Point - One window of generic audio feature values.
- Audio
Feature Series - A windowed series of generic audio features.
- Audio
Feature Summary - Summary metrics for an audio feature series.
- Audio
Format Spec - Data type for audio format spec.
- Audio
Frames - Data type for audio frames.
- Audio
Waveform Batch View - Data type for audio waveform batch view.
- Audio
Window - Data type for audio window.
- Biquad
Coefficients - Re-exports the math signal core API. Data type for biquad coefficients.
- FirKernel1d
- Re-exports the math signal core API. Data type for fir kernel1d.
- Frame
Spec - Data type for frame spec.
- Frame
Stride - Re-exports the math signal core API. Data type for frame stride.
- Mono
Samples - Data type for mono samples.
- Owned
Audio Waveform Batch - Data type for owned audio waveform batch.
- Resample
Ratio - Re-exports the math signal core API. Data type for resample ratio.
- Resample
Spec - Re-exports the math signal core API. Data type for resample spec.
- Sample
Rate - Re-exports the math signal core API. Data type for sample rate.
- Streaming
Frame Buffer - Data type for streaming frame buffer.
- Streaming
Frame Config - Data type for streaming frame config.
- Window
Spec - Re-exports the math signal core API. Data type for window spec.
Enums§
- Biquad
Design - Re-exports the math signal core API. Variants describing biquad design.
- Channel
Mix - Variants describing channel mix.
- Concat
Policy - Policy for concatenating clips with different formats.
- Fade
Curve - Fade curve shape.
- Interpolation
Mode - Re-exports the math signal core API. Variants describing interpolation mode.
- MixPolicy
- Policy for mixing clips with different lengths.
- Window
Function - Re-exports the math signal core API. Variants describing window function.
Functions§
- interleaved_
to_ mono - Returns interleaved to mono.
- mean_
absolute - Returns mean absolute.
- mono_
samples - Returns mono samples.
- mono_
samples_ with_ mix - Returns mono samples with mix.
- normalized_
samples - Returns normalized samples.
- peak
- Returns peak.
- rms
- Returns rms.
- sample_
to_ timestamp - Returns sample to timestamp.
- samples_
to_ seconds - Returns samples to seconds.
- seconds_
to_ samples - Returns seconds to samples.
- summarize_
feature_ series - Summarizes a windowed audio feature series.
- timestamp_
to_ sample - Returns timestamp to sample.
- windowed_
level_ series - Converts mono samples into a windowed level feature series.
- zero_
crossing_ rate - Returns zero crossing rate for adjacent sample pairs.
- zero_
pad_ to - Returns zero pad to.