Correct 2-voice counterpoint


CA2 counterpoint correction algorithm analyses and corrects a 2-voice counterpoint by searching for minimum combination of changes, which result in minimum rule violations penalty. Example of 2-voice counterpoints, that can be uploaded, analysed and corrected:

Species 1:

Species 2:

Species 3:

Species 4:

Species 5:

An uploaded counterpoint must comply with the following requirements.

  • Cantus firmus consisting of whole notes can be in the upper or lower voice but there should not be a repeat of note, a tie or a pause in cantus firmus
  • There should not be any pause inside counterpoint
  • Only two modes are supported:
    • Natural major
    • Melodic minor
  • Only time signature 4/4 or 2/2 is supported
  • Alterations are only supported in melodic minor (only VI# and VII# are supported)
  • Last chord should always be tonic in root position

If one of these requirements is not fulfilled, correction will not be able to start, returning an error.

There can be multiple counterpoints in an uploaded file, but there must be pause in both voices between counterpoints. Multiple counterpoints in one file is only recommended for advanced users, because it increases complexity and makes debugging more difficult.

Usually CA2 algorithm will be able to detect species and cantus position automatically, but there can be situations, when detected species or cantus position will be wrong. In this case you can select species or cantus position manually in settings. Also, you can specify species and cantus position in source MIDI file by adding lyrics or text to the first note of counterpoint (some of notation software will not export either lyrics or text into MIDI file, so experiment). For example, add lyrics like this: "CF=low", "CF=high", "sp1", "sp2", "sp3", "sp4", "sp5". You can also combine these if needed, for example: "CF=low,sp1".

The rules that are used for 2-voice counterpoint correction are the same as used for CP1 2-voice counterpoint generation algorithm. They can be enabled or disabled by user and their severity can be changed.

Pay attention, that CA2 2-voice counterpoint correction algorithm will not analyse or correct cantus firmus. Use CA1 cantus firmus correction algorithm for this.

Correction parameters

Key generator input parameters:

  • Enable or disable rules, change their severity
  • Time for correction

Due to the nature of algorithm and large number of rules used, correcting long counterpoint can take long. Time needed to correct counterpoint increases with the length of cantus. If time needed to correct counterpoint exceeds specified limit, best found correction will be returned. You will find mistakes in PDF file. You can decrease number of mistakes left after correction by increaseing time parameter.

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

Correction results

Corrected counterpoint is output in MIDI and PDF files in two separate staffs above initial counterpoint. Notes, that were corrected, are circled in source counterpoint:

In this example, cantus firmus was specified in an upper part. The lower two staffs will show mistakes that were detected in source counteropoint (cantus firmus will not be analysed). If you see no mistakes in corrected counterponit, this means that correction process was able finish.


Problem Solution
Correction takes long Try decreasing allowed time for correction. If resulting corrected melody shows many mistakes, you will need to increase time and wait.
Correction 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 correction 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 correct too long counterpoint can result in mistakes in corrected melody due to timeout. Try increasing allowed time for correction in settings.

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

How algorithm works

Correction algorithm uses same SWA algorithm, that is described in CP1 counterpoint generation algorithm.

The only important difference is that instead of trying to generate a new counterpoint melody, system tries to find counterpoint melody with not only has minimum rule penalty, but also has minimum difference from the source melody by calculating Distance from source melody (each changed note adds penalty of 3 point + 1 point for each semitone of change). For example changing one note from C to E note will add 7 to distance (which is 3 for one note and 4 for 4 semitones). This means that if there are multiple variants with same rule penalty, the variant with least distance from source melody will be selected.

Cantus firmus voice is not analysed or corrected.

The longer correction time is specified in the file settings, the more precise result you will get. Even if solution is found without any mistakes, there is always a small probability of finding a better solution without mistakes, which is closer to source melody. The general approach used in SWA algorithm (note variants are ordered by increasing distance penalty from source melody) usually guarantees that the first solution without mistakes will have lowest distance penalty or close to lowest.