It is hard to write a beautiful song. It is harder to write several individually beautiful songs that, when sung simultaneously, sound as a more beautiful polyphonic whole. The internal structures that create each of the voices separately must contribute to the emergent structure of the polyphony, which in turn must reinforce and comment on the structures of the individual voices. The way that is accomplished in detail is...'counterpoint'.
- John Rahn
As a member of the Pivotal evangelism team, one of my primary activities is to create demo applications and use them as a basis for technical presentations at conferences. I'd like to share with you the first such demo app, named Counterpoint Composer, located at CounterpointComposer.com
Counterpoint Composer, developed in the Java programming language, leverages rules expressed by composers such as Giovanni Pierluigi da Palestrina and Johann Joseph Fux in the 16th - 18th centuries to create counterpoint music. It also builds on the work of Bill Schottstaedt who coded those rules using the SAIL and C programming languages. As an example of using Counterpoint Composer, here's a two-minute video of creating a counterpoint tune from the melody known as Twinkle Twinkle Little Star:
If you're new to counterpoint, a gentle introduction to it is the Species Counterpoint article by Nicholas H. Tollervey
Counterpoint Composer application diagram
Here's a high-level diagram of the application:
The user interface of this application is a one-page web app that uses a dynamically embedded music notation component from Noteflight.com. As shown in the diagram above, this application also includes the following two microservices available via HTTP protocols:
- CounterpointService: Given a JSON representation of the main melody, initial chord, counterpoint species, and music mode, this service returns a MusicXML representation of the resultant counterpoint composition.
- ChordAnalyzerService: This service analyzes a set of musical notes to see if they represent a musical chord, returning the name of an identified chord.
Here is an illustration of these services, including how the CounterpointService uses the ChordAnalyzer service:
Getting up to speed with Counterpoint Composer
The best way to get up to speed with Counterpoint Composer is to follow the guidance of the Getting Started tutorial, also available in the app's Help -> Getting Started menu item:
In addition, the Help -> Technical Presentation menu item contains the slides shown below that give a technical perspective of the application:
Independently demonstrating the ChordAnalyzerService with the Web MIDI API
The penultimate slide in the deck shown previously contains the following diagram of how the ChordAnalyzerService may be demonstrated with a MIDI keyboard connected to a computer that has a Chrome browser. Opening the Chord Analyzer Client web app in the browser and playing simultaneous notes on the MIDI keyboard should result in the chords being identified and displayed as shown below:
Please note that it is best to use the Chrome browser, as that is currently (Nov 2015) the only one that supports the Web MIDI API. By the way, the innovative instrument in the diagram above is a LinnStrument, which is the current focus of my CulturedEar.com blog, but any conventional MIDI keyboard controller should work as well.
Downloading the source code
The microservices described are running in Cloud Foundry at Pivotal Web Services, so the application links above should always be available. The source code is licensed under Apache License 2.0 and may be download from the following GitHub repositories:
- CounterpointService and Counterpoint Composer UI:
- ChordAnalyzerService and Chord Analyzer Client:
It is my hope that this application will serve as a resource for music students of all ages, as well as an example of using Spring Boot and Cloud Foundry to develop and deploy cloud native applications.