Skip to content
generated from stagas/ts

WebAssembly build of a small, pretty fast FFT library (PFFFT).

License

Notifications You must be signed in to change notification settings

stagas/pretty-fast-fft

Repository files navigation

pretty-fast-fft

WebAssembly build of a small, pretty fast FFT library (PFFFT).

npm i pretty-fast-fft pnpm add pretty-fast-fft yarn add pretty-fast-fft

Examples

# web
    # view source example/web.ts

    import { createRunner } from 'pretty-fast-fft'
    
    const blockSize = 4096
    const stepSize = 1024
    
    const main = async () => {
      const runner = await createRunner(blockSize, stepSize)
    
      const buffer = await (await fetch('./test/fixtures/sound.ogg')).arrayBuffer()
      const ctx = new OfflineAudioContext(1, 1, 44100)
      const audioBuffer = await ctx.decodeAudioData(buffer)
      const floats = audioBuffer.getChannelData(0)
    
      const stft_magnitudes = runner.processAudio(floats)
    
      console.log(stft_magnitudes)
    }
    
    main()

This is simply npm packaging for this project:

https://github.com/JorenSix/pffft.wasm

API

# createRunner(blockSize, stepSize)

    # blockSize  =  1024

      number

    # stepSize  =  128

      number

    createRunner(blockSize, stepSize)  =>

      Promise<{

      # destroy()

        destroy()  =>

          void

      # processAudio(samples)

        # samples

          Float32Array

        processAudio(samples)  =>

          number [] []

      }>

Contributing

Fork or edit and submit a PR.

All contributions are welcome!

License

MIT © 2022 stagas

About

WebAssembly build of a small, pretty fast FFT library (PFFFT).

Resources

License

Stars

Watchers

Forks

Packages

No packages published