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