Interactively generate interesting and well-balanced counterpoint following the strict rules of species counterpoint. See a live example here.
What is Species Counterpoint?
Species counterpoint is a time-honored method for learning how to write two or more lines of music that work well together. Infamous for its many rules, species counterpoint applies restrictions on both the horizontal and vertical dimensions of music — meaning that each line must be balanced and harmonious not only by itself left to right, but also up and down between all the lines at any given moment. The result is a kind of musical sudoku puzzle in which every decision resonates out in multiple directions.
The module is in development, and currently only supports creating a cantus firmus -- the horizontal dimension of counterpoint. Soon it will support 2-part first species counterpoint, and eventually all species.
In this example we will build this cantus firmus in G major:
[ 'G4', 'E5', 'D5', 'F#5','G5', 'B4', 'C5', 'A4', 'G4' ] G5 o F#5 o E5 o D5 o C5 o B4 o A4 o G4 o o Do La Sol Ti Do Mi Fa Re Do 1 6 5 7 1 3 4 2 1
Install the npm module.
npm install counterpoint
To generate a cantus firmus in G major:
var CantusFirmus = CantusFirmusvar cantus = 'G major'
See the next note choices. At the beginning we have to start with G, but after that it gets more interesting.
cantus 'G'cantuscantus 'A4' 'B4' 'C5' 'D5' 'E5' 'G5''F#4' 'E4' 'G3' 'B3' 'C4' 'D4'cantuscantus 'D5' 'C5' // choices are limited after a leapcantuscantus 'E5' 'F#5' 'G5' 'A5' 'B5''C5' 'B4' 'G4' 'A4'cantus
See what you've built so far:
cantus 'G4' 'E5' 'D5' 'F#5'
The choices are filtered for standard cantus firmus rules: no choices are given that would extend the range beyond a 10th, augmented and diminished intervals are avoided, dissonant melodic outlines are avoided, and more.
cantus 'G5' 'E5' 'F#4' 'A4' 'B4'cantuscantus 'A5' 'B5' 'F#5' 'E5' 'G4' 'B4' 'C5' 'D5'cantus
You can also look ahead more than one note by giving
cantus.choices() a number indicating the depth to search. If given a depth, choices returns an array of nDeep TreeNodes each with a
val pointing to a pitch and
next pointing to an array of more TreeNodes.
cantus 'C5' 'D5'cantusval: 'C5'next:val: 'D5' next:val: 'E5' next:val: 'G5' next:val: 'B4' next:val: 'A4' next: // I will pick this path -> C5, A4val: 'E4' next:val: 'G4' next:val: 'D5'next:val: 'E5' next:val: 'C5' next:val: 'F#4' next:val: 'G4' next:val: 'A4' next:cantuscantuscantus 'B4' 'D5' 'E5' 'F#5' 'A5' 'G4'cantus
We have worked our way back to the starting tonic and can now check if this is a valid cantus firmus. It will be checked to make sure there is a unique climax note (G5 in our case) along with other standard checks.
cantus truecantus'G4' 'E5' 'D5' 'F#5''G5' 'B4' 'C5' 'A4' 'G4'
Clone the git repository and install development dependencies:
git clone https://github.com/jrleszcz/computational-counterpoint.git cd computational-counterpoint npm install
To run eslint and tape tests:
To generate api documentation for api.md:
npm run docs