Live data from Hacker News

Basic Music Theory in ~200 Lines of Python

mvanga.com

161–170 of 192 posts

Re: Basic Music Theory in ~200 Lines of Python

#161

Earlier quoted context omitted.

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?

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 demonstration…

https://learnxinyminutes.com might be what you're looking for. Concise syntax guides for many languages.

Re: Basic Music Theory in ~200 Lines of Python

#162

Earlier quoted context omitted.

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,…

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 thi…

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. Or even just B' J' M', as in "B'eatles J'amming M'usic" et al. 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 (in MaNePu, Jazz, Word notes):

Ja Ja Ka Ma Ma Ka Ja Fa Ba Ba Fa Ja Ja Fa Fa

3 3 4 5 5 4 3 2 1 1 2 3 3 2 2

Re Re Su Ve Ve Su Re Pu Ma Ma Pu Re Re Pu Pu

It's great to see that. I immediately notice we're both using consonants only for the first character. I can describe to you the trigram lines being referred to in MaNePu as a bottom line if ending in a, middle if e, and top if u. But the glyphs didn't work here so find the trigrams. I notice you didn't demote the letter 'u' out of your system. I personally am much more partial to the letter 'o'. ;)

We can write this passage with the bass accompaniment as well. Bassline just plays 1/Ja/Ma and 5/Ma/Ve. Weird to look at here because Ma=root for you and Ma=fifth for me! Obviously our layperson reader might not also know that Ma is a standard way to notate a major chord in music, as well.. which kind of also has nothing to do with the first two Ma's we were discussing. And we're not going to bring your mom into it either ;) Anyway here it is. Maybe mistakes (?) cause I'm handwriting here, and I just learned your system:

Bat BAt BAk BApEp Map MApAt MApAb MapEp Bap Bap BIp BAt Bat BIp Map

3/1 3 4 5 5/5 4 3 2/5 1 1 2 3 3/1 2 2/5

ReMa Re Su VeMa Ve Su Re PuVe Ma Ma Pu Re ReMa Pu PuVe

As a critique of your system if I was fluent and you read that out to me, I'd be unsure of when the root actually changes.. because when I read ReMa out I think of playing F# then D. As opposed to F#/D (at the same time).

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). I want to point out that when my system uses less letters it's because the last letters are "A" or "p" meaning no notes in this quarter. That's why some are only one syllable instead of my mentioning two. In another way if a chord is over the root we could omit the B at the beginning because it would be assumed. In this second example I included all the B's and M's (1 and 5. D and A in "normal" notes). This way the melody is seperate on top and the root motion is still specified.

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.

Re: Basic Music Theory in ~200 Lines of Python

#163
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.

Re: Basic Music Theory in ~200 Lines of Python

#164

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…

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.

Re: Basic Music Theory in ~200 Lines of Python

#165
post #64

Not a musician here but are scales really necessary? Why not just play any frequency I want?

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.

Re: Basic Music Theory in ~200 Lines of Python

#166
post #64

Not a musician here but are scales really necessary? Why not just play any frequency I want?

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.

Re: Basic Music Theory in ~200 Lines of Python

#167

Is there a (really) accessible book on music theory that anyone would recommend?

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...

Re: Basic Music Theory in ~200 Lines of Python

#168

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…

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?

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). The main notes of a chord (that will sound the best) are found by taking every two notes (the note+2+2), e.g. for the C chord it’s C, E and G.

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 (C major, F major, G major). The numbers here are simply the 1-index of the note in the scale used as the base for the chord.

So while you have three dimensions simultaneously which can feel overwhelming the parent was saying that simply following the 1-4-5 progression and playing randomly white keys will sound ok.

Next step try to hit one the main notes of the chord when it is playing (C E or G for the 1 for example).

Re: Basic Music Theory in ~200 Lines of Python

#169

Earlier quoted context omitted.

> 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. B…

So if you pretend that the sharps arent there and that they dont make any difference to anything then its all simple?

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.

Re: Basic Music Theory in ~200 Lines of Python

#170

Earlier quoted context omitted.

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,…

> Just a note This made me smile.

That was (p)unintentional on my part, your pointing it out was instrumental!
Post reply on HN