Giter VIP home page Giter VIP logo

spectrogram's Introduction

Spectrogram

Spectrogram is a .NET library which makes it easy to create spectrograms from pre-recorded signals or live audio from the sound card. This library supports .NET Framework (4.5) and .NET Core (3.0) and can be installed using NuGet.

Quickstart

Song to Spectrogram

The code below converts a WAV file to a spectrograph and saves it as an image. This code analyzed Mozart's Piano Sonata No. 11 in A major to produce the picture above.

// load audio and process FFT
var spec = new Spectrogram.Spectrogram(sampleRate: 8000, fftSize: 2048, step: 700);
float[] values = Spectrogram.Tools.ReadWav("mozart.wav");
spec.AddExtend(values);

// convert FFT to an image and save it
Bitmap bmp = spec.GetBitmap(intensity: 2, freqHigh: 2500);
spec.SaveBitmap(bmp, "mozart.jpg");

Human Voice

This code analyzes audio from HAL's famous quote, "I'm sorry Dave, I'm afraid I can't do that". The output is can be rendered using different colormaps.

// load audio and process FFT
var spec = new Spectrogram.Spectrogram(sampleRate: 15000, fftSize: 4096, step: 400);
float[] values = Spectrogram.Tools.ReadMp3("cant-do-that.mp3");
spec.AddExtend(values);

// convert FFT to an image and save it
Bitmap bmp = spec.GetBitmap(intensity: .2, freqHigh: 1000,
    colormap: Spectrogram.Colormap.grayscaleInverted);
spec.SaveBitmap(bmp, "cant-do-that-grayscale-inverted.jpg");
colormap sample output
Grayscale Inverted is used in many scientific publications when analyzing things like human voices and bird sounds
Grayscale provides highest contrast output but does not benefit from color vision
Viridis is the default colormap. It was specifically designed to represent 2D data in a way ideally suited for human vision.
vdGreen is the default colormap used for QRSS-VD, a very old software project of mine.

QRSS Analysis

Experimenters with ultra-narrowband radio transmissions often use continuous wave frequency-shifting radio transmitters to send data at very low rates over very long distances using very little power. See What is QRSS? for more information.

The following code produces a QRSS spectrogram from an MP3 file. This program took less than 5 seconds to analyze 30 minutes of audio, producing the image below.

// load audio and process FFT
var spec = new Spectrogram.Spectrogram(sampleRate: 8000, fftSize: 16384, step: 8000);
float[] values = Spectrogram.Tools.ReadMp3("qrss-w4hbk.mp3");
spec.AddExtend(values);

// convert FFT to an image and save it
Bitmap bmp = spec.GetBitmap(intensity: 1.5, freqLow: 1100, freqHigh: 1500,
    showTicks: true, tickSpacingHz: 50, tickSpacingSec: 60);
spec.SaveBitmap(bmp, "qrss.png");

Demo Applications

This project comes with a few interactive applications which serve as useful references for some of the ways this Spectrogram library can be used.

Download Demo EXE Files

If you want to see what this library can do without downloading source code, click-to-run (EXE) demos are available in SpectrogramDemo.zip

Audio Monitor

A demo program is included which monitors the sound card and continuously creates spectrograms from microphone input. It runs fast enough that the entire bitmap can be recreated on each render. This means brightness and color adjustments can be applied to the whole image, not just new parts.

Waterfall with Graphs

This demo program was created to demonstrate Spectrogram and ScottPlot working together.

Resources

Similar Software

  • Argo (website) - closed-source QRSS viewer for Windows
  • SpectrumLab (website) - closed-source spectrum analyzer for Windows
  • QrssPIG (GitLab) - open-source spectrograph for Raspberry Pi (C++)
  • Lopora (GitHub) - open-source spectrograph (Python 3)
  • QRSS VD (GitHub) - open source spectrograph (Python 2)

QRSS Information

spectrogram's People

Contributors

swharden avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.