Replies: 2 comments
-
|
Sorry for the late reply 🙏 If you want all the chords starting from "D", this could work: import { ChordDictionary, Note, PcSet } from "tonal";
const notes = ["D3", "A3", "Bb3", "C4", "D4", "E4", "F4", "G4", "A4"];
const transposed = notes.map((note) => Note.transpose(note, "-2M"));
const set = PcSet.chroma(transposed); // => "101011010110"
const isSubset = PcSet.isSubsetOf(set);
const chordNames = ChordDictionary.all()
.filter((chord) => isSubset(chord.chroma))
.map((chord) => "D" + chord.aliases[0]);
console.log(chordNames);This will print: If you want all chords for all notes, maybe this: import { ChordDictionary, Interval, Note, PcSet, Scale } from "tonal";
const notes = ["D3", "A3", "Bb3", "C4", "D4", "E4", "F4", "G4", "A4"];
const uniqueNotes = Scale.scaleNotes(notes);
const chords = uniqueNotes.map((note) => {
const interval = Interval.distance("C", note);
const inverted = Interval.invert(interval);
const transposed = notes.map(Note.trBy(inverted));
const set = PcSet.chroma(transposed);
const isSubset = PcSet.isSubsetOf(set);
return ChordDictionary.all()
.filter((chord) => isSubset(chord.chroma))
.map((chord) => note + chord.aliases[0]);
});
console.log(chords);This will return a lot of chords: |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Danigb,
Thank you for replying. I will try out your suggestions to see if I am missing any chords, but in my playing around with your library I came up with the following to discover many chords that I can actually play on this subset of notes on the handpan:
var handpanNotes = ["D3", "A3", "Bb3", "C4", "D4", "E4", "F4", "G4", "A4"]; // Kurd
var scales = Tonal.Scale.detect(handpanNotes);
if (scales[0]) {
var scale = scales[0]; // first choice seems best
var chords = Tonal.Scale.scaleChords("chromatic") // get all possible chords
chords.forEach(function(chord) {
var chordName = Tonal.Chord.get(chord).name;
if (chordName === "") {
chordName = chord;
}
handpanNotes.forEach(function(handpanNote) {
var chordNotes = Tonal.Chord.getChord(chord, handpanNote).notes;
var isChordPossible = true;
chordNotes.forEach(function(chordNote) {
if (!handpanNotes.includes(chordNote)) {
isChordPossible = false;
}
});
if (isChordPossible) {
console.log(handpanNote + " " + chordName + " — " + chordNotes.join(', '));
}
});
});
}
This will give me the following results:
D3 fifth — D3, A3
A3 fifth — A3, E4
Bb3 fifth — Bb3, F4
C4 fifth — C4, G4
D4 fifth — D4, A4
A3 suspended fourth — A3, D4, E4
C4 suspended fourth — C4, F4, G4
D4 suspended fourth — D4, G4, A4
A3 suspended fourth seventh — A3, D4, E4, G4
Bb3 major — Bb3, D4, F4
C4 major — C4, E4, G4
Bb3 major seventh — Bb3, D4, F4, A4
Bb3 sixth — Bb3, D4, F4, G4
C4 sixth — C4, E4, G4, A4
A3 m7#5 — A3, C4, F4, G4
A3 minor — A3, C4, E4
D4 minor — D4, F4, A4
A3 minor seventh — A3, C4, E4, G4
A3 madd4 — A3, C4, D4, E4
D4 madd4 — D4, F4, G4, A4
Bb3 suspended second — Bb3, C4, F4
C4 suspended second — C4, D4, G4
D4 suspended second — D4, E4, A4
C4 sus24 — C4, D4, F4, G4
D4 sus24 — D4, E4, G4, A4
D3 eleventh — D3, A3, C4, E4, G4
If there is a better approach to using your library, or if I am missing something important please let me know. BTW, I have greatly enjoyed getting to work with your library!
Thanks!
Rick
From: danigb ***@***.***>
Reply-To: tonaljs/tonal ***@***.***>
Date: Monday, January 15, 2024 at 11:32 AM
To: tonaljs/tonal ***@***.***>
Cc: rdmeyers2 ***@***.***>, Author ***@***.***>
Subject: Re: [tonaljs/tonal] Possible Chords in a set of Notes (Discussion #402)
Sorry for the late reply 🙏 If you want all the chords starting from "D", this could work:
import { ChordDictionary, Note, PcSet } from "tonal";
const notes = ["D3", "A3", "Bb3", "C4", "D4", "E4", "F4", "G4", "A4"];
const transposed = notes.map((note) => Note.transpose(note, "-2M"));
const set = PcSet.chroma(transposed); // => "101011010110"
const isSubset = PcSet.isSubsetOf(set);
const chordNames = ChordDictionary.all()
.filter((chord) => isSubset(chord.chroma))
.map((chord) => "D" + chord.aliases[0]);
console.log(chordNames);
This will print:
[
'D5', 'D7#5sus4', 'Dsus4',
'D7sus4', 'Dm#5', 'Dm7#5',
'Dm', 'Dm7', 'D4',
'Dmadd4', 'Dm7add11', 'Dsus2',
'Dsus24', 'D11', 'D9sus4',
'Dm9#5', 'Dmadd9', 'Dm9',
'Dm11A', 'Dm11'
]
If you want all chords for all notes, maybe this:
import { ChordDictionary, Interval, Note, PcSet, Scale } from "tonal";
const notes = ["D3", "A3", "Bb3", "C4", "D4", "E4", "F4", "G4", "A4"];
const uniqueNotes = Scale.scaleNotes(notes);
const chords = uniqueNotes.map((note) => {
const interval = Interval.distance("C", note);
const inverted = Interval.invert(interval);
const transposed = notes.map(Note.trBy(inverted));
const set = PcSet.chroma(transposed);
const isSubset = PcSet.isSubsetOf(set);
return ChordDictionary.all()
.filter((chord) => isSubset(chord.chroma))
.map((chord) => note + chord.aliases[0]);
});
console.log(chords);
This will return a lot of chords:
[
[
'D5', 'D7#5sus4', 'Dsus4',
'D7sus4', 'Dm#5', 'Dm7#5',
'Dm', 'Dm7', 'D4',
'Dmadd4', 'Dm7add11', 'Dsus2',
'Dsus24', 'D11', 'D9sus4',
'Dm9#5', 'Dmadd9', 'Dm9',
'Dm11A', 'Dm11'
],
[
'E7#5sus4', 'Em#5',
'Em7#5', 'Edim',
'Em7b5', 'E4',
'Emb6b9'
],
[
'F5', 'Fsus4',
'FM7sus4', 'FM',
'Fmaj7', 'F6',
'Fsus2', 'Fsus24',
'FM9sus4', 'FMadd9',
'Fmaj9', 'F6add9',
'Fmaj13', 'FM7add13'
],
[
'G5', 'Gsus4', 'G7sus4',
'Gm', 'Gm7', 'Gm6',
'G4', 'Gmadd4', 'Gm7add11',
'Gsus2', 'Gsus24', 'G11',
'G9sus4', 'G13sus4', 'Gmadd9',
'Gm9', 'Gm69', 'Gm13',
'Gm11'
],
[
'A5', 'A7#5sus4',
'Asus4', 'A7sus4',
'Am#5', 'Am7#5',
'Am', 'Am7',
'A4', 'Amadd4',
'Am7add11', 'Ab9sus',
'A11b9', 'A7sus4b9b13',
'Amb6b9'
],
[
'Bb5', 'BbM',
'Bbmaj7', 'Bb6',
'BbMb5', 'BbM7b5',
'Bbmaj#4', 'BbM6#11',
'Bbsus2', 'BbMadd9',
'Bbmaj9', 'Bb6add9',
'Bbmaj13', 'BbM7add13',
'BbM9b5', 'Bbmaj9#11',
'Bb69#11'
],
[
'C5', 'Csus4', 'C7sus4',
'C7no5', 'CM', 'C7',
'C6', 'C7add6', 'Csus2',
'Csus24', 'C11', 'C9sus4',
'C13sus4', 'C9no5', 'C13no5',
'CMadd9', 'C9', 'C6add9',
'C13'
]
]
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Is it possible to query for a list of chords (triads, inversions, etc.) from a set of notes like the following:
"D3", "A3", "Bb3", "C4", "D4", "E4", "F4", "G4", "A4"
These are the notes on a typical Kurd handpan.
Scale.detect will correctly return 'D3 minor'. I can visually detect C Major and D Minor chords, but how can I programmatically locate these chords (and maybe more) using Tonal?
Beta Was this translation helpful? Give feedback.
All reactions