Skip to content

eleven-i/spectral-analysis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spectral Analysis

TypeScript library spectral analysis such as PSD and FFT. For calculating FFT, this package uses kissfft-js. This package extends it to make it easier to use and combines it with windowing functions.

This package contains three public functions calculateFFT, welch and spectrogram.

Each of these functions accept the same inputs, an array of data, the sample rate of the data (frequency), the window size, the overlap (50% overlap is default), and the windowing function to use.

The windowing functions available are those found in fft-windowing-ts.


How to use

yarn add spectral-analysis
import { calculateFFT, welch, spectrogram } from 'spectral-analysis'

Below are descriptions and type definitions for these functions


FFT

Raw FFT of data. 50% window overlap is standard.

const calculateFFT = (
  inputData: number[],
  sampleRate: number,
  windowSize: number,
  overlap = 0.5,
  windowingFunction: WindowFunctionName = "hann"
)

PSD (Welch's Method)

Implementation of Welch's method of spectral density estimation.

const welch = (
  inputData: number[],
  sampleRate: number,
  windowSize: number,
  overlap = 0.5,
  windowingFunction: WindowFunctionName = "hann"
)

Spectrogram

Generates a two dimensional array, and set of corresponding frequencies for plotting a spectogram of PSDs

const spectrogram = (
  inputData: number[],
  sampleRate: number,
  windowSize: number,
  overlap = 0.5,
  windowingFunction: WindowFunctionName = "hann"
)

About

TypeScript library spectral analysis such as PSD and FFT

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors