/* Author: Bill Manaris (original code by David Koelle) Email: manaris@cs.cofc.edu Class: CSCI 220 Assignment: HMWK # 6 Due Date: April 21, 2004 Task: This program plays the children's song "Frere Jacques". It demonstrates how to construct songs with several concurrent voices using JFugue. Input: None. Output: MIDI notes and events to the MIDI output device. Credits: Adapted from http://www.jfugue.org/JFugue-UserGuide.html#example3 */ import org.jfugue.*; public class FrereJacques { public static void main(String[] args) { Player player = new Player(); Pattern frereJacques = new Pattern("C5q D5q E5q C5q"); // "Frere Jacques" Pattern dormezVous = new Pattern("E5q F5q G5h"); // "Dormez-vous?" Pattern sonnezLesMatines = new Pattern("G5i A5i G5i F5i E5q C5q"); // "Sonnez les matines" Pattern dingDingDong = new Pattern("C5q G4q C5h"); // "Ding ding dong" Pattern doubleMeasureRest = new Pattern("Rw Rw"); // the offset between rounds Pattern phrase = new Pattern(); // holds one complete phrase Pattern round1 = new Pattern("V0 "); // holds the first voice Pattern round2 = new Pattern("V1 "); // holds the second voice Pattern round3 = new Pattern("V2 "); // holds the third voice Pattern song = new Pattern(); // holds the complete song // Put the phrase together phrase.add(frereJacques); phrase.add(frereJacques); phrase.add(dormezVous); phrase.add(dormezVous); phrase.add(sonnezLesMatines); phrase.add(sonnezLesMatines); phrase.add(dingDingDong); phrase.add(dingDingDong); // build the first voice round1.add(phrase); // build the second voice round2.add(doubleMeasureRest); round2.add(phrase); // build the third voice round3.add(doubleMeasureRest); round3.add(doubleMeasureRest); round3.add(phrase); // Put the voices together song.add(round1); song.add(round2); song.add(round3); // Play the song! player.play(song); System.exit(0); // necessary to shut down properly, since Java MIDI // classes leave some threads running. } }