Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Does anyone here know any formal music theory?

Does anyone here know any formal music theory?

Scheduled Pinned Locked Moved The Lounge
question
44 Posts 23 Posters 0 Views 1 Watching
  • 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.
  • H honey the codewitch

    I don't. It's sad I know, esp considering I just delivered a MIDI library unto the world. Anyway, I have a question for a music nerd, and it has to do with key signatures. Googling led me to some confusion. Basically I'm getting my key signature back as an int and a bool together, where the int is range -7 to 7 and the bool indicates minor or major. The int indicates the number of flats (int is negative) or the number of sharps (int is positive) or C if it's 0. Regarding the int, I'm not sure if I'm translating it correctly in code.

    const string FLATS = "FBEADGC";
    const string SHARPS = "GDEABFC";

    if (0 == scode)
    return "C " + (IsMinor ? "minor" : "major");
    if(0>scode)
    return FLATS[((-scode)-1)].ToString() + "b " + (IsMinor ? "minor" : "major");
    else // if(0

    scode is the aforementioned int.

    Real programmers use butterflies

    D Offline
    D Offline
    David ONeil
    wrote on last edited by
    #21

    This is what I came up with after a lot of googling on the 'fifths' that was mentioned earlier. I use it in my MIDI sequencer. I'm relatively sure I got it right, but not absolutely, so if anyone sees anything I've screwed up, feel free to give me hell! :laugh: (And I see I should have used non-caps for some, from another comment!) - edit: fixed

    const KeySignatures::KeySig KeySignatures::keySigsC[] = {
    { "g# min (af min)", 5, true },
    { "g min", -2, true },
    { "f# min", 3, true },
    { "f min", -4, true },
    { "e min", 1, true },
    { "ef min (d# min)", -6, true },
    { "d# min (ef min)", 6, true },
    { "d min", -1, true },
    { "c# min (df min (unused))", 4, true },
    { "c min", -3, true },
    { "b min", 2, true },
    { "bf min (a# min)", -5, true },
    { "a# min (bf min)", 7, true },
    { "a min", 0, true },
    { "af min (g# min)", -7, true },
    { "Af Maj", -4, false },
    { "A Maj", 3, false },
    { "Bf Maj", -2, false },
    { "B Maj (Cf Maj)", 5, false },
    { "Cf Maj (B Maj)", -7, false },
    { "C Maj", 0, false },
    { "C# Maj (Df Maj)", 7, false },
    { "Df Maj (C# Maj)", -5, false },
    { "D Maj", 2, false },
    { "Ef Maj", -3, false },
    { "E Maj", 4, false },
    { "F Maj", -1, false },
    { "F# Maj (Gf Maj)", 6, false },
    { "Gf Maj (F# Maj)", -6, false },
    { "G Maj", 1, false }
    };

    The forgotten roots of science | C++ Programming | DWinLib

    R 1 Reply Last reply
    0
    • K kalberts

      I guess that even a piano would turn into a forte, or forte fortissimo molto, so you for practical purposes you are right. You could also point out the accelerando - close to 9.8 m/s2. But we were talking scales, weren't we?

      Greg UtasG Offline
      Greg UtasG Offline
      Greg Utas
      wrote on last edited by
      #22

      Accelerando? :laugh:

      Robust Services Core | Software Techniques for Lemmings | Articles

      <p><a href="https://github.com/GregUtas/robust-services-core/blob/master/README.md">Robust Services Core</a>
      <em>The fox knows many things, but the hedgehog knows one big thing.</em></p>

      1 Reply Last reply
      0
      • D David ONeil

        This is what I came up with after a lot of googling on the 'fifths' that was mentioned earlier. I use it in my MIDI sequencer. I'm relatively sure I got it right, but not absolutely, so if anyone sees anything I've screwed up, feel free to give me hell! :laugh: (And I see I should have used non-caps for some, from another comment!) - edit: fixed

        const KeySignatures::KeySig KeySignatures::keySigsC[] = {
        { "g# min (af min)", 5, true },
        { "g min", -2, true },
        { "f# min", 3, true },
        { "f min", -4, true },
        { "e min", 1, true },
        { "ef min (d# min)", -6, true },
        { "d# min (ef min)", 6, true },
        { "d min", -1, true },
        { "c# min (df min (unused))", 4, true },
        { "c min", -3, true },
        { "b min", 2, true },
        { "bf min (a# min)", -5, true },
        { "a# min (bf min)", 7, true },
        { "a min", 0, true },
        { "af min (g# min)", -7, true },
        { "Af Maj", -4, false },
        { "A Maj", 3, false },
        { "Bf Maj", -2, false },
        { "B Maj (Cf Maj)", 5, false },
        { "Cf Maj (B Maj)", -7, false },
        { "C Maj", 0, false },
        { "C# Maj (Df Maj)", 7, false },
        { "Df Maj (C# Maj)", -5, false },
        { "D Maj", 2, false },
        { "Ef Maj", -3, false },
        { "E Maj", 4, false },
        { "F Maj", -1, false },
        { "F# Maj (Gf Maj)", 6, false },
        { "Gf Maj (F# Maj)", -6, false },
        { "G Maj", 1, false }
        };

        The forgotten roots of science | C++ Programming | DWinLib

        R Offline
        R Offline
        Ron Anders
        wrote on last edited by
        #23

        Free Bird!!!

        1 Reply Last reply
        0
        • H honey the codewitch

          I don't. It's sad I know, esp considering I just delivered a MIDI library unto the world. Anyway, I have a question for a music nerd, and it has to do with key signatures. Googling led me to some confusion. Basically I'm getting my key signature back as an int and a bool together, where the int is range -7 to 7 and the bool indicates minor or major. The int indicates the number of flats (int is negative) or the number of sharps (int is positive) or C if it's 0. Regarding the int, I'm not sure if I'm translating it correctly in code.

          const string FLATS = "FBEADGC";
          const string SHARPS = "GDEABFC";

          if (0 == scode)
          return "C " + (IsMinor ? "minor" : "major");
          if(0>scode)
          return FLATS[((-scode)-1)].ToString() + "b " + (IsMinor ? "minor" : "major");
          else // if(0

          scode is the aforementioned int.

          Real programmers use butterflies

          R Offline
          R Offline
          Rich Leyshon
          wrote on last edited by
          #24

          Maybe it's just a typo, but you have two of the major keys transposed (bad choice of words maybe in this context!) Line 2 SHARPS should be "GDAEBFC" However, there are bigger problems! This code will return mostly wrong answers. If we look at the sharps only, your code (assume it's major) would return: C, G# major, D# major, A# major ... which is incorrect. The correct sequence (without all the "majors" shown) would be: C G D A E B F# C# And a sort of reverse applies situation applies to the flats. (C), F, Bb, Eb, Ab, Db, Gb, Cb Hope that helped!

          1 Reply Last reply
          0
          • H honey the codewitch

            I don't. It's sad I know, esp considering I just delivered a MIDI library unto the world. Anyway, I have a question for a music nerd, and it has to do with key signatures. Googling led me to some confusion. Basically I'm getting my key signature back as an int and a bool together, where the int is range -7 to 7 and the bool indicates minor or major. The int indicates the number of flats (int is negative) or the number of sharps (int is positive) or C if it's 0. Regarding the int, I'm not sure if I'm translating it correctly in code.

            const string FLATS = "FBEADGC";
            const string SHARPS = "GDEABFC";

            if (0 == scode)
            return "C " + (IsMinor ? "minor" : "major");
            if(0>scode)
            return FLATS[((-scode)-1)].ToString() + "b " + (IsMinor ? "minor" : "major");
            else // if(0

            scode is the aforementioned int.

            Real programmers use butterflies

            S Offline
            S Offline
            Steve A Lee
            wrote on last edited by
            #25

            Hi, I'm not sure what language the pretty generic C-style code is in but I guess it's not Javascript as ToString is Pascal case. Anyway, this JS library is brilliant for accessing musical theory in code.

            H 1 Reply Last reply
            0
            • G giulicard

              Accelerando - Conjugation of the infinite "Accelerare" in italian; In English, "to accelerate": The "Gerundio" (a form of the verb), is like the -ing in English. Most of the musical notation currently used was invented in Italy many centuries ago (even the pentagram, for example). In Italy the musical notes are represented by syllables which traditionally are: DO, RE, MI, FA, SOL, LA, SI with LA to be the equivalent to A in international notation. All words like crescendo, diminuendo, piano, pianissimo, etc. etc. they are Italian words used as an international jargon for the music.

              K Offline
              K Offline
              kalberts
              wrote on last edited by
              #26

              I wouldn't call it "international jargon for the music", but "established notational conventions". You'll see acc. in all sorts of sheet music. It has been used for centuries. We had a conductor that took pleasure in playing with such terms, like he could ask for an "accelerandissimo" - a small increase in the beat rate. Or "acelerando moltissimo", not a very strong accelerando (like an "accelerando molto") but above average.

              G 1 Reply Last reply
              0
              • H honey the codewitch

                I don't. It's sad I know, esp considering I just delivered a MIDI library unto the world. Anyway, I have a question for a music nerd, and it has to do with key signatures. Googling led me to some confusion. Basically I'm getting my key signature back as an int and a bool together, where the int is range -7 to 7 and the bool indicates minor or major. The int indicates the number of flats (int is negative) or the number of sharps (int is positive) or C if it's 0. Regarding the int, I'm not sure if I'm translating it correctly in code.

                const string FLATS = "FBEADGC";
                const string SHARPS = "GDEABFC";

                if (0 == scode)
                return "C " + (IsMinor ? "minor" : "major");
                if(0>scode)
                return FLATS[((-scode)-1)].ToString() + "b " + (IsMinor ? "minor" : "major");
                else // if(0

                scode is the aforementioned int.

                Real programmers use butterflies

                U Offline
                U Offline
                User 13554759
                wrote on last edited by
                #27

                SHARPS string is wrong. Should be GDAEBFC. Otherwise looks good

                1 Reply Last reply
                0
                • K kalberts

                  I wouldn't call it "international jargon for the music", but "established notational conventions". You'll see acc. in all sorts of sheet music. It has been used for centuries. We had a conductor that took pleasure in playing with such terms, like he could ask for an "accelerandissimo" - a small increase in the beat rate. Or "acelerando moltissimo", not a very strong accelerando (like an "accelerando molto") but above average.

                  G Offline
                  G Offline
                  giulicard
                  wrote on last edited by
                  #28

                  Member 7989122 wrote:

                  acelerando moltissimo

                  Accelerando, not acelerando always put double 'c' the correct form in italian.

                  K 1 Reply Last reply
                  0
                  • Greg UtasG Greg Utas

                    I just realized this is probably regional. Maybe you do it that way in Norway. I have some Le Orme sheet music, and those weird Italians don't write A minor as "a" or "Am". They actually write "La m" (La from do-re-mi... and m = minore). I rarely think in solfege. And if I do, it's relative: "la" = submediant (^6). But they use it absolutely: "la" = A, regardless of the key. Needless to say, I find their annotations useless.

                    Robust Services Core | Software Techniques for Lemmings | Articles

                    G Offline
                    G Offline
                    giulicard
                    wrote on last edited by
                    #29

                    Accelerando - Conjugation of the infinite "Accelerare" in italian; In English, "to accelerate": The "Gerundio" (a form of the verb), is like the -ing in English. Most of the musical notation currently used was invented in Italy many centuries ago (even the pentagram, for example). In Italy the musical notes are represented by syllables which traditionally are: DO, RE, MI, FA, SOL, LA, SI with LA to be the equivalent to A in international notation. All words like crescendo, diminuendo, piano, pianissimo, etc. etc. they are Italian words used as an international jargon for the music.

                    K 1 Reply Last reply
                    0
                    • H honey the codewitch

                      I don't. It's sad I know, esp considering I just delivered a MIDI library unto the world. Anyway, I have a question for a music nerd, and it has to do with key signatures. Googling led me to some confusion. Basically I'm getting my key signature back as an int and a bool together, where the int is range -7 to 7 and the bool indicates minor or major. The int indicates the number of flats (int is negative) or the number of sharps (int is positive) or C if it's 0. Regarding the int, I'm not sure if I'm translating it correctly in code.

                      const string FLATS = "FBEADGC";
                      const string SHARPS = "GDEABFC";

                      if (0 == scode)
                      return "C " + (IsMinor ? "minor" : "major");
                      if(0>scode)
                      return FLATS[((-scode)-1)].ToString() + "b " + (IsMinor ? "minor" : "major");
                      else // if(0

                      scode is the aforementioned int.

                      Real programmers use butterflies

                      T Offline
                      T Offline
                      t j home
                      wrote on last edited by
                      #30

                      Hi HtC What you really need is an appreciation of the Circle of Fifths - check through to Circle of fifths - Wikipedia[^]

                      1 Reply Last reply
                      0
                      • H honey the codewitch

                        I don't. It's sad I know, esp considering I just delivered a MIDI library unto the world. Anyway, I have a question for a music nerd, and it has to do with key signatures. Googling led me to some confusion. Basically I'm getting my key signature back as an int and a bool together, where the int is range -7 to 7 and the bool indicates minor or major. The int indicates the number of flats (int is negative) or the number of sharps (int is positive) or C if it's 0. Regarding the int, I'm not sure if I'm translating it correctly in code.

                        const string FLATS = "FBEADGC";
                        const string SHARPS = "GDEABFC";

                        if (0 == scode)
                        return "C " + (IsMinor ? "minor" : "major");
                        if(0>scode)
                        return FLATS[((-scode)-1)].ToString() + "b " + (IsMinor ? "minor" : "major");
                        else // if(0

                        scode is the aforementioned int.

                        Real programmers use butterflies

                        D Offline
                        D Offline
                        Dan Neely
                        wrote on last edited by
                        #31

                        The closest I've came was writing a few measures of "music" containing abominations like 4096th notes, and notes with a half dozen dots in a highschool class to spite a teacher I disliked. (It was trivial - if a bit tedious - to create iteratively by splitting notes in half and inserting the new one randomly, far harder for the teacher to actually add up to make sure it actually had the correct total. :-\ )

                        Did you ever see history portrayed as an old man with a wise brow and pulseless heart, weighing all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt

                        1 Reply Last reply
                        0
                        • S Steve A Lee

                          Hi, I'm not sure what language the pretty generic C-style code is in but I guess it's not Javascript as ToString is Pascal case. Anyway, this JS library is brilliant for accessing musical theory in code.

                          H Offline
                          H Offline
                          honey the codewitch
                          wrote on last edited by
                          #32

                          it's C#.. oooh and thank you. I'll take a look

                          Real programmers use butterflies

                          1 Reply Last reply
                          0
                          • K kalberts

                            Or learn German (or a related language, such as Norwegian): In the Germanic tradition, B is called H, and B flat is called B. In any case, it will be less confusing if you use a true musical ♭ sign for the flats, rather than a plain lowercase b letter. B♭ and b♭ isn't that confusing. Bonus joke: What could you get if you drop a piano down a mine shaft? Answer: a♭

                            J Offline
                            J Offline
                            Jim Kolb 0
                            wrote on last edited by
                            #33

                            What could you get if you drop a piano down a mine shaft?

                            ab minor (miner)

                            K 1 Reply Last reply
                            0
                            • H honey the codewitch

                              I don't. It's sad I know, esp considering I just delivered a MIDI library unto the world. Anyway, I have a question for a music nerd, and it has to do with key signatures. Googling led me to some confusion. Basically I'm getting my key signature back as an int and a bool together, where the int is range -7 to 7 and the bool indicates minor or major. The int indicates the number of flats (int is negative) or the number of sharps (int is positive) or C if it's 0. Regarding the int, I'm not sure if I'm translating it correctly in code.

                              const string FLATS = "FBEADGC";
                              const string SHARPS = "GDEABFC";

                              if (0 == scode)
                              return "C " + (IsMinor ? "minor" : "major");
                              if(0>scode)
                              return FLATS[((-scode)-1)].ToString() + "b " + (IsMinor ? "minor" : "major");
                              else // if(0

                              scode is the aforementioned int.

                              Real programmers use butterflies

                              M Offline
                              M Offline
                              Member_5893260
                              wrote on last edited by
                              #34

                              It's not right: major and minor keys have different numbers of sharps or flats. For example, while B major has 5 sharps: C#, D#, F#, G#, A#, B minor has a D natural, and then, if it's a harmonic minor, a G natural; if it's a melodic minor, a G# and A# for an ascending scale, whereas both those are natural for a descending scale. Minor keys are tricky: there's no fixed answer. More here: musictheory.net[^]

                              1 Reply Last reply
                              0
                              • H honey the codewitch

                                I don't. It's sad I know, esp considering I just delivered a MIDI library unto the world. Anyway, I have a question for a music nerd, and it has to do with key signatures. Googling led me to some confusion. Basically I'm getting my key signature back as an int and a bool together, where the int is range -7 to 7 and the bool indicates minor or major. The int indicates the number of flats (int is negative) or the number of sharps (int is positive) or C if it's 0. Regarding the int, I'm not sure if I'm translating it correctly in code.

                                const string FLATS = "FBEADGC";
                                const string SHARPS = "GDEABFC";

                                if (0 == scode)
                                return "C " + (IsMinor ? "minor" : "major");
                                if(0>scode)
                                return FLATS[((-scode)-1)].ToString() + "b " + (IsMinor ? "minor" : "major");
                                else // if(0

                                scode is the aforementioned int.

                                Real programmers use butterflies

                                D Offline
                                D Offline
                                destynova
                                wrote on last edited by
                                #35

                                Not sure if this was already mentioned in one of the other responses, but you have E and A in the wrong order for the sharp key signatures. A has 3 and E has 4. I learned the sequence of sharps (aka circle of fifths) back in piano classes many years ago as "Father Charles Goes Down And Ends Battle". Conveniently, you can reverse the phrase to get the order of flats (ie circle of fourths) and it still makes sense.

                                1 Reply Last reply
                                0
                                • J Jim Kolb 0

                                  What could you get if you drop a piano down a mine shaft?

                                  ab minor (miner)

                                  K Offline
                                  K Offline
                                  kalberts
                                  wrote on last edited by
                                  #36

                                  or to make it more explicit: A flat minor (/miner)

                                  1 Reply Last reply
                                  0
                                  • G giulicard

                                    Member 7989122 wrote:

                                    acelerando moltissimo

                                    Accelerando, not acelerando always put double 'c' the correct form in italian.

                                    K Offline
                                    K Offline
                                    kalberts
                                    wrote on last edited by
                                    #37

                                    Sure. A pure typo on my part!

                                    1 Reply Last reply
                                    0
                                    • Greg UtasG Greg Utas

                                      The flat key signatures go F, Bb, Eb, Ab, Db, Gb, Cb. The sharp key signatures go G, D, A, E, B, F#, C#. EDIT: That's major. No sharps/flats = C. The minor flat key signatures go D, G, C, F, Bb, Eb, Ab. The minor sharp key signatures go E, B, F#, C#, G#, D#, A#. No sharps/flats = A. But that's just major/minor. Then there's Dorian, Phrygian, and others. :laugh:

                                      Robust Services Core | Software Techniques for Lemmings | Articles

                                      J Offline
                                      J Offline
                                      Jeffrey McLellan
                                      wrote on last edited by
                                      #38

                                      I think you may have a typo in the sharp key signatures. I think it should be G, D, A, E, B, F#, C#. That's the way the circle of fifths works. I'm definitely a novice at this stuff.

                                      Greg UtasG 1 Reply Last reply
                                      0
                                      • J Jeffrey McLellan

                                        I think you may have a typo in the sharp key signatures. I think it should be G, D, A, E, B, F#, C#. That's the way the circle of fifths works. I'm definitely a novice at this stuff.

                                        Greg UtasG Offline
                                        Greg UtasG Offline
                                        Greg Utas
                                        wrote on last edited by
                                        #39

                                        Thanks. I've fixed it.

                                        Robust Services Core | Software Techniques for Lemmings | Articles

                                        <p><a href="https://github.com/GregUtas/robust-services-core/blob/master/README.md">Robust Services Core</a>
                                        <em>The fox knows many things, but the hedgehog knows one big thing.</em></p>

                                        1 Reply Last reply
                                        0
                                        • K kalberts

                                          There is a strong tradition for denoting major scales with uppercase letters, and minor scales with lowercase letters. So, The minor flat key signatures go d, g, c, f, bb, eb, ab. The minor sharp key signatures go e, b, f#, c#, g#, d#, a#. No sharps/flats = a. Maybe this tradition is stronger in some musical styles than others. I have never seen guitar chord annotations where it is not followed.

                                          M Offline
                                          M Offline
                                          MadtM
                                          wrote on last edited by
                                          #40

                                          I think there's some potential for confusion here. Regarding key signatures in scores: A score with one sharp is traditionally interpreted to be either G major or E minor. There is no other indication of whether or not the key signature implies G major or E minor unless it is included in the title such as "Polonaise in Ab Minor." (I say traditional because there are non-traditional scoring methods too.) Regarding chords, there are a variety of ways to show chords in a score. For example, a C minor chord can be designated as Cm or C-. A G major 7 can be GMAJ or G^. And so on. Now 7989122's comment about major/minor scales is interesting to me. I've never used a score that does it that way, but it makes sense on a certain level. I don't need that sort of notation in my arranging, but hey, maybe I've learned something new. If you sign up with the Sonic Scores forum (no affiliation) you can ask questions and get a lot of helpful answers from professional musicians. They also know a lot about MIDI. There are other music notation apps that have active forums.

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups