Audio I/O

WAV (PCM/Float/ADPCM/u-Law/A-Law), MP3, and AAC audio I/O with FFT/STFT, Log-Mel spectrograms, MFCCs, and Griffin-Lim inversion.

class Audio JBit · File/Audio/Audio.h · 5 members

Multi-channel audio buffer with sinc resampling, silence trimming, FFT/STFT spectral transforms, and Whisper/Conformer/CNN tensor adapters.

enum WAVE_ENCODING_FORMAT
enum WAVE_ENCODING_FORMAT { WAV_PCM_8, WAV_PCM_16, WAV_PCM_24, WAV_PCM_32, WAV_IEEE_FLOAT_32, WAV_IEEE_FLOAT_64, WAV_ALAW, WAV_MULAW, WAV_IMA_ADPCM, WAV_MS_ADPCM };
enum WINDOW_TYPE
enum WINDOW_TYPE { WINDOW_HANN, WINDOW_HAMMING, WINDOW_BLACKMAN, WINDOW_RECTANGULAR };
Audio &toMono() / resample(uint32_t targetSampleRate, bool sincInterpolation = true) / normalize(float targetPeakDb = 0.0f) / trimSilence(float thresholdDb = -40.0f);
Tensor2D toMelSpectrogramTensor2D(size_t nMels = 80, size_t nFft = 400, size_t hopLength = 160, float fMin = 0.0f, float fMax = 0.0f, bool logScale = true, WINDOW_TYPE windowType = WINDOW_HANN) const; Produces [nMels, numFrames] Log-Mel spectrogram.
Tensor3D toMelSpectrogramTensor3D(size_t nMels = 80, size_t nFft = 400, size_t hopLength = 160, float fMin = 0.0f, float fMax = 0.0f, bool logScale = true, bool includeDeltas = false, WINDOW_TYPE windowType = WINDOW_HANN) const; When includeDeltas=true, returns [3, nMels, numFrames] (Static, Delta, Delta-Delta).
Tensor2D toMFCCTensor2D(size_t nMfcc = 13, size_t nMels = 40, size_t nFft = 400, size_t hopLength = 160, float fMin = 0.0f, float fMax = 0.0f) const;
static Audio fromMelSpectrogramTensor2D(const Tensor2D &melSpectrogram, uint32_t sampleRate = 16000, size_t nFft = 400, size_t hopLength = 160, float fMin = 0.0f, float fMax = 0.0f, bool isLogScale = true, size_t griffinLimIters = 32, WINDOW_TYPE windowType = WINDOW_HANN); Griffin-Lim phase reconstruction back to waveform.
class AudioFactory JBit · File/Audio/AudioFactory.h · 2 members

Auto-detecting audio loader/saver supporting WAV, MP3, and AAC codecs.

static Audio decodeFile(const std::string &filePath) / decodeSlice(const std::string &filePath, double startSeconds, double durationSeconds);
static Tensor2D loadToMelSpectrogramTensor2D(const std::string &filePath, uint32_t targetSampleRate = 16000, size_t nMels = 80, size_t nFft = 400, size_t hopLength = 160, bool logScale = true);