Welcoming Spring with some new features in JFugue! Public domain picture from http://www.publicdomainpictures.net/view-image.php?image=60821&picture=paper-birds-musical-notes

What’s New in JFugue 5.0.8

There are some exciting new features in JFugue 5.0.8 that I’d like to share with you!

  • Support for broken chords
  • An update to real-time player events so each note comes with its voice and instrument information
  • A new method added to Intervals that checks whether a given note is in an interval that has a root
  • A change to replacement strings: The underscore reference, $_, has been changed to $!

New feature: Support for Broken Chords

With JFugue, you could always let you play a chord like this:

new Player().play(“Cmaj”);

Of course, this would play a C-major chord (C, E, and G) — all three notes at the same time, with the default quarter duration.

But sometimes, you might want to play a chord with a particular style. For example, you may want the notes of a C-major chord played more like a march, with the first two notes in the chord played once, followed by the third note played twice. And then, maybe you decide that march doesn’t match what you’re looking for, and you’d like to try a different arrangement.

To make this kind of musical experimentation and discovery as simple and as quick as possible to write, JFugue introduces support for broken chords. This capability uses the same “replacement strings” that are already used in chord progressions and intervals to give an index into which note of the chord you want to play at a given time.

Here’s how it works: You specify your chord, followed by a colon, then a comma-separated replacement string. Here’s the march example discussed earlier:

new Player().play(“Cmaj:$0h+$1h,$2q,$2q”);

For more examples and a deeper dive, including learning how to refer to bass or root notes regardless of their index, can be found here: Broken Chords in JFugue.

Read to the end of this post for a cool video about broken chords.

New feature: Update to Real-Time Player

You can send musical events to the JFugue player in real-time using the RealTimePlayer. But if you want to specify a voice, instrument, and note all at the same time, you need to send three different elements to the RealTimePlayer, and if there is a second thread that is also sending three different elements, it’s possible for those elements to become entwined, resulting in music that you do not expect.

The solution to this is to create an atom of music that lets you specify a voice (and, optionally, a layer), an instrument, and a note at the same time. Then you can send the atom to the RealTimePlayer, and the music is rendered correctly. An atom is a single Staccato element; it starts with a semicolon, then contains a comma-separated list of voice (and, optionally, layer), instrument, and note elements. For example, “&V1,I[Piano],Cw” is an atom that changes to Voice 1, instrument Piano, and plays a C note, whole duration, without any other voice-instrument-note settings interfering in the time that it takes to process this atom.

There is also a new method on Pattern called atomize(), which will return a new Staccato string containing atoms for each note in the pattern.

New feature: Check whether Intervals has a Note

There are two new method in Intervals, has(String s) and has (Note n), which return true if an instance if Intervals that has a root (i.e., setRoot() has been called) contains the note that you’re interested in.

Updated feature: Change to the replacement string $_ reference

When using replacement strings for ChordProgression (in the eachChordAs() or allChordsAs() methods) or Interval (in the as() method), and now for Broken Chords, references starting with dollar signs let you specify an index into the chord, chord progression, or interval (e.g., $0 is the first note of a chord), and $_ was used to refer to the chord or chord progression itself. The parser for replacement strings (found in the ReplacementFormatUtil class) was rewritten to support broken chords, and in the process, the $_ reference needed to be changed (because underscore is also a connecting character to indicate notes played at the same time while other notes play simultaneously, as in Ch+Eq_Gq). The replacement is $!.

Thanks for reading!

If you’ve gotten this far, please enjoy this video on broken chords!