The algorithm is half combinatorial (mechanical deterministic) on the notes and half human-preference-based (non-mechanical deterministic), with rules that their variation allows chord harmonizations that range from minimalist to maximalistic results on the number of chords.
It is called contrapunctal, because it is highly relevant to counterpoint music: Given a melody, when applying counterpoint to create 3 voices, we have automatically also created a chord progression that accompanies the melody. Conversely, given a melody, if we harmonize it with an accompanying chord progression, we automatically have also created in a minimal way a counterpoint of 3 voices.
The mechanically deterministic part of the algorithm, is based on the mathematical theorem that any note of a diatonic scale belongs to three (3 or 4 notes) chords of the diatonic scale.
STEP 1: We may start with all the notes of the melody x1,x2,...xn, or start with only the notes y1,y2,...,yn that have not very short duration and could be called the simplicial submelody of the melody. Of course this is easier if we have the melody written in a pentagram or in piano roll.
STEP 2: At first we listen to the melody or its simplicial submelody , to get a musical feeling. Then we proceed as follows: we try the 3 chords that y1 belongs , and by our feeling we chose one Ch1. Some ofthe canditate chords are major and some are minor. We follow our feling.
STEP 3 We repeat it for note y2. If we find a chord that is the Ch1, or a previously used chord for the note y2 we prefer it if we seek a minimal chord progression. But if we are seeking for a maximally different chords , in the chord progression, we chose a chord Ch2, not used before for the note y2. The difference of repeating previously used chords for the same note or using new chords or mixing both gives all the spectrum between the minimal number (usually 3 chords) and maximal number (7 chords) for the diatonic melody.
STEP 4 : After finishing all the notes y1,...,yn, and the finding-composing of the chord progression Ch1,....Chn, we try it for the melody, and usually we may omit some chords, so that , finally not all notes ofthe melody x1,x2,...xn are inside the underlying chords (passing notes). The passing notes usually should not be more than 50% of the total duration. (Still in Bach's counterpoint, the passing notes that are in dissonance with teh underlying chords may be 50%-75% of the total time!) We may also alter some chords to one of the other two possible choices so that, in total, the chords are a minimal number. But this is only if we seek minimal chord progressions. If we seek maximal chord progressions, we must do the oposite. The same notes in that case are preferred to have different chords. The minimal chord progressions will usually be 1 or 2 chords, the intermediate 4-5, and the maximal chord progressions will by 7 chords.