powerSpectrogram function
Loads a WAV file and computes its Power spectrogram via STFT in decibels (dB).
Returns a 2D list (list of frames, where each frame is a list of frequency bins).
The number of frequency bins is nFft / 2 + 1.
Implementation
Future<List<Float64List>> powerSpectrogram(
String filePath, {
int sampleRate = 22050,
int nFft = 2048,
int? hopLength,
double topDb = 80.0,
}) async {
final audio = await loadAudio(filePath, sampleRate);
final powerSpec = calculateSpectrogram(
audio.samples,
fftSize: nFft,
hopSize: hopLength,
);
return powerToDb(powerSpec, topDb: topDb);
}