core/audio/audio_spectrogram library

Classes

ProcessedAudio
Container for PCM audio data loaded from a file.

Functions

applyMelFilterbank(List<Float64List> spectrogram, List<Float64List> filterbank) → List<Float64List>
Applies a Mel filterbank to a power spectrogram.
calculateSpectrogram(List<double> samples, {int? hopSize, int fftSize = 2048}) → List<Float64List>
Computes the power spectrogram via Short-Time Fourier Transform (STFT).
createMelFilterbank({required int sampleRate, required int nFft, int nMels = 128, double fMin = 0.0, double? fMax}) → List<Float64List>
Creates a Mel filterbank matrix.
hzToMel(double hz) → double
loadAudio(String filePath, int sampleRate) → Future<ProcessedAudio>
Decodes a WAV file into raw PCM samples (mono), resampled to sampleRate.
melSpectrogram(String filePath, {int sampleRate = 22050, int nFft = 2048, int? hopLength, int nMels = 128, double fMin = 0.0, double? fMax, double topDb = 80.0}) → Future<List<Float64List>>
Loads a WAV file and computes its Mel-frequency spectrogram in decibels (dB).
melToHz(double mel) → double
powerSpectrogram(String filePath, {int sampleRate = 22050, int nFft = 2048, int? hopLength, double topDb = 80.0}) → Future<List<Float64List>>
Loads a WAV file and computes its Power spectrogram via STFT in decibels (dB).
powerToDb(List<Float64List> spectrogram, {double topDb = 80.0}) → List<Float64List>
Converts a power spectrogram (amplitude squared) to decibel (dB) units.
savePowerSpectrogramPng(String wavPath, String pngPath, {int sampleRate = 22050, int nFft = 2048, int? hopLength, double topDb = 80.0, String title = 'Power Spectrogram', int plotWidth = 1000, int plotHeight = 400, bool useNearest = true}) → Future<void>
Generates a Power spectrogram (linear frequency) from a WAV file and saves it as a PNG.
saveSpectrogramImage(List<Float64List> spectrogramDb, String outputPath, {required int sampleRate, required int hopLength, double fMin = 0.0, double? fMax, double topDb = 80.0, String title = 'Spectrogram', int plotWidth = 800, int plotHeight = 256, bool useNearest = true, bool isMel = true}) → Future<void>
Renders a Mel spectrogram in dB to a PNG image file.
saveSpectrogramPng(String wavPath, String pngPath, {int sampleRate = 22050, int nFft = 2048, int? hopLength, int nMels = 128, double fMin = 0.0, double? fMax, double topDb = 80.0, String title = 'Mel-frequency spectrogram', int plotWidth = 1000, int plotHeight = 400, bool useNearest = true}) → Future<void>
Generates a Mel-frequency spectrogram from a WAV file and saves it as a PNG image.