uk.org.toot.midi.message
Class MetaMsg

java.lang.Object
  extended by uk.org.toot.midi.message.MidiMsg
      extended by uk.org.toot.midi.message.MetaMsg

public class MetaMsg
extends MidiMsg

The class for creating accessing and mutating arbitrary length MidiMessages representing Meta messages without knowledge of the implementation class. Accessors and mutators are provided for Tempo and String attributes. Note that getString() provides a String representation of the data even for those messages where the data bytes cannot be directly converted to a String.

Author:
Steve Taylor

Field Summary
static int CHANNEL_PREFIX
           
static int COPYRIGHT
           
static int CUE_POINT
           
static int DEVICE_NAME
           
static int END_OF_TRACK
           
static int INSTRUMENT_NAME
           
static int LYRIC
           
static int MAJOR_MINOR_KEY
           
static int MARKER
           
static int META
          Status byte for MetaMessage (0xFF, or 255), which is used in MIDI files.
static int PORT_PREFIX
           
static int SEQUENCE_NUMBER
           
static int SEQUENCER_SPECIFIC
           
static int SMPTE_OFFSET
           
static int TEMPO
           
static int TEXT
           
static int TIME_SIGNATURE
           
static int TRACK_NAME
           
 
Constructor Summary
MetaMsg()
           
 
Method Summary
static float convertTempo(float value)
           
static javax.sound.midi.MidiMessage createMeta(int type, byte[] data, int length)
          Create an arbitrary length Meta message of the specified type with the specified data bytes.
static javax.sound.midi.MidiMessage createMeta(int type, java.lang.String name)
          Create an arbitrary length Meta message with the specified type and the specified String.
static javax.sound.midi.MidiMessage createTempo(float bpm)
          Create a Tempo Meta message with the specified tempo in beats per minute.
static byte[] getData(javax.sound.midi.MidiMessage msg)
          Return the data byte array (excluding the type byte) for the specified Meta message.
static java.lang.String getString(javax.sound.midi.MidiMessage msg)
          Get the String representation of the specified MidiMessage.
static float getTempo(javax.sound.midi.MidiMessage msg)
          Get the Tempo value (in beats per minute) from the specified TEMPO MidiMessage,
static int getType(javax.sound.midi.MidiMessage msg)
          Return the type of the Meta message.
static boolean isMeta(int status)
           
static boolean isMeta(javax.sound.midi.MidiMessage msg)
          Determine whether the specified MidiMessage can be handled by this class.
static javax.sound.midi.MidiMessage setData(javax.sound.midi.MidiMessage msg, byte[] data, int length)
          Set the data bytes for the specified Meta message.
static javax.sound.midi.MidiMessage setString(javax.sound.midi.MidiMessage msg, java.lang.String str)
          Set the String representation of the specified MidiMessage.
static javax.sound.midi.MidiMessage setTempo(javax.sound.midi.MidiMessage msg, float bpm)
          Set the Tempo (in beats per minute) of the specified TEMPO MidiMessage.
static byte[] tempoBytes(float bpm)
          Return the data bytes representing the specified Tempo.
 
Methods inherited from class uk.org.toot.midi.message.MidiMsg
getLength, getMessage, getStatus
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

META

public static final int META
Status byte for MetaMessage (0xFF, or 255), which is used in MIDI files. It has the same value as SYSTEM_RESET, which is used in the real-time "MIDI wire" protocol.

See Also:
Constant Field Values

SEQUENCE_NUMBER

public static final int SEQUENCE_NUMBER
See Also:
Constant Field Values

TEXT

public static final int TEXT
See Also:
Constant Field Values

COPYRIGHT

public static final int COPYRIGHT
See Also:
Constant Field Values

TRACK_NAME

public static final int TRACK_NAME
See Also:
Constant Field Values

INSTRUMENT_NAME

public static final int INSTRUMENT_NAME
See Also:
Constant Field Values

LYRIC

public static final int LYRIC
See Also:
Constant Field Values

MARKER

public static final int MARKER
See Also:
Constant Field Values

CUE_POINT

