tonal-interval
tonal-interval
is a collection of functions to create and manipulate music intervals.
This is part of tonal music theory library.
You can install via npm: npm i --save tonal-interval
API Reference
- ivlName(ivl, the)
Get interval name. Can be used to test if it's an interval. It accepts intervals
as pitch or string in shorthand notation or tonal notation. It returns always
intervals in tonal notation.
- semitones(ivl) ⇒
Integer
Get size in semitones of an interval
- fromSemitones(num) ⇒
String
Get interval name from semitones number. Since there are several interval
names for the same number, the name it's arbitraty, but deterministic.
- ic(interval) ⇒
Integer
Get the interval class
number of a given interval.
In musical set theory, an interval class is the shortest distance in
pitch class space between two unordered pitch classes
As paramter you can pass an interval in shorthand notation, an interval in
array notation or the number of semitones of the interval
- itype(interval) ⇒
String
Get interval type. Can be perfectable (1, 4, 5) or majorable (2, 3, 6, 7)
- invert(interval) ⇒
String
| Pitch
Get the inversion#Intervals)
of an interval.
- simplify(interval) ⇒
String
| Array
Get the simplified version of an interval.
ivlName(ivl, the)
Get interval name. Can be used to test if it's an interval. It accepts intervals
as pitch or string in shorthand notation or tonal notation. It returns always
intervals in tonal notation.
Kind: global function
Param | Type | Description |
---|
ivl | String | Pitch | |
the | String | interval name or null if not valid interval |
Example
import { ivlName } from 'tonal-interval'
ivlName('m-3')
ivlName('3')
tonal.ivlName('blah')
semitones(ivl) ⇒ Integer
Get size in semitones of an interval
Kind: global function
Returns: Integer
- the number of semitones or null if not an interval
Param | Type |
---|
ivl | String | Pitch |
Example
import { semitones } from 'tonal-interval'
semitones('P4')
tonal.semitones('P5')
fromSemitones(num) ⇒ String
Get interval name from semitones number. Since there are several interval
names for the same number, the name it's arbitraty, but deterministic.
Kind: global function
Returns: String
- the interval name
Param | Type | Description |
---|
num | Integer | the number of semitones (can be negative) |
Example
import { fromSemitones } from 'tonal-interval'
fromSemitones(7)
tonal.fromSemitones(-7)
ic(interval) ⇒ Integer
Get the interval class
number of a given interval.
In musical set theory, an interval class is the shortest distance in
pitch class space between two unordered pitch classes
As paramter you can pass an interval in shorthand notation, an interval in
array notation or the number of semitones of the interval
Kind: global function
Returns: Integer
- A value between 0 and 6
Param | Type | Description |
---|
interval | String | Integer | the interval or the number of semitones |
Example
const ic = require('interval-class')
ic('P8')
ic('m6')
['P1', 'M2', 'M3', 'P4', 'P5', 'M6', 'M7'].map(ic)
itype(interval) ⇒ String
Get interval type. Can be perfectable (1, 4, 5) or majorable (2, 3, 6, 7)
Kind: global function
Returns: String
- 'P' for perfectables, 'M' for majorables or null if not
valid interval
Param | Type |
---|
interval | String | Pitch |
Example
tonal.itype('5A')
invert(interval) ⇒ String
| Pitch
Get the inversion
of an interval.
Kind: global function
Returns: String
| Pitch
- the inverted interval
Param | Type | Description |
---|
interval | String | Pitch | the interval to invert in interval shorthand notation or interval array notation |
Example
import { invert } from 'tonal-interval'
invert('3m')
tonal.invert('2M')
simplify(interval) ⇒ String
| Array
Get the simplified version of an interval.
Kind: global function
Returns: String
| Array
- the simplified interval
Param | Type | Description |
---|
interval | String | Array | the interval to simplify |
Example
import { simplify } from 'tonal-interval'
simplify('9M')
['8P', '9M', '10M', '11P', '12P', '13M', '14M', '15P'].map(simplify)
simplify('2M')
simplify('-2M')
tonal.simplify('9m')