jMusic setup

Before we do any programming it is important to understand how things fit together. This is quite complex but for the moment all we need to discuss are the basics, and here they are.


jMusic is split into a number of core packages. If you downloaded the jMusic source files you will see that they are contained in a number of directories. A java package must live in the same directory as their package name. Therefore all files in the package will be found in the directory jm/music/data. The directory in which jm lives must be included in your CLASSPATH so that Java knows where to find the jMusic files. For example, if you want to put all your code in a directory called c:\code\ you might want to put jm in there as well so that you end up with c:\code\jm\music\data. Your CLASSPATH may look like this classpath=.;c:\java\lib\;c:\code . For the Macintosh OS the class path is a folder called MRJ Libraries in the Extensions Folder within the System Folder. Drop the jm folder, or jm.jar file, or file into that MRJ Library folder. All done, sorry about that for all you Java legends out there. For more details on setting up jMusic see the download page.

What goes Where

The reason we use packages is to contain code within like parts. In jMusic there are four significant packages at the moment. They are:

  • jm - Is the overall jMusic package and contains useful umbrella information like constant values representing note lengths, pitch values etc..
  • - Holds files used to hold the jMusic data representation which is what you will be mainly concerned with.
  • - Holds classes which manipulate or generate or edit jm data.
  • jm.midi - Holds all the files used to read and write SMF's.
  • - Holds MIDI event classes such as NoteOn, NoteOff, SysEx etc.
  • - Contains the files which generate, read, render, and write audio.
  • jm.util - Contains classes that translate and modify jMusic data.

Feel free to peruse the .java files contained in these packages and see what they do. If you don't understand everything that's going on that's ok, just have a look anyway.*

Let's turn our attention to the package as this is the only one that you really need to know. It contains four Java source code file:

  • - The file contains one class called Note (remember that Java expects that the class name to be the same as the file name).
  • - The file contains one class called Phrase (Phrases in jMusic are monophonic).
  • - The file contains one class called CPhrase (C stands for chord).
  • - The file contains one class called Part.
  • - The file contains one class called Score.

These classes form the backbone of the jMusic data structure which allows you, the composer, to create, analyse, manipulate or maybe mutilate music. The next section looks at these classes in more detail.

jMusic Tutorial Index