Noodles, Poodles and More!

    spectral-analysis

    1.0.12 • Public • Published

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

    Install

    npm i spectral-analysis

    DownloadsWeekly Downloads

    38

    Version

    1.0.12

    License

    MIT

    Unpacked Size

    23.3 kB

    Total Files

    8

    Last publish

    Collaborators

    • khems