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.
Classpath
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 jm.music.data 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\classes.zip;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 jm.zip 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..
- jm.music.data - Holds files used to
hold the jMusic data representation which is what you will be mainly
concerned with.
- jm.music.tools - Holds classes which
manipulate or generate or edit jm data.
- jm.midi - Holds all the files used to
read and write SMF's.
- jm.midi.events - Holds MIDI event classes
such as NoteOn, NoteOff, SysEx etc.
- jm.audio - 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.
jm.music.data.*
Let's turn our attention to the jm.music.data
package as this is the only one that you really need to know. It contains
four Java source code file:
- Note.java - The Note.java file contains
one class called Note (remember that Java expects that the class
name to be the same as the file name).
- Phrase.java - The Phrase.java file contains
one class called Phrase (Phrases in jMusic are monophonic).
- CPhrase.java - The CPhrase.java file
contains one class called CPhrase (C stands for chord).
- Part.java - The Part.java file contains
one class called Part.
- Score.java - The Score.java 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.
|