PHILOMENA

Monday 17 December, 2007 at 2:43:22 am
filed under music, projects

PHILOMENA is a program designed to part write against a bassline based on an arbitrary set of rules. It contains a small declarative language for describing acceptable part writing rules, and can be used to generate both classical harmonic progressions and more unconventional harmonizations.

PHILOMENA’s primary purpose is, naturally, to do my music homework for me, but when it is finished it should be an extremely powerful tool for describing and realizing the full scope of possible four-part harmonies.

How it works

Brute force.

More descriptively, PHILOMENA takes as input a file describing a bassline and another containing part-writing rules, and then iterates through all possible configurations of voices until it finds one matching the rules. In order to introduce variety into pieces and aid in finding more difficult solutions, there is an added 50% probability that any given chord will be rejected (this number is currently a fixed constant in the code, but will be adjustable from the rule file in future versions). If no solution is found, PHILOMENA will return to the beginning and try again. As such, the program is Ω(n) for both the length of the bassline and the number of rules. As a result of the random factor, the program is technically not guaranteed to terminate; in practice, I can usually find a solution with the root-position, major rule set in a few seconds.

The program outputs to a LilyPond file that can be used to produce a PDF or midi.

Download

Writing basslines

All notes are given an absolute scale degree such that the lowest Do is 0, Dis is 1, Re is 2 and 12 represents an octave above the lowest Do. A bassline file (.pmb) is just a series of these notes separated by spaces. PHILOMENA doesn’t currently support notes of different durations, though this is easily changed by editing the .ly file produced as output.

A sample bassline:

0 4 5 7 9 5 2 7 0

Writing rules

  1. A note descriptor takes the form [ ^ ] < [< | > | = ] [ ' | . | + | - ] n | ?>
  2. The symbol ^, if present, indicates that this chord factor is the anchor.
  3. One of <, > or = may be used to specify whether this descriptor will match notes respectively less than, greater than or equal to the one described.
  4. The symbols ‘ (an apostrophe) and . (a period) may only be used in the second part of motion rules, and specify a note respectively greater or lower than than this voice’s note in the previous chord by the number n.
  5. The symbols + and - (a hyphen) specify a not respectively greater or lower than the anchor by the number n.
  6. The symbol ? will match any note. It may be used in conjunction with ^, but no other symbol.
  7. A chord rule takes the form < * | ! > b t a s, where b, t, a and s are note descriptors and b matches the bass note in the bassline provided.
  8. A motion rule takes the form < @ | ~ > b0 t0 a0 s0 : b1 t1 a1 s1
  9. An arrangement of voices matches a rule if all of its notes match their respective note descriptors
  10. In a motion rule, the first set of descriptors matches the notes of the previous chord.
  11. All arrangements of voices are forbidden unless explicitly allowed
  12. An arrangement of voices is allowed if it matches a chord rule beginning with * or a motion rule beginning with @
  13. An arrangement of voices may be explicitly forbidden if it matches a chord rule beginning with ! or a motion rule beginning with ~.

Sample rules

Major root-position triads:

* ^0,5,7 +4 +7 +12

(if the bass has Do, Fa or So add a M3 in the tenor, a P5 in the alto and a P8 in the soprano.

* ^2,4,9 +3 +7 +12

(if the bass has Re, Mi or La add a m3 in the tenor, a P5 in the alto and a P8 in the soprano)

* ^11 +3 +6 +12

(if the bass has Ti add a m3 in the tenor, a °5 in the alto and a P8 in the soprano)

Forbidding parallel fifths:

~ ^? +7 ? ? : ^? +7 ? ?
~ ^? ? +7 ? : ^? ? +7 ?
~ ^? ? ? +7 : ^? ? ? +7
~ ? ^? +7 ? : ? ^? +7 ?
~ ? ^? ? +7 : ? ^? ? +7
~ ? ? ^? +7 : ? ? ^? +7

Forcing the leading tone to resolve up in the soprano:

~ ? ? ? 11,23,35 : ? ? ? >'1
~ ? ? ? 11,23,35 : ? ? ? <.0

(Forbid the soprano from moving to any note that is more than a semitone greater or any lower note)

License

GNU GPL

PHILOMENA is still in development and I greatly appreciate feedback. Please send your suggestions to jqubit [at] gmail [dot] com.

1 comment

RSS / trackback

respond

  1. Christine

    on Saturday 22 December, 2007 at 5:53:32 am

    O___O …and you thought you weren’t going to get into columbia?