Currently all Artinfuser Algo servers are in maintenance mode. I did not get enough patrons to continue supporting rendering music in this project.


Generate 2-voice counterpoint

Introduction

CP1 music generator generates a 2-voice counterpoint by searching for a combination of notes which has minimum rule violations penalty. First cantus firmus is generated using CF1 algorithm, consisting of whole notes without pauses inside. Then second voice is generated above or below cantus firmus. This second voice can be generated in any of 5 standard counterpoint species. This generator can create counterpoint only in time signature 4/4. Example of generation results in each species:

Species 1:

Species 2:

Species 3:

Species 4:

Species 5:

Cantus firmus ("fixed song") is a pre-existing melody forming the basis of a polyphonic composition. It is also used to write counterpoint exercises by superimposing additional voices above or below it.

The rules that are used for cantus firmus and counterpoint generation can be enabled or disabled by user. For generating and correction of cantus firmus mainly Cantus and Melody rule groups are used. For generating and correction of 2-voice counterpoint Melody, Harmony and Rhythm rule groups are used. By default the rules are tuned to generating a vocal cantus firmus starting and ending with a tonic note; and vocal counterpoint starting with a tonic chord and ending with an authentic cadence.

Generation parameters

Key generator input parameters:

  • Species 1, 2, 3, 4 or 5
  • Number of cantus notes to generate. Also can be changed in config with parameter c_len.

Due to the nature of algorithm and large number of rules used, generating long counterpoint can take long. Time needed to generate counterpiont increases with the length of counterpiont, but it is not a static value, because number of operations to generate counterpoint of same length differs due to randomization. This means that longer counterpoint can sometimes take less time to generate and sometimes more. If time needed to generate cantus exceeds some limit (1 to 10 minutes, depending on server settings), task will be aborted and counterpoint will contain mistakes. This is not always bad, sometimes you can like results with mistakes. You can restart task until you get result without mistakes.

Cantus firmus generation of 40 notes usually takes no more than 10 seconds. Generation of a second voice starts after generation of cantus. It has more rules and more complex algorithm, which results in a slower generation compared to cantus generation. Species 3 and species 5 are slowest (counterpoint with 11 measures usually generates during 1 minute). Species 2 and 4 are faster (counterpoint with 25 measures usually generates during 1 minute). Species 1 is fasters (counterpiont with 40 measures usually generates during 1 minute).

  • Cantus position: in lower or upper voice. Also can be changed in config: soprano (cantus_high=1) or bass (cantus_high=0).
  • Mode
    • Natural major
    • Melodic minor
  • Enable or disable rules, change their severity

In expert mode user can also change other parameters in text configuration:

  • GUI allows to choose only C major or C minor key for simplicity. In config user can choose any key (e.g. key=Bbm), but in this case you also need to change first and last notes correspondingly so that they are root notes of the selected key (e.g. first_note=Bb4 and last_note=Bb4). Algorithm supports only natural major and melodic minor modes.
  • Time for generation in ms (e.g. to limit generation to 10 seconds, set max_correct_ms=10000)

By default generation time is limited only by server (1 to 10 minutes, depending on server settings). When using SWA algorithm, generation is done by first creating a random melody and then fixing mistakes that are found in it. User can limit generation time to get melody with some mistakes still not corrected. This can lead to some experimental results. Mistakes, that were not corrected, can be seen in PDF file.

Other parameters in config should be changed only if you know what you are doing.

Generation results

Same as in CF1 cantus firmus generation algorithm

Troubleshooting

Problem Solution
Generation takes long Try decreasing length of cantus or revert rules to their default settings. If you changed t_cnt in config, reset it to 1.
Generation fails with error First try to restart the processing. If this does not help, try to unroll your latest changes, which could result in the error. In Expert mode on the Config tab you will find history of all your changes under the Save button. Pay attention that due to complex generation algorithms, some combinations of rules severities can result in unexpected behaviour. Try to set rules severities back to their default values or create new generation task. If you applied any changes previously, you will find default values in "Rule changes" box under the rules tree on the Settings tab. Also, keep in mind that trying to generate too long cantus can result in mistakes in melody due to timeout. Try decreasing length of cantus.

If you cannot find solution to your problem, please create support request (menu Support)

Playback

See playback section.

How algorithm works

Generating counterpoint first requires running CF1 cantus firmus generation algorithm.

On the second step, counterpoint is generated. Generating counterpoint supports two methods: Strict Appending Scan (SAS) and Sliding Windows Approximation (SWA). SAS method is not optimal for counterpoint, and usually should not be used. Instead, SWA algorithm is used by default. If for some reason you want to choose SAS, you can select algorithm by editing method parameter in config (method=sas or method=swa).

In CP1 counterpoint generation algorithm each note is split into a series of tied micronotes of same length. This allows algorithm to build any rhythm. If adjacent notes have the same pitch, they are considered to be parts of the same note. The length of a micronote is equal to the minimum allowed note length in species:

  • whole note in species 1
  • half note in species 2 and 4
  • quarter note in species 3
  • quaver in species 5

Please see descriptions of SAS and SWA methods in CF1 cantus generation algorithm.

Harmony detection

Evaluation of harmonic rules requires harmony in each measure to be detected. Harmony detection is implemented this way:

  1. First notes, that are probably harmonic, are detected (notes on downbeat, notes after and before leaps, notes longer than previous).
  2. Then specific patterns of non-chord tones are detected (suspensions, anticipations, PDD - passing downbeat dissonances, cambiatas, DNT - double neighbor tones). Patterns are applied, making some notes chord tones (resolution notes of DNT, PDD, cambiata, anticipation, suspension) and other notes non-chord tones (non-chord tones of DNT, PDD, cambiata, anticipation, suspension).
  3. Now all notes are marked chord tones or non-chord tones. Harmony is detected by combining all chord tones in a measure.