This is fine for simple cases such as "all sharps", "all flats" etc, but not adequate for how notes are typically spelled in scores and parts.
For this we need to formalize rules such as:
If this is an upward or downward chromatic sequence, use only flats/sharps (depending on direction)
If one note is a leading or passing note, make it a diatonic step lower/higher than its successor (even if this means writing an unusual accidental)
If this note is part of a chord, assure that the diatonic intervals are readable (i.e. in c# major chord, use e# rather than f, in ab minor use cb rather than b etc).
I am not sure how to model "note context". Maybe something similar to the Ctxt functor:
type Spelling = ([Semitones], Semitones, [Semitones]) -> Number
this can be used for both vertical and horizontal context.
Promlems:
How to weight the various context.
How to resolve recursive dependencies, i.e. to spell note A we need to have the spelling its neighbour B, but to spell B we need the spelling of A. Investigate automatons/L-systems etc.
The current definition of spelling is simply
This is fine for simple cases such as "all sharps", "all flats" etc, but not adequate for how notes are typically spelled in scores and parts.
For this we need to formalize rules such as:
I am not sure how to model "note context". Maybe something similar to the
Ctxt
functor:this can be used for both vertical and horizontal context.
Promlems: