JFugue

Last updated

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. Version 2 was released under a proprietary license. [1] Versions 3 and 4 were released under the LGPL-2.1-or-later license. [2] [3] The current version, JFugue 5.0, was released in March 2015, under the Apache-2.0 license. [4] Brian Eubanks has described JFugue as "useful for applications that need a quick and easy way to play music or to generate MIDI files." [5]

Contents

Example

Here's an example Java program that will play the C-major scale in JFugue.

importorg.jfugue.player.Player;publicclassHelloWorld{publicstaticvoidmain(String[]args){Playerplayer=newPlayer();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. This format, called "Staccato," can represent all of the musical features of MIDI [6] and is specifically designed to be easy for people to read and write. [7] While the default use case for JFugue is to convert Staccato to MIDI, the architecture allows it to read and write musical information from and to a variety of formats (e.g., MIDI to MusicXML, [8] Staccato to LilyPond). Below is an example converting a MIDI file to the Staccato format.

MidiParserparser=newMidiParser();StaccatoParserListenerlistener=newStaccatoParserListener();parser.addParserListener(listener);parser.parse(MidiSystem.getSequence(newFile("YourMidiFile.mid")));// Change to the name of a MIDI file that you own the rights toPatternstaccatoPattern=listener.getPattern();System.out.println(staccatoPattern);

JFugue 5.0 contains a set of classes that represent ideas in music theory, including intervals, scales, chords, and chord progressions.

The notion of Patterns is integral to JFugue. Patterns are used to represent phrases of music that can be combined, repeated, and altered using tools that are aware of the musical content of the pattern.

Patternpattern1=newPattern("A B C");Patternpattern2=newPattern("G F E");pattern1.add(pattern2).repeat(3);Playerplayer=newPlayer();player.play(pattern1);

JFugue 5.0 makes extensive use of fluent interfaces, also known as method chaining, which lets developers write short, expressive pieces of code like the following:

Chord[]chords=newChordProgression("I IV V").setRoot("C").getChords();

Advanced Features

JFugue is capable of producing microtonal music by using a Staccato element consisting of the letter 'm' followed by the frequency in Hertz of the desired tone. Like other notes in JFugue, this tone may be followed by a duration (such as 'w' for a whole note or 'q' for a quarter note) and note dynamics (e.g., "note on" and "note off" velocities). JFugue converts the microtone frequency to a sequence of MIDI Pitch Wheel and Note events to achieve the desired tone.

Playerplayer=newPlayer();player.play("m440.0q A4q");// These sound the sameplayer.play("m568.7w");// Whole duration note at 568.7 Hertz

JFugue provides an intuitive programming interface for creating beats and rhythms. The characters in the strings below each correspond to a percussion note that is played on the percussive MIDI Channel (the tenth channel); default settings are provided for common sounds (e.g., "O" for "[BASS_DRUM]q"), although any Java Map or Character to String may be passed to the Rhythm constructor.

Rhythmrhythm=newRhythm().addLayer("O..oO...O..oOO..").addLayer("..S...S...S...S.").addLayer("````````````````").addLayer("...............+");newPlayer().play(rhythm.getPattern().repeat(2));

In addition to allowing music to be converted from one music format to another, the architecture of JFugue can be used to create programmatic tools that are capable of both performing computations on incoming music (from any format) and changing incoming music. The example below is a simple tool that keeps track of all instruments used in a musical piece.

publicclassInstrumentToolDemo{publicstaticvoidmain(String[]args)throwsInvalidMidiDataException,IOException{MidiParserparser=newMidiParser();// Remember, you can use any Parser!InstrumentToolinstrumentTool=newInstrumentTool();parser.addParserListener(instrumentTool);parser.parse(MidiSystem.getSequence(newFile("YourMidiFile.mid")));// Change to a real filenameList<String>instrumentNames=instrumentTool.getInstrumentNames();for(Stringname:instrumentNames){System.out.println(name);}}}classInstrumentToolextendsParserListenerAdapter{privateList<String>instrumentNames;publicInstrumentTool(){super();instrumentNames=newArrayList<String>();}@OverridepublicvoidonInstrumentParsed(byteinstrument){StringinstrumentName=MidiDictionary.INSTRUMENT_BYTE_TO_STRING.get(instrument);if(!instrumentNames.contains(instrumentName)){instrumentNames.add(instrumentName);}}publicList<String>getInstrumentNames(){returnthis.instrumentNames;}}

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.

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" [15]

Related Research Articles

<span class="mw-page-title-main">Bass (sound)</span> Tone of low frequency or range

Bass ( BAYSS) (also called bottom end) describes tones of low (also called "deep") frequency, pitch and range from 16 to 250 Hz (C0 to middle C4) and bass instruments that produce tones in the low-pitched range C2-C4. They belong to different families of instruments and can cover a wide range of musical roles. Since producing low pitches usually requires a long air column or string, and for stringed instruments, a large hollow body, the string and wind bass instruments are usually the largest instruments in their families or instrument classes.

In music, syncopation is a variety of rhythms played together to make a piece of music, making part or all of a tune or piece of music off-beat. More simply, syncopation is "a disturbance or interruption of the regular flow of rhythm": a "placement of rhythmic stresses or accents where they wouldn't normally occur". It is the correlation of at least two sets of time intervals.

Sheet music is a handwritten or printed form of musical notation that uses musical symbols to indicate the pitches, rhythms, or chords of a song or instrumental musical piece. Like its analogs – printed books or pamphlets in English, Arabic, or other languages – the medium of sheet music typically is paper. However, access to musical notation since the 1980s has included the presentation of musical notation on computer screens and the development of scorewriter computer programs that can notate a song or piece electronically, and, in some cases, "play back" the notated music using a synthesizer or virtual instruments.

<span class="mw-page-title-main">Electronic keyboard</span> Musical instrument

An electronic keyboard, portable keyboard, or digital keyboard is an electronic musical instrument based on keyboard instruments. Electronic keyboards include synthesizers, digital pianos, stage pianos, electronic organs and digital audio workstations. In technical terms, an electronic keyboard is a rompler-based synthesizer with a low-wattage power amplifier and small loudspeakers.

A variety of musical terms are encountered in printed scores, music reviews, and program notes. Most of the terms are Italian, in accordance with the Italian origins of many European musical conventions. Sometimes, the special musical meanings of these phrases differ from the original or current Italian meanings. Most of the other terms are taken from French and German, indicated by Fr. and Ger., respectively.

<span class="mw-page-title-main">GarageBand</span> Digital audio workstations for macOS, iOS, and iPadOS

GarageBand is a software application by Apple for macOS, iPadOS, and iOS devices that allows users to create music or podcasts. It is a lighter, amateur-oriented offshoot of Logic Pro. GarageBand was originally released for macOS in 2004 and brought to iOS in 2011. The app's music and podcast creation system enables users to create multiple tracks with software synthesizer presets, pre-made and user-created loops, an array of various effects, and voice recordings.

MusicXML is an XML-based file format for representing Western musical notation. The format is open, fully documented, and can be freely used under the W3C Community Final Specification Agreement.

<span class="mw-page-title-main">Yamaha QY10</span>

The Yamaha QY10 is a hand-held music workstation produced by the Yamaha Corporation in the early 1990s. Possessing a MIDI sequencer, a tone generator and a tiny single-octave keyboard, the portable and battery-powered QY10 enables a musician to compose music while traveling.

<span class="mw-page-title-main">Strum</span>

In music, strumming is a way of playing a stringed instrument such as a guitar, ukulele, or mandolin. A strum or stroke is a sweeping action where a finger or plectrum brushes over several strings to generate sound. On most stringed instruments, strums are typically executed by a musician's designated strum hand, while the remaining hand often supports the strum hand by altering the tones and pitches of any given strum.

<span class="mw-page-title-main">Omnichord</span> Electronic musical instrument

The Omnichord is an electronic musical instrument introduced in 1981 by the Suzuki Musical Instrument Corporation. It allows users to play distinctive harp-like arpeggios produced through an electronic strum plate, simulating the experience of playing a stringed instrument. Originally conceived as an electronic Autoharp, the Omnichord found popularity due to its portability, its unique timbre, and its value as a kitsch object.

<span class="mw-page-title-main">Transcription (music)</span> Process of creating sheet music from a recording or performance

In music, transcription is the practice of notating a piece or a sound which was previously unnotated and/or unpopular as a written music, for example, a jazz improvisation or a video game soundtrack. When a musician is tasked with creating sheet music from a recording and they write down the notes that make up the piece in music notation, it is said that they created a musical transcription of that recording. Transcription may also mean rewriting a piece of music, either solo or ensemble, for another instrument or other instruments than which it was originally intended. The Beethoven Symphonies transcribed for solo piano by Franz Liszt are an example. Transcription in this sense is sometimes called arrangement, although strictly speaking transcriptions are faithful adaptations, whereas arrangements change significant aspects of the original piece.

<span class="mw-page-title-main">Live PA</span> Live performance for electronic dance music

Live PA is the act of performing live electronic music in settings typically associated with DJing, such as nightclubs, raves, and more recently dance music festivals.

<span class="mw-page-title-main">LMMS</span> Free software digital audio workstation

LMMS is a digital audio workstation application program. It allows music to be produced by arranging samples, synthesizing sounds, entering notes via computer keyboard or mouse or by playing on a MIDI keyboard, and combining the features of trackers and sequencers. It is free and open source software, written in Qt and released under GPL-2.0-or-later.

<span class="mw-page-title-main">Power Tab Editor</span> Scorewriter

Power Tab Editor is a freeware tablature authoring tool created by Brad Larsen for Windows. It is used to create guitar, bass and ukulele tablature scores, among many others. The current version uses the *.ptb file format.

<span class="mw-page-title-main">Mozart the music processor</span> Scorewriter

Mozart the music processor is a proprietary WYSIWYG scorewriter program for Microsoft Windows. It is used to create and edit Western musical notation to create and print sheet music, and to play it via MIDI.

<span class="mw-page-title-main">Guitar picking</span> Guitar playing technique

Guitar picking is a group of hand and finger techniques a guitarist uses to set guitar strings in motion to produce audible notes. These techniques involve plucking, strumming, brushing, etc. Picking can be done with:

Pop music automation is a field of study among musicians and computer scientists with a goal of producing successful pop music algorithmically. It is often based on the premise that pop music is especially formulaic, unchanging, and easy to compose. The idea of automating pop music composition is related to many ideas in algorithmic music, Artificial Intelligence (AI) and computational creativity.

<span class="mw-page-title-main">Glossary of jazz and popular music</span> List of definitions of terms and jargon used in jazz and popular music

This is a glossary of jazz and popular music terms that are likely to be encountered in printed popular music songbooks, fake books and vocal scores, big band scores, jazz, and rock concert reviews, and album liner notes. This glossary includes terms for musical instruments, playing or singing techniques, amplifiers, effects units, sound reinforcement equipment, and recording gear and techniques which are widely used in jazz and popular music. Most of the terms are in English, but in some cases, terms from other languages are encountered.

References

  1. "License Agreement - JFugue - Java API for Music Programming". Archived from the original on 2004-02-10.
  2. "Download JFugue - JFugue - Java API for Music Programming". Archived from the original on 2007-05-10.
  3. "Download JFugue - JFugue - Java API for Music Programming". Archived from the original on 2015-02-18.
  4. "Download JFugue". Archived from the original on 2015-04-02.
  5. Eubanks, Brian D. (2005), "Wicked Cool Java". pp. 154–156.
  6. "The Complete Guide to JFugue," Chapter 2, "http://www.jfugue.org/4/jfugue-chapter2.pdf Archived 2016-03-04 at the Wayback Machine "
  7. "slideshare.net/dmkoelle/4130-musical-programs"
  8. Recordare LLC, "http://www.recordare.com/xml/software.html
  9. About TransProse, "http://www.musicfromtext.com/about.html Archived 2015-04-04 at archive.today "
  10. JFugue Music NotePad project, "https://java.net/projects/nbjfuguesupport%5B%5D"
  11. JFrets project, "https://jfrets.dev.java.net/ Archived 2007-07-28 at the Wayback Machine "
  12. Log4JFugue, "http://log4jfugue.org/"
  13. PragPub Magazine, Issue 3, September 2009, "http://www.pragprog.com/magazines/download/3.pdf"
  14. Audovia, "https://songbase.github.io/"
  15. Koenig, Dierk, et al. (2007)