1
1
---
2
2
title : Intervals
3
- sidebar_position : 3
3
+ description : Calculate and manipulate intervals
4
+ package : interval
4
5
---
5
6
6
- ![ tonal ] ( https://img.shields.io/badge/@tonaljs-interval-yellow.svg?style=flat-square ) [ ![ npm version ] ( https://img.shields.io/npm/v/@tonaljs/interval.svg?style=flat-square )] ( https://www.npmjs.com/package/@tonaljs/interval )
7
+ ` Intervals ` module allow to do distance calculations between notes using intervals, obtain information and do calculations:
7
8
8
9
``` js
9
10
import { Interval } from " tonal" ;
10
11
12
+ Interval .distance (" C4" , " G4" ); // => "5P"
11
13
Interval .invert (" 2M" ); // => "7m"
12
14
Interval .simplify (" 9M" ); // => "2M"
13
- Interval .semitones (" P4 " ); // => 5
14
- Interval .distance ( " C4 " , " G4 " ); // => "5P"
15
+ Interval .semitones (" 4P " ); // => 5
16
+ Interval .add ( " 4P " , " 2M " ); // => "5P"
15
17
```
16
18
17
19
## Interval properties
18
20
19
21
### ` Interval.get `
20
22
21
- #### ` get(name: string) -> Interval `
23
+ ` get(name: string) -> Interval `
22
24
23
25
Get properties of an interval:
24
26
@@ -49,7 +51,7 @@ Interval.semitones("P4"); // => 5
49
51
50
52
### ` Interval.names `
51
53
52
- #### ` names() => string[] `
54
+ ` names() => string[] `
53
55
54
56
Return a list of (natural) interval names:
55
57
@@ -59,7 +61,7 @@ Interval.names(); // => ["1P", "2M", "3M", "4P", "5P", "6m", "7m"]
59
61
60
62
### ` Interval.fromSemitones `
61
63
62
- #### ` fromSemitones(semitones: number) => string `
64
+ ` fromSemitones(semitones: number) => string `
63
65
64
66
Given a number of semitones, returns the interval name:
65
67
@@ -74,7 +76,7 @@ Interval.fromSemitones(-7); // => "-5P"
74
76
75
77
### ` Interval.simplify `
76
78
77
- #### ` simplify(interval: string) => string `
79
+ ` simplify(interval: string) => string `
78
80
79
81
Simplify an interval:
80
82
@@ -88,7 +90,7 @@ Interval.simplify("-2M"); // => "7m"
88
90
89
91
### ` Interval.invert `
90
92
91
- #### ` invert(interval: string) => string `
93
+ ` invert(interval: string) => string `
92
94
93
95
Get the interval inversion:
94
96
@@ -99,7 +101,7 @@ Interval.invert("2M"); // => "7m"
99
101
100
102
### ` Interval.distance `
101
103
102
- #### ` distance(from: string, to: string) => string `
104
+ ` distance(from: string, to: string) => string `
103
105
104
106
Find the interval between two notes.
105
107
@@ -109,7 +111,7 @@ Interval.distance("C4", "G4"); // => "5P"
109
111
110
112
### ` Interval.add `
111
113
112
- #### ` add(a: string, b: string) => string `
114
+ ` add(a: string, b: string) => string `
113
115
114
116
Add two intervals:
115
117
@@ -119,7 +121,7 @@ Interval.add("3m", "5P"); // => "7m"
119
121
120
122
### ` Interval.subtract `
121
123
122
- #### ` subtract(min: string, sub: string) => string `
124
+ ` subtract(min: string, sub: string) => string `
123
125
124
126
Substract two intervals:
125
127
0 commit comments