||An automated process has detected links on this page on the local or global blacklist.|
JFugue is an open source programming library that allows one to program music in the Java programming language without the complexities of MIDI. It was first released in 2002 by David Koelle. Brian Eubanks has described JFugue as "useful for applications that need a quick and easy way to play music or to generate MIDI files." JFugue is free software released under the GNU LGPL.
Here's an example Java program that will play the C-major scale in JFugue.
Player player = new Player(); player.play("C D E F G A B");
The string passed to JFugue contains a series of musical instructions that JFugue parses and turns into musical events, which by default are rendered in MIDI. These strings, called the "MusicString", can represent all of the musical features of MIDI. JFugue also provides features that enable the developer to write music in a straightforward manner; for example, chords and instruments are represented in a user-centered manner.
Player player = new Player(); player.play("V0 Cmaj V1 I[Flute] D#6q V2 I[Alto_Sax] F#minI GminI");
A notion of Patterns is integral to JFugue. Patterns are used to represent phrases of music that can be combined and repeated.
Pattern pattern1 = new Pattern("A B C"); Pattern pattern2 = new Pattern("G F E"); pattern1.add(pattern2); pattern1.repeat(3); Player player = new Player(); player.play(pattern1);
Patterns can also be transformed into new phrases of music using a PatternTransformer:
Pattern pattern = new Pattern("A B C"); ReversePatternTransformer rpt = new ReversePatternTransformer(); Pattern reversePattern = rpt.transform(pattern);
JFugue uses the MIDI implementation provided by the Java programming language to create audio output from the "MusicString", the series of instructions that JFugue parses.
The architecture of JFugue allows it to read and write musical information from and to a variety of formats. Currently, JFugue is capable of reading and writing its own MusicString; MIDI files; and MusicXML files. Additionally, each of these readers and writers (which JFugue calls "Parsers" and "Renderers") can be mixed and matched. For example, it is possible to create an application that reads MIDI files and writes them as MusicXML through JFugue.
JFugue is capable of producing microtonal music.
One can create rhythms as if programming a beat box:
Rhythm rhythm = new Rhythm(); rhythm.setLayer(1, "O..oO...O..oOO.."); rhythm.setLayer(2, "..*...*...*...*."); rhythm.addSubstitution('O', "[BASS_DRUM]i"); rhythm.addSubstitution('o', "Rs [BASS_DRUM]s"); rhythm.addSubstitution('*', "[ACOUSTIC_SNARE]i"); rhythm.addSubstitution('.', "Ri"); Player player = new Player(); player.play(rhythm);
JFugue provides functionality on top of Java's MIDI Transmitter and Receiver classes to reduce the amount of code that a developer would need to write to connect to external MIDI devices.
Uses in Other Applications
JFugue has been used in a number of applications, including software projects and artistic installations.
- The JFugue Music NotePad provides a user interface for composing music
- JFrets is an application for teaching and training guitar tablature 
- Log4JFugue is a utility for converting log files created by log4j into musical patterns; this allows one to listen for changes in a log file, which provides a much different experience than reading through the file line-by-line.
JFugue has been used to play music when a software build fails or succeeds.
JFugue is one of the few Java libraries that lets one do something interesting in as little as one or two lines of code. This distinction earned JFugue a place in the book "Groovy in Action"
- Eubanks, Brian D. (2005), "Wicked Cool Java". pp. 154–156.
- "The Complete Guide to JFugue," Chapter 2, "http://www.jfugue.org/jfugue-chapter2.pdf"
- Recordare LLC, "http://www.recordare.com/xml/software.html
- "JFugue Goes Hip Hop", interview at JavaLobby, "http://java.dzone.com/news/interview-jfugue-goes-hip-hop"
- JFugue Music NotePad project, "https://nbjfuguesupport.dev.java.net/"
- JFrets project, "https://jfrets.dev.java.net/"
- Log4JFugue, "http://log4jfugue.org/"
- PragPub Magazine, Issue 3, September 2009, "http://www.pragprog.com/magazines/download/3.pdf"
- Koenig, Dierk, et al. (2007)
- JFugue.org—Official JFugue website