Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

rhythm-math

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rhythm-math

Rhythm mathematics for the browser and web audio — tempo, polyrhythm, groove, syncopation, and meter

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

rhythm-math

Rhythm mathematics for the browser and web audio — tempo, polyrhythm, groove, syncopation, and meter.

Install

npm install rhythm-math

API

Types

  • Tempo{ bpm: number }
  • Polyrhythm{ rates: number[] }
  • Groove{ velocities: number[], offsets: number[] }
  • Meter{ numerator: number, denominator: number }

Tempo

  • bpmToMs(bpm) → milliseconds per beat
  • msToBpm(ms) → BPM
  • tempoCurve(start, end, steps, curve)number[] where curve is "linear", "exponential", or "logarithmic"

Polyrhythm

  • polyrhythmCycleLength(rates) → LCM of rates
  • polyrhythmPattern(rates) → binary arrays per voice
  • polyrhythmDensity(rates) → average hit density

Groove

  • swingFactor(grid, amount) → swung grid positions
  • grooveVelocity(pattern, accents?) → MIDI velocities (0–127)
  • microtiming(offsets, humanize) → humanized offsets

Syncopation

  • syncopationScore(pattern, meterNumerator) → Longuet-Higgins/Lee score
  • offbeatDensity(pattern, meterNumerator) → fraction of off-beat hits
  • rhythmicEntropy(pattern) → Shannon entropy of interval distribution

Meter

  • isSimple(meter), isCompound(meter), isOdd(meter) → boolean
  • beatCount(meter) → main beats per measure
  • subdivision(meter) → subdivisions per beat
  • downbeats(measures, meter) → downbeat positions
  • timeSignatureChanges(meters, repeats?) → expanded meter sequence

License

MIT

Keywords

rhythm

FAQs

Package last updated on 01 Jun 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts