Closed henryksloan closed 4 years ago
I came here to finally take care of this just now and it's already been done! Thanks!
That's super cool @henryksloan!
Left some comments for the pitch
function and an arbitrary number of accidentals support.
Let me know what you think! 💪
@ozankasikci good points, all done! I removed that pitch
function. As for multiple accidentals, I added support for an arbitrary number of accidentals of the same type, i.e. C##x
returns Some(Pitch {letter: C, accidental: 4})
, because sharp+sharp+double sharp = 4. That kind of thing is not uncommon when representing higher-order accidentals. I return None
when flats and sharps are combined, like in C#b
.
I also extended REGEX_PITCH
to allow multiple accidentals. The regex now accepts any number of accidents. I think it would be unnecessarily complex to encode the no-mixing constraint into a regex, especially since Rust's built-in regexes don't support backreferencing.
Original PR is #15 by @jagen31
On top of #15, this PR:
Changes from
master
NoteLetter
: A, B, C, etc. Just the letters of the white keys on a pianoPitch
: A note letter and an accidentalPitchSymbol
, an enum { Cb, C, Cs, Db...} convertible to Pitch for code brevityNote
wraps aPitch
with an octaveSome notes going forward (pun intended)
Cb
breaks everything as a result of the current design of integer conversionsC4
is flatted, does it produceCb4
orCb3
. It's enharmonic toB3
but relative toC
. Either solution brings up some dependency questions.@ozankasikci tests run perfectly, but the actual test code and style consistency could use a good lookover