Skip to content

Add ReScript bindings for Tone.js audio library#1

Closed
brnrdog wants to merge 8 commits intomainfrom
claude/rescript-tonejs-bindings-ffKSd
Closed

Add ReScript bindings for Tone.js audio library#1
brnrdog wants to merge 8 commits intomainfrom
claude/rescript-tonejs-bindings-ffKSd

Conversation

@brnrdog
Copy link
Copy Markdown
Owner

@brnrdog brnrdog commented Mar 31, 2026

This PR introduces comprehensive ReScript bindings for Tone.js, a Web Audio API framework for creating interactive music in the browser.

Summary

Complete type-safe ReScript bindings for Tone.js v15, enabling developers to use Tone.js functionality with full type checking and IDE support in ReScript projects.

Key Changes

Core Bindings

  • Type definitions (ToneJs_Types.res): Comprehensive type aliases for Tone.js units (time, frequency, decibels, etc.) and enums (oscillator types, playback states, etc.)
  • Main module (ToneJs.res): Central entry point re-exporting all Tone.js modules
  • Core modules: Bindings for Tone, Context, Transport, Destination, Param, and AudioNode

Instruments & Synthesizers

  • Synth, AMSynth, FMSynth, MonoSynth, PolySynth with full trigger/release methods and parameter access

Sources

  • Oscillator, Player (audio file playback), and Noise generators with lifecycle and property management

Effects (20+ effects)

  • Reverb, FeedbackDelay, Chorus, Distortion, AutoFilter, AutoPanner, AutoWah, BitCrusher, Chebyshev, Freeverb, JCReverb, Phaser, PingPongDelay, PitchShift, Tremolo, Vibrato, and more
  • Each with appropriate constructor overloads and parameter getters/setters

Signal Processing

  • Signal, Volume, Gain, Filter, Channel, Compressor, Limiter, Gate, EQ3, CrossFade, FrequencyShifter, Panner, StereoWidener

Scheduling & Events

  • Loop, Event, Part, Sequence for timeline-based scheduling and event management

Testing

  • Comprehensive test suites validating all binding exports (CoreTests, SourceTests, EffectTests, SignalTests, SchedulingTests)
  • Tests verify type correctness at compile time and basic runtime functionality

Build & CI/CD

  • ReScript configuration with ES module output
  • npm scripts for building and testing
  • GitHub Actions CI workflow for automated testing
  • Semantic Release configuration for automated versioning and publishing

Implementation Details

  • All bindings use @module("tone") to import from the Tone.js npm package
  • Constructor overloads provided for common parameter combinations
  • Proper use of optional parameters with ~ syntax for named arguments
  • Type-safe enums for oscillator types, noise types, playback states, etc.
  • Getter/setter patterns for properties using @get/@set attributes
  • Promise support for async operations (load, resume, close)

brnrdog added 8 commits March 31, 2026 17:52
Initialize rescript-tonejs project with ReScript v12, Vite, Tone.js, and zekr
for testing. Set up directory structure, build configuration, and verify
compilation and test runner work.
Add ReScript bindings for the core Tone.js API:
- Types module with time, frequency, and unit types
- Tone module (start, now, getContext, getTransport, getDestination)
- Context (now, immediate, sampleRate, lookAhead)
- Transport (start/stop/pause, scheduling, BPM, position, loop)
- Destination (volume, mute)
- Param (value get/set, ramp methods)
- AudioNode (connect, disconnect, toDestination, chain, fan, dispose)

Includes 17 tests covering runtime behavior and compile-time binding
verification.
Add ReScript bindings for Tone.js instruments and sources:
- Synth, AMSynth, FMSynth, MonoSynth, PolySynth (instruments)
- Oscillator, Player, Noise (sources)
- Shared envelope, oscillator, and filter option types in Types module

Each module exposes constructors, trigger methods, properties, and
AudioNode casting. Includes 8 test suites verifying binding correctness.
Add ReScript bindings for Tone.js effects and audio components:
- 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

Each module includes constructors, property accessors, and AudioNode
casting. Includes 24 test suites verifying binding correctness.
Add ReScript bindings for Tone.js signal and channel modules:
- Signal (schedulable audio signal with ramp/automation methods)
- Volume (volume control with mute)
- Gain (basic gain node)
- Channel (routing with pan, volume, solo, mute, send/receive)
- CrossFade (crossfade between two inputs)

Includes 5 test suites verifying binding correctness.
Add ReScript bindings for Tone.js scheduling modules:
- Loop (looping callback with interval, iterations, probability)
- Event (schedulable event with loop and playback control)
- Part (collection of events on a timeline)
- Sequence (ordered series of events with subdivision)

Each module exposes constructors, start/stop/cancel, and properties
for loop, playbackRate, probability, humanize, and mute.
Includes 4 test suites verifying binding correctness.
Configure semantic-release for automated versioning and changelog
generation based on conventional commits. Add GitHub Actions CI
workflow that runs tests on PRs and triggers releases on main.
Add README.md with installation, quick start, and usage examples.
Add docs/API.md with comprehensive API reference for all modules.
Rename package from rescript-tonejs to rescript-tone across all configs.
@brnrdog brnrdog force-pushed the claude/rescript-tonejs-bindings-ffKSd branch from 69e0680 to 9e7ed87 Compare March 31, 2026 15:55
@brnrdog brnrdog closed this Mar 31, 2026
@brnrdog brnrdog deleted the claude/rescript-tonejs-bindings-ffKSd branch March 31, 2026 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant