I'm writing something that's basically in C but mixes in Cm quite a bit. I'm entering notes via midi. Two examples of where I'm running into bad accidentals and I think the machine should know better:
1) A melodic line that goes C–Bb–Ab–(Bb) is spelled C–Bb–G#.
2) An Ab major chord's default spelling is C, Eb, G#.
I'm not sure if accidental spellings are chosen based on key or based on context.
In the former case, I think in major, lowered spellings should be more common except in the case of #4 vs b5, and in minor, raised spellings more common, except in the case of #1 vs b2.
In the latter case, I think spellings that avoid diminished/augmented intervals should be preferred.
Asst Prof of Music Theory