npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

vue-fft-visualizer

v0.1.0

Published

A high-performance WebGL-based FFT spectrum visualizer component for Vue 3

Readme

vue-fft-visualizer

A high-performance WebGL-based FFT spectrum visualizer component for Vue 3.

FFT Visualizer Demo

Features

  • WebGL Rendering - GPU-accelerated for smooth 120fps visualization
  • Zero Dependencies - Only requires Vue 3, uses native WebGL
  • Configurable Bands - Display 10, 20, 40, or 80 frequency bands
  • LED Effect - Optional LED segment display mode
  • Peak Indicators - Falling peak markers with configurable decay
  • Responsive - Automatically adapts to container size

Installation

npm install vue-fft-visualizer
# or
pnpm add vue-fft-visualizer
# or
yarn add vue-fft-visualizer

Usage

<script setup>
import { FFTVisualizer } from 'vue-fft-visualizer'
</script>

<template>
  <FFTVisualizer
    websocket-url="ws://localhost:3001/fft"
    :bands="40"
    :led-bars="true"
    :show-peaks="true"
  />
</template>

<style>
/* Container needs a defined height */
.visualizer-container {
  height: 200px;
}
</style>

Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | websocketUrl | string | required | WebSocket URL to connect to for FFT data | | bands | 10 \| 20 \| 40 \| 80 | 80 | Number of frequency bands to display | | showPeaks | boolean | true | Show falling peak indicators | | peakDecay | number | 0.997 | Peak decay rate (0.99 = slow, 0.9 = fast) | | ledBars | boolean | false | Enable LED segment effect |

Events

| Event | Payload | Description | |-------|---------|-------------| | connected | - | WebSocket connection established | | disconnected | - | WebSocket connection closed | | error | string | Error message |

Exposed Methods

<script setup>
const visualizer = ref()

// Manually control connection
visualizer.value.connect()
visualizer.value.disconnect()

// Check connection state
console.log(visualizer.value.isConnected)
</script>

<template>
  <FFTVisualizer ref="visualizer" websocket-url="..." />
</template>

WebSocket Protocol

The component expects a WebSocket server that implements the following protocol:

1. Connection

Client connects to the specified websocketUrl. The server should accept the connection and begin streaming.

2. Configuration Message (JSON)

Server sends a JSON configuration message immediately after connection:

{
  "type": "config",
  "mode": "fft",
  "bins": 80,
  "fps": 120
}

| Field | Type | Description | |-------|------|-------------| | type | string | Must be "config" | | mode | string | Must be "fft" | | bins | number | Number of frequency bins in the data (typically 80) | | fps | number | Target frames per second (informational) |

3. Binary FFT Data

After the config message, server continuously sends binary frames:

  • Format: Raw bytes, one uint8 (0-255) per frequency bin
  • Length: Must match bins from config (e.g., 80 bytes)
  • Value mapping: 0 = silence, 255 = maximum amplitude
  • Frequency range: Typically 100Hz to 18kHz, exponentially spaced

Example: 80 bytes representing frequency magnitudes from low to high.

4. Recommended FFT Processing

For best results, the server should:

  1. Capture audio at 48kHz or higher
  2. Apply window function (Hann/Hamming) to reduce spectral leakage
  3. Compute FFT (1024-2048 samples recommended)
  4. Map to frequency bands using exponential spacing (100Hz - 18kHz)
  5. Apply A-weighting to match human hearing perception
  6. Convert to dB scale and normalize to 0-255 range
  7. Stream at 60-120fps for smooth visualization

Backend Examples

See the /backend-examples directory for reference implementations:

  • Python - Using pyalsaaudio and numpy
  • Node.js - Using node-audiorecorder and fft.js
  • Rust - Using cpal and rustfft

Each example captures system audio, computes FFT, and streams to WebSocket clients.


Development

# Install dependencies
pnpm install

# Run dev server
pnpm dev

# Build library
pnpm build

# Type check
pnpm typecheck

How It Works

  1. WebSocket Connection: Component connects to your server and receives FFT data
  2. Data Processing: Aggregates server bins to display bands, tracks peaks
  3. WebGL Rendering: Fragment shader renders bars with gradient, LED effect, and peaks
  4. Animation Loop: requestAnimationFrame drives smooth 120fps rendering

Browser Support

Requires WebGL support (all modern browsers):

  • Chrome 56+
  • Firefox 51+
  • Safari 15+
  • Edge 79+

License

MIT © Wouter Vernaillen