đŸ Archived View for tilde.pink âș ~ssb22 âș cworks.gmi captured on 2022-04-28 at 17:28:33. Gemini links have been rewritten to link to archived content
âŹ ïž Previous capture (2022-03-01)
âĄïž Next capture (2023-01-29)
-=-=-=-=-=-=-
Clara Empricost works as follows:
1. An overall plan for the piece is generated, in terms of phrases (e.g. AABBA, ABACA, etc).âStructures like sonata form can be pre-programmed.â(See sonata.h, canon.h, minuet.h, rondo.h and symphony.h)
2. Each phrase is composed independently (although there are some common parameters such as how long it should be and what key it should start and finish in).âThe program writes all of these âcompose a phraseâ tasks to separate files on disk (each task to its own file).
3. Multiple copies of the program can now work on the different phrases in parallel (assuming that they all have access to the same disk directory).âThey look for a phrase file, load it, work on it until finished or interrupted, and save their state back (see network.cpp).âWhen all of the files have been completely processed, the result is put together and output to Manuscript Writer files (see mwr.h); these can then be converted to MIDI or whatever by the music program Manuscript Writer.â
The parameters for each phrase are as follows (see melody.h):
The values of these parameters depend on the piece being composed.âFor example, a development section may allow more chromaticisms and modulations than the first subject.âNote that all of them are set in advance by the programmer; the computer does not choose any of the above values itself.â
Each phrase is made up of chords (see chord.h). When a chord is constructed, it is only partially specified; the initial specification is:
The rest of the specification is filled in at ârandomâ.âThe random choice is then evaluated against a set of rules (see rules.cpp) which were taken from a music harmony textbook; if it is found to be unacceptable then another random choice is made.âThe possibilities are tried in a random order without replacement; if after trying every possibility, no acceptable chord can be found, then the program backtracksâthe *previous* chord is treated as unacceptable and another one is tried.âIf the program canât find any solution even after trying all possibilities of the previous chord, the one before that is marked as unacceptable and so on.âIf you make the rules too draconian then the program will spend ages trying out every single possibility and then crash with an error message because it backtracked right to the start.â(Prolog would just say ânoâ.)â
In practice, what often happens is that the program quite quickly gets to a cadence point, then finds that there is no way to put a cadence on its current chord sequence, and has to do a lot of backtracking and re-trying until it finds a chord sequence that can lead to a cadence at that point.â
The backtracking is optimised a little by noting that modulations can often cause problems, particularly if the cadence needs to be in some key that is unrelated to the current one.âTherefore, if a chord has caused the phrase to modulate and it is found to be unacceptable, it will first try modulating to the phraseâs destination key rather than whatever key it happened to modulate to before; if that doesnât solve the problem then it will try not modulating at all.âDespite these optimisations, though, the backtracking is still very inefficient and it often takes a large amount of computer time to compose a work.â
The parameters of a chord that have to be decided are as follows (see chord.h):
This is all a bit limitedâI didnât get as far as implementing sevenths, ninths etc (although the program can write seventh passing notes).âSince there are 4 parts each with 2 possible octaves and 3 possible chord degrees, and there are 7 possible figures, the total number of possibilities for each chord is 9072; most of these would fail the rules immediately.â
Selecting chords at random without replacement can be likened to writing each possible chord on a card, giving a pack of 9072 cards, and evaluating the chords in order after shuffling the pack.âBecause shuffling the pack can be computationally expensive (particularly on the old DOS machines for which this program was originally written), it is only shuffled once for each phrase, and the selection of each chord starts at a random position in the shuffled pack.âIf longer phrases are allowed then perhaps the pack should be shuffled more often.â
Since most of the rules are written in terms of such things as the inversion of the chord, the intervals between various parts, and so on, the program calculates these from the notes.â
Suspensions, passing notes, auxiliary notes, pedal notes, ornaments and chromaticisms are added after the chord sequence has been completed, using additional rules to determine what is acceptable, but this time no backtracking is necessary because the acceptability of an ornament etc does not depend on what has happened previously (one could argue that actually it does, but not in this program).âInstrumentation is chosen at random (within some restrictions) and octave doubling of the soprano and bass is also performed.â
The rules themselves are arranged in order of how frequently they are violated by choosing at random (this was determined emperically); this is so that an unacceptable choice can be identified as such as quickly as possible.âBasically, the rules are as follows (see William Lovelockâs âFirst Year Harmonyâ, âSecond Year Harmonyâ and âThird Year Harmonyâ for full details).
1. 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.
2. 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).
3. Perform a melody check on the soprano part.âA melody check is defined as follows:
3.1. Make sure it doesnât go out of range
3.2. If itâs the final chord, then the soprano part must have the tonic (reject anything else)
3.3. 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
3.4. Reject a leap of an augmented interval
3.5. Reject a leap of a seventh, or of a ninth or higher, even if there is one note intervening
3.6. Reject any leap that does not land within the compass of the previous leap if the previous leap was an octave, a sixth, or a diminished fifth
3.7. Octave leaps must also be preceded by notes within their compass
3.8. If the soprano part has the same note from a weak beat to a strong beat then the chordâs figure must change (reject if it doesnât)
3.9. Reject bass parts that rise a third from weak to strong
3.10.âReject leaps of diminished fourths and sevenths
3.11.âAvoid too many consecutive leaps (Iâve arbitrarily set âtoo manyâ to 3)
3.12.âA three-note descending or ascending scale passage in the bass part should be followed by further step in the same direction rather than a leap (it was unclear from the text whether a repetition of the same note is allowed; in this implementation I allowed it)
3.13.âThe soprano and bass parts should avoid remaining around one note for too long.âI interpreted this as: Reject pitches that have already been used more than once in the previous four notes
3.14.âIf chromaticisms are to be added later, then the following rule is put in to help with progressions from chord II: If progressing to the tonic, force an upward resolution; if there is a subdominant of the scale in the chord then remain on the same note.
4. If this is a final chord and the phrase needs to end on chord I, reject it if it isnât I
5. Reject any chords whose notes do not match notes that were pre-defined (additionally, anything that has been pre-defined is not checked)âthis is in case the code needs to be modified to harmonise a given melody or whatever
6. Avoid certain chords: VII in root position, any chord in second inversion except I, IV or V, and any chord in second inversion at the beginning of a phrase.
7. Check the melody of the alto part (as with the soprano part above)
8. Reject chords that cause a phrase to not start âproperlyâ (I or V-I) when its specification said it should
9. Check the melody of the tenor part (as with the soprano part above)
10.âCheck the melody of the bass part (as with the soprano part above)
11.âCheck the following pairs of parts (in this order): soprano/alto, alto/tenor, soprano/bass, soprano/tenor, tenor/bass and alto/bass.âFor each pair, the following things need to be checked:
11.1. Donât cross the parts
11.2. Avoid parallel octaves and fifths
11.3. Donât double the third, unless itâs on a V-VI or VI-V by stepwise motion
11.4. In the soprano and bass, avoid exposed octaves and fifths (i.e. ones that are approached by similar motion in both parts, with some exceptions)
11.5. Avoid overlaps (i.e. a note in one part âjumps overâ the previous note in another)
11.6. Avoid chords where two or more of the parts are playing the same note as in the previous chord
11.7. If the progression is IV-V or V-IV (both in root position), make the soprano, alto and tenor move contrary to the bass and go to the nearst note (i.e. reject all chords that donât do this)
11.8. Avoid having a perfect fifth followed by a diminished fifth or vice versa between the bass and any other part
11.9. Avoid doubling the leading note
11.10.âAvoid chords in which the alto doubles the bass if the chord is a diminished first inversion
11.11.âAvoid chords in which there is more than an octave between any two adjacent parts except tenor and bass
12.âCheck that there is a third in the chord
13.âCheck that there is a root in the chord
14.âIf the chord is an inversion, or a chord III, then check that there is a fifth in the chord as well
15.âCheck that the third is not doubled in a major triad other than a chord VI
16.âCheck that the chord does not have the same figure as the previous one, unless the previous one was on a stronger beat or was the first chord in the phrase
17.âSecond inversions cannot be approached by leap (in the bass part) from an inversion of another chord
18.âIII must be followed by VI (reject anything else)
19.âAvoid II-I and I-II (in root position)
20.âDouble the third if progressing IIb-V (i.e. reject anything that doesnât)
21.âReject a second inversion if the previous chord was also a second inversion
22.âMore rules about second inversions: A passing 6/4: 6/4 must be on a weak beat and must be Ic or Vc; a cadential 6/4 must be on a stronger beat, must be Ic or IVc and must not contain leaps in any of the parts.âReject all second inversions that cannot be explained as cadential or passing.
23.âIf the chord is the final chord of a cadence, it must be weak to strong (unless the cadence is going to VI) and the cadence cannot be preceded by its final chord (except in the case of V-I-IV-I). Also reject if the first chord of the cadence has been anticipated by the previous chord.
24.âIf the chord is not the final chord of a cadence then check that it does not form the cadential progression V-I (unless itâs part of a modulationâif modulations are allowed then they can occur anywhere even if unspecified by the phrase specification).âIn retrospect, I think this is one reason why the modulations arenât always so goodâthe above rule should probably have been checked as well before allowing them.
25.âAvoid repetition of the same chord (figure and inversion) with only one chord intervening
26.âIn the progression V-IV, the soprano should rise a third, going from the fifth of V to the root of IV (reject if it doesnât)
27.âIf the previous chord is IIa and the key is minor, then this chord must be Va and on a weaker beat (reject if not)
28.âIf the last chord was VIIb then avoid anything except I or Ib (or VI a in major key)
Modulations are handled by noting whenever a chord could be the first of a modulatory cadence into any key, i.e. it must be some form of V, it cannot cause false relations (although there are exceptions here), and it must not be the final chord of the phrase unless the phrase is allowed to end in a modulating imperfect cadence.âIf these criteria are met (and the melody is allowed to modulate) then it does modulate, provided of course that a suitable chord can be found to follow it (this is why âcheck the modulation worksâ got to the top of the rules list).â
Note that there are few rules about musical idioms.âThe program tends to âdiscoverâ these for itself, since it is often the case that an idiom is almost the only solution.â
While the output is harmonically correct, I thought it not sufficiently interesting to qualify as good music.âThe melodies are rarely lyrical, the cadences are predictable, and there are no climaxes or impressions.âThe instrumentation can sometimes be interesting, but this is very much dependent on the quality of the playback equipment in use.âBugs in the implementation can lead to small unintended deviations from the harmonic rules or the synchronisation of the parts, and this can add interest.âWhile the above rules do not represent the entirety of Lovelockâs work on harmony, I felt that any further implementation was unlikely to deliver much improvement.â
In 1998, I submitted four movements generated by the program to Schwobbâs âClassical MIDI Archivesâ website, using the name of the program, and publishing the fact that the music was written by a computer program.âSince then, Iâve received occasional email from people who enjoyed the output more than I did; some wanted to use parts of it in their compositions.
All material © Silas S. Brown unless otherwise stated.