JFugue
Encyclopedia
JFugue is an open source
Open source
The term open source describes practices in production and development that promote access to the end product's source materials. Some consider open source a philosophy, others consider it a pragmatic methodology...

 programming library that allows one to program music
Music
Music is an art form whose medium is sound and silence. Its common elements are pitch , rhythm , dynamics, and the sonic qualities of timbre and texture...

 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."

Example

Here's an example Java program that will play the C-major scale
Musical scale
In music, a scale is a sequence of musical notes in ascending and descending order. Most commonly, especially in the context of the common practice period, the notes of a scale will belong to a single key, thus providing material for or being used to conveniently represent part or all of a musical...

 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);

Functionality

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
MusicXML
MusicXML is an open, XML-based music notation file format.It was developed by Recordare LLC, deriving several key concepts from existing academic formats . It is designed for the interchange of scores, particularly between different scorewriters.Version 1.0 was released in January 2004...

 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.

Advanced Features

JFugue is capable of producing microtonal music
Microtonal music
Microtonal music is music using microtones—intervals of less than an equally spaced semitone. Microtonal music can also refer to music which uses intervals not found in the Western system of 12 equal intervals to the octave.-Terminology:...

.

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"

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK