Python API
Audio
The Python-visible decoder, encoder, feature extraction, and signal-processing surface.
oa.audio
Functions
AmplitudeToDb(buffer, floor_db)20·log10(max(|x|, floor)) — amplitude to dB with a silence floor.
Clip(buffer, min, max)Hard clip to [min, max].
Fade(buffer, fade_in_samples, fade_out_samples)Linear fade-in/out envelope (sample counts per edge).
Gain(buffer, gain_db)Scalar gain in dB.
MelSpectrogram(buffer, sample_rate, config)Mel spectrogram → [Channels, NumMels, Frames] F32 (Whisper/CLAP layout).
Mfcc(buffer, sample_rate, config)MFCC → [Channels, NumCoeffs, Frames] F32 (orthonormal DCT-II of log-mel).
Mix(a, b, gain_a, gain_b)Weighted sum gain_a·a + gain_b·b.
Normalize(buffer, target_db, mode)Peak (mode 0) or RMS (mode 1) normalization to target_db.
OaChannelsForLayout(layout)Expected channel count for a layout (0 = unknown).
OaLayoutForChannels(channels)Best-effort layout for a raw channel count.
PreEmphasis(buffer, alpha)Pre-emphasis filter y[n] = x[n] − α·x[n−1] (y[0] = x[0]).
Resample(buffer, in_rate, out_rate, filter_half_width)Windowed-sinc resample → [Channels, Samples·out/in] F32.
Stft(buffer, config)STFT magnitude → [Channels, Frames, FftSize/2+1] F32.
ToMatrix(buffer)Zero-copy reshape of raw waveform to [Channels, 1, SampleCount].
ToMono(buffer)Average channels → [1, Samples].
Classes
OaAudioDecoder2 members
LoadFile(path)Decode a WAV/FLAC/MP3 file to a planar [Channels, Samples] F32 GPU buffer.
LoadMemory(data)Decode audio from an in-memory byte buffer (bytes; WAV/FLAC/MP3).
OaAudioDecodeResult7 members
Buffer(...)Decoded planar [Channels, Samples] F32 GPU buffer.
SampleRate(...)ChannelCount(...)SampleCount(...)IsValid(...)DurationSeconds(...)Meta(...)Metadata POD for the OaFnAudio ops (layout inferred from channels).
OaAudioEncoder2 members
EncodeWavF32(buffer, sample_rate)Encode a [Channels, Samples] F32 GPU buffer to WAV-F32 bytes (synchronous).
SaveWavF32(path, buffer, sample_rate)Encode + write a lossless WAV-F32 file (synchronous file/codec boundary).
OaAudioMeta6 members
__init__(...)SampleRate(...)ChannelCount(...)SampleCount(...)Layout(...)DurationSeconds(...)Clip duration in seconds (SampleCount / SampleRate).
OaMelConfig8 members
__init__(...)FftSize(...)HopSize(...)NumMels(...)FMin(...)FMax(...)Highest frequency in Hz (0 = SampleRate/2).
LogScale(...)Normalize(...)Per-channel instance normalization.
OaMfccConfig3 members
__init__(...)NumCoeffs(...)Mel(...)OaNormalizeAudioConfig3 members
__init__(...)Mode(...)0=peak (max abs), 1=RMS
TargetDb(...)OaResampleConfig4 members
__init__(...)InRate(...)OutRate(...)FilterHalfWidth(...)OaStftConfig6 members
__init__(...)FftSize(...)HopSize(...)WinSize(...)Window(...)0=Hann, 1=Hamming, 2=Blackman, 3=Rect
Center(...)Enums
OaChannelLayoutSource Mono · Stereo · Surround5_1 · Surround7_1 · Unknown