# @tonaljs/pitch-interval

> Parse intervals in shorthand notation

Latest version **6.1.0** (published 2025-01-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install @tonaljs/pitch-interval
pnpm add @tonaljs/pitch-interval
yarn add @tonaljs/pitch-interval
bun add @tonaljs/pitch-interval
```

## Health

**Score 35/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 6.1.0 |
| Published | 2025-01-03 |
| First published | 2023-11-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 30.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | danigb@gmail.com |
| Maintainers | danigb |
| Keywords | note, music, theory, interval, shorthand notation |

## Links

- npm: https://www.npmjs.com/package/@tonaljs/pitch-interval
- npm.io page: https://npm.io/package/@tonaljs/pitch-interval

## Dependencies (1)

- [@tonaljs/pitch](https://npm.io/package/@tonaljs/pitch.md) 5.0.2

## Recent versions

- 6.1.0 (latest) — 2025-01-03
- 6.0.0 — 2024-02-03
- 5.0.2 — 2024-02-03
- 5.0.1 — 2024-01-04
- 5.0.0 — 2023-11-29

## README

# @tonaljs/pitch-interval ![tonal](https://img.shields.io/badge/@tonaljs-pitch_interval-yellow.svg?style=flat-square) [![npm version](https://img.shields.io/npm/v/@tonaljs/pitch-interval.svg?style=flat-square)](https://www.npmjs.com/package/@tonaljs/pitch-interval)

> Pitch interval support

## Usage

⚠️ It's probably you don't need to use this package directly. Use [tonal-interval](/packages/interval) instead.

```js
import { parse, toName } from "@tonaljs/pitch-interval";

parse("4P").semitones; // => 5
```

## API

### `interval(name: string) => Interval`

Given an interval name, ite returns an object with the following properties:

- name: the interval name
- type: perfectable | majorable
- dir: direction: 1 | -1
- num: the interval number
- q: quality (...| 'dd' | 'd' | 'm' | 'M' | 'A' | ...)
- alt: the quality number as a number
- oct: the number of octaves it spans
- semitones: the number of semitones it spans
- simple: the simplified number

Example:

```js
interval("4d");
// =>
// {
//   name: "4d",
//   type: "perfectable",
//   dir: 1,
//   num: 4,
//   q: "d",
//   alt: -1,
//   chroma: 4,
//   oct: 0,
//   semitones: 4,
//   simple: 4,
// }
```

This function always returns an object:

```js
interval("hello"); // => { empty: true, name: "" }
```

---
_Source: https://npm.io/package/@tonaljs/pitch-interval · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
