[HN Gopher] Basic Music Theory in ~200 Lines of Python
       ___________________________________________________________________
        
       Basic Music Theory in ~200 Lines of Python
        
       Author : mvanga
       Score  : 398 points
       Date   : 2021-04-19 07:18 UTC (15 hours ago)
        
 (HTM) web link (www.mvanga.com)
 (TXT) w3m dump (www.mvanga.com)
        
       | adamnemecek wrote:
       | I've been working on an IDE for music composition and I like to
       | think that I nailed the UI.
       | 
       | Launching soon http://ngrid.io.
        
       | muyanapar wrote:
       | Love this article, i really enjoyed reading the code and now i
       | want to reproduce it.
        
       | codeulike wrote:
       | This is great but if we could go back in time and influence the
       | naming conventions so that the 12 semitones were called A-L or
       | just numbered 1 to 12, and if the intervals were named after the
       | actual semitone distance (a 'fifth' is actually seven semitones)
       | the whole thing would be soooo much less jargonny. With all that
       | bumf removed, the patterns of the 'scales' and 'chords' would be
       | foregrounded and thats the actually interesting bit IMHO (the bit
       | defined as 'formulas = {..}' in the article)
        
         | keymasta wrote:
         | I'm too excited not to comment on here specifically, although I
         | have another comment in this thread already. I made a proposal
         | for this in my book which isn't out yet but basically I'm using
         | only consonants for these.. so that I can link a vowel for a
         | separate encoding.. so in order of notes where their set
         | notation is 0 1 2 3 4 5 6 7 8 9 10 11, B D F G J K L M N P R S.
         | 
         | It's an idea, and possibly somewhat arbitrary, but it's a
         | proposal at least and it will connect to other things well due
         | to uniformity. Then there's my python code which takes a
         | scale.. and writes nonsense with shakespeare verse using words
         | beginning with the letters that spell them. Then words can be
         | used to learn melodies.
         | 
         | But what I was really thinking about more is like depending on
         | the vowel after that letter you will form different chord
         | qualities.. The first most important being the unison, or 'a'..
         | so to play a major scale with single notes you would say Ba Fa
         | Ja Ka Ma Pa Sa.
         | 
         | But to say the seventh chords that the major scale implies
         | you'd say: BatEk FabEt JabEt KaTEk MatEt PabEt Sabat, which
         | would be a a way of saying: DMa7 Emi7 F#mi7 GMa7 A7 Bmi7 C#[?]
         | - but way less syllables
         | 
         | [?] is pronounced "half diminished" or "half diminished
         | seventh" which is a mi7(5) which would be pronounced "minor
         | seven flat five" for those who don't know.
         | 
         | The insanity of modern music theory is the superimposition of
         | the number 7 (A B C D E F G) onto the number 12 (the number of
         | notes).. everything in the system is skewed by this fundamental
         | wonky shape. But I'll remind everyone that 12/2=6 and 12/3=4
         | and from these facts more logical systems can be envisioned, as
         | opposed what's 12 notes with 7 names. 12/7=? A number that
         | seems not to have relevance to the comprehension of music
         | patterns.. BESIDE the fact we are forced to think like that
         | with things that conform to 12/7 like sheet music, note names,
         | or piano key locations...
         | 
         | But nature and even a guitar fretboard has less concept of the
         | obsession with the number 7 by design.
        
           | bazeblackwood wrote:
           | I've been working on a fixed chromatic solfege system
           | (MaNePu) for a while as well. It uses a repeating vowel
           | pattern which I find produces some really interesting
           | effects. In MaNePu, the chromatic scale is ma - ne - pu - qa
           | - re - su - ta - ve - wu - xa - ye - zu. In other words,
           | consonants starting with M til the end of the alphabet, and
           | rotating through the vowel sounds "ah", "ee", and "ooh".
           | What's neat about this is that the pattern repeats every
           | minor third, so that means every diminished scale internally
           | rhymes! Similarly, transposing any melody by a minor third
           | will also result in a melody that rhymes with the former.
           | Likewise, either whole tone scale will result in a reversal
           | of the vowel pattern. There are other fixed chromatic solfege
           | systems that use an alternating vowel pattern, but MaNePu is
           | the only one that uses a minor third rotation (the others
           | I've seen typically alternate by whole tone), and I think it
           | opens up some interesting avenues for music education.
           | 
           | I like your shortened chord quality convention, though MaNePu
           | takes a different tack. Instead, it favors what I call
           | "descriptive chord naming". Instead of being prescriptive
           | about the quality, a chord is simply described by appending
           | the notes contained within it. This is great because it also
           | removes ambiguity in the cases where a chord might include
           | certain notes or exclude certain notes implicitly. So Dmaj7
           | would be PuTaXaNe ("Xa" is pronounced like a "j"/"sh" sound
           | sort of like in Pinyin). It also typically reduces the number
           | of syllables spoken, like your system.
           | 
           | The superimposition of 7 on 12 as you put it, is indeed a
           | problem, but there's also an issue with intervallic
           | favoritism (of half and whole tones). After all, there are 7
           | note scales with minor third intervals, and so on--imagine a
           | world where one of those scales was the basis for
           | diatonicism. Representing that on a keyboard, and the
           | subsequent accidentals would be a nightmare.
           | 
           | Notation is the big unsolved problem, I think, but I'm aware
           | of some work being done in the area if you're interested. As
           | far as the public facing projects I'm aware of, Dodeka is
           | likely the most promising.
        
             | keymasta wrote:
             | Your MaNePu system sounds very cool! It's interesting that
             | you speak of the symmetry vis a vis the number 3. My "way
             | of word" has a similar property. It's based on trigrams
             | from the I-Ching and all of that follows the diminished (3)
             | geometry.
             | 
             | Regarding spelling chords as the iteration over their notes
             | like MaReVe for a major chord, my system can do this as
             | well, by using an -a ending for each letter. In this case a
             | major chord would be BaJaMa. I think this would be used
             | melodically rather than chordally in my system.
             | 
             | Let's say that the first measure of the melody to Ode To
             | Joy is
             | 
             | Ja Ja Ka Ma Ma Ka Ja Fa Ba Ba Fa Ja Ja Fa Fa
             | 
             | I use an idea more analogous to the jazz chord symbol
             | system where one specifies the root and the harmony as a
             | compound symbol.. Like 1ma7 or b5mi7.
             | 
             | There are actually two separate systems at work in chord
             | symbols like this, and my system is the same as that
             | concept. So you can go either way with "word". That is,
             | using notes (horizontal) vs. using harmonies (vertical).
             | 
             | My site is rudimentary but all one needs to name every
             | chord by this method is in a small chart. I threw it in a
             | little html file because posting a table in HN is not going
             | to work well.
             | https://edrihan.neocities.org/ngramcharts.html
             | 
             | I should actually have an explanation on the site which I
             | will add at some point.. but basically you pick a letter
             | for each trigram (quarter scale/chord). So there are four.
             | If they are the first/third it's the vowel, and
             | second/fourth is a consonant. That makes up your quality.
             | Then you combine that with a root-letter of mine. Because
             | those are consonants.. and my word starts with a vowel..
             | your five-letter word is pronounceable.
             | 
             | You mentioned the pinyin which I intuited on as soon as I
             | saw the "x". You'll see pinyin on my link. Fundamentally
             | related to way of word by its connection to the I-Ching,
             | but not in the sense that I am using it as a sound in my
             | system, like you are.
             | 
             | I like reduction of syllables for these systems. I tried to
             | maximise this property insomuch as all 49152 expressible
             | root-harmonies can be expressed in two syllables. I also
             | like the descriptive property. It just so happens I
             | designed it to be pronounceable and so seem prescriptive as
             | well. I guess the prescriptive version here (which is also
             | derivably descriptive) would be to use the
             | trigram/tetragran/hexagram names. So for our major chord
             | example.. it would be respectively,
             | 
             | Lightning Water Water Earth = = atEp (for some reason HN
             | seems to censor trigram glyphs, on my system at least)
             | 
             | Law Increase Response =
             | 
             | Sprouting Leader = [?][?] = (atEp)
             | 
             | The trigrams and hexagrams map to this system.. but not the
             | tetragrams. In this trigrammatic way our systems are
             | analogous.
             | 
             | The 7/12 problem is one of the biggest problems with music,
             | I feel as an artist. People have explored a small fraction
             | of tonal possibility.
             | 
             | I will check out Dodeka.. Feel free to check out my
             | material, mostly as we approach the future. I've been
             | hoarding my work for a few years now but am unleashing
             | things. So I guess you heard it here first cause atm I
             | basically do not exist on the internet. But ya I wrote
             | thousands of lines of code to get to this point.
             | 
             | For notation systems I like the circle geometry.. the way
             | of word.. or simply instrument diagrams (mostly only
             | possible with strings and keyboard instruments though,
             | where one can visualise multiple notes simultaneously). I
             | also like the idea of colours.
             | 
             | I think one thing that needs to happen in the education is
             | for people to start learning movable-root systems like
             | yours, mine, the jazz system, or the set system, rather
             | than learning in static keys. People then learn 12 times as
             | much data per neuron (-ish). I thought of a keyboard with
             | 6+6 keys instead of the standard 5+7. Then you'd learn
             | shapes on the instrument 6 times faster by reduction.
             | 
             | Ok there's stuff to meditate on.
             | 
             | Actually my chord naming system is "descriptive" as well
             | but admittedly uses a slightly more compressed encoding.
        
               | bazeblackwood wrote:
               | Thanks for sharing all this, I'll definitely dig deeper
               | into your site! Exciting time for new theories of music.
        
         | a_lieb wrote:
         | Agreed. I whinge about this all the time. The C-based system is
         | convenient for piano players but it's a mess for guitar
         | players, violinists, and other instruments where there are no
         | 
         | There have been many attempts at a chromatic music notation,
         | but nothing has caught on so far [1].
         | 
         | Things are a little better with solfege -- there is "chromatic
         | fixed do" solfege, where every note has its own name, rather
         | than only having a name for the "white notes," which leaves you
         | to mentally calculate the sharps and flats.
         | 
         | It's a minority thing--maybe 5-10% in Europe? Even regular
         | fixed "do" is rare in English-speaking countries, so I would
         | assume the chromatic fixed "do" is almost unheard of in the US,
         | Britain, etc.
         | 
         | At any rate, there're are at least seeds of hope for a
         | chromatic fixed-do solfege to catch on more. I use it for my
         | own learning.
         | 
         | [1] http://musicnotation.org/
        
           | codeulike wrote:
           | I find the paino-roll notation on DAWs to be a lot more
           | intuitive. Not much good for perfomers of course, but it
           | helped me understand things better. Each semitone is given
           | the same amount of space.
        
             | klodolph wrote:
             | I find piano roll very hard to work with. The notes are
             | just too far apart vertically.
        
             | kortex wrote:
             | I find piano roll a lot easier to write/produce but a lot
             | harder to sight-read.
             | 
             | I actually find hooktheory's system, where it's diatonic
             | and accidentals are based on the active chord, not the
             | current key, to be the easiest to understand relationships,
             | but also hardest to translate into concrete notes to play.
        
             | jacquesm wrote:
             | Here's that one weird tip that you were looking for all
             | your life but didn't realize it: pretend the front part of
             | the piano keyboard isn't there, and just look at the part
             | closest to the fingerboard. Presto: chromatic keyboard.
        
         | mvanga wrote:
         | Agreed. The patterns are the most interesting bits. Actually,
         | just the fact that there exist patterns is pretty amazing. It's
         | unfortunately hard to see them through the notation and that
         | made it very unintuitive for me for the longest time.
         | 
         | Unfortunately the momentum that Western music notation has,
         | with a few centuries of tradition behind it, means one has to
         | work within that system.
         | 
         | There was an interesting discussion I came across on Stack
         | Exchange while writing the article:
         | https://music.stackexchange.com/questions/67730/why-have-sha...
        
           | codeulike wrote:
           | re: the patterns, see discussion here
           | https://news.ycombinator.com/item?id=26860627
           | 
           | and my comment here
           | https://news.ycombinator.com/item?id=26861415
        
           | coldtea wrote:
           | > _Actually, just the fact that there exist patterns is
           | pretty amazing._
           | 
           | How so? If patterns didn't exist, it would just be random
           | choices.
           | 
           | Any non-random music making (and thus theory) requires
           | patterns.
        
         | protoman3000 wrote:
         | I disagree, because with the way of writing it down we have a
         | homomorphism, e.g. transpositions preserve relations between
         | letters, e.g. (A D E) -> (Ab Db Eb), or (G C D) -> (G# C# D#).
         | 
         | Of course, for every rule there are exceptions, e.g. we have
         | things like (F Bb C) -> (F# B C#)
        
         | klodolph wrote:
         | People have had this idea before but I've never seen a version
         | of it that is better than our existing notation systems. Most
         | of our music is diatonic, and we named the notes in our scale A
         | B C D E F G. Seven notes in the scale, seven letters. Seven
         | positions on the staff.
         | 
         | Our harmonies are built on stacked thirds, and the stacked
         | thirds line up perfectly on a staff. Line, line, line; or
         | space, space, space. Three dots stacked neatly on top of each
         | other. Easy peasy. Easy to read all the common intervals at a
         | glance, once you get past an octave it starts getting a bit
         | harder.
         | 
         | If you had chromatic notation, you'd allocate a bunch of extra
         | space and names for things that you spend most of your time not
         | using. An octave would have eleven spaces in the middle, which
         | is practically unreadable.
         | 
         | I think in the long-run chromatic notation is just hostile. Go
         | ahead and use chromatic solfege, that's super useful, but
         | chromatic notation is usually not.
         | 
         | Most often I hear the criticsm from people who are not
         | musicians or do not know how to read music. It's often smart
         | people with an analytical mind, but people who don't have much
         | experience with music. Just speaking from my own experience,
         | it's much harder to read a chord from a piano roll than to read
         | a chord from traditional notation.
        
           | seba_dos1 wrote:
           | In some parts of the world, it's A H C D E F G, with B being
           | what you'd call B flat.
           | 
           | Because of that, it took me way too long to figure out that
           | there was any sense in the note names.
        
           | codeulike wrote:
           | I appreciate most of your points and I appreciate the
           | conciseness of the stave notation for example. But ...
           | 
           |  _A B C D E F G. Seven notes in the scale, seven letters.
           | Seven positions on the staff._
           | 
           | Thats fine as long as you're in C Major. As soon as you
           | depart from C Major it all starts going wonky. Why is C Major
           | baked into the notation as if you'd never want to use
           | anything else?
        
             | kortex wrote:
             | You have to pick something as your starting point.
             | 
             | The sharps and flats diatonic system is way easier to read
             | because you just mentally parse "key of D" instead of
             | "start on D but also sharp the F and C". It takes time but
             | your brain just starts to grok shapes.
             | 
             | "Piano roll" notation, like in DAWs/midi editors, is
             | actually in certain ways a lot hard to read than staff
             | notation, due to the lower density and lack of reference
             | frame. It _is_ easier to see chord shapes transposed up and
             | down as the same. But I'd argue that's an anti-feature,
             | because of said lack of reference points. The symmetry
             | /sameness makes it a lot easier to start on the wrong note.
        
             | klodolph wrote:
             | > Thats fine as long as you're in C Major. As soon as you
             | depart from C Major it all starts going wonky. Why is C
             | Major baked into the notation as if you'd never want to use
             | anything else?
             | 
             | Actually, it works for every major scale and natural minor
             | scale!
             | 
             | What are the notes in E major? E F# G# A B C# D# E.
             | 
             | It's still the same letters, E F G A B C D. Now, you may
             | think that this is CHEATING because I've added sharps. But
             | when you write it out on staff paper, the sharps get shoved
             | off to the side on the far left in the key signature, and
             | you basically forget that they are there. You really still
             | just care about seven notes, so you still have seven
             | letters, and seven spaces on the staff, they're just a
             | different seven notes from the C major scale.
             | 
             | You have to know which key the song is in... but you have
             | to do that anyway.
             | 
             | When I say that you basically forget that they are there...
             | I mean it. This does not even require an especially
             | advanced level of musical skill. People with even a passing
             | interest in music theory should be able to breeze past it.
        
               | codeulike wrote:
               | So if you pretend that the sharps arent there and that
               | they dont make any difference to anything then its all
               | simple?
        
               | klodolph wrote:
               | I'm saying that our music is largely diatonic, and it's
               | better to base our notation and terminology on the
               | diatonic rather than the chromatic scale.
               | 
               | The idea that you can number semitones 1-12 has some
               | mathematical elegance to it, but it's a terrible system
               | in practice. It turns out that mathematical elegance
               | doesn't count for much, and domain knowledge is important
               | here.
        
             | seba_dos1 wrote:
             | > Thats fine as long as you're in C Major.
             | 
             | C major, yes, but also A minor - where it actually starts
             | from A :)
        
         | chjdev wrote:
         | There probably is a better or more general notation system, but
         | specifically for western music it is actually pretty efficient
         | and logical once you start working with it a bit. Just don't
         | put too much weight on the names and think in intervals. You
         | have a scale made up of 7 notes/intervals with the "fifth"
         | simply being the fifth note in the scale. Same with third, etc.
         | The specific flavor (major/minor) of e.g. the third you're
         | playing usually depends on the mode, but it is still a "third"
         | and serves the same-ish function. Extending the names i think
         | would actually be more confusing. I'd argue it already puts the
         | patterns of scales and chords in the foreground.
        
       | markc wrote:
       | Overtone is a music toolkit in Clojure. One of its source modules
       | similarly captures music theory:
       | 
       | https://github.com/overtone/overtone/blob/master/src/overton...
        
       | fatiherikli wrote:
       | lop
        
       | HorkHunter wrote:
       | Does any programmer suffer with music theory as well, just based
       | on the fact that an exact thing could be called in many different
       | ways, depends on its position, function..etc?
       | 
       | my brain kind of cannot accept this fact and I struggle with it
        
         | nickelcitymario wrote:
         | Yes, but we have similar issues in programming. Is a list a
         | hash? Is a hash a dictionary? Are these all arrays? Are arrays
         | collections?
         | 
         | Of course, there is a right answer, and depending on the
         | language, all of the above can be VERY different things. But
         | they're also similar enough to be completely unintuitive...
         | their distinctions take practice to master.
         | 
         | Likewise, in music there is a right time to call a note a flat,
         | a right time to call it a sharp, and a right time to talk about
         | intervals instead. They can all technically refer to the same
         | thing, yet there is a proper word to be used in any given
         | context.
         | 
         | It's all very confusing, until you start using those terms in
         | their proper contexts on a regular basis. Just like in
         | programming.
         | 
         | Some other examples:
         | 
         | "=" vs. "==" vs. "===" vs. ":" vs. "=>" vs. "~>"
         | 
         | "function_name first_parameter" vs.
         | "function_name(first_parameter)" vs. "hash_name[key]" vs.
         | "object.property_or_method"
         | 
         | "MethodName" vs. "methodName" vs. "method_name"
         | 
         | "function" vs. "method"
         | 
         | ...none of these are intuitive. But we use them, we get used to
         | them, and then they seem obvious and we wonder how we could
         | have ever written these things differently.
         | 
         | I think the same goes for musical notations. I struggle with
         | them heavily, but I'm far too casual of a guitar player to take
         | the time and learn the language properly. It's tempting to say
         | the problem is the complicated and confusing language of music,
         | but I know the problem is my own unwillingness to put in the
         | time.
        
         | noman-land wrote:
         | It's all about thinking in thirds. If you want an A chord it
         | has to be A, C, E, in thirds. A major would be A, C#, E not A,
         | Db, E because that breaks the rule of thirds.
         | 
         | Also, and most importantly, if you're playing an instrument
         | like violin, C# and Db are not actually the same note. Since
         | they happen in different contexts, and have different positions
         | in whatever key they're in, they have different psychological
         | roles and are actually played differently by the player.
         | 
         | If I'm not mistaken, a C# would be played slightly sharper, and
         | a Db slightly flatter to fit the particular key.
        
         | analog31 wrote:
         | I've been programming for 40 years and playing music for 50. My
         | original background was classical and I play jazz today. I'm a
         | fluent reader.
         | 
         | I think that historically, people were already familiar with
         | "standard" notation and terminology before they learned theory,
         | so it wasn't a major hurdle. Not only do theory students (i.e.,
         | at the college level) know how to read, but they are also
         | required to learn keyboard. I've heard people say: Don't try to
         | learn theory without a keyboard in front of you.
         | 
         | Music instrumentation and notation are _technologies_ and as
         | such they are replete with historical baggage. I have an
         | unorthodox view, which is that if someone is not already
         | usefully reading standard music notation by adulthood, then
         | they have no reason to learn it. Explanation of theory for non
         | readers would be better served by using an invented notation
         | that sidesteps the historical naming problems.
         | 
         | One such notation is the Nashville number system. It's not
         | nearly universal, but for the purposes of just enjoying a wide
         | swath of popular and folk music, it actually works. It's fun to
         | see how many different songs boil down to a few basic patterns.
         | 
         | A computerized tutorial could show both notations. There is a
         | lot of instructional material for guitar, that shows
         | conventional notation in parallel with a notation based on a
         | diagram of the fingerboard.
         | 
         | Programming would be just as bad if we were stuck with a 400
         | year old language. Fortunately we develop new languages, but
         | that's because old programs just get thrown away, and it's easy
         | to teach a computer to read a new language. We also teach
         | programmers not only how to read, but how to create better
         | notation themselves.
        
           | mahathu wrote:
           | This is the first time I heard of the Nashville number system
           | - what's the difference to Roman Numeral Analysis? Is it
           | essentially the same concept, but with Arabic numerals
           | instead?
        
             | analog31 wrote:
             | Pretty much the same, adapted to the specific purposes. For
             | instance, Nashville charts also include some notations for
             | the form of a song, such as Intro, Verse, Chorus, etc.
             | 
             | A reason for the usefulness was how recorded music was
             | made. The recording musicians had to be able to choose a
             | key that accommodated the singer's range, on the spot. So a
             | transpose-able format was ideal.
             | 
             | I think the industry in New York had a different scheme,
             | which was to write for a "standard" male tenor voice, and
             | rely on the musicians to handle exceptions.
        
             | nickelcitymario wrote:
             | My take: It's a communication issue.
             | 
             | If you tell me you're going to make my life easier by
             | teaching me "Roman numeral Analysis", I'm gonna run away.
             | That sounds scary and vaguely reminds me of Latin class.
             | 
             | "Nashville number system" sounds easy to master. It's
             | country, and country has a well-known self-imposed
             | reputation as simple. (In truth, country can be just as
             | complicated as anything else. But I'm talking about first
             | impressions.)
             | 
             | I used to be a part of a congregation whose band spoke in
             | 5ths and 7ths and I had no idea what they were going on
             | about. And then I learned that part of joining the band was
             | learning the Nashville system. It's just the simplest way
             | to get everyone on the same page, and when you say
             | "Nashville" musicians immediately relate to what you're
             | saying.
        
       | calebm wrote:
       | I have some similar notes here: https://calebmadrigal.com/music-
       | theory-notes/. It's all about the ratios.
        
       | dvh wrote:
       | Not a musician here but are scales really necessary? Why not just
       | play any frequency I want?
        
         | analog31 wrote:
         | I'm a musician. For me, a great deal of the pleasure of being a
         | musician is making fairly sophisticated, coherent music, with
         | other musicians, in front of an audience.
         | 
         | Scales are not strictly necessary, but are part of an apparatus
         | of making music work in the way that I enjoy it. They are a
         | _technology._
        
         | scpedicini wrote:
         | Most composers were musicians before that and a lot of
         | instruments adhere to scales such as fretted instruments or
         | percussive instruments like the piano.
         | 
         | Using scales gives people a familiar territory in which to
         | compose music and a western audience will already be culturally
         | attuned to those sensibilities.
        
         | geekster777 wrote:
         | You may enjoy looking up micro-tones. Where western scales are
         | made up of whole-tones and semi-tones, other cultures don't
         | necessarily use the 12 semi-tone based scale system. Notably,
         | Toxic by Britany Spears samples some Bollywood music, where the
         | backing singing uses a bit of micro-tonality. You can often
         | find different satisfying intervals, although they won't
         | necessarily have the same cultural context/baggage associated
         | with the sounds and therefore won't convey the same strong
         | connotations that a diminished chord might.
        
         | bazeblackwood wrote:
         | Musician here--strictly speaking, music itself isn't necessary.
         | Armed with that knowledge, you should produce any combinations
         | of sounds that please you.
        
         | mhh__ wrote:
         | Scales and Chords are broadly speaking just a way of neatly-ish
         | categorizing sounds and moods. This is true of both most
         | classical music and jazz, for example, _but_ Jazz in particular
         | has a very practical relationship with scales.
         | 
         | One of the personality tests of an improviser is how you think
         | about the music - do you think vertically (in the chord),
         | horizontally (in the mode), for example.
        
         | zild3d wrote:
         | > Why not just play any frequency I want? reply
         | 
         | You're more than welcome to. If you try to discover what
         | intervals between these random frequencies tend to be pleasing,
         | or displeasing, you'll rediscover some of the intervals and
         | scales covered above
        
       | peterpostman wrote:
       | Unreadable code,considering the subject should have been written
       | in either in c, c#, d, f or f#.
        
         | madcaptenor wrote:
         | Interesting that there are no languages with "flat" names. I
         | can think of two reasons: - the word "sharp" has more positive
         | connotations - if you're limited to the keys on a usual
         | keyboard "flat" would be denoted by "b".
        
           | seanhunter wrote:
           | Jazz musicians (and brass players) generally prefer playing
           | in flat keys (because of transposition making the reading
           | easier) so while "sharp" has a more positive connotation in
           | normal use, if you asked a tenor saxophone player to play
           | something in F# or C# they would generally not be pleased :-)
        
             | madcaptenor wrote:
             | I didn't think of that. My musical experience is on piano
             | and voice (neither of which has a preference for sharp or
             | flat keys) and I've played around with guitar a bit (which
             | prefers sharp keys in standard tuning) so I tend to forget
             | that some people like flat keys.
        
           | goto11 wrote:
           | I think it is just due to C# being a play on C++ (the # could
           | be seen as ++ just rearranged to overlap). No doubt the
           | positive connotations of "sharp" also played a role. Cb or
           | C-flat neither looks or sound cool! That said, MS did have en
           | experimental language called C-flat, but it was not intended
           | for general purpose use, so the name might have been chosen
           | as a joke.
           | 
           | F# is in turn named after C#, as it is the functional
           | equivalent to C# in the framework.
        
       | tomrod wrote:
       | I love this!
        
       | sampo wrote:
       | There are maybe three aspects to music theory:
       | 
       | (1) Theory of how things sound like: Tones, melodies, scales,
       | chords, based on the frequencies of individual sounds.
       | 
       | (2) How to name things.
       | 
       | (3) How to handle the mess of naming things in Western music
       | theory, where things have 12 different names, depending on which
       | note you choose as the base.
       | 
       | This post seems to focus on 3.
        
         | max_ wrote:
         | I once listened to a podcast where fourier transforms were used
         | to generate sounds that otherwise don't exist.
        
           | Jenz wrote:
           | > sounds that otherwise don't exist.
           | 
           | hmmm
        
           | tobr wrote:
           | Could you maybe share which podcast? Generating "sounds that
           | otherwise don't exist" does not sound particularly remarkable
           | taken at face value. It's basically what any synthesizer or
           | audio processor does, and Fourier transforms are also a very
           | commonly used in audio processing.
        
             | max_ wrote:
             | This podcast. The episode of Joseph Fourier.
             | 
             | https://www.bbc.co.uk/programmes/b00srz5b/episodes/download
             | s
             | 
             | What I meant by "sounds that otherwise don't exist" are
             | sounds that are too complex to be created by physical music
             | instruments its easier to simulate them by computer.
        
         | andrepd wrote:
         | > How to handle the mess of naming things in Western music
         | theory, where things have 12 different names, depending on
         | which note you choose as the base.
         | 
         | You are missing the point.
        
         | billfruit wrote:
         | Why is that mess necessary? Cant a semantically rich notation
         | be devised to avoid that mess?.
        
           | reikonomusha wrote:
           | To me, that's like asking "why are inconsistencies in English
           | necessary? can't we all just learn Esperanto?" There's
           | hundreds of years worth of written music, hundreds of years
           | worth of pedagogical material, and millions of people who
           | simply will not "un-learn" the current tradition. Just like
           | English, over the centuries, music notation evolves, but only
           | just does that, evolves.
        
         | DavidPiper wrote:
         | Here I was expecting you to say:
         | 
         | (1) Melody
         | 
         | (2) Harmony
         | 
         | (3) Rhythm
         | 
         | :-)
        
           | twelvechairs wrote:
           | Really all of these are shorthand for something much more
           | fundamental around ratios and how these are experienced by
           | the human body at different frequencies.
           | 
           | Harmony is shorthand for ratios at audible frequencies
           | (~20-20,000 Hz) as they are quite directly picked up in the
           | ear. Rhythm is shorthand for ratios expressed at much lower
           | frequencies (~0.1-10Hz) which the body interprets with
           | relation to its own functions (heartbeat, walking, dancing,
           | speech). Melody is a combination of harmonic and rhythmic
           | ratios in a way the human body has been trained to hear as a
           | 'voice'.
        
         | 867-5309 wrote:
         | most disciplines, music included, have theory and practice. how
         | things sound is an element of the latter, whereas why things
         | sound the former. this article as the title atates is about
         | music theory and does a pretty decent job IMO
         | 
         | I would be delighted to see a follow up article that explores
         | frequencies and harmonics while sticking with the code
         | demonstrations and incorporating a simple tone generator for
         | the practice side of things
        
         | analog31 wrote:
         | It would be interesting to go through a modern college level
         | music theory textbook and break it down into which of those 3
         | things each concept falls into. I can't imagine getting past
         | maybe the first chapter.
        
       | noisem4ker wrote:
       | Perhaps related:
       | 
       | Haskell School of Music http://www.euterpea.com/haskell-school-
       | of-music/
        
       | pohl wrote:
       | A fun idea for a function to implement: the negative harmony
       | mapping, which is a note-by-note transformation that preserves
       | some character of the note:                 R [?] 5 (stable)
       | 2 [?] 4 (unstable)       3 [?] 3 (modal)       7 [?] 6 (leading)
       | 6 [?]7 (hollow)       2 [?] #4 (uncanny)           [1]
       | https://www.youtube.com/watch?v=et3CMn2oCsA      [2]
       | https://www.youtube.com/watch?v=SF8CdxcdJgw
        
       | jancsika wrote:
       | It can be tricky to deal with the intersection of music and
       | programming. For example:
       | 
       | > The chromatic scale is the easiest scale possible
       | 
       | So far so good-- in both programming and music we're just
       | stepping through the smallest values (half step for music, the
       | integer "1" in programming). So "easy" definitely applies to both
       | domains.
       | 
       | > We can generate a chromatic scale for any given key very easily
       | 
       | For programming, sure-- you just find your offset and go to town.
       | 
       | For music, however, this is a wrong warp. The chromatic scale is
       | a special case of a symmetric scale which cannot be transposed.
       | There's literally only one such scale-- each transposition brings
       | you back to the same exact set of pitch classes.
       | 
       | Figuring out what it means to have a chromatic scale "for a given
       | key" is advanced music theory. In fact, I can only think of a few
       | places where that makes sense:
       | 
       | * studying the complex harmony of late-19th century Romantic
       | music
       | 
       | * studying the choice of accidentals in chromatic passages of
       | Bach, Beethoven, etc. to infer the implied harmony
       | 
       | Those are important things, but they are definitely advanced
       | concepts.
       | 
       | Long story short for programming, the author moves logically from
       | an array to stepping through an array. But in terms of music,
       | they start with the simplest possible scale and then jump to a
       | third year undergrad theory concept.
        
         | DavidPiper wrote:
         | > Figuring out what it means to have a chromatic scale "for a
         | given key" is advanced music theory
         | 
         | Interesting... Do you have any links for learning more about
         | this - maybe some analyses?
         | 
         | My take on chromatic scales (in the context of this post) is
         | that the very existence of a(n equally tempered 12 tone)
         | chromatic scale is the axiom the OP is using but not stated -
         | hence a comment further up/down about P5s not necessarily being
         | equivalent to d6 in other tunings.
         | 
         | My take on chromatic scales (outside the context of this post)
         | is that there is only one, like there are only two whole-tone
         | scales, etc, and that it wouldn't necessarily make sense to say
         | "the E chromatic scale" - instead you'd say "playing a
         | chromatic scale over an E major harmony" (for example).
         | 
         | However, if there are cases where it's useful to be more
         | specific I'd be really keen to go deeper.
        
           | jancsika wrote:
           | > My take on chromatic scales (in the context of this post)
           | is that the very existence of a(n equally tempered 12 tone)
           | chromatic scale is the axiom the OP is using but not stated -
           | hence a comment further up/down about P5s not necessarily
           | being equivalent to d6 in other tunings.
           | 
           | Ooh, good catch-- I completely left out tuning systems!
           | 
           | But again-- the point of "basic" music theory is to simplify
           | the practice of discussing music. In that context, the
           | fundamental purpose of the chromatic scale is to introduce
           | the complete set of note names, as well as the range of the
           | piano pitches. This gives the student a full set from which
           | to derive all other concepts like scales, keys, triads, and
           | all the other fundaments of the common practice period.
           | 
           | So again, if you start with a chromatic scale and then start
           | talking about the differences in half-step intervals along
           | it-- boom. Huge conceptual warp.
           | 
           | Honestly, I don't know much about the intersection between
           | symmetric scales and alternate tuning systems. Personally, it
           | seems like it would be an incredibly esoteric niche, although
           | I can imagine some funny musical jokes with the idea. :)
        
         | muelo wrote:
         | > The chromatic scale is a special case of a symmetric scale
         | which cannot be transposed.
         | 
         | I would not agree here. I think you can transpose a chromatic
         | scale, but you end up with the same "set" of pitches. (So you
         | _can_ transpose, but if you only consider the _set of pitches_
         | you end up with a invariant.
         | 
         | But scales are not just a set of pitches, but also have a root
         | note.
         | 
         | You can establish the key of C and play a chromatic scale from
         | c' up to c'' and there would be the feeling to accept C as the
         | root of the scale.
         | 
         | So the chromatic scale is kind of a _total_ (all 12 pitch
         | names) and _trivial_ example, as you pointed out, very
         | symmetric and usually not so interesting for analysis if you
         | want to detect and describe structure.
         | 
         | In general it depends on the music. If the music is based on
         | diatonics, then a major scale or it's modes will be a fitting
         | primitive for analysis, considering chromatic notes something
         | like side notes.
         | 
         | On the other hand 12-tone music uses a chromatic scale as a
         | basis, negating the structure and hierarchy of diatonic scales.
         | 
         | So I don't see a problem with transposing a chromatic scale,
         | it's useful and necessary for mathematical sound systems
         | (helpful for computation) to define operations, even if there
         | is no direct gain (functionally speaking - identity / mempty
         | etc.) :
         | 
         | 1 + 0 = 1
        
         | shwestrick wrote:
         | I don't think this is really anything to do with music vs
         | programming. The author just used the wrong words... it's
         | pretty clear they meant "generate a chromatic scale starting at
         | any note" ;)
         | 
         | Thanks for bringing up the connection with symmetric scales --
         | these are really interesting!
        
           | paradygm wrote:
           | If you want to go further down the rabbit hole of symmetrical
           | scales, checkout Olivier Messiaen's modes of limited
           | transposition
           | https://en.wikipedia.org/wiki/Mode_of_limited_transposition.
           | For a given set of pitches within an octave there are a
           | limited number of times those pitches can be transposed
           | before you wind up with the same set of pitches. And the
           | modes in that scale must also be fewer in number than the
           | number of pitches in the scale, meaning at least two modes of
           | the scale must have the same interval spelling. The simplest
           | example is the whole tone scale. Up a half step I get the
           | same set of pitches, another half step and I get the same
           | pitches I started with, so it is 'limited' to one
           | transposition. And there is only one mode of the whole tone
           | scale, since no matter where I start I always have the same
           | set of intervals.
        
             | piannucci wrote:
             | Shtaaap, you're headed for the Totient Function! Collision
             | immanent, abort, abort!
        
       | sideshowb wrote:
       | Anyone wanting to take things back a step further to first
       | principles may enjoy this (shameless plug - I wrote it)
       | 
       | Deriving the piano keyboard from biological principles using
       | clustering (Jupyter)
       | 
       | https://fiftysevendegreesofrad.github.io/JupyterNotes/piano....
        
         | harperlee wrote:
         | > If you hear a sound of frequency f and others of frequency
         | 2f, 3f, etc then there's a good chance these sounds come from
         | the same object, due to the physical principle of resonance.
         | And so our perception of sound evolved to reflect this...
         | 
         | Wow that's interesting enough to share as a standalone post, so
         | I took the liberty! Thanks for the link!
        
           | enriquto wrote:
           | The quoted sentence seems false to me. Most physical objects
           | do not have naturally harmonic vibration spectra. The
           | vibration modes are not integer multiples ofthe fundamental
           | (except for a vibrating string). Only the finely tuned
           | western instruments do. So this is a somewhat backwards
           | argument.
        
             | OscarCunningham wrote:
             | The code itself also contradicts that sentence. Notice that
             | the first roughness graph doesn't have any local minima at
             | rational numbers. It's only when the overtones are added to
             | the notes (at integer multiples of the fundamental
             | frequency) that the minima appear.
             | 
             | So the code thinks that human ears don't detect integer
             | multiples specifically, they just detect sounds whose
             | overtones line up with each other.
        
             | IggleSniggle wrote:
             | I don't think so. If a sound _persists_ long enough to hear
             | its continuation, then its partials are generally going to
             | be harmonic. Non-resonant frequencies will have a tendency
             | to dissipate very quickly, unless they are explicitly
             | designed to warble between resonances (like a gong or
             | similar).
        
             | jacquesm wrote:
             | > Most physical objects do not have naturally harmonic
             | vibration spectra.
             | 
             | What is your basis for saying this?
             | 
             | A large number of physical objects, solids as well as
             | hollow can be approximated as systems of springs, surfaces
             | and tensile elements, which all have some frequency
             | response. It isn't rare at all for a physical system to
             | have a very sharp resonant peak in its frequency response,
             | to the point that you'll often find mechanisms to dampen
             | that response so the structure will survive certain inputs.
        
               | enriquto wrote:
               | what you are describing is a graph. The laplacian
               | spectrum of a graph is arbitrary.
        
               | PEJOE wrote:
               | Every rigid object has a fundamental frequency,
               | regardless of whether you put it on a graph.
        
               | enriquto wrote:
               | Sure. But the other frequencies need not be integer
               | multiples of the fundamental.
        
               | jacquesm wrote:
               | They don't have to, but usually those integer multiples
               | will be present as well. Whether they are dominant or not
               | is another matter but it is quite hard to design
               | something in such a way that if it has a natural
               | resonance at a certain frequency that integer multiples
               | will not be present in the response spectrum.
               | 
               | A typical object will have multiple modes of resonance as
               | well.
        
               | enriquto wrote:
               | > usually those integer multiples will be present as well
               | 
               | "usually", under what probability model? A random 3d or
               | 2d shape will have zero harmonic partials with
               | probability 1. What is hard to achieve is having even a
               | few harmonic partials. A rectangular wooden piece is
               | painstakingly carved to have a couple of harmonic
               | partials, in order to become a xylophone or marimba bar.
        
               | jacquesm wrote:
               | Yes, but shapes are not usually random. Bars, cylinders,
               | cubes, rectangles, squares and circles are everywhere.
               | That does not mean that they will have a string like
               | attenuation curve for those higher harmonics, but they'll
               | be there.
        
               | fuckf4ce wrote:
               | > Yes, but shapes are not usually random. Bars,
               | cylinders, cubes, rectangles, squares and circles are
               | everywhere.
               | 
               | While there are some exceptions, this is skewed in the
               | modern industrial world. If we're making evolutionary
               | scale arguments about sound perception it's a much
               | tougher sell.
        
               | HelloNurse wrote:
               | Many objects don't have _audible_ vibration modes
               | (infrasonic, ultrasonic, so damped that sounds are too
               | brief and too quiet) but it doesn 't mean that they don't
               | vibrate.
        
             | kortex wrote:
             | You have the causality backwards though. It isn't saying
             | most objects emit quantized overtones. But if you hear
             | quantized overtones, there's a very good chance they are
             | from the same source.
             | 
             | It's not just strings, either. Drum heads have varying
             | degrees of quantized modes.
        
         | blagie wrote:
         | As someone who might use these with kids: I think the problem
         | with both of these is lack of, well, sound.
         | 
         | To get things, people need to hear sounds, not just see note
         | names and pictures.
        
           | 867-5309 wrote:
           | it could be argued that this is music theory, and therefore
           | sound belongs to the realm of music practice
        
       | keymasta wrote:
       | I've worked on music theory coding for a while. I originally used
       | a dict-lookup style like you have done, but found a simpler way
       | (for me). The problem with that approach is you have to maintain
       | values for enharmonics of note names. It's hardwired. Also what
       | if you gave it something like 44? Why shouldn't it
       | "theoretically" be able to handle that. It is "theory" after all.
       | I use something like this to convert things basically to an int
       | (if we want to for some other function):                 #
       | Assuming note values are of Jazz style.. i.e,  '1', 'b3', '#5',
       | or '3' with unicode-sub after       jazzAllFlats =
       | ['1','b2','2','b3','3','4','b5','5','b6','6','b7','7']
       | sharpStrs = ['#','#']       flatStrs = ['b','']
       | accidentalStrs = sharpStrs + flatStrs       def
       | stripAccidentals(note:str) -> str:           return ''.join([c
       | for c in note if not c in accidentalStrs])       def
       | jazzToDist(jazz:str) -> int:           dist = 0           degree
       | = int(stripAccidentals(jazz))           while degree > 7:
       | dist += 12               degree -= 7           dist +=
       | jazzAllFlats.index(str(degree))           for c in jazz:
       | if c in sharpStrs:                   dist += 1               elif
       | c in flatStrs:                   dist -= 1               #Here
       | you could add support for double sharps and double flats if you
       | want.. although unlikely as font support for these glyphs is
       | horrible overall.               else:                   break
       | return dist       print(jazzToDist('bb3')) # returns 2
       | print(jazzToDist('1')) # returns 0       print(jazzToDist('44'))
       | # returns 68       print(jazzToDist('2')) # This one is strange
       | as it's the   only one where input == output
       | 
       | I started making stuff more like this as it just saves a lot of
       | trouble in the long run. Once you have things made generic like
       | these it's easier to think about going into ways that are not
       | Jazz/Dist (which is semitone distance, or set notation), like
       | Keys for example.. because it turns out the logic for that is
       | really similar to what is in the jazz.
       | 
       | The shape of the jazz system is the same shape as a change in the
       | key of C. You would just separate the accidental part of the
       | note's name like I did and look up let's say the index in all
       | keys, giving you distance from C instead of what I showed there
       | which is like distance from what is called 1 in Jazz.
       | 
       | So yes I prefer to make helper functions like this that actually
       | kind of "get it" about what the languages/ways like Jazz or note
       | names are actually saying.. then you can go one to another, or
       | different keys really easily. If interested in more of my "Way Of
       | Change" algorithms I can share.
       | 
       | I think your article is cool and I could comment more.. maybe if
       | you want you could read my repo I could pm it to you. But it's
       | long. In the meantime I have a new website using some of this
       | type of logic. unfortunately js instead of python (where my
       | bigger codebase resides).
       | 
       | Google thinks this site is a security threat and I literally
       | posted it two days ago but it's got all scales/chords etc, and
       | other stuff. Still in prototype phase.
       | https://edrihan.neocities.org/wayofchange%20v14.html
        
         | lioeters wrote:
         | From your link, I followed to the music of Lotus Helix:
         | 
         | https://lotushelix.bandcamp.com/
         | 
         | Wow, I'm very captivated by it, such high musical weirdness!
         | Excellent stuff.
        
         | mvanga wrote:
         | Very nice! I like your way much better than the one in my
         | writeup :-) I'll refactor things over the weekend to use this
         | approach if that's OK with you.
        
           | keymasta wrote:
           | That would be very cool! Maybe just give me a mention if that
           | is cool, you can use the code verbatim (or changed) if you
           | want. My name is Edrihan Levesque. My book on music theory
           | which isn't out is called Way Of Change.. which is what I
           | refer to these algorithms by.
           | 
           | You might just realise how this approach goes back into
           | keys.. like Ab, C#, F.. it's almost exactly the same, but you
           | have to account for the accidentals being on the right side
           | of the string as opposed the the left, as it is in Jazz.
           | 
           | And ya! - I actually originally wrote almost exactly what you
           | wrote.. but I kept adding enharmonics of things.. like
           | ['3','##2','b4','bbb5'] # and so on..
           | 
           | So I got to a point where it's like.. yeah this should just
           | understand it. I'll give you another hint for the keys.. Use
           | the scale degree to get your root note name. Get rid of the
           | accidentals (do it after). Once you know that Major in dist
           | == [0,2,4,5,7,9,11] you can use the list that contains all 12
           | notes in one spelling to find it. That's why I'm getting rid
           | of accidentals. That way if you're looking for C# but you
           | wrote as I did with all flat-spellings, it throws away the
           | "#", finds the 'C', counts from there, and finally adds the
           | sharp back if necessary. Just kinda paying attention to
           | adding a flat to a note with a sharp.. they cancel out etc.
           | Usually that's why it makes sense to keep the degree part
           | separate from the accidentals part in some way. At the end
           | you reconcile a difference between distance and degree-
           | distance. Really easy to do double sharps or flats that way
           | cause you know that all valid note names will work.. don't
           | have to worry about giving it a particular format.
           | 
           | Not only can you use any names notes may have, but you can
           | specify an odd rule.. like for example the difference between
           | looking at the scale in "Western" vs. "Indian". Let's say a
           | scale like Mela Vanaspati/Raga Bhanumati/Zaptian (number 1129
           | on my site). If it's Zaptian, then let's say we're Western.
           | I'd say it's spelled like the first line following this. If
           | it's a Raga or Mela and we're looking at it that way then
           | even in Jazz we can correctly see it how it's originally
           | stated as the second spelling.
           | 
           | 1 b2 2 4 5 6 b7
           | 
           | 1 b2 bb3 4 5 6 b7
           | 
           | For me in this case the Indian numbers make sense as you are
           | just counting up integers.. albeit with the "ugly" double
           | flat. And yes it's ugly unless you were using a system that
           | doesn't express it as uglily. Here I'm just comparing the
           | first three notes in a few ways. Let's say for a bb3 a system
           | that would express that less ugly than some would be in the
           | key of C#.. as in [1 b2 bb3] == [C# D Eb] == [Db Ebb Fbb]. Of
           | course all these can be described as [S R1 G1]. This is how
           | it's notated in Indian.. but equivilent to Jazz in that there
           | is a part that talks of which nth note of the change and a
           | part that talks about how far from where it usually is.
           | Obviously C# is better for this change than Db. Even if you
           | use the Western Jazz to derive it it's not good unless in C#.
           | Of course the Western jazz statement to me is more ugly
           | because it doesn't count up in degrees sensibly from 1
           | through 7. The ugliness of the jazz numbers is equal to the
           | ugliness of putting it in the key of C, like I said before.
           | On other changes Jazz wins because Indian won't let you use
           | #4 or b5.
           | 
           | I'm glad you'll use my codes too. Eventually once you have it
           | working you can do a scale in the key of like... let's say
           | Abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb.. which is actually
           | also known as C or even B#.. ok stay sharp out there in code
           | land. ;) Music theory is an obsession of mine and fun with
           | codes. There are always many options. There's more than one
           | correct answer. And there are ones that make less sense than
           | others.
           | 
           | And P.S. to anyone just dropping in.. we're lazy so we type b
           | instead of , and # instead of #. The former is pronounced
           | flat, is equal to the number -1 and is pronounced double-flat
           | if there are two. The latter is pronounced sharp, is equal to
           | +1 and same rule applies about not pronouncing something like
           | "sharp sharp" in music ever. This way I can pronounce C
           | septuple-sharp, which I made up. That particular strange way
           | to describe a note is equivalent to G because music is weird
           | like that. Also if something has six sharps then you could
           | just as easily say it has six flats. So B is the same note as
           | B######. And yes those are the very sexy-sounding sextuple
           | type words ;)
        
       | tarboreus wrote:
       | Is there a (really) accessible book on music theory that anyone
       | would recommend?
        
         | analog31 wrote:
         | I'm going to go in a slightly different direction and recommend
         | starting with a book on music _history._ There will probably be
         | enough theory in there, as it 's needed to explain many
         | developments. And then, don't try to study it, but start out by
         | just reading it as a narrative.
         | 
         | Modern college textbook writers are doing a decent enough job
         | of not focusing strictly on classical music. You could find out
         | what your local university uses.
        
         | geekster777 wrote:
         | I've been finding Signal Music Studio[1] to be doing a good job
         | of conveying theory with minimal notation and practical
         | examples. E.g. less labeling of things and more "here's what
         | folks like to use this construct for". Not quite a book, and
         | maybe not as comprehensive as you're hoping.
         | 
         | [1]
         | https://www.youtube.com/playlist?list=PLTR7Cy9Sv285kV3pohsMt...
        
       | FabHK wrote:
       | I haven't found an introduction to music theory that makes sense
       | to me.
       | 
       | I vaguely understand that complications arise because we want
       | nice harmonics, ie frequencies whose ratio is a "nice" rational
       | number, such as 2/3 or 3/5 or so.
       | 
       | But our chosen notes should be invariant under doubling of
       | frequencies ("shifting by an octave"), because that's basically
       | the same note.
       | 
       | The problem then is that roots of 2 are irrational, that is, one
       | cannot find (p/q)^2 = 2, or (p/q)^n = 2, or even (p/q)^n = 2^m.
       | Therefore, one cannot find a "nice" interval that, applied
       | several times, wraps around to an octave (or multiple octaves).
       | 
       | However, in a neat coincidence, (3/2)^12 = 129.7463378906...
       | which is close to 2^7 = 128. So, based on that ("Pythagorean
       | comma"), something something something, and we end up with 12
       | half notes that are basically of frequency f_i = f_0 * 2^(i/12),
       | which are all horribly irrational, but apparently sound "nice"
       | enough, largely (because they are close enough to some "nice"
       | fractions), but only if we pick out some specific 7 of them.
       | 
       | And then the question becomes, which 7 of the 12 do we pick,
       | approximately uniformly distributed. (Why not 6? Every second? I
       | don't know.)
       | 
       | And then, you can transpose them somehow (ie multiply frequencies
       | by 2^(j/12) for some j, but then you change the names for some
       | reason, and everything gets complicated and tonic and Mixolidian
       | double-sharp.
       | 
       | Also, instead of frequencies of the form f_i = f_0 * 2^(i/12)
       | (which, clearly, have the advantage that any multiplication by a
       | power of 2^(1/12) is just a shifting of the index i), you could
       | also use non-equal tuning, with the powers of the 12th root of 2
       | replaced by some "nice" fraction, which means that any shifting
       | then subtly changes the character of everything, I assume.
       | 
       | This is complicated, admittedly, but for me the nomenclature
       | obscures, rather than elucidates, the issue.
       | 
       | ETA: I sympathise with what _irrational_ wrote:  "Is this what it
       | is like when I talk to people who don't know anything about
       | programming about my work? Pure gibberish?"
        
         | zarmin wrote:
         | If you're trying to learn music theory by thinking about the
         | mathematical relationship between frequencies, you are severely
         | overcomplicating things for yourself. I have a tendency to do
         | the same thing.
         | 
         | What question are you trying to answer with what you just
         | wrote?
        
       | goto11 wrote:
       | > For historical reasons, there are no sharps or flats between
       | the notes B/C, and E/F.
       | 
       | Come on, that is not for "historical reasons", that is because
       | those notes are only one semitone apart!
        
         | harry8 wrote:
         | Different way of saying the same thing.
         | 
         | "For historical reasons the notes B/C and E/F are one semitone
         | apart."
        
           | goto11 wrote:
           | But that is not for historical reasons, that is due to the
           | universal mathematical properties of the intervals.
           | 
           | The _names_ of the notes and scales are due to historical
           | reasons, but a major third and a fourth is one semitone apart
           | due to math, not history.
        
             | kaoD wrote:
             | What the article means is: we dont have 12 notes (A B C D E
             | F G H I J K L). Instead, for historical reasons (the choice
             | of CMaj/Amin as a reference due to the notation evolution
             | from heptatonic scales) we have A B C D E F G and we
             | annotate with accidentals but, since those are not evenly
             | spaced, there are some missing "black keys" there.
             | 
             | Also, what devnonymous says, which I agree with too (but
             | that's another story...)
        
             | [deleted]
        
         | devnonymous wrote:
         | The idea of a semitone in Western classical music is historical
         | not (just) tonal.
        
           | goto11 wrote:
           | True, but that does not mean you can just space notes in a
           | scale randomly.
        
             | devnonymous wrote:
             | Hmm, I guess someone should tell those people, like Like
             | Tolgahan Cogulu who are writing music in microtonal scales
             | with 19, 24 or 31 notes in a scale, that their notes
             | spacing is random.
             | 
             | https://en.m.wikipedia.org/wiki/19_equal_temperament
             | 
             | https://en.m.wikipedia.org/wiki/31_equal_temperament
             | 
             | https://en.m.wikipedia.org/wiki/Arab_tone_system
        
               | goto11 wrote:
               | The spacings are not random, they are still based on
               | ratios. They just include more intervals in (what we
               | call) the octave.
               | 
               | The linked article actually explains the math pretty
               | well.
        
               | devnonymous wrote:
               | Ah alright, I finally understand you. What you meant to
               | say is the reason why Western classical music is built on
               | the 12 note chromatic scale is because the musicians used
               | the math! It has nothing to do with history. Sound about
               | right?
        
               | kaoD wrote:
               | Although I agree with you... didn't Pythagoras derive the
               | pythagorean tuning of diatonic doing the math with the
               | 3:2 ratio?
               | 
               | I know near zero music history, but I was under the
               | impression that that's the evolution from diatonic scales
               | and eventually into our western music system.
        
               | goto11 wrote:
               | Not exactly, although I think I understand what you are
               | getting at.
               | 
               | What I meant was that the interval between a major third
               | and fourth in a 12-tone chromatic scale _has_ to be a
               | semitone due to math, not due to some historical accident
               | or decision.
               | 
               | It might be an accident of history that we use a 12-step
               | scale in the first place though, since you can have
               | arbitrary many intervals in an octave - but you can't
               | just divide the octave in arbitrarily places and get
               | music out of it. The intervals still have to be ratios.
               | 
               | (Well I'm sure some avant-garde composer have tried
               | making music with intervals that are not ratios just to
               | be clever, but I hope you get my point!)
        
       | starchild_3001 wrote:
       | I thought this is very cute. Playing these as chords or
       | arpeggios, then adding other features to put them together to
       | form a melody or chord progression, then hearing the effects
       | would be super cool.
        
       | valdiorn wrote:
       | Hi there - was wondering if you had come across my Pentatonic
       | scale github repo by any chance? :) It's a very similar type of
       | study, where I attempted to generate all possible pentatonic
       | scales (within reason).
       | 
       | https://github.com/ValdemarOrn/PentatonicScales
        
       | delineator wrote:
       | Things get more fun when we explore musical tunings other than
       | the 12 equal divisions of the octave (EDO) of Western music.
       | 
       | You can define interval structure as a sequence of large L, small
       | s, and optionally medium M steps.
       | 
       | For example, the Major diatonic scale - a 7 note scale from 12
       | EDO - in Ls notation is:                  LLsLLLs with L: 2  s: 1
       | (12=2+2+1+2+2+2+1)
       | 
       | A 19 EDO, 7 note scale:                  LLsLLLs with L: 3  s: 2
       | (19=3+3+2+3+3+3+2)
       | 
       | And here's a 19 EDO scale with 9 notes (Godzilla-9):
       | LLsLsLsLsLs with L: 3 s: 1 (19=3+3+1+3+1+3+1+3+1)
       | 
       | You can then explore frequency ratios beyond those available in
       | 12 EDO:
       | https://github.com/robmckinnon/pitfalls/blob/main/lib/ratios...
       | 
       | And chords based on those ratios:
       | https://github.com/robmckinnon/pitfalls/blob/main/lib/chords...
       | 
       | The above links are Lua code files for a monome norns library for
       | exploring microtonal tuning: https://llllllll.co/t/pitfalls/37795
        
       | njharman wrote:
       | We need more "Explain things like I'm a programmer" explanations.
       | 
       | I've tried to grok music theory several times. I've never
       | understood the scale/notes, notations. The 2nd array (with sharps
       | and flats) and couple paragraphs made it "click" instantly.
       | Because it was in a language and presentation I understand.
        
       | algesten wrote:
       | A perfect 5th is not the same as a diminished 6th unless we
       | assume equal temperament tuning. Granted it is the dominant
       | tuning, but it irks me when this is just silently assumed.
       | 
       | Plenty of music around that is recorded using actual perfect
       | intervals, so why muddy the waters?
        
         | jedimastert wrote:
         | I think going out of equal temperament into other modes of
         | tuning/intonation would definitely be considered outside of
         | "basic music theory".
         | 
         | It feels like grumping about some inaccuracies/glossing over in
         | elementary school mathematics because of the existence of
         | imaginary numbers.
        
           | IggleSniggle wrote:
           | I firmly disagree. I learned about staying "in tune" with
           | those that I was playing with in an ensemble long before I
           | learned about equal-temperament and its concessions to multi-
           | key harmony.
           | 
           | I'd say removing the beats from your partials is way more
           | fundamental to both music making and music theory than
           | chromaticism. Chromaticism is the _next_ step, beyond basic
           | music theory.
        
             | jedimastert wrote:
             | > I learned about staying "in tune" with those that I was
             | playing with in an ensemble long before I learned about
             | equal-temperament and its concessions to multi-key harmony.
             | 
             | I'd consider that a performance technique before a theory
             | aspect, like vibrato speed and control or enharmonic
             | fingerings.
             | 
             | Consider this: If you were in a duet as a beginner and the
             | sheet music had your partner playing a C and you playing an
             | A double-flat, how would you be instructed to play it?
             | 
             | You'd be told it was enharmonic to a G, and play it as a G.
             | 
             | Until you start reaching deep into historical re-enactment
             | or advanced theory, it's very safe to assume equal
             | temperament and leave the ear-adjustment to performance.
        
               | IggleSniggle wrote:
               | I guess my response to this is that _basic_ music theory
               | is roughly equivalent with basic acoustics, has more
               | bearing on generalized musical practice than what you are
               | implying, and that even reading sheet music is an
               | abstraction that requires foundations in a musical
               | culture that has a prerequisite of certain assumptions
               | that may not actually hold.
               | 
               | If you listen to CPE Bach knowing that each note can be
               | bent (as on a guitar, because it is a clavichord), then
               | the _written_ music makes more sense because each note
               | can be tuned to be harmonic with the fundamental. The
               | sheet is just a sketch. The presumed required bend in
               | each note totally changes the expectations of the key it
               | is written in.
               | 
               | Or, if you are listening to a gamelan, then the beating
               | of notes becomes an essential rhythm of the instrument,
               | informing the tempo of the ensemble as a whole.
               | 
               | Music theory is a combination of acoustics and music
               | history, but the acoustic part is more fundamental/basic.
               | Like knowing "Clueless" is based on "The Taming of the
               | Shrew" is informative, but the _fundamentals_ of quality
               | movie making or movie consuming do not require you to
               | know anything about Shakespeare.
        
           | [deleted]
        
         | mvanga wrote:
         | Interesting. Do you have some reference or link where I can
         | learn more?
        
           | ebiester wrote:
           | You basically can look up just intonation versus equal
           | temperament for the basics.
           | https://pages.mtu.edu/~suits/scales.html gives the
           | mathematical answer but doesn't get into the history.
           | 
           | A clause that says "assuming twelve-tone equal temperament"
           | would be sufficient here, but you can really go down the
           | rabbit hole if you start digging into scales (see
           | microtonal), and your page is meant to be more basic.
        
           | algesten wrote:
           | The wikipedia page is pretty good https://en.wikipedia.org/wi
           | ki/Equal_temperament#Comparison_w...
           | 
           | A fifth might even sound off key if you're very used to equal
           | temperament (it's about 2 cents below an equal temperament).
           | You know it by there being no or less "wobbling" between the
           | tones.
           | 
           | For listening tips, look for vocalist groups where there's
           | "One Voice Per Part" (OVPP). Voces8, Vox Luminis, etc. When
           | there's only one voice, you don't get the inherent wobbling
           | happening when two instruments/voices play in unison.
           | 
           | Not all genres are possible to have just (jazz chord colors
           | would sound rubbish).
        
           | mmcconnell1618 wrote:
           | Here's some good background on equal temperament as explain
           | by Howard Goodall on a BBC series about music:
           | 
           | https://www.youtube.com/watch?v=41g2fSYZ4Sc
        
       | dvfjsdhgfv wrote:
       | It would be awesome to add short audio clips. I mean, the
       | examples are correct and all, but it's like discussing painting
       | or photography without a single picture.
        
         | siltpotato wrote:
         | As a musician, I'd say no. Sure, you don't get the significance
         | of "what is this Dorian thing" unless Scarborough Fair is
         | playing, but nothing in the article really applies to hearing
         | music.
        
           | dvfjsdhgfv wrote:
           | > As a musician, I'd say no. Sure, you don't get the
           | significance of "what is this Dorian thing" unless
           | Scarborough Fair is playing, but nothing in the article
           | really applies to hearing music.
           | 
           | I don't know what's with the current flagging/downvoting
           | trends on HN, comments get dead before I can reply.
           | 
           | That said, your view seems rather extreme. What would be the
           | downside of illustrating at least some of the samples with
           | audio clips?
        
             | siltpotato wrote:
             | I didn't mean there was no downside, certainly not. Just
             | that it didn't seem as needful to me.
        
       | protoman3000 wrote:
       | > Modes are essentially left-rotations of a scale.
       | 
       | While true, I find this interpretation harmful to the
       | understanding of modes. It didn't provide me with any insight and
       | instead it seemed irregular to the other theoretical constructs
       | we have and thus deterred and misled me in the beginning.
       | 
       | To me, it all clicked when I took all the modes, except Lydian,
       | and constructed them by putting down the augmentations to the
       | major scale in a circle-of-fifths sorted way:
       | 
       | Mixolydian: b7, Dorian: b7 b3, Aeolian: b7 b3 b6, ...
       | 
       | You can see that the modes appear walking left on the circle of
       | fifths or walking along fourths (or going "darker", as some
       | prefer to say). Try this out when starting at e.g. C and you see
       | the pattern immediately.
       | 
       | Then take Lydian: #4
       | 
       | That's going right on the circle of fifths or going in fifths
       | going "brighter".
       | 
       | Also, tangential comment: My music and my life has changed
       | profoundly when I found out how to use the Lydian mode. I can't
       | explain it, but it is just exciting.
        
         | mvanga wrote:
         | Oddly, for me it was the opposite!
         | 
         | I used to be confused on _why_ modes required modifying certain
         | notes from a major scale until I tried deriving them in the way
         | shown in the article.
         | 
         | Of course, once you understand that, the way you go about
         | memorizing and practicing is probably easier the way you
         | described; that is, deriving modes in any given key by
         | modifying notes of the major scale using the circle of fifths.
        
           | protoman3000 wrote:
           | > modes required modifying certain notes from a major scale
           | 
           | But why though? If you're improvising on a dominant (e.g. a
           | G7 in the key of C Major) with a G Mixolydian scale, you're
           | actually not playing a Mixolydian sound, but Ionian, since
           | your tonal center is C Ionian. It is true, it is indeed a G
           | Mixolydian scale and it is using the tonal contents of our
           | key C Ionian. But our frame is Ionian, so what is the purpose
           | of adding Mixolydian other than ease of construction of the
           | scale?
        
         | seanhunter wrote:
         | One way to make that ordering work with Lydian is to start with
         | Lydian and flatten one note each time. So say we start in C. C
         | lydian, flatten the F# we have C Ionian, flatten the b we have
         | C mixolydian, flatten the e we have C dorian, flatten the A we
         | have C aeolian, flatten the d we have C phrygian, flatten the g
         | we have C locrian
         | 
         | Now we flatten the C (after all this is the next note in the
         | cycle of fifths) and we have.... B lydian. And the whole thing
         | starts again.
         | 
         | In this way you can understand how all the modes and keys
         | relate. You can do a similar thing with the other 3 similar
         | modes of limited transposition in this order (melodic minor,
         | harmonic minor and harmonic major).
         | 
         | Have fun.
        
         | paradygm wrote:
         | What made it click for me analyzing music, in particular rock
         | songs like 'Gloria.' That song very strongly identifies E major
         | as the tonic, but the D and A chords are not in E, they are
         | diatonic to A major. To say it is in A major would mean the
         | song's tonic would be A, but since it is E major it is more
         | correct to say the song is in E Mixolydian.
         | 
         | Adam Neely recently did a great analysis of 'Hey Joe' that goes
         | pretty deep into this stuff https://youtu.be/DVvmALPu5TU
        
       | whiddershins wrote:
       | " For historical reasons, there are no sharps or flats between
       | the notes B/C, and E/F."
       | 
       | Mmmm yes, and that's also a bit confusing because it dodges
       | around why the scale was and is 7 notes to begin with.
        
         | xavriley wrote:
         | Coincidentally there are no commonly used scales or modes with
         | two consecutive semitones. The semitone gaps are always spaced
         | out. With 11 notes (excluding the octave), that only leaves 4
         | possibilities for a 7 note scale if you remove rotations. These
         | correspond to major, harmonic minor, melodic minor and harmonic
         | major. It's easy to prove with pencil and paper concentrating
         | on c to c
        
           | boomlinde wrote:
           | _> Coincidentally there are no commonly used scales or modes
           | with two consecutive semitones._
           | 
           | It's common in Bebop to add a passing tone to otherwise
           | heptatonic scales. Consecutive semitones are also a common
           | feature in blues.
        
         | euroderf wrote:
         | As a kid I dismissed the piano because nobody explained to me
         | why the keyboard was so stupid looking, laid out so
         | irregularly. WbWbWWbWbWW. Wot? Only some self-education (much
         | later) revealed that 12 tones per octave deliver some excellent
         | harmonies, not 11 or 13 or 20 or 36 or whatever. Twelve. But
         | the harmonies come only on odd steps. So we have 5 semitones to
         | a perfect fourth (4:3 harmony), then two semitones to a perfect
         | fifth (3:2 harmony), then 5 semitones to the octave. And then -
         | just to keep it confusing - we have to split both of those
         | groups of five semitones, so... we arbitrarily split them as
         | 2-2-1 (i.e. WbWbWW keys). Thus the white/black keyboard
         | pattern, starting at C, of WbWbWWbWbWW. If only someone had
         | explained all this in grade school.
        
           | kaoD wrote:
           | I didn't really understand your explanation so I might be
           | restating your ideas, but just in case:
           | 
           | > And then - just to keep it confusing - we have to split
           | both of those groups of five semitones, so... we arbitrarily
           | split them as 2-2-1 (i.e. WbWbWW keys). Thus the white/black
           | keyboard pattern, starting at C, of WbWbWWbWbWW. If only
           | someone had explained all this in grade school.
           | 
           | We don't arbitrarily split them! It was very much made on
           | purpose to match the diatonic scales, which are very natural
           | due to being a chain of fifths. E.g. from F ascending 5ths:
           | F-C-G-D-A-E-B-!F!
           | 
           | It's not arbitrary that we based modern keyboards around
           | heptatonic scales! Then we added some black notes so we can
           | transpose, which is pretty convenient on 12-TET.
        
       | diegoperini wrote:
       | I wonder if there is a scripting environment where I describe a
       | chord progression in one thread, a lead voice in another and run
       | them simultaneously, written entirely in code as a single file
       | (or 2 files for parts + 1 for importing those).
        
         | ksm1717 wrote:
         | https://github.com/synestematic/kord
         | 
         | I don't think this has "execution"/synthesis features, but it
         | could at least provide the basis for this environment.
        
         | reitzensteinm wrote:
         | You might want to try Sonic Pi, which pairs Ruby with the
         | SuperCollider synthesizer engine: https://sonic-pi.net/
        
           | xavriley wrote:
           | It will work in Sonic Pi, but I'm looking at ways to make the
           | voice leading of chords more intelligent. At the moment it
           | will voice chords in root position unless you specify
           | otherwise. I'm also looking at writing a parser so the chord
           | symbols can be written naturally as a string
           | 
           | Edit: I'm on the Sonic Pi core team. I mean that I'm looking
           | to add these features to sonic pi soon
        
             | TheOtherHobbes wrote:
             | There are no simple algorithms, because solutions are style
             | dependent, covering the range from parallel transposition
             | of house chords to a full Baroque counterpoint solver, via
             | pop, rock, and jazz theory.
             | 
             | The question isn't can you do it - because you can, with
             | varying degrees of difficulty.
             | 
             | The question is what _specific_ user problem you 're trying
             | to solve.
        
       | WhompingWindows wrote:
       | As a primer for music theory, this post doesn't teach much. It's
       | using Python to derive various sets of notes in scales and modes,
       | which is already easily available via google search, and in a
       | more learnable format than Python code.
       | 
       | The most basic aspect of Western music theory overlooked here is
       | the relationship between tonic and dominant. If you know the
       | "home" chord aka "the I" aka "tonic" is C major, the dominant
       | will be G major, aka the V chord. Add just the F major chord, and
       | you'll know 1-4-5 in a "basic" key: C major. 1-4-5 is the
       | simplest chord progression, you can play amazing grace, you are
       | my sunshine, even The Beatles, you'll be rocking with 1-4-5.
       | 
       | Next level, if you add in the minor 6 (a minor) and minor 2 (d
       | minor), you realistically know 95% of the chords you'll ever hear
       | in C major pieces. And on the piano, this is ALL white notes, so
       | even someone with zero musical knowledge can "solo" over your
       | chords by just plunking any white notes while you play these
       | chords (kids LOVE LOVE this btw, highly recommend trying with a
       | kiddo).
       | 
       | I wouldn't consider double-sharps and double-flats "basic" music
       | theory. They really aren't needed for beginners, since they're
       | relegated to keys like C# major where you'll occasionally sharpen
       | a note like E# (aka F) into E## (aka F#). I didn't run into these
       | until around 5 years into my piano training, playing Chopin's F#
       | major nocturne Op 15 No 2, there's a bunch of double sharps in
       | that piece.
       | 
       | In any case, don't worry about double-flats and double-sharps or
       | the precise notes of various modes and scales. Just learn pieces
       | you enjoy, preferably with a mentor or teacher who can suggest
       | improvements based on their trained ear.
        
         | bazeblackwood wrote:
         | Just a note, it would be less ambiguous to say the chords are a
         | 6 minor and 2 minor since minor 6th and minor 2nd are both
         | intervals that don't relate to those chord qualities, for
         | example the minor 2nd is a semitone above the tonic note,
         | whereas a 2 minor chord (or ii, since lowercase represents
         | minor chords in roman numeral chordal analysis) starts a whole
         | tone above the tonic. Also, I think you mean the iii chord,
         | since the ii chord is much less common. But by that measure you
         | may as well be teaching the bVII (flat 7 dominant), which shows
         | up all over the place in popular music
         | (https://www.hooktheory.com/theorytab/common-chord-
         | progressio...). That said, I agree chordal analysis is quite
         | useful as a beginning point, but mostly for teaching the
         | instruments that, well... play chords.
        
           | MrsPeaches wrote:
           | > Just a note
           | 
           | This made me smile.
        
             | bazeblackwood wrote:
             | That was (p)unintentional on my part, your pointing it out
             | was instrumental!
        
         | strokirk wrote:
         | Do you know why these chords are so common? Is it simply
         | cultural or something else?
        
           | hexane360 wrote:
           | The notation OP is using is relative to the key of your song.
           | So if your key is C major, the V chord is G. However, if your
           | key is F major, the V chord is Bb. So it's not that there's
           | only a few chords used in popular music, it's that there's a
           | very consonant group of chords for any key your choose.
           | 
           | Also, OP is leaving out lots of ways to modulate these basic
           | chords into more complex ones (adding a seventh step,
           | inversions, power chords, etc.).
           | 
           | Finally, as with a lot of pseudo-Pareto type things, often
           | the few exceptions are what make or break a piece musically.
        
             | lovelyviking wrote:
             | Any suggestions about theory learning beyond this?
             | 
             | Something that would help with composition perhaps? Music
             | phrasing? Some book to read? Something for self learning? I
             | wish that melodies I am trying to compose would be better
             | in reflecting what I like in music, and I whish to figure
             | out what is missing.
             | 
             | I can improvise with different chords but it is getting
             | boring and once I try to do something more comlex it
             | doesn't reflect what I like.
             | 
             | I think I am missing something basic and simple but since I
             | had no other option but to learn myself mostly it is
             | probable that I simply wasn't exposed to something
             | essential in theory, something that all good composers know
             | very whell, something that allows experimenting but in a
             | productive way.
             | 
             | May be there is a book that is like a _bible_ for all
             | composers and I simply never heard about it?
        
               | ska wrote:
               | I don't have any specific recommendations and am quite
               | rusty - but years ago when I was similarly interested I
               | just looked up a decent undergraduate music programs
               | course requirements and got their intro harmony text
               | followed by intro comp text; learned a lot from that.
        
           | mywittyname wrote:
           | As it was explained to me by my musician aunt (and I've heard
           | it repeated in other places): because Music Execs. Lots of
           | successful pop music is uses the 1-4-5-(6) chord progression,
           | thus, when executives are picking hit songs, they go with
           | what they know will work.
           | 
           | It's like bringing brownies to a potluck. It won't blow
           | anyone's mind, but everyone will happily eat them.
        
             | fuckf4ce wrote:
             | That still doesn't explain why those chord progressions
             | became popular, and they far predate the late 20th century
             | record industry, so it really isn't a very satisfying or
             | informative explanation, even though it's not outright
             | wrong (it's just a restatement of familiarity bias, which
             | generalizes outside music).
        
               | ska wrote:
               | A fair bit of early music composition is weighted by what
               | is easily sung, more than anything else.
        
         | irrational wrote:
         | Heh, I understood your first paragraph. I understood literally
         | nothing in the following two paragraphs. Is this what it is
         | like when I talk to people who don't know anything about
         | programming about my work? Pure gibberish?
        
           | tarsinge wrote:
           | Scales are the set of notes you can play during the song that
           | will sound ok to the ear.
           | 
           | On a song in C major (or A minor), you can play any white
           | key.
           | 
           | Chords are sections based around a note.
           | 
           | The notes played during a chord give mood and color to the
           | chord (harmonies).
           | 
           | Also the sequence of the notes is the melody.
           | 
           | And also simultaneously the ordering of the chord "drive" the
           | song and also the mood. The 1-4-5 the parent is talking about
           | is a very common chord progression. The numbers here are
           | simply the 1-index of the note in the scale used as the base
           | for the chord.
        
           | zibzab wrote:
           | I recommend you subscribe to prof Guy Michelmores YouTube
           | channel then.
           | 
           | He is pretty good at explaining music theory without boring
           | you to death. He even has a video on 1-4-5
        
           | taormina wrote:
           | Yup!
        
           | actusual wrote:
           | I think it depends on who is explaining the complex topic.
           | The main goal for the "explainer" is to implant ideas in
           | someone else's head in a way they can understand and relate
           | to. This is done through a shared vocabulary. If someone
           | knows nothing about a topic, then the entire explanation must
           | be done in the listener's vocabulary (while slowly and
           | deliberately introducing new terms, and clearly defining
           | them), which OP didn't really attempt to do.
        
           | RHSman2 wrote:
           | Add on top the time signature grid and then you got some real
           | giberrish! 'The 6th hits on the ah of 3 ok!'
        
           | abakker wrote:
           | Yes, it is! Music and programming both have a lot of
           | notation, syntax, and terminology.
           | 
           | I am not really a programmer, but the thing I always wanted
           | wasn't a "how to program guide" but "what is all this syntax"
           | guide.
           | 
           | It is funny, but when you learn a written language, you spend
           | a lot of time learning grammar and punctuation, but when you
           | go to learn programming it all seems conceptual. there are
           | lots of demonstrations of grammar and punctuation, but I
           | rarely see nice, succinct lists of all the syntax you might
           | encounter.
        
             | Atlas-Marbles wrote:
             | https://learnxinyminutes.com might be what you're looking
             | for. Concise syntax guides for many languages.
        
             | yumaikas wrote:
             | So, this is for a few reasons.
             | 
             | Syntax is a skill floor, but it's not anywhere close to a
             | skill ceiling.
             | 
             | If you want rapid-fire example of the various forms a given
             | language commonly uses, I recommend X in Y minute guides.
             | Those show off the various bits of syntax for a given
             | programming language, though without rigorously defining
             | them as such.
             | 
             | Part of the reason that programming syntax is usually
             | taught by example, rather than by formalism is that the
             | formalisms for programming syntax, well, look like this:
             | (cribbing from wikipedia).                 program =
             | 'PROGRAM', white_space, identifier, white_space,
             | 'BEGIN', white_space,                  { assignment, ";",
             | white_space },                  'END.' ;       identifier =
             | alphabetic_character, { alphabetic_character | digit } ;
             | number = [ "-" ], digit, { digit } ;       string = '"' , {
             | all_characters - '"' }, '"' ;       assignment = identifier
             | , ":=" , ( number | identifier | string ) ;
             | alphabetic_character = "A" | "B" | "C" | "D" | "E" | "F" |
             | "G"                            | "H" | "I" | "J" | "K" |
             | "L" | "M" | "N"                            | "O" | "P" |
             | "Q" | "R" | "S" | "T" | "U"                            |
             | "V" | "W" | "X" | "Y" | "Z" ;       digit = "0" | "1" | "2"
             | | "3" | "4" | "5" | "6" | "7" | "8" | "9" ;
             | white_space = ? white_space characters ? ;
             | all_characters = ? all visible characters ? ;
             | 
             | Can you take that grammar and write 10 examples of valid
             | statements from it, with no other context?
             | 
             | vs, if I give you                 PROGRAM ASSIGNMENTS
             | BEGIN         MYSTRING := "A STRING";       MYNUMBER :=
             | 123;       END
             | 
             | That gives you a much better flavor from looking at things.
             | 
             | Ultimately, most programming languages should have defined
             | grammars in their docs somewhere, but most devs use them by
             | intuition, rather than formally.
             | 
             | The other thing, as well, is that it's one you get past
             | grammar as a primary concern that you gain true fluency.
             | And there are a lot of things that are higher level than
             | grammar that can aid/hurt a program much more than the
             | grammar constructs (like various patterns, know algorithms,
             | schemes of organization for different types of projects,
             | and so on). A mostly human-usable grammar is table-stakes
             | these days.
             | 
             | If you have a specific language you want examples or a
             | grammar on, let me know, and I'll see if I can find it.
             | 
             | (edited for formatting)
        
               | fao_ wrote:
               | > Part of the reason that programming syntax is usually
               | taught by example, rather than by formalism is that the
               | formalisms for programming syntax, well, look like this:
               | (cribbing from wikipedia).
               | 
               | Here's the thing though -- a "what is this syntax" guide
               | does not imply that you need a _formalism_ of the syntax.
               | What the person is asking for, in my opinion, is a
               | linkage between the symbols and the concepts.
               | 
               | For example, when reading mathematics, often the problem
               | was not my conceptual understanding of the material, but
               | merely that I was not sure how to parse the symbols and
               | map them to what it was _doing_. I could read a formula,
               | but the mapping of each component piece as a shorthand
               | was not there. At the time I did not internalize that
               | "square root" is literally just getting the side of a
               | square (A somewhat silly, obvious-in-retrospect idea! But
               | it gives you a perfect example of the kind of mapping I'm
               | talking about) -- because of this I wasn't able to get an
               | idea of what it was doing!
               | 
               | In such a case, your formalism would not have worked,
               | because it's simply a grammar. I did not need the grammar
               | -- examples can show that, wikipedia can show that, what
               | I needed was enough information about the link between
               | the symbolic, and the conceptual, that I could find
               | reference material. What I found instead was either as
               | you put down, literal grammars, or vast tomes of
               | knowledge that required _more_ vast tomes of knowledge to
               | read and figure out what each one in turn was saying. So
               | I would get lost down this rabbit hole.
               | 
               | What the _solution_ to this is, again IMHO, is a listing
               | of syntax, yes, but with a conceptual mapping on the
               | right.
               | 
               | So not saying things that we already know -- like "this
               | is a number", but having a construction of an IF
               | statement, and then a conceptual mapping on the right in
               | the form of written description of how it works, or a
               | visual description like a flow chart.
               | 
               | The point of writing was to convey knowledge, it is
               | possible to convey intuition, and yet in scientific
               | fields we seem adverse to doing so! It's treated almost
               | like an unspoken thing, it is covered in passing, but
               | almost never explicitly. It's why much of "intermediate
               | programming" is difficult to break into, in my opinion --
               | and the same for mathematics (3blue1brown is breaking
               | this up, however)
        
               | yumaikas wrote:
               | Also, to add a further point: Because much programming is
               | done by intuition rather than formalism is why there can
               | be so much unintended use of a given program.
        
         | scpedicini wrote:
         | Good stuff, but since it seems like there is a lot of pedantic
         | responses to this post I'm going to chip in myself and say that
         | most traditional gospel renditions of amazing Grace also make
         | use of the supertonic. In the key of C that would be DMaj.
        
         | lovelyviking wrote:
         | Your advice is good and most of the advices stop at this level.
         | Do you have any advices for what to learn next?
         | 
         | Any suggestions about theory learning beyond of what you've
         | described?
         | 
         | Something that would help with composition perhaps? Music
         | phrasing? Some book to read?
        
         | unixhero wrote:
         | Thanks a lot. I am adding your post into my collection of
         | Hacker News wisdom snippets :)
        
         | grawprog wrote:
         | >The most basic aspect of Western music theory overlooked here
         | is the relationship between tonic and dominant. If you know the
         | "home" chord aka "the I" aka "tonic" is C major, the dominant
         | will be G major, aka the V chord. Add just the F major chord,
         | and you'll know 1-4-5 in a "basic" key: C major. 1-4-5 is the
         | simplest chord progression, you can play amazing grace, you are
         | my sunshine, even The Beatles, you'll be rocking with 1-4-5.
         | 
         | Having learned music theory on a guitar rather than a piano, I
         | learned this in a different order. C Major wasn't the focus at
         | first. We started with Am Pentatonic and learned the common
         | 1-4-5 progression and how to build chords and progressions out
         | of that. Then added the rest of the notes of the Am scale in
         | before finally going into root notes and relative scales and
         | learning C major.
         | 
         | It's just my conjecture, but i think Am works better on guitars
         | for learning because it's right in the middle of the guitar
         | starting on fret 5 on the 6th string. Makes it easy, like you
         | say, for someone to solo along with a 1-4-5 progression just by
         | running up and down the scale. As long as you hit the right
         | frets, it'll sound decent, you don't have to stretch too far,
         | you get a nice clear view of the scale's 'pattern' on the
         | frets. Plus, it's the relative minor of Cmajor meaning, you can
         | still play along with someone just hammering white keys on a
         | piano.
         | 
         | We also learned using a lot of blues music. There's a lot of
         | easy variations you can do on a guitar in an Am blues key that
         | can teach you all those fundamentals.
         | 
         | Modes were also worked in at the same time. This was probably
         | not the best though, cause i really didn't get them at the time
         | and only fairly recently sat down to study them and actually
         | figure them out.
        
       | williesleg wrote:
       | Oh what a genius! Somebody wrote some code!
        
       | [deleted]
        
       | bdenckla wrote:
       | This is a fun read but IMO it falls into the common trap of
       | trying to formalize concepts in music theory based on a
       | representation too close to traditional music notation. A notable
       | consequence of this trap is that the author has to do a lot of
       | distracting work to handle enharmonics, and yet still has
       | arbitrary limits on number of flats and sharps. In other words,
       | he has to do a lot of distracting work, and still all that work
       | doesn't yield a general system.
       | 
       | In my opinion (and experience) it is better to do a little work
       | "up front" and "in the back" to convert to the line-of-fifths
       | representation since that is more friendly to formalization. In
       | other words you can take input in traditional musical notation
       | and give output in traditional musical notation, but "in the
       | middle," formalization should be done in the line-of-fifths
       | representation.
       | 
       | Above I have used "formalize" to mean something like
       | "mathematicize" (if that's a word) or "be precise" or "be able to
       | compute" or "be able to express in a programming language (like
       | Python)". For example, I consider the line-of-fifths
       | representation to be a good one in which to formalize music
       | theory because in line-of-fifths representation, transposition
       | can simply be formalized as integer addition, and integer
       | addition needs no further explanation or formalization, i.e. it
       | can be taken as sort of axiomatic.
       | 
       | Here's another way of putting it: if you wanted to be able to add
       | Roman numeral strings, would you write code that directly
       | operated on the Roman numeral strings, or would you first convert
       | to a compute-friendly representation like integers, and then do
       | your adding from there? No doubt there are tradeoffs involved,
       | but I tend to think that it is usually worth it to move to a
       | compute-friendly representation, both with Roman numerals and
       | music notation.
       | 
       | An added benefit of line-of-fifths representation is it provides
       | a good basis to formalize many important historical European
       | tuning systems.
        
       | geekster777 wrote:
       | Something I wish was more clear in music theory is just how much
       | overlap exists between the various concepts. I think it suffers
       | from having so many names for everything, the learning curve
       | seems much steeper than it really is. Even in this article, much
       | time is spent on the duplicate names of notes and intervals. As a
       | fairly proficient self-taught guitarist, this intimidating
       | perception of theory delayed my learning of it for easily 5-8
       | years.
       | 
       | For example, you may spend a while learning the major scale, and
       | what can be done with it. Then you learn the minor scale, and it
       | seems like a totally separate scale that sounds completely
       | different. And after that you learn that there are five other
       | scales (modes) to learn about! (Dorian, Phrygian, Lydian,
       | Mixolydian, and Lochrian!). It can seem extremely overwhelming
       | until you learn that they're all the same scale with different
       | relative starting positions. Where major is [1,2,3,4,5,6,7],
       | minor is [6,7,1,2,3,4,5], and the other modes are all the other
       | permutations of starting positions.
       | 
       | My other gripe is that learning theory on piano puts a lot of
       | bias on the notes themselves rather than the intervals. For
       | example, the B major scale has 5 sharp notes (black keys) to
       | remember whereas C major scale has none. These are pretty
       | different shapes to remember. Learning these on guitar means
       | taking the same exact shape and shifting it up a fret (so if you
       | know one major scale, you know them all!). Not to say that guitar
       | is the perfect instrument for learning this - folks will often
       | learn scales as close to the 0th fret as possible, causing you to
       | start on different strings and have slightly different patterns.
       | 
       | That being said, I wish there was a purely linear instrument (a
       | piano with the black keys flattened?) for learning theory. The
       | real magic comes from identifying the shapes and patterns, and
       | how they're similar to each other. Like how major and mixolydian
       | are identical except for one note, so it's very easy to modulate
       | between them, or make a listener think they're in one mode when
       | they're in another. Same with minor and phrygian. Being able to
       | drop the baggage of "the second note of the B major scale is C#
       | which is this black key here" and just focus on a floating set of
       | intervals seems like it would make this all easier and less
       | intimidating.
       | 
       | That all said, I still feel reasonably early in my theory
       | journey. So maybe this is just my bias coming from guitar.
        
       | pashariger wrote:
       | I found this very helpful! As a self-taught musician, it filled
       | some gaps in my music theory knowledge - especially being able to
       | visualize computing scales, modes, and intervals as algorithms. I
       | can now better evaluate these in my head when I encounter a
       | key/scale that I haven't seen before! Thank you!
        
       ___________________________________________________________________
       (page generated 2021-04-19 23:01 UTC)