All Projects → swharden → FftSharp

swharden / FftSharp

Licence: MIT license
A .NET Standard library for computing the Fast Fourier Transform (FFT) of real or complex data

Programming Languages

c
50402 projects - #5 most used programming language
C#
18002 projects
fortran
972 projects

Projects that are alternatives of or similar to FftSharp

DTMF-Decoder
A Java program to implement a DMTF Decoder.
Stars: ✭ 28 (-78.79%)
Mutual labels:  signal-processing, signal, fft
Eulerian Remote Heartrate Detection
Remote heart rate detection through Eulerian magnification of face videos
Stars: ✭ 48 (-63.64%)
Mutual labels:  signal-processing, fft
CCWT
Complex Continuous Wavelet Transform
Stars: ✭ 136 (+3.03%)
Mutual labels:  signal-processing, fft
Stocks
Programs for stock prediction and evaluation
Stars: ✭ 155 (+17.42%)
Mutual labels:  signal-processing, signal
tmo-live-graph
A simpe react app that plots a live view of the T-Mobile Home Internet Nokia 5G Gateway signal stats, helpful for optimizing signal.
Stars: ✭ 15 (-88.64%)
Mutual labels:  signal-processing, signal
Neurokit
NeuroKit2: The Python Toolbox for Neurophysiological Signal Processing
Stars: ✭ 264 (+100%)
Mutual labels:  signal-processing, signal
Pycroscopy
Scientific analysis of nanoscale materials imaging data
Stars: ✭ 144 (+9.09%)
Mutual labels:  signal-processing, fft
antropy
AntroPy: entropy and complexity of (EEG) time-series in Python
Stars: ✭ 111 (-15.91%)
Mutual labels:  signal-processing, signal
Rustfft
A mixed-radix FFT library written in pure Rust
Stars: ✭ 183 (+38.64%)
Mutual labels:  signal-processing, fft
ooura
Javascript port of Ooura FFT implementation
Stars: ✭ 23 (-82.58%)
Mutual labels:  signal-processing, fft
susa
High Performance Computing (HPC) and Signal Processing Framework
Stars: ✭ 55 (-58.33%)
Mutual labels:  signal-processing, fft
filtering-stft-and-laplace-transform
Simple demo of filtering signal with an LPF and plotting its Short-Time Fourier Transform (STFT) and Laplace transform, in Python.
Stars: ✭ 50 (-62.12%)
Mutual labels:  signal-processing, fft
spafe
🔉 spafe: Simplified Python Audio Features Extraction
Stars: ✭ 310 (+134.85%)
Mutual labels:  frequency, signal-processing
Audio Spectrum Analyzer In Python
A series of Jupyter notebooks and python files which stream audio from a microphone using pyaudio, then processes it.
Stars: ✭ 273 (+106.82%)
Mutual labels:  signal-processing, fft
audiowmark
Audio Watermarking
Stars: ✭ 101 (-23.48%)
Mutual labels:  signal-processing, fft
Edsp
A cross-platform DSP library written in C++ 11/14. This library harnesses the power of C++ templates to implement a complete set of DSP algorithms.
Stars: ✭ 116 (-12.12%)
Mutual labels:  signal-processing, signal
VoiceNET.Library
.NET library to easily create Voice Command Control feature.
Stars: ✭ 14 (-89.39%)
Mutual labels:  spectrogram, fft
spectrogram
Taking an audio signal (wav) and converting it into a spectrogram. Written in Go programming language.
Stars: ✭ 34 (-74.24%)
Mutual labels:  spectrogram, fft
Signals And Systems Lecture
Continuous- and Discrete-Time Signals and Systems - Theory and Computational Examples
Stars: ✭ 166 (+25.76%)
Mutual labels:  signal-processing, signal
SpleeterRT
Real time monaural source separation base on fully convolutional neural network operates on Time-frequency domain.
Stars: ✭ 111 (-15.91%)
Mutual labels:  signal-processing, spectrogram

FftSharp

CI/CD

FftSharp is a collection of Fast Fourier Transform (FFT) tools for .NET. FftSharp is provided under the permissive MIT license so it is suitable for use in commercial applications. FftSharp targets .NET Standard and has no dependencies so it can be easily used in cross-platform .NET Framework and .NET Core applications.

Quickstart

// Begin with an array containing sample data
double[] signal = FftSharp.SampleData.SampleAudio1();

// Shape the signal using a Hanning window
var window = new FftSharp.Windows.Hanning();
window.ApplyInPlace(signal);

