de.humatic.mmj
Class MidiSystem

java.lang.Object
  extended by de.humatic.mmj.MidiSystem

public class MidiSystem
extends java.lang.Object

MidiSystem provides static methods to open Midi ports and to get information on a machine's MIDI system. When using mmj via javasound an application does not use this class and the objects it creates, but accesses the CoreMIDI wrapper through standard javax.sound.midi methods.


Method Summary
static void addSystemListener(MidiSystemListener msl)
          Attaches a MidiSystemListener to be notified when changes in the Midi System - like device removal or attachment - occur.
static void closeMidiSystem()
           
static void dump(byte[] data)
           
static void enableActiveSensing(boolean enable)
           
static CoreMidiDevice[] getDevices()
          Returns an array of CoreMidiDevice objects for hard- and software devices available on the system.
Virtual endpoints do not have enclosing devices and devices may be not currently connected (USB boxes) or not set online in OS X's Audio / Midi Setup.
static long getHostTime()
          Returns the current AudioSystem time in microseconds.
static java.lang.String[] getInputs()
          Returns the names of available Midi Inputs.
static java.lang.String getJarVersion()
           
static java.lang.String getLibraryVersion()
           
static int getNumberOfInputs()
           
static int getNumberOfOutputs()
           
static java.lang.String[] getOutputs()
          Returns the names of available Midi Outputs.
static void initMidiSystem(java.lang.String virtualSource, java.lang.String virtualDestination)
          Initializes CoreMIDI and eventually creates virtual endpoints (set any unwanted to null).
static MidiInput openMidiInput(int index)
          Opens the CoreMIDI source at %index and returns a MidiInput object that an application can attach itself to as a MidiListener.
static MidiOutput openMidiOutput(int index)
          Opens the CoreMIDI destination at %index and returns a MidiOutput object that an application can use to send MIDI.
static void setLibraryPath(java.lang.String path)
          Allows to set the path the native library is loaded from.
static void setMidiThru(int srcIndex, int destBitMask)
          Instructs the CoreMIDI Server to route MIDI from the source at %srcIndex to all destinations that the corresponding bits in %destBitMask are set for.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setLibraryPath

public static void setLibraryPath(java.lang.String path)
                           throws java.io.IOException
Allows to set the path the native library is loaded from. This must be the very first call to mmj if a non standard path is needed. By default Mac OSX looks for libraries in /Library/Java/Extensions and the /Contents/Java/Resources subdirectory of the application bundle without need to take care of it.

Throws:
java.io.IOException

initMidiSystem

public static void initMidiSystem(java.lang.String virtualSource,
                                  java.lang.String virtualDestination)
Initializes CoreMIDI and eventually creates virtual endpoints (set any unwanted to null). Virtual sources are fed by the application and appear as Midi inputs in other applications (but are outputs to the app that created them). Virtual destinations appear as Midi outputs in other apps and let them send Midi to the mmj application (where they effectively are inputs). If no virtual ports are to be created this methods needs not be called as all methods that open ports will eventually initialize the system.


getDevices

public static CoreMidiDevice[] getDevices()
Returns an array of CoreMidiDevice objects for hard- and software devices available on the system.
Virtual endpoints do not have enclosing devices and devices may be not currently connected (USB boxes) or not set online in OS X's Audio / Midi Setup. An application should therefore use getInputs() and getOutputs() to learn about the ins and Outs that will be available.


closeMidiSystem

public static void closeMidiSystem()

getNumberOfInputs

public static int getNumberOfInputs()

getInputs

public static java.lang.String[] getInputs()
Returns the names of available Midi Inputs. This will include all inputs that are "online", i.e. ports that belong to hardware devices that are attached or software devices that are activated in "Audio/Midi Setup" plus virtual endpoints provided by other programs.


getNumberOfOutputs

public static int getNumberOfOutputs()

getOutputs

public static java.lang.String[] getOutputs()
Returns the names of available Midi Outputs. This will include all outputs that are "online", i.e. ports that belong to hardware devices that are attached or software devices that are activated in "Audio/Midi Setup" plus virtual endpoints provided by other programs.


dump

public static void dump(byte[] data)

openMidiInput

public static MidiInput openMidiInput(int index)
Opens the CoreMIDI source at %index and returns a MidiInput object that an application can attach itself to as a MidiListener. If the source at %index is allready opened when this call is made, a reference to the existing object is returned.


openMidiOutput

public static MidiOutput openMidiOutput(int index)
Opens the CoreMIDI destination at %index and returns a MidiOutput object that an application can use to send MIDI. If the destination at %index is allready opened when this call is made, a reference to the existing object is returned.


setMidiThru

public static void setMidiThru(int srcIndex,
                               int destBitMask)
Instructs the CoreMIDI Server to route MIDI from the source at %srcIndex to all destinations that the corresponding bits in %destBitMask are set for. Data is not passing mmj or application code, guaranteeing for lowest possible latency.


getLibraryVersion

public static java.lang.String getLibraryVersion()

getJarVersion

public static java.lang.String getJarVersion()

getHostTime

public static long getHostTime()
Returns the current AudioSystem time in microseconds.


enableActiveSensing

public static void enableActiveSensing(boolean enable)
                                throws java.lang.Exception
Throws:
java.lang.Exception

addSystemListener

public static void addSystemListener(MidiSystemListener msl)
Attaches a MidiSystemListener to be notified when changes in the Midi System - like device removal or attachment - occur.