HISE Logo Forum
    • Categories
    • Register
    • Login

    How to chose accidentals?

    Scheduled Pinned Locked Moved Scripting
    3 Posts 2 Posters 142 Views
    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.
    • ulrikU
      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 15.3.1, Xcode 16.2
      http://musikboden.se

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

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

          Hise Develop branch
          MacOs 15.3.1, Xcode 16.2
          http://musikboden.se

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

          45

          Online

          1.7k

          Users

          11.7k

          Topics

          102.3k

          Posts