-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
168 lines (168 loc) · 4.32 KB
/
index.d.ts
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
declare type ChordType = "maj" | "min" | "maj7" | "min7" | "dom7" | "aug" | "dim";
declare type IntervalName = "Augmented" | "Diminished" | "Major" | "Minor";
declare type IntervalType = "aug" | "dim" | "maj" | "min";
declare type Mode = "ionian" | "dorian" | "phrygian" | "lydian" | "mixolydian" | "aeolian" | "locrian" | "melodic" | "harmonic";
declare type ModeVanity = "major" | "minor";
declare type Notation = "C" | "C#" | "D" | "D#" | "E" | "F" | "F#" | "G" | "G#" | "A" | "A#" | "B";
declare type NotationAlternate = "C" | "Db" | "D" | "Eb" | "E" | "F" | "Gb" | "G" | "Ab" | "A" | "Bb" | "B";
interface Chord {
key: string;
label: string;
notation: Notation;
notes: IntervalNote[];
type: ChordType;
}
interface MusicalScaleParams {
/**
* The root of the scale. Can be alternative format (flat instead of sharp).
*/
root: Notation | NotationAlternate;
/**
* The scale mode, can provide vanity modes (major, minor).
*/
mode: Mode | ModeVanity;
}
interface IntervalNote {
/**
* Notation for the note
*/
notation: Notation;
/**
* Octave relative to the first interval's root octave.
* 0 | 1 | 2
*/
octave: number;
}
declare type IntervalNotes = IntervalNote[];
export declare const STEP_NOTATIONS: Notation[];
export declare const STEP_NOTATION_ALTERNATES: NotationAlternate[];
export declare const CHORD_TYPES: ChordType[];
/**
* Turns an array of notes into the chords unique id.
* @param notes
* @returns key for the chord.
*/
export declare const chordKeyFromNotes: (notes: IntervalNote[]) => string;
/**
* Builds a chord for a step and ChordType
* @param step
* @param type
* @returns Chord
*/
export declare const chordFromStepAndType: (step: number, type: ChordType) => Chord;
export declare const intervalNotes: (offset: number, octave: number, type: IntervalType) => IntervalNotes;
declare class MusicalScaleNote {
/**
* Frequency hz for this note
*/
frequency: number;
/**
* A unique identifier for this note
*/
id: string;
/**
* Global index of the note on a keyboard (
* 0 through 107
*/
index: number;
/**
* Primary notation for the note
*/
notation: Notation;
/**
* Optional secondary notation for the note
*/
notationAlternate?: NotationAlternate;
/**
* Global octave number for the note
* 0 through 8
*/
octave: number;
/**
* Index of the note within the octave
* 0 through 11
*/
octaveIndex: number;
constructor({ octave, step }: {
octave: number;
step: number;
});
}
declare class MusicalScaleInterval {
/**
* Common representation of the interval
*/
label: string;
/**
* Metadata
*/
meta: {
/**
* Interval name
*/
name: IntervalName;
/**
* Interval roman numeral syntax
*/
numeral: string;
/**
* Interval type
*/
type: IntervalType;
};
/**
* Primary identifier of the interval root note
*/
notation: Notation;
/**
* Optional secondary identifier of the interval root note
*/
notationAlternate?: NotationAlternate;
/**
* Interval triad notes
*/
notes: IntervalNotes;
/**
* Octave relative octave to first interval's root note.
* 0 | 1
*/
octave: number;
/**
* Interval step in the mode
* 0 through 6
*/
step: number;
constructor(step: number, offset: number, type: IntervalType);
}
export default class MusicalScale {
/**
* Array of 7 intervals in the scale
*/
intervals: MusicalScaleInterval[];
/**
* Common label for the scale's key.
*/
label: string;
/**
* Scale's mode. Can be a vanity mode (minor, major)
*/
mode: Mode | ModeVanity;
/**
* Array of playable note ids in the scale
*/
noteIds: string[];
/**
* Notation or alternative notation for the root of the scale.
*/
root: Notation | NotationAlternate;
constructor(params: MusicalScaleParams);
update({ root, mode }: MusicalScaleParams): void;
/**
* Array of playable notes in the scale.
*/
get notes(): MusicalScaleNote[];
}
export declare const NOTES_LIBRARY: {
[k: string]: MusicalScaleNote;
};
export {};