I'm creating a scale visualiser (JavaScript based website) for guitar. I recently updated so it will use "correct" enharmonics e.g. major scales it will default to "Bb" tonic rather than "A#" because there's less accidentals.
But currently it's the same rules for all scales and modes, including harmonic major and harmonic & melodic minor scales and modes... It just calculates the least number of accidentals and ensures there's only one letter for each note.
So question is for example: (excuse my terminology) if A# major scale is "Db", should something like the "altered dominant bb7" scale (7th mode of harmonic minor) also be built in Db? Because if so, technically it then would have more flats that sharps (compared to if I built it from A#)
Because this is a project where i want to do all this programmatically (i.e. there's no fun in me just doing it based on a big table of information) then I'm looking for the "best option that makes logical sense that I can easily code".
My best guess is "check if the third is major or minor, then base it off the same enharmonic as the major or minor key"?
[Edit:] So based on responses I've hopefully settled on a design that satisfies the majority of users, and doesn't completely devastate the music theory experts (oh which I am in awe of, and thanks everyone for your detailed answers and comments).
I think key thing I've learnt (excuse the pun) is both enharmonic options are just as valid in different contexts, i.e. there's no set rule to automatically select one over the other. And obviously 7 note scales should have one of each letter. There seems conjecture over the rule "minimum symbols", but I think for users of my tool, that option will be nice. By extension, if there's no "default" option, then comparing to "default for Major scale" may be non-sensical... but Im keeping that option for now.
For seven note scales I have three options for enharmonics in top dasboard (you'll need to be on a wide enough device to see the buttons):
Manual: you can now drop the note to the left or right side of the same "spot" to set the enharmonic (i.e. just after previous fret = A#, just before next fret = Bb). So "manual" mode just displays scales built from that "drop note"
Auto: this uses whatever has the fewer amount of symbols regardless of where you dropped the note (but that information is retained if you want to switch back to manual mode). The tool doesn't work very well with more than one sharp or flat especially (i.e. not much space on a dot): so this is probably going to be the most comman use
Parallel Major: this uses the same enharmonic that the parallel Major does (assuming that's also based on minimum symbols)