Platonic Music Engine logo

First Annual Progress Report on the Platonic Music Engine

I began coding the Platonic Music Engine on 4 July 2014. I had intended to provide a progress report one year later. Unfortunately life got in the way and my plan fell apart.

But here we are two+ months late which is better than never, as we’re told.

The project is going slower than I had anticipated but is moving forward and there are several big changes being implemented which I will outline below.

First a bit of background about the underlying music technology: MIDI.

MIDI

On several occasions people have told me that I should be using C-sound instead of MIDI because it’s more powerful and flexible. My response:

1. C-sound is also like a hundred times more complicated to use. I’m a composer and not a programmer. Figuring out why I would ever want to generate an audible sine wave is way beyond me. I just want notes. MIDI does that.

2. MIDI has really nice built-in support for a ton of instruments many of which sound pretty decent and all of which are easy to plug in. C-sound instruments are all synthesized and difficult to implement and don’t necessarily sound that good.

3. C-Sound does allow for the use of instrument samples instead of synthesized instruments, I think, but so does MIDI but I can’t figure them out for either platform anyway.

4. I found a really nice MIDI library for Lua that does more than everything I need. While I did find a C-sound library for Lua I couldn’t figure it out. At all. And I don’t think it’s actively maintained anyway.

But there are serious limitations to vanilla General MIDI that you won’t find in C-sound and it has to do with alternate tunings.

There are 128 notes available in MIDI. General MIDI defaults to standard 12-TET (12-EDO) tuning which divides each octave into 12 notes. If you divide 128 by 12 you get 10.666666 octaves which is a larger range than any acoustic instrument I know about. Cool.

But because MIDI defaults to 12-TET and makes no allowances for any other tuning this makes using any other tuning hackish. If you want any kind of just intonation or mean tone tuning then you have to find a workaround.

Most people use the pitch bend feature of MIDI which provides for 4096 pitches between each note. So by bending each pitch you can achieve many common alternate tunings. The problem with this method is that any bend you apply necessarily applies to every note that occurs in that channel. And since MIDI only has 16 channels this means you are basically limited to that many simultaneous notes.

The MIDI synthesizer I use, Timidity, a free command line program available for multiple platforms, implements an addition to the MIDI Standard called the MIDI Tuning Standard. Timidity allows you to create a tuning table which redefines each of the 128 notes to whatever audio frequency you want.

This is awesome. Now you change the underlying tuning to match whatever tuning you want like just intonation and you are no longer limited by the channel issue above. You can have full 128+ note polyphony (or whatever it is in Timidity—I can’t figure it out but I know it’s a lot) per channel with every note tuned as it’s supposed to be. But there’s a caveat.

What happens if you want to divide the octave into something other than 12 notes per octave? Like say Harry Partch’s 43-tone system? Now you divide the 128 notes provided by MIDI by 43 notes in an octave which results in just about 3 octaves. Ouch. So if you want to use Harry Partch’s tuning on a piano you can but only in a three octave range. And if you want a 128-EDO tuning then you’re limited to one octave. If 1280-EDO then a tenth of an octave. Super ouch.

But I didn’t know what else to do so I abandoned the pitch bend method above and switched over to the tuning table method thinking either I’d have to live with this limitation in exchange for better polyphony or that maybe a solution would present itself in the future (like C-sound maybe?)

Fortunately one did and I found it within the very same MIDI Tuning Standard. In fact it was just bad luck that I found the tuning table method first instead of this one.

The MTS allows you to actually define the audio frequency for every single note you send to the synthesizer. This means that now I can just compute all 13653 notes I need for our 1280-EDO tuning (1280 * 10.666666 octaves) and we’re back to using the full range of any known acoustic instrument.

I’ve only partially switched over to this new method as there is a lot of underlying infrastructure that needs to be updated to fully handle it but it is working and it is beautiful. The math and programming is also a bit hairy but I’ve had help from several people (on Reddit and the developer of the MIDI library I’m using). I’m slightly concerned about some limitations like how many audio frequencies for one MIDI pitch can we use in one channel—again I can’t find the answer to this but I know it’s at least two—but regardless it’s a much improved situation.

Incidentally the MTS is not very well supported by MIDI synthesizers. In fact as best as I can tell Timidity is the only free one that does. Several people have recommended that I switch to Fluidsynth for MIDI synthesis as it’s newer and has all sorts of cool features. Doubtless this is true but it does not support the MTS at all so Timidity it is.

But we now have full and complete control over the exact audio frequencies that are generated by the software and we are no longer subject to any range limits. It’s probably not as elegant as what we’d get with C-sound but it does work and we retain the advantages of using MIDI.

Calculating intervals

One of the cool features of the PME is that not only can you generate music for any tuning and scale but you can weight the results. So for example if you are using standard tuning and the D-Major scale you can tell the PME to probabilistically use more tonic and dominant notes and not any super tonic notes. The command used in the interface might look like this: tonic:3, dominant:2, super_tonic:0

