How to chose accidentals?



  • I have an app for playing and visualising different music scales and patterns of these scales.
    It automatically transpose the scales depending on my start note.
    So if I've chosen the ionian scale and play the tone C it will display the scale on the GUI keyboard and also write out the note names, if I chose Eb (D#) it will always display all accidentals as sharps (because I use the inbuilt noteNumber2noteName function), but what if I want to display the scale as an E flat ionian scale, do you have any suggestions how I should implement this function?
    Any tip is valuable!

    scalemodes.gif



  • Maybe use different note names and then check for each note if it should print a # or a b like this:

    
    const var flatNames = ["C", "Db", "D", ...];
    const var sharpNames = ["C", "C#", "D", ...];
    
    inline function getNoteName(noteNumber, isFlatScale)
    {
        return isFlatScale ? flatNames [noteNumber % 12] : 
                             sharpNames[noteNumber % 12];
    }
    
    inline function isSharpNote(noteName)
    {
        return noteName.contains("#");
    }
    


  • @Christoph-Hart thank you, it looks like a great idea! 🙂


Log in to reply
 

10
Online

1.3k
Users

4.2k
Topics

38.3k
Posts