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

@temper.sh/pitch

v1.0.2

Published

Utilities for working with pitch in arbitrary equal temperament spaces

Readme

@temper.sh/pitch

A TypeScript library for working with pitch, intervals, and pitch collections in arbitrary equal temperament systems.

Installation

npm install @temper.sh/pitch

Features

  • Pitch Class Operations: Convert MIDI pitches to pitch classes
  • Interval Calculations: Calculate intervals between pitches and interval classes
  • Normal Order: Find the most compact representation of pitch collections
  • Set Theory: Tools for analyzing pitch collections using music theory principles
  • Equal Temperament Support: Works with any equal division of the octave (12-TET, 24-TET, etc.)

Core Types

type Pitch = number           // MIDI pitch (60 = middle C)
type PitchClass = number      // Pitch class (0-11 in 12-TET)
type Chord = Array<Pitch>     // Array of pitches
type Interval = number        // Semitone difference between pitches
type IntervalClass = number   // Smallest interval between given pitch classes

API Reference

Pitch Class

Convert MIDI pitches to pitch classes:

import { pitchClass } from '@temper.sh/pitch'

pitchClass(60)  // 0 (C)
pitchClass(61)  // 1 (C#)
pitchClass(72)  // 0 (C, octave higher)

Intervals

Calculate intervals between pitches:

import { interval, intervals } from '@temper.sh/pitch'

// Single interval
interval(60, 64)  // 4 (major third)

// All consecutive intervals in a chord
intervals([60, 64, 67])  // [4, 3] (major third, minor third)

Interval Classes

Calculate the smallest interval between pitch classes:

import { intervalClass } from '@temper.sh/pitch'

// From interval
intervalClass(7)   // 5 (perfect fourth, smaller than tritone)
intervalClass(11)  // 1 (minor second, smaller than major seventh)

// From two pitches
intervalClass(60, 67)  // 5

Normal Order

Find the most compact representation of a pitch collection:

import { normalOrder } from '@temper.sh/pitch'

normalOrder([60, 64, 67])      // [0, 4, 7] (C major triad)
normalOrder([67, 60, 64])      // [0, 4, 7] (same result, different input order)
normalOrder([61, 65, 68])      // [1, 5, 8] (C# major triad)

Music Theory Background

This library implements standard music theory concepts for computer-assisted analysis:

  • Pitch Classes: Pitches reduced to their octave equivalents (C, C#, D, etc.)
  • Normal Order: The most left-compressed arrangement of a pitch class set
  • Interval Classes: The smallest possible interval between two pitch classes
  • Equal Temperament: Musical tuning systems that divide the octave into equal parts

Development

# Install dependencies
pnpm install

# Run tests
pnpm test

# Run tests in watch mode
pnpm dev

# Build
pnpm build

# Format and lint
pnpm format-and-lint