@tonaljs/chord
Advanced tools
Comparing version
@@ -86,5 +86,9 @@ import { detect } from '@tonaljs/chord-detect'; | ||
* [1, 2, 3, 4].map(Chord.degrees("C")) => ["C", "E", "G", "C"] | ||
* [1, 2, 3, 4].map(Chord.degrees("C4")) => ["C4", "D4", "E4", "C5"] | ||
* [1, 2, 3, 4].map(Chord.degrees("C4")) => ["C4", "E4", "G4", "C5"] | ||
*/ | ||
declare function degrees(scaleName: string): (degree: number) => string; | ||
declare function degrees(chordName: string | ChordNameTokens): (degree: number) => string; | ||
/** | ||
* Sames as `degree` but with 0-based index | ||
*/ | ||
declare function steps(chordName: string | ChordNameTokens): (normalized: number) => string; | ||
declare const _default: { | ||
@@ -100,5 +104,6 @@ getChord: typeof getChord; | ||
degrees: typeof degrees; | ||
steps: typeof steps; | ||
chord: (this: unknown, ...args: unknown[]) => Chord; | ||
}; | ||
export { Chord, chord, chordScales, _default as default, degrees, extended, get, getChord, reduced, tokenize, transpose }; | ||
export { Chord, chord, chordScales, _default as default, degrees, extended, get, getChord, reduced, steps, tokenize, transpose }; |
@@ -32,2 +32,3 @@ "use strict"; | ||
reduced: () => reduced, | ||
steps: () => steps, | ||
tokenize: () => tokenize, | ||
@@ -149,6 +150,11 @@ transpose: () => transpose | ||
} | ||
function degrees(scaleName) { | ||
const chord2 = get(scaleName); | ||
return (0, import_core.transposeIntervalSetByDegree)(chord2.intervals, chord2.tonic ?? ""); | ||
function degrees(chordName) { | ||
const { intervals, tonic } = get(chordName); | ||
const transpose2 = (0, import_core.tonicIntervalsTransposer)(intervals, tonic); | ||
return (degree) => degree ? transpose2(degree > 0 ? degree - 1 : degree) : ""; | ||
} | ||
function steps(chordName) { | ||
const { intervals, tonic } = get(chordName); | ||
return (0, import_core.tonicIntervalsTransposer)(intervals, tonic); | ||
} | ||
var chord_default = { | ||
@@ -164,2 +170,3 @@ getChord, | ||
degrees, | ||
steps, | ||
chord | ||
@@ -177,2 +184,3 @@ }; | ||
reduced, | ||
steps, | ||
tokenize, | ||
@@ -179,0 +187,0 @@ transpose |
{ | ||
"name": "@tonaljs/chord", | ||
"version": "4.9.0", | ||
"version": "4.10.0", | ||
"description": "Musical chords and its relations", | ||
@@ -22,3 +22,3 @@ "keywords": [ | ||
"@tonaljs/collection": "^4.8.0", | ||
"@tonaljs/core": "^4.9.0", | ||
"@tonaljs/core": "^4.10.0", | ||
"@tonaljs/pcset": "^4.8.0", | ||
@@ -25,0 +25,0 @@ "@tonaljs/scale-type": "^4.8.0" |
@@ -82,2 +82,11 @@ # @tonaljs/chord  [](https://www.npmjs.com/package/@tonaljs/chord) | ||
It can be used to find chord inversions: | ||
```js | ||
[1, 2, 3, 4].map(chord); // => ["C4", "Eb4", "G4", "Bb4"] | ||
[2, 3, 4, 5].map(chord); // => ["Eb4", "G4", "Bb4", "C5"] | ||
[3, 4, 5, 6].map(chord); // => ["G4", "Bb4", "C5", "Eb5"] | ||
[4, 5, 6, 7].map(chord); // => ["Bb4", "C5", "Eb5", "G5"] | ||
``` | ||
Bear in mind that degree numbers starts with 1 and 0 returns an empty string: | ||
@@ -91,2 +100,13 @@ | ||
### `Chord.steps(chordName: string) => (degree: number) => string` | ||
Same as `Chord.degrees` but 0 is the tonic. Plays better with numeric ranges: | ||
```js | ||
import { Range, Chord } from "tonal"; | ||
Range.numeric([-3, 3]).map(Chord.steps(["C4", "aug"])); | ||
// => ["G#3", "E3", "C3", "C4", "E4", "G#4", "C5"] | ||
``` | ||
#### `Chord.detect(notes: string[]) => string[]` | ||
@@ -93,0 +113,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
41317
6.03%446
4.69%154
14.93%Updated