In the early alpha releases the interval indications were hard-coded for tunings involving 12 divisions of the octave. If you wanted to emphasize the dominant in, say, Harry Partch’s 43-tone system you had to figure out which interval (in semitones) that would be and use that command: #0:3, #24:2, #7:0 (producing the same results as the command above). This method works but isn’t as elegant or intuitive as using the names of intervals that we are used to from music theory.

This limitation was also felt in how we defined scales. The major scale was defined in semitones assuming 12 (standard) divisions of the octave: 0, 2, 4, 5, 7, 9, 11. If you wanted the major scale for Harry Partch’s system it might look something like: 0, 7, 14, 17, 24, 31, 38. This meant that you had to figure out and create a definition for each scale for each tuning you might want to use.

This was going to be extremely cumbersome and a huge headache and just wouldn’t do. But that is the state of the earliest public alpha releases.

So I created a function that analyzes whatever tuning you’re using (be it the standard 12-TET or anything else like Harry Partch’s 43 Tone System, 1000-EDO, etc.) and calculates the 12 standard scale degrees (minor third, perfect fifth, tritone, &c) for that tuning. This provides a tremendous amount of power to our quantization routines. Instead of having to create a major scale for each tuning we can now just define a scale in terms of the computed intervals like:

major: tonic, major_second, major_third, perfect_fourth, perfect_fifth, major_sixth, major_seventh

and it will work in any tuning.

This also means that we can weight our scales during the quantization process using the same interval names so that our command above (tonic:3, dominant:2, super_tonic:0) will now work in any tuning that we might want to use.

This is very cool. And insanely powerful and flexible. It is not fully implemented but does work. Ish. I mean there are bugs and once again there are significant infrastructure issues but the basic idea is currently supported in the development version of the PME.

Right now the PME calculates these intervals by comparing the audio frequencies against a 5-limit just intonation tuning but in the future other options will be available such as 12-TET or 7-limit just intonation or whatever. Plus we might have it calculate various other intervals (once I figure out their names).

An interesting consequence of all this is that the basic data of the Platonic Score will be slightly different now. Previously we had five tables for each note: pitch, volume, duration, pitch bend, and other. We’ll still have the same number of tables for each note but we won’t be using pitch bend at all in generating music. Instead it will be just another extra set of data for use in our Style Algorithms. This does mean that we will be eliminating our quarter tone music as instead we’ll just use, say, 24-EDO instead of 12-TET with quarter tones.

Future

Generating a standard score is a key part of the PME. With all this new power I will have to come up with ways to notate these scores. The PME currently uses Lilypond which, as far as I can tell, is the only engraving software that can do everything we need. The question becomes, how do we generate, on-the-fly, a notation method for, say, 1042-EDO tuning? I have an idea for this which involves getting rid of the standard accidentals and using the percentage difference between the base note and the note to be played and printing that number as an accidental. This is of little use to a performer but at least the score will be fairly accurate and will otherwise still use standard notation. I know how to generate accidentals like this in Lilypond but there will be some work involved to make it work seamlessly in the PME.

Right now work has come to a halt with regard to adding new Style Algorithms to the PME. This is a shame as it is by far the most fun part of the project. But I have to get the infrastructure back working again with these new features and then I’ll be able to work on the Style Algorithms again. The Style Algorithms will have to be updated to use the new methods but they will gain tremendously in power. For example, the Serialism SA can already use any scale other than just the 12-tone chromatic and now it will also be able to use any scale in any tuning (like the major blues scale in 42-EDO). Or the Simple Invention SA won’t just be for a tuning that divides the octave into 12 notes but can work with any tuning and you can have simple counterpoint in 50-EDO tuning. And you’ll be able to do these things without making any changes to the Style Algorithms other than specifying what tuning you want to use.

I also need to get the tutorial and reference manual updated to match the new methods implemented above. That will take work. The manual remains unfinished as it is now so now it is super unfinished. The tutorial won’t be as difficult.

For those of you who know me well or better than the average internet stranger, you know that my life is not in the best of places. I won’t go into detail here (message me privately and I’ll spill everything or if you go through my internet history you can figure out the salient details). But the upshot is that I am in desperate need of financial support. I don’t want to turn this into a plea for money but as I am desperate I will say that on the PME website you can find links to various ways to support work on this project. Recently I opened up a Cafepress store where you can buy coffee mugs and buttons with the PME logo on them. I’m also going to add an option for a custom mug where the design is generated by the PME as a Style Algorithm. You can send me a name and the software will generate music for the name and a custom designed mug. Pretty nifty.

If you have any questions, comments, ideas, or suggestions please let me know. Thanks for reading all of this!

Copyright 2015 David Bellows

Colophon