Realm
Audio

Waveforms and features through the same matrix runtime.

OA Audio is a compact offline, batched, capture, playback, and media layer. It uses explicit Float32 channel-major buffers and composes with the Core, Vision, and ML modules.

Rust · PythonWAV · FLAC · MP3 decodeFloat32-first
A luminous grand piano beneath audio light trails
Audio

Input and output

01

File decode

WAV, FLAC, and MP3 decode to semantic oa::Audio values backed by planar Float32 matrices with attached rate and channel layout.
02

Capture

A bounded real-time device ring publishes timestamped Float32 chunks without blocking the audio callback.
03

Playback

oa::audio::AudioPlayer supports incremental decode, play, pause, seek, loop, and monotonic position tracking.
04

Encoding

Lossless WAV-F32 output is public; stateful encoders expose their own packet contracts. FLAC and Opus encoding remain roadmap work.

Verified operations

GroupOperations
I/OLoad file or memory; save WAV-F32
SignalGain, mix, fade, clip, pre-emphasis, mono, normalization, resampling
FeaturesSTFT magnitude, mel spectrogram, MFCC, amplitude to dB
InteropZero-copy raw-audio matrix view

Audio processing example

STFT, mel, and MFCC outputs are ordinary oa::Matrix values. The feature path can therefore feed a model without a second tensor type or an adapter framework.

1use anyhow::Context;
2use oa::{Filesystem, Path, audio};
3
4fn main() -> anyhow::Result<()> {
5 let audio_path = Path::asset_rel("audio/oaNarration.wav");
6
7 let output = Path::var_rel("example/audio/oaNarrationRoom.wav");
8 Filesystem::create_directories(&output.parent().unwrap())?;
9
10 let source =
11 audio::decode_file(&audio_path).with_context(|| format!("decode {}", audio_path.display()))?;
12 let mono = audio::to_mono(&source)?;
13 let normalized = audio::normalize(
14 &mono,
15 audio::NormalizeAudioConfig {
16 target_db: -3.0,
17 ..Default::default()
18 },
19 )?;
20 let faded = audio::fade(&normalized, 2400, 2400)?;
21 let reverberated = audio::reverb(&faded, 1.5, 0.4)?;
22 audio::save_wav_f32(&output, &reverberated)?;
23
24 assert!(reverberated.channels() == 1);
25 assert!(output.is_file());
26
27 println!(
28 "Saved reverberated audio (1.5 s tail): {}",
29 output.display()
30 );
31 Ok(())
32}
33

Media integration

Video sessions can open the first audio track from the same URI and preserve video-only operation when no compatible track exists. Capture and recording share timestamps with Vision; entropy codecs remain explicit CPU codec boundaries around Vulkan DSP.