net.charlesames.music.midi
Class Midi

java.lang.Object
  extended by net.charlesames.music.midi.Midi

public abstract class Midi
extends java.lang.Object

MIDI adapted from http://www.jsresources.org/examples/DumpReceiver.java.html

Author:
Matthias Pfisterer, Florian Bomers

Field Summary
static int BANK_LIMIT
           
static int CHANNEL_LIMIT
           
static int META_EVENT_CHANNEL_PREFIX
           
static int META_EVENT_COPYRIGHT
           
static int META_EVENT_CUE_POINT
           
static int META_EVENT_DEVICE_NAME
           
static int META_EVENT_END_OF_TRACK
           
static int META_EVENT_INSTRUMENT_NAME
           
static int META_EVENT_KEY_SIGNATURE
           
static int META_EVENT_LYRIC
           
static int META_EVENT_MARKER
           
static int META_EVENT_PORT
           
static int META_EVENT_PROGRAM_NAME
           
static int META_EVENT_SEQUENCE_NUMBER
           
static int META_EVENT_SEQUENCER_SPECIFIC
           
static int META_EVENT_SMPTE_OFFSET
           
static int META_EVENT_TEMPO
           
static int META_EVENT_TEXT
           
static int META_EVENT_TIME_SIGNATURE
           
static int META_EVENT_TRACK_NAME
           
static double MICROSECONDS_PER_MINUTE
           
static double MICROSECONDS_PER_SECOND
           
static int PAN_LIMIT
           
static int PAN_POSITION_CENTER
           
static int PITCH_BEND_CENTER
           
static int PORT_LIMIT
           
static int PROGRAM_LIMIT
           
static long seByteCount
          System exclusive message byte count tracked by the decodeMessage(SysexMessage) method.
static long seCount
          System exclusive message count tracked by the decodeMessage(SysexMessage) method.
static long smByteCount
          Short message byte count tracked by the decodeMessage(ShortMessage) method.
static long smCount
          Short message count tracked by the decodeMessage(ShortMessage) method.
static int VELOCITY_LIMIT
           
 
Constructor Summary
Midi()
           
 
Method Summary
static java.lang.String decodeMessage(javax.sound.midi.MetaMessage message)
          Decode a MIDI Meta message.
static java.lang.String decodeMessage(javax.sound.midi.ShortMessage message, boolean generalMidi)
          Decode a MIDI ShortMessage instance.
static java.lang.String decodeMessage(javax.sound.midi.SysexMessage message)
          Decode a MIDI System Exclusive message.
static int get14bitValue(int nLowerPart, int nHigherPart)
          Pack two 7-bit bytes into a 14-bit integer.
static java.lang.String getHexString(byte[] aByte)
          Convert a byte array into a hexadecimal string.
static java.lang.String getHexString(javax.sound.midi.ShortMessage sm)
          Convert a short MIDI message to a hexadecimal string.
static java.lang.String getKeyName(int nKeyNumber, boolean percussion)
          Express a MIDI key number as a letter name, accidental, and octave number.
static int microsecondsPerBeat(double beatsPerSecond)
          Convert beats per second to microseconds per beat.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PITCH_BEND_CENTER

public static final int PITCH_BEND_CENTER
See Also:
Constant Field Values

PAN_POSITION_CENTER

public static final int PAN_POSITION_CENTER
See Also:
Constant Field Values

CHANNEL_LIMIT

public static final int CHANNEL_LIMIT
See Also:
Constant Field Values

PORT_LIMIT

public static final int PORT_LIMIT
See Also:
Constant Field Values

PROGRAM_LIMIT

public static final int PROGRAM_LIMIT
See Also:
Constant Field Values

VELOCITY_LIMIT

public static final int VELOCITY_LIMIT
See Also:
Constant Field Values

PAN_LIMIT

public static final int PAN_LIMIT
See Also:
Constant Field Values

BANK_LIMIT

public static final int BANK_LIMIT
See Also:
Constant Field Values

META_EVENT_SEQUENCE_NUMBER

public static final int META_EVENT_SEQUENCE_NUMBER
See Also:
Constant Field Values

META_EVENT_TEXT

public static final int META_EVENT_TEXT
See Also:
Constant Field Values

META_EVENT_COPYRIGHT

public static final int META_EVENT_COPYRIGHT
See Also:
Constant Field Values

META_EVENT_TRACK_NAME

public static final int META_EVENT_TRACK_NAME
See Also:
Constant Field Values

META_EVENT_INSTRUMENT_NAME

