CocoaMIDI 1.0



328 KB


36 KB


CocoaMIDI is a program I wrote because as a bass player I sometimes need to hear actual chords played so I can test out some new bass line. CocoaMIDI has you select a plain text input file in the format described below, and then has you save it as a MIDI file. It converts chords in the text file, such as "A" or "F#", into a MIDI file, including variable note length, volume, and key. CocoaMIDI is public domain. The source code and a tutorial on how to write it are available here. CocoaMIDI is public domain. Feel free to use it or its source code in any way you like.

Input File Format
The input file should be a plain text file consisting of chords and a some control items. At startup, CocoaMIDI reads in the file Chords.txt, which you can edit to define your own chords. A chord consists of up to 7 contiguous characters, the first one of which must be A-G. It is these chord names that CocoaMIDI recognizes in the input file. The rest of each line in the Chords.txt file consists of the MIDI key numbers that should be played to make that chord. The default Chords.txt file includes the basic chords E, F, F#, Gb, G, G#, Ab, A, A#, Bb, C, C#, Db, D, D#, Eb in that order, going from lowest to highest. The basic chord input consists of one of these, for example, "A", or "ABCD", or "E F# G# A B C# D#". To make a chord stretch out for an additional note length, add a dash. For example, "AAA---" will continue the last A for another 3 note lengths. Whenever a new chord (i.e., not just a continuation by "-") is played, the previous chord is silenced. If you want to silence a chord before the next chord plays, use an "x", which will kill the previously played chord. You can then use "-" to mark out space until the next chord is played.

By default, CocoaMIDI assumes input is being given in quarter notes. You can change this to values from whole notes to 64th notes by putting the value you want inside parentheses, for example, "A (8) B C#" will play an A chord for a quarter note length followed by a B chord for an 8th note length, and a C# for an 8th note length. Supported time values are 1, 2, 4, 8, 16, 32, and 64.

You can shift chords up and down the scale an arbitrary number of half-steps by enclosing the number of half-steps inside the "^" character. For example, the default D# chord is the one an octave below the default E. If you want to play a D# and then the next higher E, you would need to type "D# ^12^ E" to move up 12 half-steps, which equals one octave. The step offset applies to all following chords, so to go back, you would use the following "D# ^12^ E ^0^ D#", which moves you up 12, and then back to your starting point.

The volume can also be adjust inside the colon character. The volume ranges from 1 to 127. For example, ":40: E :60: E :80: E :100: E :127: E---" plays the E chord progressively louder.


Mary Had a Little Lamb

E Major Scale

Back to Main