interval-class

1.0.1 • Public • Published

interval-class npm version

tonal

Get the 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:

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

Usage

Work with intervals in shorthand notation:

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

You can pass the interval in semitones:

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

Or using array notation:

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

License

MIT License

/interval-class/

    Package Sidebar

    Install

    npm i interval-class

    Weekly Downloads

    9

    Version

    1.0.1

    License

    MIT

    Last publish

    Collaborators

    • danigb