-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Transposing chords by a number of semitones #83
Comments
Hi Louis, thanks for writing! Well, you don't "misunderstand" how intervals work - it's just that they're ambiguous in music theory. You could argue that you can't hear any difference, but there are several intervals that represent the same amount of semitones (in western equal temperament). E.g. A "major" third and a "diminished fourth" "contains" the same amount of semitones, but are theoretically different. Anyways. I'd probably do it in a different way, since it seems that you don't care whether you get a "C#" or a "Db". What about transposing the root by key number? var root = teoria.note('E');
var chordE7 = teoria.chord(root, '7');
var chordF7 = teoria.note.fromKey(root.key() + 1).chord(chordE.symbol)
var chordG7 = teoria.note.fromKey(chordF.root.key() + 2).chord(chordF.symbol)
// general function
function transposeChord(chord, semitones) {
return teoria.note.fromKey(chord.root.key() + semitones).chord(chord.symbol)
} Here I'm just reusing the |
Much better! However, I'm having issues with slashed chords. Should the expected behavior be such that the bass note remains the same when a slashed chord is transposed? For instance: var transposed_DF = transposeChord(teoria.chord('D/F'), 1);
console.log(transposed_DF.name); // "Eb/F"
console.log(transposed_DF.symbol); // "/F" Shouldn't the transposed chord actually be Note: using |
Yes it should - an oversight :) |
(Whoops, didn't mean to close the issue there) I'd be happy to write some tests for these edge-cases if that helps! |
Yes please do! It might need some rethinking on how we handle "slash chords". My initial thought is if the voicing doesn't have the root in voiced lowest, then display as a "/ chord", and don't let the slash be part of the |
Closing this instead of #92 |
I'm creating a simple ukulele composition tool and need a way to transpose chords by a numerical offset in semitones (this is common in lots of tablature sites/apps).
In order to transpose a
Chord
, you must pass anInterval
object to the.transpose
or.interval
method, but I don't know how to create such anInterval
that correctly represents the operation I'm trying to achieve.I'm not very familiar with music theory, but I determined that I can achieve this with a lookup table of interval names that achieve what I want:
This seems to work, but feels sloppy. What would you suggest? Personally, I'd love it if
.transpose
/.interval
could simply take an integer value, but I'm probably misunderstanding something about how intervals work.The text was updated successfully, but these errors were encountered: