Spectrogram 1.6.1

.NET Standard 2.0
dotnet add package Spectrogram --version 1.6.1
NuGet\Install-Package Spectrogram -Version 1.6.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Spectrogram" Version="1.6.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Spectrogram --version 1.6.1
#r "nuget: Spectrogram, 1.6.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Spectrogram as a Cake Addin
#addin nuget:?package=Spectrogram&version=1.6.1

// Install Spectrogram as a Cake Tool
#tool nuget:?package=Spectrogram&version=1.6.1

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.

alternate text is missing from this package README image


(double[] audio, int sampleRate) = ReadWavMono("hal.wav");
var sg = new SpectrogramGenerator(sampleRate, fftSize: 4096, stepSize: 500, maxFreq: 3000);

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 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. 
.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. 
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on Spectrogram:

Repository Stars
.NET library for creating spectrograms (visual representations of frequency spectrum over time)
Version Downloads Last updated
1.6.1 2,661 7/10/2022
1.6.0 365 7/10/2022
1.5.0 465 6/16/2022
1.4.4 936 3/22/2022
1.4.3 666 10/27/2021
1.4.2 369 10/8/2021
1.4.1 412 9/5/2021
1.4.0 302 9/5/2021
1.3.0 932 1/4/2021
1.2.6 4,829 11/1/2020
1.2.5 658 8/6/2020
1.2.4 496 7/26/2020
1.2.3 774 7/4/2020
1.2.2 440 6/23/2020
1.2.1 424 6/18/2020
1.2.0 438 6/18/2020
1.0.1 932 8/26/2019
1.0.0 472 8/25/2019
0.0.1 447 8/16/2019