<:> Pseudocode snippet
Clara Empricost embodies rules such as
- If this is the second chord in a modulation, check that the
modulation works: It must be on a stronger beat than the
previous chord, it must be a I (or a VI if the previous chord
was a root position V), and if it's of the same figure as the
pivot chord in a gradual modulation then it must be a
different inversion.
- If this is a final chord and it's chord I, and the phrase is
not supposed to end on chord I, reject it (otherwise you get
too many perfect cadences).
- Perform a melody check on the
soprano part. A melody check is defined as follows:
- Make sure it doesn't go out of range
- If it's the final chord, then the soprano part must have the tonic (reject anything else)
- The leading note should rise to the tonic (but it's acceptable to repeat the leading note once before it does so) - reject anything else
etc. etc.
Full details at http://www.flatline.org.uk/~silas/clara/works.htm