// Calculate the FFT as an array of complex numbers
Complex[] fftRaw = FftSharp.Transform.FFT(signal);

// or get the magnitude (units²) or power (dB) as real numbers
double[] fftMag = FftSharp.Transform.FFTmagnitude(signal);
double[] fftPwr = FftSharp.Transform.FFTpower(signal);
Signal Windowed Signal FFT

Sample Data

// sample audio with tones at 2, 10, and 20 kHz plus white noise
double[] signal = FftSharp.SampleData.SampleAudio1();
int sampleRate = 48_000;

// plot the sample audio
var plt = new ScottPlot.Plot(400, 200);
plt.AddSignal(signal, sampleRate / 1000.0);
plt.YLabel("Amplitude");
plt.Margins(0);
plt.SaveFig("time-series.png");

Spectral Magnitude and Power Density

Most people performing FFT operations are interested in calculating magnitude or power of their signal with respect to frequency. Magnitude units are the square of the original units, and power is in decibels.

Frequency of each point is a linear range between zero and half the sample rage (Nyquist frequency). A helper function makes it easy to get an array of frequencies (Hz units) to match the FFT that was generated.

// sample audio with tones at 2, 10, and 20 kHz plus white noise
double[] signal = FftSharp.SampleData.SampleAudio1();
int sampleRate = 48_000;

// calculate the power spectral density using FFT
double[] psd = FftSharp.Transform.FFTpower(signal);
double[] freq = FftSharp.Transform.FFTfreq(sampleRate, psd.Length);

// plot the sample audio
var plt = new ScottPlot.Plot(400, 200);
plt.AddScatterLines(freq, psd);
plt.YLabel("Power (dB)");
plt.XLabel("Frequency (Hz)");
plt.Margins(0);
plt.SaveFig("periodogram.png");

FFT using Complex Numbers

If you are writing a performance application or just enjoy working with real and imaginary components of complex numbers, you can build your own complex array perform FFT operations on it in place:

Complex[] buffer =
{
    new Complex(42, 0),
    new Complex(96, 0),
    new Complex(13, 0),
    new Complex(99, 0),
};

FftSharp.Transform.FFT(buffer);

Filtering

The FftSharp.Filter module has methods to apply low-pass, high-pass, band-pass, and band-stop filtering. This works by converting signals to the frequency domain (using FFT), zeroing-out the desired ranges, performing the inverse FFT (iFFT), and returning the result.

double[] audio = FftSharp.SampleData.SampleAudio1();
double[] filtered = FftSharp.Filter.LowPass(audio, sampleRate, maxFrequency: 2000);

Windowing

Signals are often are windowed prior to FFT analysis. Windowing is essentially multiplying the waveform by a bell-shaped curve prior to analysis, improving frequency resolution of the FFT output.

The Hanning window is the most common window for general-purpose FFT analysis. Other window functions may have different scallop loss or spectral leakage properties. For more information review window functions on Wikipedia.

double[] signal = FftSharp.SampleData.SampleAudio1();

var window = new FftSharp.Windows.Hanning();
double[] windowed = window.Apply(signal);
Hanning Window Power Spectral Density

Windowing signals prior to calculating the FFT improves signal-to-noise ratio at lower frequencies, making power spectrum peaks easier to resolve.

No Window Power Spectral Density

Window Functions

This chart (adapted from ) summarizes windows commonly used for FFT analysis.

Window Use Case Frequency Resolution Spectral Leakage Amplitude Accuracy
Barlett Random Good Fair Fair
Blackman Random Poor Best Good
Cosine Random Fair Fair Fair
Flat Top Sine waves Poor Good Best
Hanning Random Good Good Fair
Hamming Random Good Fair Fair
Kaiser Random Fair Good Good
Rectangular Transient Best Poor Poor
Tukey Transient Good Poor Poor
Welch Random Good Good Fair

Demo Application

A sample application is included with this project that interactively displays an audio signal next to its FFT using different windowing functions.

Microphone Demo

One of the demos included is a FFT microphone analyzer which continuously monitors a sound card input device and calculates the FFT and displays it in real time.

Spectrogram

A spectrogram is a visual representation of the spectrum of frequencies of a signal as it varies with time. Spectrograms are created by computing power spectral density of a small window of an audio signal, moving the window forward in time, and repeating until the end of the signal is reached. In a spectrogram the horizontal axis represents time, the vertical axis represents frequency, and the pixel intensity represents spectral magnitude or power.

Spectrogram is a .NET library for creating spectrograms.

I'm sorry Dave... I'm afraid I can't do that

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].