// Zorah Fung, CSE 143 // Demonstrates the use of the JFugue library to make music // To use, first download the JFugue library from http://www.jfugue.org/ // In Eclipse, right click on your project and go to Properties // Then, access Java Build Path > Libraries and click on the "Add External Jar" button // Select the library's jar file import org.jfugue.midi.MidiDictionary; import org.jfugue.pattern.Pattern; import org.jfugue.player.Player; import org.jfugue.rhythm.Rhythm; public class MusicPlayer { public static void main(String[] args) { Player player = new Player(); System.out.println(Rhythm.DEFAULT_RHYTHM_KIT); System.out.println(MidiDictionary.INSTRUMENT_BYTE_TO_STRING); Rhythm rhythm = new Rhythm() .addLayer("O..oO...O..oOO..") .addLayer("..S...S...S...S.") .addLayer("````````````````") .addLayer("x..xxx..x..xxx..") .addLayer("..............+."); Pattern p1 = rhythm.getPattern().setVoice(0).repeat(4); Pattern p2 = new Pattern("C5 D E F G A B C6 C5 E D F E C5 D B4").setInstrument("clarinet").setVoice(1).repeat(2); Pattern p3 = new Pattern("Cmajw Gmajw Aminw Fmajw").setInstrument("Electric_Piano").setVoice(2).repeat(2); player.play(p1, p2, p3); } }