saebekassebil / teoria

Javascript taught Music Theory
http://saebekassebil.github.io/teoria
MIT License
1.31k stars 114 forks source link

Chords in the key of a note #106

Open ishmangit opened 8 years ago

ishmangit commented 8 years ago

Hi to all!, I'm very impressed with the possibilities of this library. However I'm wondering if it's possible to obtain the chords in the key of a certain note.

Sorry in advance if I missed something in the documentation...

saebekassebil commented 7 years ago

Hey, thanks for the interest!

It's definitely possible. Create a note, create a scale from that note (major, minor, whatever), and map over all the notes in the scale, creating chords by just selecting every other note in the scale array.

C,D,E,F,G,A,B
^---^---^---- = C, E, G = C major

C,D,E,F,G,A,B
--^---^---^-- = D, F, A = D minor

etc.

Makes sense?

Walther commented 6 years ago

This could be useful, perhaps in combination with some chord degree notation (e.g. ii, V, I) getters.

In addition to the triads, ability to get the common tetrads for the scale - e.g. in a major key, Maj7, m7, m7, Maj7, 7, m7, m7b5 - as Chord objects.

saebekassebil commented 6 years ago

I’m convinced that this would Indeed be quite useful. A get method on the Scale object. About the naming of it, I’m not completely sure though. Scale#getChord?

Anyway, this should be pretty straight-forward to implement, and you are more than welcome to give it a try :) Sadly I dont have time for more than maintaining at the moment.

//j

Den 20. okt. 2017 kl. 18.00 skrev Veeti Haapsamo notifications@github.com:

This could be useful, perhaps in combination with some chord degree notation (e.g. ii, V, I).

Additionally, automatically generate the common tetrads for the scale - e.g. in a major key, Maj7, m7, m7, Maj7, 7, m7, m7b5 - as Chord objects.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

Walther commented 6 years ago

We could have a function aScale.getChord(degree [, tones]) which would return a chord at the degree:th position on the scale, defaulting to a triad, optionally returning a tones polyad.

A use case could look like this:

let c4 = teoria.Note("c4");
let cIonian = c4.scale("ionian");
let iiTriad = cIonian.getChord(2); // D minor
let iiTetrad = cIonian.getChord(2, 4); // Dm7
let iiPentad = cIonian.getChord(2, 5); // Dm7(add9)

A naive implementation could indeed just pick every other note of the scale, starting at the right root, and pick the required amount of notes (triad, tetrad, pentad...). Simple!

However, it's actually a lot more complicated. Consider for example the A minor scale. With this method, the in-key chords would include Am at i and Em7 at V - however, in modern popular music, it's much more common to use E7 as the V7 in a minor key.

In addition, a naive implementation like this would result in rather curious chord voicings for non-diatonic scales, like the chromatic 😄


It might be the easiest just to take the degree:th note of a key and declare the chord quality manually, something like let ii7 = teoria.Chord(cIonian.getNoteAtDegree("ii"), "m7"). This degree-based getting could facilitate various chord substitutions, for example that dom7 instead of m7 in a minor key, or getting a bII7 (common tritone substitution for a V7 in jazz), with the end user not having to think about how to compute the required Db7 - where Db as a note doesn't even belong in C major scale.

Then again this might require a whole new concept Key in addition to Scale... Which could be a fun project to do!