2.2.2 • Published 5 years ago

tonal-interval v2.2.2

Weekly downloads
288
License
MIT
Repository
github
Last release
5 years ago

Interval

Interval.semitones("4P") // => 5 Interval.invert("3m") // => "6M" Interval.simplify("9m") // => "2m"Install

Interval.num(interval) ⇒ string

Kind: static method of Interval
Returns: string - the interval name or null if not valid interval

ParamTypeDescription
intervalstringthe interval string or array

Example

Interval.name("m-3") // => "-3m"
Interval.name("3") // => null

Interval.name(ivl) ⇒ Integer

Kind: static method of Interval
Returns: Integer - the number of semitones or null if not an interval

ParamType
ivlstring

Example

import { semitones } from "tonal-interval"
semitones("P4") // => 5
// or using tonal
Tonal.Interval.semitones("P5") // => 7

Interval.semitones(str) ⇒ Number

Kind: static method of Interval

ParamType
strstring

Interval.chroma(interval) ⇒ Integer

Kind: static method of Interval
Returns: Integer - A value between 0 and 6

ParamTypeDescription
intervalString | Integerthe interval or the number of semitones

Example

Interval.ic("P8") // => 0
Interval.ic("m6") // => 4
Interval.ic(10) // => 2
["P1", "M2", "M3", "P4", "P5", "M6", "M7"].map(ic) // => [0, 2, 4, 5, 5, 3, 1]

Interval.ic(props) ⇒ string

Kind: static method of Interval
Returns: string - the interval name

ParamTypeDescription
propsObjectthe interval property object

Example

Interval.build({ step: 1, alt: -1, oct: 0, dir: 1 }) // => "1d"
Interval.build({ num: 9, alt: -1 }) // => "9m"

Interval.build(interval) ⇒ string

Kind: static method of Interval
Returns: string - the simplified interval

ParamTypeDescription
intervalstringthe interval to simplify

Example

Interval.simplify("9M") // => "2M"
["8P", "9M", "10M", "11P", "12P", "13M", "14M", "15P"].map(Interval.simplify)
// => [ "8P", "2M", "3M", "4P", "5P", "6M", "7M", "8P" ]
Interval.simplify("2M") // => "2M"
Interval.simplify("-2M") // => "7m"

Interval.simplify(interval) ⇒ string

Kind: static method of Interval
Returns: string - the inverted interval

ParamTypeDescription
intervalstringthe interval to invert in interval shorthand notation or interval array notation

Example

Interval.invert("3m") // => "6M"
Interval.invert("2M") // => "7m"

Interval~names(qualities) ⇒ Array

Kind: inner method of Interval
Returns: Array - the interval names

ParamTypeDescription
qualitiesstring(Optional, default "PMm") the valid types

Example

Interval.names() // => [ "1P", "2m", "2M", "3m", "3M", "4P", "5P", "6m", "6M", "7m", "7M", "8P" ]
Interval.names("P") // => [ "1P", "4P", "5P", "8P" ]
Interval.names("PM") // => [ "1P", "2M", "3M", "4P", "5P", "6M", "7M", "8P" ]
Interval.names("Pm") // => [ "1P", "2m", "3m", "4P", "5P", "6m", "7m", "8P" ]
Interval.names("d") // => []

Interval~props(interval) ⇒ Object

Kind: inner method of Interval
Returns: Object - the interval in the form number, alt

ParamTypeDescription
intervalstringthe interval

Interval~num(interval) ⇒ Integer

Kind: inner method of Interval

ParamTypeDescription
intervalstringthe interval

Example

Interval.num("m2") // => 2
Interval.num("P9") // => 9
Interval.num("P-4") // => -4

Interval~fromSemitones(num) ⇒ string

Kind: inner method of Interval
Returns: string - the interval name

ParamTypeDescription
numIntegerthe number of semitones (can be negative)

Example

import { fromSemitones } from "tonal-interval"
fromSemitones(7) // => "5P"
// or using tonal
Tonal.Distance.fromSemitones(-7) // => "-5P"
2.2.2

5 years ago

2.2.1

5 years ago

2.2.0

5 years ago

2.1.2

5 years ago

2.1.0

6 years ago

2.0.0

6 years ago

1.1.2

6 years ago

1.1.0

7 years ago

1.0.0

7 years ago

1.0.0-pre6

7 years ago

1.0.0-pre5

7 years ago

1.0.0-pre4

7 years ago

1.0.0-pre3

7 years ago

1.0.0-pre2

7 years ago

1.0.0-1

7 years ago

1.0.0-0

7 years ago

0.69.9

7 years ago

0.69.8

7 years ago

0.69.7

7 years ago

0.69.6

7 years ago

0.69.4

7 years ago

0.69.3

7 years ago

0.69.2

7 years ago

0.69.0

7 years ago

0.68.1

7 years ago

0.66.0

7 years ago

0.65.0

7 years ago

0.64.0

7 years ago

0.61.0

7 years ago

0.60.0

7 years ago

0.50.1

8 years ago

0.50.0

8 years ago