Notes:
To start the JaMISS server, open a terminal type: java -jar jaMISS.To get help type: java -jar JaMISS.jar --help which will print this:
========================================================================
Java MIDI Sound Server started ...                      (ctrl-c to quit)
========================================================================
>> Detected OS: MAC OS X
JaMISS Help:
-------------------------------------------------------
Usage:
 #java -jar jaMISS [arguments]
 
Command line arguments:
  -p [port]     Specifies the port to listen on (Default is 8006)
  -d            Enable diagnostic mode (No synth used, only prints data received)
  --info        Returns program info (what it does, packet format, etc...)
  --help        Returns program usage & parameters
 
JaMISS inputs are fairly robust.
 - If the port argument is omitted, the default port (8006) is used.
 - Parameters can be entered in any order
 - Boundary conditions (ports, etc) are checked for validity
 - Parameters are evaluated in logical order
       (Example: '--help' in any location will override any other parameters)
 
Note that the diagnostic mode (-d) does NOT PLAY ANY SOUND. For more info use java -jar JaMISS.jar --info which prints this:
...
Functions:
     1) Starts a Java MIDI synthesizer
     2) Accepts connections on a given port
     3) Allows remote control of sound creation & its parameters
 
In addition, there is a diagnostic mode.
    In this mode, the program accepts connections, and simply prints the data it receives.
 
Communications:
    JaMISS accepts socket connections on the specified port.  The data format is as follows:
        JaMISS,[command]
          or
        JaMISS,[channel],[note],[instrument],[velocity]
    'JaMISS' is a header, and must precede every message string.
    [command] can be either 'off' which turns off the note playing, or 'quit'
            which shuts down the server.
    [channel] is the range 0-15 (MIDI channels 1-16). 10 should be avoided (drum track only)
    [note] is the range 0-127, but note that values too low are inaudible and
            values too high are annoying.
    [instrument] is the range 0-127, and selects the General MIDI instrument.
        (examples: 0 is grand piano which decays, 81 is sqare wave which has infinite sustain.)
    [velocity] is the intensity of the instrument. It may or may not be the
        same as volume, depending on the sound.
 
To test the connection a running server, you can use the JaMISS client. To use a local server listening on port 8006, play a note on channel 0, with instrument 14, pitch 60 and volume 100, type: java -jar JaMISS_Client.jar localhost 8006 "JaMISS,0,60,14,120"
Note that the message is comma separated and must not have any whitespace. To kill the sound use: java -jar JaMISS_Client.jar localhost 8006 "JaMISS,off" and to force the server to close down use: java -jar JaMISS_Client.jar localhost 8006 "JaMISS,quit"
 
Here is a python program to play two intervals:
 
from socket import *
from time import sleep
 
# mini test client for JaMISS, assuming a local server listens on 8006
# the server requires a close and total rebuild of the socket
 
def playSound(channel, key, instrument, velocity):
    ADDR = ("localhost", 8006)
    sock = socket(AF_INET, SOCK_STREAM)
    sock.connect(ADDR)
    msg = "JaMISS," + str(channel) + "," + str(key) + "," + str(instrument-1) + "," + str(velocity)
    sock.send(msg)
    sock.close()
 
def stopSound():
    ADDR = ("localhost", 8006)
    sock = socket(AF_INET, SOCK_STREAM)
    sock.connect(ADDR)
    msg = "JaMISS,off"
    sock.send(msg)
    sock.close()
        
playSound(0, 60, 9, 127)
playSound(0, 62, 61, 70)
sleep(2.5) # floating point time in secs
stopSound()
 
playSound(0, 62, 9, 127)
playSound(0, 64, 61, 70)
sleep(2.5)
stopSound()
 
 
JaMISS - a simple Java MIDI server
Downloads:
 
Todo:
  1. Change the sound server so that it does not require a complete rebuild of the socket for each message
  2. Add UDP sockets
  3. Look for alternatives (pysonic/fmod?)

Alternatives (?)
There is a cross-platform sound/audio C++ API called fmod ExAPI for "gaming" sound programming that seems to be able to play MIDI (not sure if it can do that on the fly?) and there is pysonic for python bindings to fmod. However pysonic hasn't been updated in a while (2005?) so I don't know what of the current fmod API it supports and I have not played around with it.
 
I asked one of my students (David Stulken) to create a very simple way to play MIDI notes in real time (i.e., not as a MIDI file player would do) and the result is JaMISS. JaMISS is a sound server written in Java and uses JavaSound and the Java internal wave table (sound bank). It seems to work on Linux, Mac and Windows (although on Windows, the wavetable might not be installed which will lead to no sound being produced - rather than an error). This is a really simplistic way of creating a MIDI sound as response to a real-time interaction event - oddly enough I could not find such a thing for python, at least not cross-platform. Maybe that has to do with how the actual sound is generated on Mac vs. Win vs. Linux (?) but using a JavaSound based network server seems to provide a decent enough way around that.