Monthly Archives: November 2015

Introducing Counterpoint Composer

Note: This article is a remix for CulturedEar.com blog of my original post on JavaFXpert.com

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 part of my day job on 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, and the chord analysis capabilities of JFugue by David Koelle. 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

If you’ll permit me to dive a bit into the software aspects of Counterpoint Composer, here’s a high-level diagram of the application:

counterpoint-composer-architecture

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:

rest-services

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 which is available in the app’s Help -> Getting Started menu item:

help-menu

The resources in the Getting Started tutorial demonstrate how to generate each of the five species of counterpoint, and how to select various scale modes.  The tutorial also demonstrates how to disable one or more of the 70+ counterpoint rules in the following dialog to see/hear the effects on the composition:

counterpoint-rules-dialog-toggled

In addition, the Help -> Technical Presentation menu item contains slides that give a technical perspective of the application.

Independently demonstrating the ChordAnalyzerService with the Web MIDI API

The penultimate slide in the deck mentioned 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:

chord-analyzer-architecture

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. I’m sure that you recognize the innovative instrument in the diagram above is a LinnStrument (the current focus of this 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:

It is my hope that this Counterpoint Composer application will serve as a resource for music students, as well as software developers, of all ages!

Regards,

James Weaver
http://CulturedEar.com