Brute-force generation of ten-note cantus firmus melodies and first species counterpoint
melody.py generates random 10-note first species counterpoint melodies by first finding a random cantus firmus melody that matches a set of heuristics and then finding an appropriate counterpoint melody. A total of 16 heuristics are used for each individual melody and 4 heuristics are used to match two melodies in counterpoint. Results are outputted as MIDI files using Pyknon and then played using Timidity.
1. Try It Now! 2. Video Demonstration 3. Usage 3.1. Installation 3.1.1. Ubuntu / Debian 3.1.2. Other 3.2. Running melody.py 3.2.1. Command-line interface 3.2.2. Web interface 4. Heuristics Used 4.1. For each individual melody 4.2. To match cantus firmus melody to first species melody 5. Wish List
I've spun up an Amazon EC2 instance.
You can use melody.py through the command-line or by running a small web server. The advantage of the latter is that you'll also be able to see generated sheet music.
sudo apt-get install python3-pip timidity
pip3 install git+https://github.com/kroger/pyknon.git
If you wish to use the web interface, also run
pip3 install flask
If you wish to use the web interface, also install Flask. If you're using Internet Explorer (which supports MP3 but not WAV audio sources), make sure FFmpeg is installed.
python melody.py
will loop forever, generating new melodies continuously. Mash Ctrl-C a few times to stop it.
python app.py
Then go to localhost:5000
(or whatever port is chosen).
Both the cantus firmus and the first species must satisfy the following rules:
Together, the cantus firmus and the first species must satisfy the following: