Python API

Audio

The Python-visible decoder, encoder, feature extraction, and signal-processing surface.

Generated from Source/Python15 functions9 classes1 enums
This inventory is generated from symbols registered by OA's nanobind source and public Python facade. It deliberately excludes unbound C++ internals. Signatures show the Python keyword names declared by each binding; follow the source link for ownership, capability, and execution details.

oa.audio

Functions

AmplitudeToDb(buffer, floor_db)
Source

20·log10(max(|x|, floor)) — amplitude to dB with a silence floor.

Clip(buffer, min, max)
Source

Hard clip to [min, max].

Fade(buffer, fade_in_samples, fade_out_samples)
Source

Linear fade-in/out envelope (sample counts per edge).

Gain(buffer, gain_db)
Source

Scalar gain in dB.

MelSpectrogram(buffer, sample_rate, config)
Source

Mel spectrogram → [Channels, NumMels, Frames] F32 (Whisper/CLAP layout).

Mfcc(buffer, sample_rate, config)
Source

MFCC → [Channels, NumCoeffs, Frames] F32 (orthonormal DCT-II of log-mel).

Mix(a, b, gain_a, gain_b)
Source

Weighted sum gain_a·a + gain_b·b.

Normalize(buffer, target_db, mode)
Source

Peak (mode 0) or RMS (mode 1) normalization to target_db.

OaChannelsForLayout(layout)
Source

Expected channel count for a layout (0 = unknown).

OaLayoutForChannels(channels)
Source

Best-effort layout for a raw channel count.

PreEmphasis(buffer, alpha)
Source

Pre-emphasis filter y[n] = x[n] − α·x[n−1] (y[0] = x[0]).

Resample(buffer, in_rate, out_rate, filter_half_width)
Source

Windowed-sinc resample → [Channels, Samples·out/in] F32.

Stft(buffer, config)
Source

STFT magnitude → [Channels, Frames, FftSize/2+1] F32.

ToMatrix(buffer)
Source

Zero-copy reshape of raw waveform to [Channels, 1, SampleCount].

ToMono(buffer)
Source

Average channels → [1, Samples].

Classes

OaAudioDecoder2 members
LoadFile(path)

Decode a WAV/FLAC/MP3 file to a planar [Channels, Samples] F32 GPU buffer.

static
LoadMemory(data)

Decode audio from an in-memory byte buffer (bytes; WAV/FLAC/MP3).

static
Source
OaAudioDecodeResult7 members
Buffer(...)

Decoded planar [Channels, Samples] F32 GPU buffer.

prop_ro
SampleRate(...)
ro
ChannelCount(...)
ro
SampleCount(...)
ro
IsValid(...)
method
DurationSeconds(...)
method
Meta(...)

Metadata POD for the OaFnAudio ops (layout inferred from channels).

method
Source
OaAudioEncoder2 members
EncodeWavF32(buffer, sample_rate)

Encode a [Channels, Samples] F32 GPU buffer to WAV-F32 bytes (synchronous).

static
SaveWavF32(path, buffer, sample_rate)

Encode + write a lossless WAV-F32 file (synchronous file/codec boundary).

static
Source
OaAudioMeta6 members
__init__(...)
constructor
SampleRate(...)
rw
ChannelCount(...)
rw
SampleCount(...)
rw
Layout(...)
rw
DurationSeconds(...)

Clip duration in seconds (SampleCount / SampleRate).

method
Source
OaMelConfig8 members
__init__(...)
constructor
FftSize(...)
rw
HopSize(...)
rw
NumMels(...)
rw
FMin(...)
rw
FMax(...)

Highest frequency in Hz (0 = SampleRate/2).

rw
LogScale(...)
rw
Normalize(...)

Per-channel instance normalization.

rw
Source
OaMfccConfig3 members
__init__(...)
constructor
NumCoeffs(...)
rw
Mel(...)
rw
Source
OaNormalizeAudioConfig3 members
__init__(...)
constructor
Mode(...)

0=peak (max abs), 1=RMS

rw
TargetDb(...)
rw
Source
OaResampleConfig4 members
__init__(...)
constructor
InRate(...)
rw
OutRate(...)
rw
FilterHalfWidth(...)
rw
Source
OaStftConfig6 members
__init__(...)
constructor
FftSize(...)
rw
HopSize(...)
rw
WinSize(...)
rw
Window(...)

0=Hann, 1=Hamming, 2=Blackman, 3=Rect

rw
Center(...)
rw
Source

Enums

OaChannelLayoutSource

Mono · Stereo · Surround5_1 · Surround7_1 · Unknown