JMUSIC»Bing Java

Bing Java

This sample program has everything you need to create MIDI files. Use it to test your jMusic installation.

//give this class access to the jMusic classes
import jm.JMC;
import jm.util.*;

* This is the simplest jMusic program of all.
* The eqivalent to a programming language's 'Hello World'

public final class Bing implements JMC
   public static void main(String[] args)

      //create a middle C minim (half note)
      Note n = new Note(C4, MINIM);

      //create a phrase
      Phrase phr = new Phrase();

      //put the note inside the phrase

      //pack the phrase into a part
      Part p = new Part();

      //pack the part into a score titled 'Bing'
      Score s = new Score("Bing");

      //play the score as MIDI
      Play.midi(s, true);

      //write the score as a MIDI file to disk
      Write.midi(s, "Bing.mid");