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

rescript-audio

v1.0.0

Published

ReScript bindings for the Web Audio API

Readme

rescript-audio

ReScript bindings for the Web Audio API.

Installation

npm install rescript-audio

Add to your rescript.json:

{
  "dependencies": ["rescript-audio"]
}

Usage

// Create an audio context
let ctx = Audio.Context.make()

// Create an oscillator with options
let osc = Audio.Oscillator.make(ctx, ~options={
  waveform: Sine,
  frequency: 440.0,
})

// Create a gain node
let gain = Audio.Gain.make(ctx, ~options={gain: 0.5})

// Connect oscillator -> gain -> destination
Audio.Utils.chain([
  osc->Audio.Oscillator.asNode,
  gain->Audio.Gain.asNode,
  Audio.ContextExt.destination(ctx)->Audio.Destination.asNode,
])

// Start the oscillator
Audio.Oscillator.start(osc)

// Schedule parameter changes
Audio.Gain.gainParam(gain)
->Audio.Param.setValueAtTime(~value=0.5, ~startTime=Audio.Context.currentTime(ctx))
->Audio.Param.linearRampToValueAtTime(~value=0.0, ~endTime=Audio.Context.currentTime(ctx) +. 1.0)
->ignore

API

Context

Audio.Context.make()                    // Create new AudioContext
Audio.Context.makeWithOptions(options)  // Create with options
Audio.Context.sampleRate(ctx)           // Get sample rate
Audio.Context.currentTime(ctx)          // Get current time
Audio.Context.state(ctx)                // Get state: Suspended | Running | Closed
Audio.Context.resume(ctx)               // Resume (returns promise)
Audio.Context.suspend(ctx)              // Suspend (returns promise)
Audio.Context.close(ctx)                // Close (returns promise)

Oscillator

// Waveform types: Sine | Square | Sawtooth | Triangle | Custom
Audio.Oscillator.make(ctx, ~options=?)
Audio.Oscillator.frequencyParam(osc)    // Get frequency AudioParam
Audio.Oscillator.detuneParam(osc)       // Get detune AudioParam
Audio.Oscillator.waveform(osc)          // Get current waveform
Audio.Oscillator.setWaveform(osc, w)    // Set waveform
Audio.Oscillator.start(osc)             // Start immediately
Audio.Oscillator.startAt(osc, time)     // Start at time
Audio.Oscillator.stop(osc)              // Stop immediately
Audio.Oscillator.stopAt(osc, time)      // Stop at time

Gain

Audio.Gain.make(ctx, ~options=?)
Audio.Gain.gainParam(gain)              // Get gain AudioParam

BiquadFilter

// Filter types: Lowpass | Highpass | Bandpass | Lowshelf | Highshelf | Peaking | Notch | Allpass
Audio.BiquadFilter.make(ctx, ~options=?)
Audio.BiquadFilter.frequencyParam(f)
Audio.BiquadFilter.detuneParam(f)
Audio.BiquadFilter.qParam(f)
Audio.BiquadFilter.gainParam(f)
Audio.BiquadFilter.filterType(f)
Audio.BiquadFilter.setFilterType(f, ft)

Delay

Audio.Delay.make(ctx, ~options=?)
Audio.Delay.delayTimeParam(d)

Compressor

Audio.Compressor.make(ctx, ~options=?)
Audio.Compressor.thresholdParam(c)
Audio.Compressor.kneeParam(c)
Audio.Compressor.ratioParam(c)
Audio.Compressor.attackParam(c)
Audio.Compressor.releaseParam(c)
Audio.Compressor.reductionDb(c)         // Current gain reduction in dB

StereoPanner

Audio.StereoPanner.make(ctx, ~options=?)
Audio.StereoPanner.panParam(p)          // -1.0 (left) to 1.0 (right)

Analyser

Audio.Analyser.make(ctx, ~options=?)
Audio.Analyser.fftSize(a)
Audio.Analyser.setFftSize(a, size)
Audio.Analyser.frequencyBinCount(a)
Audio.Analyser.getFloatFrequencyData(a, array)
Audio.Analyser.getByteFrequencyData(a, array)
Audio.Analyser.getFloatTimeDomainData(a, array)
Audio.Analyser.getByteTimeDomainData(a, array)

Param (AudioParam)

Audio.Param.value(p)                    // Get current value
Audio.Param.setValue(p, v)              // Set value immediately
Audio.Param.setValueAtTime(p, ~value, ~startTime)
Audio.Param.linearRampToValueAtTime(p, ~value, ~endTime)
Audio.Param.exponentialRampToValueAtTime(p, ~value, ~endTime)
Audio.Param.setTargetAtTime(p, ~target, ~startTime, ~timeConstant)
Audio.Param.setValueCurveAtTime(p, ~values, ~startTime, ~duration)
Audio.Param.cancelScheduledValues(p, ~cancelTime)
Audio.Param.cancelAndHoldAtTime(p, ~cancelTime)

Node

Audio.Node.connect(source, destination)
Audio.Node.connectToParam(source, param)
Audio.Node.disconnect(node)
Audio.Node.disconnectFrom(node, target)
Audio.Node.numberOfInputs(node)
Audio.Node.numberOfOutputs(node)

Utils

Audio.Utils.chain(nodes)                // Connect array of nodes in series
Audio.Utils.toDestination(ctx, node)    // Connect node to destination

Development

npm install
npm run build
npm test
npm run watch  # Development mode

Contributing

This project uses Conventional Commits for automatic versioning and changelog generation.

Commit Message Format

<type>(<scope>): <description>

[optional body]

[optional footer(s)]

Types

| Type | Description | Version Bump | |------|-------------|--------------| | feat | New feature | Minor | | fix | Bug fix | Patch | | perf | Performance improvement | Patch | | refactor | Code refactoring | Patch | | docs | Documentation changes | Patch (README only) | | chore | Maintenance tasks | No release | | test | Test changes | No release |

Breaking Changes

Add BREAKING CHANGE: in the commit footer or ! after the type for major version bumps:

feat!: remove deprecated API

BREAKING CHANGE: The old API has been removed.

Examples

git commit -m "feat(oscillator): add custom waveform support"
git commit -m "fix(gain): correct parameter range validation"
git commit -m "docs(README): add filter examples"

License

MIT