22.11.11

4083 chords, with python



A chord in music is any harmonic set of two–three or more notes that is heard as if sounding simultaneously.[Wikipedia]


In previous posts i calculated there are 4083 chords and introduced to music21 python tools.
Let's use this smart framework for computer-aided musicology, with some python, to compute, view, explore and hear all the 4083 chords.
See setup instructions on music21 website.
We need to import 2 modules, music21 and itertools:

So, how many chords are there?
Below a function to compute the number of combination of n items taken t a t without repetitions (t may coincide with n):

Here we have the ever popular recursive factorial function:

A trivial iteration gives us the total (n = 12, the twelve tones!):

Itertools module is really great to handle permutations, combinations etc. The perfect ars combinatoria tool.
It is applied in the main function to make all combinations without repetitions:

Note some very nice music21 methods and attributes, like pitchedCommonName and addLyric.
As you may have noticed, i write all in a txt file to better explore chords:

We are now ready to generate all chords and display them with MuseScore:

Download commented source, txts, pdfs and MuseScore projects.

My Fav Chords
Here some of my favorite chords, nice labeled by music21:


Bugs
Unfortunately I found a few bugs. Using numbers for pitches the contiguous notes are not written in the stream.


Furthermore, method pitchedCommonName has some problems yet to appoint chords properly.


However it was a nice trip.

15.11.11

Le 5 formule matematiche che ogni musicista dovrebbe (almeno far finta di) conoscere


Ispirato da questo articolo di Wired Science, ecco le 5 formule matematiche che ogni musicista dovrebbe (almeno far finta di) conoscere:

1. La purezza di una sinusoide. Senza questa niente oscillatori digitali e quindi niente musica elettronica.





2. Sezione aurea. Senza questa niente violini Stradivari, niente Debussy (in particolare il capolavoro La Mer), niente Genesis (avete presente Firth of Fifth?).





3. La serie di Fourier (qui in forma complessa, la mia preferita). Sarebbe più facile elencare cosa rimarrebbe (ben poco) senza questa. Un diamante concettuale, tra le massime espressioni del pensiero umano.





4. Valore efficace. Senza questa, ad esempio, niente compressori (Spark!)






5. E per finire, i Cent che spezzettano i semitoni (con la formula si ottiene il numero di centesimi corrispondente a un rapporto r tra due frequenze). Senza questa niente Autotune e nemmeno Melodyne.




Adesso il Prof ce le spiega tutte nei commenti... :-)