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 🙏

© 2025 – Pkg Stats / Ryan Hefner

web-audio-hooks

v0.0.2

Published

A collection of React hooks for working with the Web Audio API.

Readme

Web Audio Hooks

A collection of React hooks for working with the Web Audio API.

License: MIT

Installation

npm install web-audio-hooks

Usage

Wrap your application with the AudioProvider to create an audio context:

import { AudioProvider } from 'web-audio-hooks'

function App() {
  return (
    <AudioProvider>
      <YourComponent />
    </AudioProvider>
  )
}

Then use the hooks in your components:

import { useGain, useOscillator } from 'web-audio-hooks'

function Synth() {
  const oscillator = useOscillator({ frequency: 440, type: 'sine' })
  const gain = useGain(0.5)
  
  useEffect(() => {
    if (oscillator && gain) {
      oscillator.connect(gain)
      gain.connect(audioContext.destination)
      oscillator.start()
      
      return () => {
        oscillator.stop()
      }
    }
  }, [oscillator, gain])
  
  return <div>Synth playing...</div>
}

Available Hooks

useAudioContext

Returns the current audio context.

const audioContext = useAudioContext()

useAnalyser

Creates an AnalyserNode for visualizing audio data.

const analyser = useAnalyser({
  fftSize: 2048,
  minDecibels: -90,
  maxDecibels: -10,
  smoothingTimeConstant: 0.85,
})

useBiquadFilter

Creates a BiquadFilterNode for filtering audio.

const filter = useBiquadFilter({
  Q: 1,
  gain: 0,
  detune: 0
  type: 'lowpass',
  frequency: 1000,
})

useChannelMerger

Creates a ChannelMergerNode for combining multiple audio channels.

const merger = useChannelMerger(2) // number of inputs

useChannelSplitter

Creates a ChannelSplitterNode for separating audio channels.

const splitter = useChannelSplitter(2) // number of outputs

useConvolver

Creates a ConvolverNode for applying reverb or other impulse responses.

const convolver = useConvolver({
  buffer: impulseResponseBuffer,
  normalize: true,
})

useDelay

Creates a DelayNode for delaying audio.

const delay = useDelay(5) // max delay time in seconds

useDynamicsCompressor

Creates a DynamicsCompressorNode for audio compression.

const compressor = useDynamicsCompressor({
  knee: 30,
  ratio: 12,
  attack: 0.003,
  release: 0.25,
  threshold: -24,
})

useGain

Creates a GainNode for controlling volume.

const gain = useGain(0.5) // initial gain value

useIIRFilter

Creates an IIRFilterNode for custom filtering.

const iirFilter = useIIRFilter(
  [0.00020298, 0.0004059599, 0.00020298], // feedforward coefficients
  [1.0126964558, -1.9991880801, 0.9873035442]  // feedback coefficients
)

useOscillator

Creates an OscillatorNode for generating audio.

const oscillator = useOscillator({
  detune: 0,
  type: 'sine',
  frequency: 440,
})

usePanner

Creates a PannerNode for 3D audio positioning.

const panner = usePanner({
  panningModel: 'HRTF',
  distanceModel: 'inverse',
  refDistance: 1,
  maxDistance: 10000,
  rolloffFactor: 1,
  coneInnerAngle: 360,
  coneOuterAngle: 0,
  coneOuterGain: 0,
})

useStereoPanner

Creates a StereoPannerNode for simple left/right panning.

const stereoPanner = useStereoPannerNode(0) // pan value (-1 to 1)

useWaveShaper

Creates a WaveShaperNode for applying distortion.

const waveShaper = useWaveShaper({
  curve: distortionCurve,
  oversample: '4x',
})

License

MIT © Lee