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">MIDI</span> Means of connecting electronic musical instruments

MIDI is a technical standard that describes a communications protocol, digital interface, and electrical connectors that connect a wide variety of electronic musical instruments, computers, and related audio devices for playing, editing, and recording music.

<span class="mw-page-title-main">Rhythm guitar</span> Technique providing rhythm and harmony to an ensemble

In music performances, rhythm guitar is a technique and role that performs a combination of two functions: to provide all or part of the rhythmic pulse in conjunction with other instruments from the rhythm section ; and to provide all or part of the harmony, i.e. the chords from a song's chord progression, where a chord is a group of notes played together. Therefore, the basic technique of rhythm guitar is to hold down a series of chords with the fretting hand while strumming or fingerpicking rhythmically with the other hand. More developed rhythm techniques include arpeggios, damping, riffs, chord solos, and complex strums.

<span class="mw-page-title-main">Orchestration</span> Study or practice of writing music for an orchestra

Orchestration is the study or practice of writing music for an orchestra or of adapting music composed for another medium for an orchestra. Also called "instrumentation", orchestration is the assignment of different instruments to play the different parts of a musical work. For example, a work for solo piano could be adapted and orchestrated so that an orchestra could perform the piece, or a concert band piece could be orchestrated for a symphony orchestra.

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 synthesizer with a low-wattage power amplifier and small loudspeakers.

A variety of musical terms are likely to be 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.

Ear training or aural skills is a music theory study in which musicians learn to identify pitches, intervals, melody, chords, rhythms, solfeges, and other basic elements of music, solely by hearing. The application of this skill is analogous to taking dictation in written/spoken language. As a process, ear training is in essence the inverse of sight-reading, the latter being analogous to reading a written text aloud without prior opportunity to review the material. Ear training is typically a component of formal musical training and is a fundamental, essential skill required in music schools.

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

GarageBand is a line of digital audio workstations developed by Apple for macOS, iPadOS, and iOS devices that allows users to create music or podcasts. 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 pre-made MIDI keyboards, pre-made loops, an array of various instrumental 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 (introduced 1981)

The Omnichord is an electronic musical instrument introduced in 1981 by the Suzuki Musical Instrument Corporation. It typically features a touch plate known as "Sonic Strings", preset rhythms, auto-bass line functionality, and buttons for major, minor, and 7th chords. The most basic method of playing the instrument is to press the chord buttons and swipe the Sonic Strings with a finger in imitation of strumming a stringed instrument. The Sonic Strings may also be touched in one place to create a single note. Originally designed as an electronic Autoharp, the Omnichord has become popular, due to its unique, chiming, harplike timbre and its value as a kitsch object.

<span class="mw-page-title-main">Transcription (music)</span>

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">Power Tab Editor</span> Scorewriter

Power Tab Editor is a free 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"
  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)