Using JMusic from JES

We use a really neat package for music called JMusic (http://jmusic.ci.qut.edu.au/) in our Media Computation Data Structures class (http://coweb.cc.gatech.edu/cs1316). I'm teaching a workshop in Chicago this week where the question came up (again), "Can we do this from JES?" At this moment, they are all working on MIDI music in Java, so I decided to try to make it work. (You can see their cool media at http://home.cc.gatech.edu/gacomputes). It works!

Here's how I did it (on Windows):

(1) Copy jmusic.jar and the JMusic inst folder into your JES directory.

(2) Edit JES.bat so that jmusic.jar and the JMusic inst folder are on the Java classpath, like this:

set java="win-jre\bin\java.exe"
set classpath=".\jars\jython.jar;.\jars\jmf.jar;.\jars\jl1.0.jar;.\jars\junit.jar;.\Sources;.\jmusic.jar;.\inst"

%java% -Dpython.home="jython-2.1" -Xmx512m -classpath %classpath% JESstartup

(3) Start up JES.

(4) Here's an example that works:

>>> import jm.JMC #Set up jMusic Constants
>>> jm.JMC.C4 # C in the 4th octave
60
>>> from jm.music.data import *
>>> n1 = Note(60,0.5)
>>> n2 = Note(62,1.0)
>>> p = Phrase()
>>> p.addNote(n1)
>>> p.addNote(n2)
>>> from jm.util import *
>>> View.notate(p)
>>> n3 = Note(jm.JMC.C4,jm.JMC.QN) # C in the 4th octave, quarter note
>>> p.addNote(n3)
>>> View.notate(p)

You'll see Western music notation, have the ability to play the notes, and the ability to save out MIDI files. Cool!

Mark