public void BuildSpectrogram(string _wavPath) { double[] audio; int sampleRate; (audio, sampleRate) = ReadWAV(_wavPath); var sg = new SpectrogramGenerator(sampleRate, fftSize: FFTSize, stepSize: FFTStepSize, maxFreq: MaxFrequency); //sg.SetFixedWidth(SpectrogramWidth); sg.Add(audio); sg.SetColormap(ImageColormap); //sg.SetFixedWidth(1024); var bmp = sg.GetBitmapMel(melBinCount: 103, dB: true, dBScale: 10); bmp.Save(ImagePath, System.Drawing.Imaging.ImageFormat.Jpeg); //sg.SaveImage(ImagePath, dB: true, dBScale: 10); }
public void Test_Make_CommonColormaps() { (double[] audio, int sampleRate) = AudioFile.ReadWAV("../../../../../data/cant-do-that-44100.wav"); int fftSize = 1 << 12; var spec = new SpectrogramGenerator(sampleRate, fftSize, stepSize: 700, maxFreq: 2000); spec.SetWindow(FftSharp.Window.Hanning(fftSize / 3)); // sharper window than typical spec.Add(audio); // delete old colormap files foreach (var filePath in System.IO.Directory.GetFiles("../../../../../dev/graphics/", "hal-*.png")) { System.IO.File.Delete(filePath); } foreach (var cmap in Colormap.GetColormaps()) { spec.SetColormap(cmap); spec.SaveImage($"../../../../../dev/graphics/hal-{cmap.Name}.png"); Debug.WriteLine($"![](dev/graphics/hal-{cmap.Name}.png)"); } }
private void cbColormap_SelectedIndexChanged(object sender, EventArgs e) { spec.SetColormap(cmaps[cbColormap.SelectedIndex]); }