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

@vaudio/core

v0.4.7

Published

Core visualization functionality for audio applications

Downloads

9

Readme

@vaudio/core

Core engine for building 3D audio-reactive visualizations with Three.js

@vaudio/core is the low-level library behind the @vaudio/react system. It provides a fluent builder API to define custom visualizer objects, including geometry, materials, animations, and audio-reactive behaviors.


🚀 Features

  • 🔧 Builder API for creating custom Three.js visualizer objects
  • 🎧 Audio domain integration (time / frequency)
  • 🎥 Centralized VisualizerStore for rendering and scene management
  • 🧱 Type-safe defaults, geometry, and material definitions
  • 💥 Supports both built-in and custom object construction logic

📦 Installation

npm install @vaudio/core three

🛠 Quick Start

import { createVisualizerObject } from '@vaudio/core';
import { AudioUtils } from '@vaudio/utils';
import * as THREE from 'three';

export const MyVisualizer = createVisualizerObject()
  .defaults(() => ({
    color: '#00ffff',
    speed: 0.3,
    intensity: 0.05,
    glow: 1.0,
    lineCount: 60,
    lineWidth: 0.01,
    zoom: 1.0,
    domain: 'frequency',
    x: 0, y: 0, z: 0,
    rotationX: 0, rotationY: 0, rotationZ: 0,
    scaleX: 1, scaleY: 1, scaleZ: 1,
  }))
  .object(({ props }) => {
    const geometry = new THREE.PlaneGeometry(10, 10);
    const uniforms = {
      u_time: { value: 0 },
      u_color: { value: new THREE.Color(props.color) },
      u_speed: { value: props.speed },
      u_intensity: { value: props.intensity },
      u_glow: { value: props.glow },
      u_lineCount: { value: props.lineCount },
      u_lineWidth: { value: props.lineWidth },
      u_zoom: { value: props.zoom },
      u_bass: { value: 0 },
      u_mid: { value: 0 },
      u_treble: { value: 0 },
    };
    const material = new THREE.ShaderMaterial({
      uniforms,
      vertexShader: `
        varying vec2 vUv;
        void main() {
          vUv = uv;
          gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
        }
      `,
      fragmentShader: `
        // ... (your fragment shader code here)
      `,
      transparent: true,
      blending: THREE.AdditiveBlending,
    });
    return new THREE.Mesh(geometry, material);
  })
  .update(({ object, props }) => {
    const shader = object.material;
    shader.uniforms.u_color.value.set(props.color);
    shader.uniforms.u_speed.value = props.speed;
    shader.uniforms.u_intensity.value = props.intensity;
    shader.uniforms.u_glow.value = props.glow;
    shader.uniforms.u_lineCount.value = props.lineCount;
    shader.uniforms.u_lineWidth.value = props.lineWidth;
    shader.uniforms.u_zoom.value = props.zoom;
  }, [
    'color',
    'speed',
    'intensity',
    'glow',
    'lineCount',
    'lineWidth',
    'zoom',
  ])
  .cleanup(({ object }) => {
    object.geometry.dispose();
    object.material.dispose();
    object.userData = {};
  })
  .render(({ object, audioData, delta }) => {
    const shader = object.material;
    shader.uniforms.u_time.value += delta;
    // Example: update audio uniforms (implement your own audio utils as needed)
    shader.uniforms.u_bass.value = AudioUtils.getBassEnergy(audioData) * 0.1;
    shader.uniforms.u_mid.value = AudioUtils.getMidEnergy(audioData) * 0.1;
    shader.uniforms.u_treble.value = AudioUtils.getTrebleEnergy(audioData) * 0.1;
  });

🔧 API Overview

createVisualizerObject()

Returns a fluent builder for defining a custom audio-reactive object.

.defaults(fn)

Define your object's default props. These extend the base VisualizerObject (transform + domain).

.object(fn)

Define the Three.js object (Mesh, Group, etc) using a function that receives runtime props and audio context.

.update(fn, [props])

(Optional) Update the object's props.

.cleanup(fn)

(Optional) Clean up geometry/materials when the object is removed.

.render(fn)

Runs every frame with access to audioData, delta, object, and props.


🧠 VisualizerStore

VisualizerStore manages your Three.js scene and rendering loop.

import { VisualizerStore } from '@vaudio/core';

const store = new VisualizerStore(containerElement);

store.init({
  backgroundColor: '#000000',
  cameraOptions: { fov: 75, x: 0, y: 0, z: 10 },
  fps: 60,
});

store.setAudioElement(audioEl);
store.registerRenderFn('box1', MyVisualizer.getRenderFn(), MyVisualizer.getDefaults());
store.animate(); // Starts the loop

🧩 Types

VisualizerObject

All visualizer objects extend the base transform props:

type VisualizerObject = {
  domain: 'time' | 'frequency';
  startTime: number;
  endTime: number | null;
  hidden: boolean;
  x: number; y: number; z: number;
  rotationX: number; rotationY: number; rotationZ: number;
  scaleX: number; scaleY: number; scaleZ: number;
};

RenderArgs<T>

Passed into all builder functions (object, render, etc.)

{
  id: ObjectId;
  props: T;
  audioData: Uint8Array;
  scene: THREE.Scene;
  camera: THREE.PerspectiveCamera;
  renderer: THREE.WebGLRenderer;
  idToObjectMap: Map<ObjectId, THREE.Object3D>;
  delta: number;
  currentTime: number;
}

🧪 Utility Functions

defaultTransform()

Returns a clean transform object.

defaultVisualizerObject()

Returns a VisualizerObject with default domain and transform values.


🤝 React Integration

Pair @vaudio/core with @vaudio/react to easily mount visualizer components in React.


�� License

MIT