Forum

    • Register
    • Login
    • Search
    • Categories

    How to chose accidentals?

    Scripting Forum
    2
    3
    49
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ulrik
      ulrik last edited by

      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

      Hise Develop branch
      MacOs 13, Xcode 14.0.1
      http://musikboden.se

      1 Reply Last reply Reply Quote 0
      • Christoph Hart
        Christoph Hart last edited by

        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("#");
        }
        
        ulrik 1 Reply Last reply Reply Quote 1
        • ulrik
          ulrik @Christoph Hart last edited by ulrik

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

          Hise Develop branch
          MacOs 13, Xcode 14.0.1
          http://musikboden.se

          1 Reply Last reply Reply Quote 0
          • First post
            Last post

          16
          Online

          982
          Users

          6.6k
          Topics

          60.8k
          Posts