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-tone

v1.1.0

Published

ReScript bindings for Tone.js

Readme

rescript-tone

ReScript bindings for Tone.js, a Web Audio framework for creating interactive music in the browser.

Installation

npm install rescript-tone tone

Add to your rescript.json:

{
  "bs-dependencies": ["rescript-tone"]
}

Quick Start

// Create a synth and connect it to the speakers
let synth = Tone.Synth.make()
let node = synth->Tone.Synth.asAudioNode->Tone.AudioNode.toDestination

// Play a note
let _ = synth->Tone.Synth.triggerAttackRelease(440.0, Tone.Types.Time.seconds(0.5))

// Start the audio context (required by browsers)
let _ = Tone.Core.start()

Usage Examples

Playing Notes with a Synth

let synth = Tone.Synth.makeWithOptions({
  oscillator: ?Some({\"type": ?Some(Tone.Types.Sawtooth)}),
  envelope: ?Some({
    attack: ?Some(Tone.Types.Time.seconds(0.1)),
    decay: ?Some(Tone.Types.Time.seconds(0.2)),
    sustain: ?Some(0.5),
    release: ?Some(Tone.Types.Time.seconds(0.8)),
  }),
})

let _ = synth->Tone.Synth.asAudioNode->Tone.AudioNode.toDestination
let _ = synth->Tone.Synth.triggerAttackRelease(440.0, Tone.Types.Time.seconds(0.5))

Chaining Effects

let synth = Tone.Synth.make()
let reverb = Tone.Reverb.makeWithDecay(1.5)
let delay = Tone.FeedbackDelay.makeWithTimeFeedback(Tone.Types.Time.notation("8n"), 0.5)
let dest = Tone.Core.getDestination()

// Chain: synth -> delay -> reverb -> destination
let _ = synth
  ->Tone.Synth.asAudioNode
  ->Tone.AudioNode.chain([
    delay->Tone.FeedbackDelay.asAudioNode,
    reverb->Tone.Reverb.asAudioNode,
    dest->Tone.Destination.asAudioNode,
  ])

Scheduling with Transport

let synth = Tone.Synth.make()
let _ = synth->Tone.Synth.asAudioNode->Tone.AudioNode.toDestination

let transport = Tone.Core.getTransport()

// Set BPM
let bpm = transport->Tone.Transport.bpm
Tone.Param.setValue(bpm, 120.0)

// Schedule a repeating note
let _ = transport->Tone.Transport.scheduleRepeat(
  _time => {
    let _ = synth->Tone.Synth.triggerAttackRelease(440.0, Tone.Types.Time.notation("8n"))
  },
  Tone.Types.Time.notation("4n"),
)

// Start the transport
let _ = transport->Tone.Transport.start

Looping Patterns

let synth = Tone.Synth.make()
let _ = synth->Tone.Synth.asAudioNode->Tone.AudioNode.toDestination

let notes = ["C4", "E4", "G4", "B4"]

let seq = Tone.Sequence.makeWithSubdivision(
  (time, note) => {
    let _ = synth->Tone.Synth.triggerAttackReleaseAt(
      Tone.Types.Frequency.fromNotation(note),
      Tone.Types.Time.notation("8n"),
      ~time=Tone.Types.Time.fromFloat(time),
    )
  },
  notes,
  Tone.Types.Time.notation("4n"),
)

let _ = seq->Tone.Sequence.start
let _ = Tone.Core.getTransport()->Tone.Transport.start

Polyphonic Synth

let poly = Tone.PolySynth.makeWithOptions({maxPolyphony: ?Some(4)})
let _ = poly->Tone.PolySynth.asAudioNode->Tone.AudioNode.toDestination

// Play a chord
let _ = poly->Tone.PolySynth.triggerAttackRelease(
  [261.63, 329.63, 392.0],
  Tone.Types.Time.seconds(1.0),
)

API Reference

See docs/API.md for the complete API reference.

Architecture

The library is organized into modules that mirror Tone.js's structure:

| Category | Modules | |----------|---------| | Core | Core, Context, Transport, Destination, Param, AudioNode, Types | | Instruments | Synth, AMSynth, FMSynth, MonoSynth, PolySynth | | Sources | Oscillator, Player, Noise | | Effects | Reverb, FeedbackDelay, Chorus, Distortion, AutoFilter, AutoPanner, AutoWah, BitCrusher, Chebyshev, Freeverb, JCReverb, Phaser, PingPongDelay, PitchShift, Tremolo, Vibrato, FrequencyShifter, StereoWidener | | Components | Compressor, Limiter, Gate, Filter, EQ3, Panner | | Signal & Channel | Signal, Volume, Gain, Channel, CrossFade | | Scheduling | Loop, Event, Part, Sequence |

All modules are accessible under the Tone namespace (e.g., Tone.Synth.make(), Tone.Reverb.makeWithDecay(1.5)).

Each Tone.js class maps to a ReScript module with an abstract type t. Modules expose:

  • make / makeWithOptions constructors
  • @send methods for instance operations
  • @get / @set for properties
  • asAudioNode for casting to the base AudioNode.t type (for connect, chain, etc.)

Requirements

  • ReScript >= 12.0.0
  • Tone.js >= 15.0.0
  • A browser environment with Web Audio API support

License

MIT