Closed henryksloan closed 4 years ago
That's great, another very much needed feature!
I'll review this ASAP :)
Great work.
I'd like to address an issue, although C/E
is the universal notation to represent the first inversion, I think we should implement C/1
as well. That's because the former entails the user to know all the notes of the given chord while the latter is just intuitive.
Let me know what you think!
@ozankasikci Good idea, done! I had that same idea for numerical syntax, but I thought it might be a bit obscure. I added it, along with an extra example in the chords help
message, so I think it's a good solution.
Awesome, thanks! Merging :)
Executable
C major triad / E
is C major in first inversionfrom_regex
functions, soC/E
andC major /E
give the same result as the abovechord help
chord.rs
inversion: u8
toChord
with_inversion
, and madenew
construct a root-position chord by defaultchord_intervals
into its own function, giving the intervallic layout of a chordfrom_regex
/
in the input, and if so, treats everything after the slash as aPitchClass
PitchClass::from_regex
, so it is error-safeimpl Notes for Chord
generates the notes of the root position chord, rotates them based on the inversion number, and corrects the octaves such that they 1) are non-decreasing and 2) start atself.octave
test_chord.rs
test_all_chords_in_c
now generates and tests all inversions of each chord type on Ctest_inversion_octaves
tests against hard-coded octave lists for every inversion of a G major ninth chordCaveat: There is no standard (to my knowledge) for voicing inverted chords beyond the octave, i.e. placing
G
inG major 9 / B
. For this reason (and to maximize simplicity and flexibility), my implementation enforces a non-decreasing order;G major 9 = B4 D5 F#5 A5 G6