JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 8
  • Score
    100M100P100Q75940F
  • License MIT

TypeScript library spectral analysis such as PSD and FFT

Package Exports

  • spectral-analysis
  • spectral-analysis/dist/main.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (spectral-analysis) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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"
)