Spectrogram 1.6.1

There is a newer prerelease version of this package available.
See the version list below for details.
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

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

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 261 11/1/2024
1.6.1 5,206 7/10/2022
1.6.0 419 7/10/2022
1.5.0 540 6/16/2022
1.4.4 1,022 3/22/2022
1.4.3 716 10/27/2021
1.4.2 436 10/8/2021
1.4.1 459 9/5/2021
1.4.0 362 9/5/2021
1.3.0 1,022 1/4/2021
1.2.6 8,350 11/1/2020
1.2.5 740 8/6/2020
1.2.4 552 7/26/2020
1.2.3 859 7/4/2020
1.2.2 469 6/23/2020
1.2.1 485 6/18/2020
1.2.0 507 6/18/2020
1.0.1 1,174 8/26/2019
1.0.0 536 8/25/2019
0.0.1 505 8/16/2019