Spectrogram 2.0.0-alpha
dotnet add package Spectrogram --version 2.0.0-alpha
NuGet\Install-Package Spectrogram -Version 2.0.0-alpha
<PackageReference Include="Spectrogram" Version="2.0.0-alpha" />
paket add Spectrogram --version 2.0.0-alpha
#r "nuget: Spectrogram, 2.0.0-alpha"
// Install Spectrogram as a Cake Addin #addin nuget:?package=Spectrogram&version=2.0.0-alpha&prerelease // Install Spectrogram as a Cake Tool #tool nuget:?package=Spectrogram&version=2.0.0-alpha&prerelease
Spectrogram is a .NET library for creating frequency spectrograms from pre-recorded signals, streaming data, or microphone audio from the sound card. Spectrogram uses FFT algorithms and window functions provided by the FftSharp project, and it targets .NET Standard so it can be used in .NET Framework and .NET Core projects.
Quickstart
(double[] audio, int sampleRate) = ReadWavMono("hal.wav");
var sg = new SpectrogramGenerator(sampleRate, fftSize: 4096, stepSize: 500, maxFreq: 3000);
sg.Add(audio);
sg.SaveImage("hal.png");
This example generates the image at the top of the page.
How to Read a WAV File
There are many excellent libraries that read audio files. Consult the documentation for those libraries to learn how to do this well. Here's an example method I use to read audio values from mono WAV files using the NAudio package:
(double[] audio, int sampleRate) ReadWavMono(string filePath, double multiplier = 16_000)
{
using var afr = new NAudio.Wave.AudioFileReader(filePath);
int sampleRate = afr.WaveFormat.SampleRate;
int bytesPerSample = afr.WaveFormat.BitsPerSample / 8;
int sampleCount = (int)(afr.Length / bytesPerSample);
int channelCount = afr.WaveFormat.Channels;
var audio = new List<double>(sampleCount);
var buffer = new float[sampleRate * channelCount];
int samplesRead = 0;
while ((samplesRead = afr.Read(buffer, 0, buffer.Length)) > 0)
audio.AddRange(buffer.Take(samplesRead).Select(x => x * multiplier));
return (audio.ToArray(), sampleRate);
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.0.0-alpha | 98 | 11/1/2024 |
1.6.1 | 4,975 | 7/10/2022 |
1.6.0 | 415 | 7/10/2022 |
1.5.0 | 536 | 6/16/2022 |
1.4.4 | 1,018 | 3/22/2022 |
1.4.3 | 709 | 10/27/2021 |
1.4.2 | 432 | 10/8/2021 |
1.4.1 | 455 | 9/5/2021 |
1.4.0 | 356 | 9/5/2021 |
1.3.0 | 1,018 | 1/4/2021 |
1.2.6 | 8,313 | 11/1/2020 |
1.2.5 | 736 | 8/6/2020 |
1.2.4 | 547 | 7/26/2020 |
1.2.3 | 853 | 7/4/2020 |
1.2.2 | 465 | 6/23/2020 |
1.2.1 | 481 | 6/18/2020 |
1.2.0 | 501 | 6/18/2020 |
1.0.1 | 1,156 | 8/26/2019 |
1.0.0 | 530 | 8/25/2019 |
0.0.1 | 499 | 8/16/2019 |