Creating Melodies Software
This is software for the book Creating Melodies.
You can download the programs individually or as one zip file.
For Windows we have precompiled binaries.
The software is free and distributed under the terms of the GNU General Public License. It is written in ANSI C and should compile with any C compiler. Send questions or comments to: Stefan (stefan at exstrom dot com) Richard (richard at exstrom dot com).
- autogen2.c
Generates all words of a given length accepted by an automaton. Result is printed to stdout.
Usage: autogen2 file.aut2 n s e1 e2 ... file.aut2 = automaton input file n = length of words s = start state ei = end state i
- fsquare.c
Generates paths in a finite square lattice from
(x,y) to (a,b). Result is printed to stdout.
Usage: fsquare nc nr x y a b n nc = number of columns nr = number of rows x = 0,1,...,nc-1 y = 0,1,...,nr-1 a = 0,1,...,nc-1 b = 0,1,...,nr-1 n = path length < 128
- fsquare2.c
Generates paths in a finite square lattice from
(x,y) to (a,b). fsquare2 does not allow the
previous step to be retraced. Result is printed
to stdout.
Usage: fsquare2 nc nr x y a b n nc = number of columns nr = number of rows x = 0,1,...,nc-1 y = 0,1,...,nr-1 a = 0,1,...,nc-1 b = 0,1,...,nr-1 n = path length < 128
- fsquares.c
Generates paths in a finite square lattice from
(x,y) to (a,b). Walk is allowed to stop at a
point for a number of steps. Result is printed
to stdout.
Usage: fsquares nc nr x y a b s n nc = number of columns nr = number of rows x = 0,1,...,nc-1 y = 0,1,...,nr-1 a = 0,1,...,nc-1 b = 0,1,...,nr-1 s = 0,1,... = number of stop steps allowed n = path length < 128
- ftri.c
Generates paths in a finite triangular lattice
from (x,y) to (a,b). Result is printed to stdout.
Usage: ftri nc nr x y a b n nc = number of columns nr = number of rows x = 0,1,...,nc-1 y = 0,1,...,nr-1 a = 0,1,...,nc-1 b = 0,1,...,nr-1 n = path length < 128
- kdebruijn.c
Generates a de Bruijn sequence for k symbols of
order n. A different sequence is generated for
v = 0 to k^(n-1)-1.
Usage: kdebruijn k n v k = number of symbols used n = order of sequence (subsequence size) v = unique sequence parameter: 0 to k^(n-1)-1
- lat2abc.c
Converts walks on a square or triangular lattice
to melodies in abc notation. Walks can be
generated by program fsquare, fsquare2, fsquares
or ftri. Input file specifies: lattice size, note
mapping, and any number of lines containing
starting point, walk, rhythm, repeats, and rest.
Result is printed to stdout.
Usage: lat2abc inst key tempo file.lat inst = MIDI instrument (program) number key = musical key, e.g. C tempo = beats per minute, e.g. 180 file.lat = name of lattice file
- pautogen.c
Generates words of a given length accepted
by a probabilistic automaton. Result is printed
to stdout.
Usage: pautogen file.pat n s seed file.pat = probabilistic automaton file n = length of words s = start state seed = random number seed [0..4294967295]
- ssline.c
Prints a random subset of the first n lines read
from stdin. The size of the subset is m. All
subsets of size m have the same probability.
Result is printed to stdout.
Usage: ssline n m n = number of lines to read from stdin m = subset size to sample
- str2abc.c
Converts strings in a file into abc notation.
Result is printed to stdout.
Usage: str2abc file.str inst key tempo unit file.str = input file inst = MIDI instrument (program) number key = musical key, e.g. C tempo = beats per minute, e.g. 180 unit = unit note length, e.g. 1/4 is a quarter note
Input file formats
Examples of these files from the book can be found here.
- autogen2 input file format (.aut2)
FORMAT: ns 0 (sn00,sym00) (sn01,sym01) ... 1 (sn10,sym10) (sn11,sym11) ... ... ns = number of states Subsequent lines describe states starting with state number and followed by transitions. States are numbered consecutively from 0 to ns-1. A transition is specified as (sn,sym) where sn is the number of the state to transition to and sym is the output for the transition.
- lat2abc input file format (.lat)
FORMAT: nc nr note(0,0) note(1,0) ... note(nc-1,0) note(0,1) note(1,1) ... note(nc-1,1) ... note(0,nr-1) note(1,nr-1) ... note(nc-1,nr-1) sc1 sr1 pathString1 rhythmString1 repeat1 endnote1 sc2 sr2 pathString2 rhythmString2 repeat2 endnote2 ... nc = number of columns in the lattice. nr = number of rows in the lattice. The next nr lines assign notes to the lattice points. Notes are specified in abc notation. Each following line has the starting column and row number of a path followed by the path string, a rhythm string, number of repeats and end note. The letters l, r, u, and d indicate left, right, up, and down, respectively for a square lattice path string. For a triangular lattice, there are two additional letters, v, which indicates up and to the right, and e, which indicates down and to the left. Lastly, the letter s indicates to stay where we are for the current step. The rhythm string must be 1 character longer than the path string because the first character is used for the starting point. The end note can be any note or chord in abc notation.
- pautogen input file format (.pat)
File format is the same as that of autogen2, except that each transition has a probability term following the output for the transition.
- str2abc input file format (.str)
FORMAT: title (T: field in abc notation) composer (C: field in abc notation) transcriber (Z: field in abc notation) nn = number of notes or chords used note1 note2 ... noten noteString1 rhythmString1 repeats1 noteString2 rhythmString2 repeats2 ... First three lines of the file are just documentation strings. The next line indicates number of notes or chords listed on the following line. This is followed by a line giving the notes or chords in abc notation separated by spaces. Following lines have a note string, a rhythm string and number of repeats. Note string and rhythm string can each be up to 128 characters long. The note string cannot contain spaces, only digits 0 through 9, and lower case letters. The note string is translated to notes/chords according to the list of notes/chords on the fifth line of the file. All 0's in the note string are translated to the first note/chord of the note/chord list. All 1's are translated to the second note/chord, and so on, so that all 9's are translated to the tenth note/chord. If there are lower case letters in the note string, all a's are translated to the eleventh note/chord, all b's are translated to the twelfth note/chord, and so on, so that all z's are translated to the 36th note/chord. If there are fewer notes/chords on the fifth line of the file than is required by the digits and letters of the note string, then the translation is done modulo the number of notes/chords. That is, if there are only three notes or chords specified, then the digit 4 will be translated to the second note/chord. The rhythm string cannot contain spaces, only digits 0 through 9, and lower case letters. The rhythm string is translated to a rhythm according to the unit note length specified in the last input to the str2abc program. For example, if the unit note length is specified as 1/4, then a 1 in the rhythm string is translated to a quarter note, a 2 is translated to a half note, a 3 is translated to a dotted half note, a 4 is translated to a whole note, and so on. Following the rhythm string is the number of repeats of that line, that is, how many times the melody of the line is to be repeated. It can be any positive integer.
Additional Software
This is additional software that you'll need to get the most out of the book.
- An ANSI C compiler like gcc
- The abc2midi program. This program is part of a package called abcMIDI and can be downloaded from
https://ifdo.ca/~seymour/runabc/top.html
or
https://sourceforge.net/projects/abc/ - A MIDI player like TiMidity++ available at
https://sourceforge.net/projects/timidity/
Send comments to: Richard Hollos (richard[AT]exstrom DOT com)
Copyright 2018 by Exstrom Laboratories LLC