public static final int CUE_POINT
See Also:
Constant Field Values

DEVICE_NAME

public static final int DEVICE_NAME
See Also:
Constant Field Values

CHANNEL_PREFIX

public static final int CHANNEL_PREFIX
See Also:
Constant Field Values

PORT_PREFIX

public static final int PORT_PREFIX
See Also:
Constant Field Values

END_OF_TRACK

public static final int END_OF_TRACK
See Also:
Constant Field Values

TEMPO

public static final int TEMPO
See Also:
Constant Field Values

SMPTE_OFFSET

public static final int SMPTE_OFFSET
See Also:
Constant Field Values

TIME_SIGNATURE

public static final int TIME_SIGNATURE
See Also:
Constant Field Values

MAJOR_MINOR_KEY

public static final int MAJOR_MINOR_KEY
See Also:
Constant Field Values

SEQUENCER_SPECIFIC

public static final int SEQUENCER_SPECIFIC
See Also:
Constant Field Values
Constructor Detail

MetaMsg

public MetaMsg()
Method Detail

isMeta

public static boolean isMeta(javax.sound.midi.MidiMessage msg)
Determine whether the specified MidiMessage can be handled by this class.


isMeta

public static boolean isMeta(int status)

createMeta

public static javax.sound.midi.MidiMessage createMeta(int type,
                                                      byte[] data,
                                                      int length)
                                               throws javax.sound.midi.InvalidMidiDataException
Create an arbitrary length Meta message of the specified type with the specified data bytes.

Throws:
javax.sound.midi.InvalidMidiDataException

createMeta

public static javax.sound.midi.MidiMessage createMeta(int type,
                                                      java.lang.String name)
                                               throws javax.sound.midi.InvalidMidiDataException
Create an arbitrary length Meta message with the specified type and the specified String.

Throws:
javax.sound.midi.InvalidMidiDataException

createTempo

public static javax.sound.midi.MidiMessage createTempo(float bpm)
                                                throws javax.sound.midi.InvalidMidiDataException
Create a Tempo Meta message with the specified tempo in beats per minute.

Throws:
javax.sound.midi.InvalidMidiDataException

getString

public static java.lang.String getString(javax.sound.midi.MidiMessage msg)
Get the String representation of the specified MidiMessage. If the data bytes of the specified MidiMessage do not directly represent a String a String is nonetheless returned which is a simple representation of the data bytes based of knowledge of the data format.


setString

public static javax.sound.midi.MidiMessage setString(javax.sound.midi.MidiMessage msg,
                                                     java.lang.String str)
                                              throws javax.sound.midi.InvalidMidiDataException
Set the String representation of the specified MidiMessage.

Throws:
javax.sound.midi.InvalidMidiDataException

convertTempo

public static float convertTempo(float value)

getTempo

public static float getTempo(javax.sound.midi.MidiMessage msg)
Get the Tempo value (in beats per minute) from the specified TEMPO MidiMessage,


setTempo

public static javax.sound.midi.MidiMessage setTempo(javax.sound.midi.MidiMessage msg,
                                                    float bpm)
                                             throws javax.sound.midi.InvalidMidiDataException
Set the Tempo (in beats per minute) of the specified TEMPO MidiMessage.

Throws:
javax.sound.midi.InvalidMidiDataException

tempoBytes

public static byte[] tempoBytes(float bpm)
Return the data bytes representing the specified Tempo.


getType

public static int getType(javax.sound.midi.MidiMessage msg)
Return the type of the Meta message.


getData

public static byte[] getData(javax.sound.midi.MidiMessage msg)
Return the data byte array (excluding the type byte) for the specified Meta message.


setData

public static javax.sound.midi.MidiMessage setData(javax.sound.midi.MidiMessage msg,
                                                   byte[] data,
                                                   int length)
                                            throws javax.sound.midi.InvalidMidiDataException
Set the data bytes for the specified Meta message. The type remains unchanged.

Throws:
javax.sound.midi.InvalidMidiDataException


Copyright © 2004, 2005, 2006, 2007 Steve Taylor. All Rights Reserved.