public static final int META_EVENT_INSTRUMENT_NAME
See Also:
Constant Field Values

META_EVENT_LYRIC

public static final int META_EVENT_LYRIC
See Also:
Constant Field Values

META_EVENT_MARKER

public static final int META_EVENT_MARKER
See Also:
Constant Field Values

META_EVENT_CUE_POINT

public static final int META_EVENT_CUE_POINT
See Also:
Constant Field Values

META_EVENT_PROGRAM_NAME

public static final int META_EVENT_PROGRAM_NAME
See Also:
Constant Field Values

META_EVENT_DEVICE_NAME

public static final int META_EVENT_DEVICE_NAME
See Also:
Constant Field Values

META_EVENT_CHANNEL_PREFIX

public static final int META_EVENT_CHANNEL_PREFIX
See Also:
Constant Field Values

META_EVENT_PORT

public static final int META_EVENT_PORT
See Also:
Constant Field Values

META_EVENT_END_OF_TRACK

public static final int META_EVENT_END_OF_TRACK
See Also:
Constant Field Values

META_EVENT_TEMPO

public static final int META_EVENT_TEMPO
See Also:
Constant Field Values

META_EVENT_SMPTE_OFFSET

public static final int META_EVENT_SMPTE_OFFSET
See Also:
Constant Field Values

META_EVENT_TIME_SIGNATURE

public static final int META_EVENT_TIME_SIGNATURE
See Also:
Constant Field Values

META_EVENT_KEY_SIGNATURE

public static final int META_EVENT_KEY_SIGNATURE
See Also:
Constant Field Values

META_EVENT_SEQUENCER_SPECIFIC

public static final int META_EVENT_SEQUENCER_SPECIFIC
See Also:
Constant Field Values

MICROSECONDS_PER_MINUTE

public static final double MICROSECONDS_PER_MINUTE
See Also:
Constant Field Values

MICROSECONDS_PER_SECOND

public static final double MICROSECONDS_PER_SECOND
See Also:
Constant Field Values

seByteCount

public static long seByteCount
System exclusive message byte count tracked by the decodeMessage(SysexMessage) method.


smByteCount

public static long smByteCount
Short message byte count tracked by the decodeMessage(ShortMessage) method.


seCount

public static long seCount
System exclusive message count tracked by the decodeMessage(SysexMessage) method.


smCount

public static long smCount
Short message count tracked by the decodeMessage(ShortMessage) method.

Constructor Detail

Midi

public Midi()
Method Detail

microsecondsPerBeat

public static int microsecondsPerBeat(double beatsPerSecond)
Convert beats per second to microseconds per beat.

Parameters:
beatsPerSecond -
Returns:
Microseconds per beat.

decodeMessage

public static java.lang.String decodeMessage(javax.sound.midi.ShortMessage message,
                                             boolean generalMidi)
Decode a MIDI ShortMessage instance.

Parameters:
message - A status byte with at most two data bytes.
generalMidi - A flag indicating whether the file adheres to General MIDI standard.
Returns:
Text explaining the message.

decodeMessage

public static java.lang.String decodeMessage(javax.sound.midi.SysexMessage message)
Decode a MIDI System Exclusive message.

Parameters:
message - A MIDI system exclusive message.
Returns:
Text explaining the message.

decodeMessage

public static java.lang.String decodeMessage(javax.sound.midi.MetaMessage message)
Decode a MIDI Meta message.

Parameters:
message - A MIDI meta message.
Returns:
Text explaining the message.

getKeyName

public static java.lang.String getKeyName(int nKeyNumber,
                                          boolean percussion)
Express a MIDI key number as a letter name, accidental, and octave number.

Parameters:
nKeyNumber -
percussion - A flag indicating if the key event happens in a General MIDI file on channel 10.
Returns:
The name of the note.

get14bitValue

public static int get14bitValue(int nLowerPart,
                                int nHigherPart)
Pack two 7-bit bytes into a 14-bit integer.

Parameters:
nLowerPart - The fine byte.
nHigherPart - The coarse byte.
Returns:
The 14-bit result.

getHexString

public static java.lang.String getHexString(byte[] aByte)
Convert a byte array into a hexadecimal string.

Parameters:
aByte - A byte array.
Returns:
A hexadecimal string

getHexString

public static java.lang.String getHexString(javax.sound.midi.ShortMessage sm)
Convert a short MIDI message to a hexadecimal string.

Parameters:
sm - A short MIDI message.
Returns:
A hexadecimal string.