-
Notifications
You must be signed in to change notification settings - Fork 2
/
README.md
67 lines (45 loc) · 2.17 KB
/
README.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# Harmonics
Tools and utilities for a generic representation of scales, chords, progressions etc. for use in music software, music related web & mobile apps, [scribbletune](https://scribbletune.com), [VCV Rack](https://vcvrack.com/) plugins and [Max for Live](https://www.ableton.com/en/live/max-for-live/) devices. Uses [tonal](https://github.com/tonaljs/tonal) for western classical and custom generators for other forms of music.
## Install
```bash
npm install harmonics
```
## Interface
Use `harmonics` in your project
```javascript
const harmonics = require('harmonics');
```
Get an `array` of all the scales available in harmonics (includes the one's from Tonal and the [Melakarta ragas](https://en.wikipedia.org/wiki/Melakarta)).
```javascript
harmonics.scales(); // ['ionian', 'dorian', 'lydian', '...', 'Kanakangi', 'Ratnangi', '...']
```
Get the notes of a scale as an `array`
```javascript
harmonics.scale('C4 major'); // ['C4', 'D4', 'E4', 'F4', 'G4', 'A4', 'B4']
```
Scales available from Tonal are lower cased while ragas have their first letter capitalized.
```javascript
harmonics.scale('C4 Kanakangi'); // ['C4', 'Db4', 'D4', 'F4', 'G4', 'Ab4', 'A4']
```
Get an `array` of all the available chords (with numeric chords such as `4`, `5`, `7` etc exposed as `4th`, `5th`, `7th`)
```javascript
harmonics.chords(); // ['M', 'm', 'maj7', '4th']
```
Get the notes of a chord as an `array` (defaults to the 4th octave)
```javascript
harmonics.chord('C4 M'); // ['C4', 'E4', 'G4']
```
Get the notes of a chord as an `array` for a specific octave
```javascript
harmonics.chord('C5 M'); // ['C5', 'E5', 'G5']
```
Get the notes of an "inline" chord such as CM or Cmaj7 or Dbsus4_6 (here 6 is the octave). This is used in Scribbletune where you can define a bunch of notes and use chords in between, e.g 'C4 E4 Csus2 G4' (here Csus2 is "inlined" with C4, E4 and G4)
```javascript
harmonics.inlineChord('CM'); // ['C4', 'E4', 'G4']
harmonics.inlineChord('CM_5'); // ['C5', 'E5', 'G5']
```
Get the indices of a scale/raga or bitmap
```javascript
harmonics.getIndicesFromScale('phrygian'); // [0, 1, 3, 5, 7, 8, 10, 12]
harmonics.inlineChord('110010110011'); // [0, 1, 3, 5, 7, 8, 10, 12]
```