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

@waveform-playlist/recording

v11.0.0

Published

Audio recording support for waveform-playlist using AudioWorklet

Readme

@waveform-playlist/recording

Audio recording support for waveform-playlist using AudioWorklet.

Features

  • AudioWorklet-based recording - Low latency, direct PCM access
  • Real-time waveform visualization - See the waveform as you record
  • React hooks - Easy integration with React apps
  • Device selection - Choose from available microphone inputs
  • Optional package - Only include if you need recording

Installation

npm install @waveform-playlist/recording

Usage

Basic Recording

import { useRecording, useMicrophoneAccess, RecordButton } from '@waveform-playlist/recording';

function RecordingApp() {
  const { stream, requestAccess } = useMicrophoneAccess();
  const { isRecording, startRecording, stopRecording, peaks, duration } = useRecording(stream);

  const handleRecord = async () => {
    if (!stream) {
      await requestAccess();
    }

    if (isRecording) {
      const audioBuffer = await stopRecording();
      // Use the recorded audio buffer
    } else {
      await startRecording();
    }
  };

  return (
    <div>
      <RecordButton isRecording={isRecording} onClick={handleRecord} />
      <p>Duration: {duration.toFixed(1)}s</p>
      {/* Display waveform using peaks */}
    </div>
  );
}

With Microphone Selection

import {
  useMicrophoneAccess,
  useRecording,
  MicrophoneSelector,
  RecordButton,
  RecordingIndicator,
} from '@waveform-playlist/recording';

function RecordingApp() {
  const { stream, devices, requestAccess } = useMicrophoneAccess();
  const { isRecording, duration, startRecording, stopRecording } = useRecording(stream);
  const [selectedDevice, setSelectedDevice] = useState<string>();

  const handleDeviceChange = async (deviceId: string) => {
    setSelectedDevice(deviceId);
    await requestAccess(deviceId);
  };

  return (
    <div>
      <MicrophoneSelector
        devices={devices}
        selectedDeviceId={selectedDevice}
        onDeviceChange={handleDeviceChange}
      />
      <RecordButton
        isRecording={isRecording}
        onClick={isRecording ? stopRecording : startRecording}
      />
      <RecordingIndicator isRecording={isRecording} duration={duration} />
    </div>
  );
}

Integration with WaveformPlaylist

import { WaveformPlaylistProvider, Waveform } from '@waveform-playlist/browser';
import { useRecording, useMicrophoneAccess } from '@waveform-playlist/recording';

function RecordingPlaylist() {
  const { stream, requestAccess } = useMicrophoneAccess();
  const { peaks, audioBuffer, startRecording, stopRecording } = useRecording(stream);
  const [tracks, setTracks] = useState([]);

  const handleStopRecording = async () => {
    const buffer = await stopRecording();
    if (buffer) {
      // Add recorded track to playlist
      setTracks([
        ...tracks,
        {
          src: buffer,
          name: 'Recording',
        },
      ]);
    }
  };

  return (
    <WaveformPlaylistProvider tracks={tracks}>
      <button onClick={requestAccess}>Request Microphone</button>
      <button onClick={startRecording}>Record</button>
      <button onClick={handleStopRecording}>Stop</button>
      <Waveform />
    </WaveformPlaylistProvider>
  );
}

API Reference

Hooks

useMicrophoneAccess()

Manages microphone access and device enumeration.

Returns:

  • stream: MediaStream | null - Active microphone stream
  • devices: MicrophoneDevice[] - Available microphone devices
  • hasPermission: boolean - Whether microphone permission is granted
  • isLoading: boolean - Loading state during access request
  • requestAccess: (deviceId?: string) => Promise<void> - Request microphone access
  • stopStream: () => void - Stop the microphone stream
  • error: Error | null - Error state

useRecording(stream, options?)

Main recording hook using AudioWorklet.

Parameters:

  • stream: MediaStream | null - Microphone stream from useMicrophoneAccess
  • options?: RecordingOptions
    • sampleRate?: number - Sample rate (defaults to AudioContext rate)
    • channelCount?: number - Number of channels (default: 1)
    • samplesPerPixel?: number - Samples per pixel for peaks (default: 1024)

Returns:

  • isRecording: boolean - Whether recording is active
  • isPaused: boolean - Whether recording is paused
  • duration: number - Recording duration in seconds
  • peaks: number[] - Peak data for waveform visualization
  • audioBuffer: AudioBuffer | null - Final recorded audio buffer
  • startRecording: () => Promise<void> - Start recording
  • stopRecording: () => Promise<AudioBuffer | null> - Stop and finalize recording
  • pauseRecording: () => void - Pause recording
  • resumeRecording: () => void - Resume recording
  • error: Error | null - Error state

Components

<RecordButton />

Button for starting/stopping recording.

Props:

  • isRecording: boolean - Recording state
  • onClick: () => void - Click handler
  • disabled?: boolean - Disabled state
  • className?: string - CSS class name

<MicrophoneSelector />

Dropdown for selecting microphone device.

Props:

  • devices: MicrophoneDevice[] - Available devices
  • selectedDeviceId?: string - Currently selected device
  • onDeviceChange: (deviceId: string) => void - Change handler
  • disabled?: boolean - Disabled state
  • className?: string - CSS class name

<RecordingIndicator />

Visual indicator showing recording status and duration.

Props:

  • isRecording: boolean - Recording state
  • isPaused?: boolean - Paused state
  • duration: number - Duration in seconds
  • formatTime?: (seconds: number) => string - Custom time formatter
  • className?: string - CSS class name

Architecture

The recording implementation uses AudioWorklet for low-latency audio capture:

getUserMedia → MediaStream
                    ↓
        MediaStreamSource (Web Audio)
                    ↓
          AudioWorklet Processor
          (captures raw PCM data)
                    ↓
        Main Thread (React Hook)
          - Accumulates audio data
          - Generates peaks in real-time
          - Updates waveform visualization
                    ↓
         Final AudioBuffer

Browser Support

  • Chrome 66+
  • Firefox 76+
  • Edge 79+
  • Safari 14.1+

Requires HTTPS or localhost for microphone access.

License

MIT