Intervals
Calculate and manipulate intervals
Intervals
module allow to do distance calculations between notes using intervals, obtain information and do calculations:
Interval properties
Interval.get
get(name: string) -> Interval
Get properties of an interval:
- name: the interval name (number + quality)
- 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
There are some shorthand functions (name
, num
, semitones
, quality
):
Collections and conversion
Interval.names
names() => string[]
Return a list of (natural) interval names:
Interval.fromSemitones
fromSemitones(semitones: number) => string
Given a number of semitones, returns the interval name:
Operations
Interval.simplify
simplify(interval: string) => string
Simplify an interval:
Interval.invert
invert(interval: string) => string
Get the interval inversion:
Interval.distance
distance(from: string, to: string) => string
Find the interval between two notes.
Interval.add
add(a: string, b: string) => string
Add two intervals:
Interval.subtract
subtract(min: string, sub: string) => string
Substract two intervals: