# interval-class

> Get the interval class of an interval

Latest version **1.0.1** (published 2016-01-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install interval-class
pnpm add interval-class
yarn add interval-class
bun add interval-class
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2016-01-09 |
| First published | 2016-01-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4236 |
| Author | danigb |
| Maintainers | danigb |
| Keywords | music, theory, interval-class, interval, tonal |

## Links

- npm: https://www.npmjs.com/package/interval-class
- Repository: https://github.com/danigb/tonal/tree/master/packages/interval-class
- Homepage: https://github.com/danigb/tonal/tree/master/packages/interval-class#readme
- Issues: https://github.com/danigb/tonal/issues
- npm.io page: https://npm.io/package/interval-class

## Dependencies (1)

- [semitones](https://npm.io/package/semitones.md) ^1.0.0

## Recent versions

- 1.0.1 (latest) — 2016-01-09
- 1.0.0 — 2016-01-09

## README

# interval-class [![npm version](https://img.shields.io/npm/v/interval-class.svg)](https://www.npmjs.com/package/interval-class)

[![tonal](https://img.shields.io/badge/tonal-interval--class-yellow.svg)](https://www.npmjs.com/browse/keyword/tonal)

Get the [interval class](https://en.wikipedia.org/wiki/Interval_class) of an interval:

> The interval class is the shortest distance in pitch class space between two unordered pitch classes

In practice, an interval class is an integer between 0 and 6:

```js
var ic = require('interval-class')
ic('P4') // => 5
ic('P5') // => 5
```

Install it via npm: `npm i --save interval-class`

This tiny function is part of [tonal](https://github.com/danigb/tonal)

## Usage

Work with intervals in shorthand notation:

```js
['1P', '2M', '3M', '4P', '5P', '6M', '7M'].map(ic)
// => [ 0, 2, 4, 5, 5, 3, 1, 0 ]
```

You can pass the interval in semitones:

```js
ic(7) // => 5 (a perfect fifth)
```

Or using [array notation]():

```js
ic([ 2, -1 ]) // => 2 (a major second)
```

## License

MIT License

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