javax.sound.midi
Class MidiFileFormat

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by javax.sound.midi.MidiFileFormat

public class MidiFileFormat
extends Object sample code for java.lang.Object definition code for java.lang.Object

A MidiFileFormat object encapsulates a MIDI file's type, as well as its length and timing information.

A MidiFileFormat object can include a set of properties. A property is a pair of key and value: the key is of type String, the associated property value is an arbitrary object. Properties specify additional informational meta data (like a author, or copyright). Properties are optional information, and file reader and file writer implementations are not required to provide or recognize properties.

The following table lists some common properties that should be used in implementations:

Property key Value type Description
"author" String sample code for java.lang.String definition code for java.lang.String name of the author of this file
"title" String sample code for java.lang.String definition code for java.lang.String title of this file
"copyright" String sample code for java.lang.String definition code for java.lang.String copyright message
"date" Date sample code for java.util.Date definition code for java.util.Date date of the recording or release
"comment" String sample code for java.lang.String definition code for java.lang.String an arbitrary text

See Also:
MidiSystem.getMidiFileFormat(java.io.File) sample code for javax.sound.midi.MidiSystem.getMidiFileFormat(java.io.File) definition code for javax.sound.midi.MidiSystem.getMidiFileFormat(java.io.File) , Sequencer.setSequence(java.io.InputStream stream) sample code for javax.sound.midi.Sequencer.setSequence(java.io.InputStream) definition code for javax.sound.midi.Sequencer.setSequence(java.io.InputStream)

Field Summary
protected  int byteLength sample code for javax.sound.midi.MidiFileFormat.byteLength definition code for javax.sound.midi.MidiFileFormat.byteLength
          The length of the MIDI file in bytes.
protected  float divisionType sample code for javax.sound.midi.MidiFileFormat.divisionType definition code for javax.sound.midi.MidiFileFormat.divisionType
          The division type of the MIDI file.
protected  long microsecondLength sample code for javax.sound.midi.MidiFileFormat.microsecondLength definition code for javax.sound.midi.MidiFileFormat.microsecondLength
          The duration of the MIDI file in microseconds.
protected  int resolution sample code for javax.sound.midi.MidiFileFormat.resolution definition code for javax.sound.midi.MidiFileFormat.resolution
          The timing resolution of the MIDI file.
protected  int type sample code for javax.sound.midi.MidiFileFormat.type definition code for javax.sound.midi.MidiFileFormat.type
          The type of MIDI file.
static int UNKNOWN_LENGTH sample code for javax.sound.midi.MidiFileFormat.UNKNOWN_LENGTH definition code for javax.sound.midi.MidiFileFormat.UNKNOWN_LENGTH
          Represents unknown length.
 
Constructor Summary
MidiFileFormat sample code for javax.sound.midi.MidiFileFormat.MidiFileFormat(int, float, int, int, long) definition code for javax.sound.midi.MidiFileFormat.MidiFileFormat(int, float, int, int, long) (int type, float divisionType, int resolution, int bytes, long microseconds)
          Constructs a MidiFileFormat.
MidiFileFormat sample code for javax.sound.midi.MidiFileFormat.MidiFileFormat(int, float, int, int, long, java.util.Map) definition code for javax.sound.midi.MidiFileFormat.MidiFileFormat(int, float, int, int, long, java.util.Map) (int type, float divisionType, int resolution, int bytes, long microseconds, Map sample code for java.util.Map definition code for java.util.Map <String sample code for java.lang.String definition code for java.lang.String ,Object sample code for java.lang.Object definition code for java.lang.Object > properties)
          Construct a MidiFileFormat with a set of properties.
 
Method Summary
 int getByteLength sample code for javax.sound.midi.MidiFileFormat.getByteLength() definition code for javax.sound.midi.MidiFileFormat.getByteLength() ()
          Obtains the length of the MIDI file, expressed in 8-bit bytes.
 float getDivisionType sample code for javax.sound.midi.MidiFileFormat.getDivisionType() definition code for javax.sound.midi.MidiFileFormat.getDivisionType() ()
          Obtains the timing division type for the MIDI file.
 long getMicrosecondLength sample code for javax.sound.midi.MidiFileFormat.getMicrosecondLength() definition code for javax.sound.midi.MidiFileFormat.getMicrosecondLength() ()
          Obtains the length of the MIDI file, expressed in microseconds.
 Object sample code for java.lang.Object definition code for java.lang.Object getProperty sample code for javax.sound.midi.MidiFileFormat.getProperty(java.lang.String) definition code for javax.sound.midi.MidiFileFormat.getProperty(java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  key)
          Obtain the property value specified by the key.
 int getResolution sample code for javax.sound.midi.MidiFileFormat.getResolution() definition code for javax.sound.midi.MidiFileFormat.getResolution() ()
          Obtains the timing resolution for the MIDI file.
 int getType sample code for javax.sound.midi.MidiFileFormat.getType() definition code for javax.sound.midi.MidiFileFormat.getType() ()
          Obtains the MIDI file type.
 Map sample code for java.util.Map definition code for java.util.Map <String sample code for java.lang.String definition code for java.lang.String ,Object sample code for java.lang.Object definition code for java.lang.Object > properties sample code for javax.sound.midi.MidiFileFormat.properties() definition code for javax.sound.midi.MidiFileFormat.properties() ()
          Obtain an unmodifiable map of properties.
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Field Detail

UNKNOWN_LENGTH sample code for javax.sound.midi.MidiFileFormat.UNKNOWN_LENGTH

public static final int UNKNOWN_LENGTH
Represents unknown length.

See Also:
getByteLength() sample code for javax.sound.midi.MidiFileFormat.getByteLength() definition code for javax.sound.midi.MidiFileFormat.getByteLength() , getMicrosecondLength() sample code for javax.sound.midi.MidiFileFormat.getMicrosecondLength() definition code for javax.sound.midi.MidiFileFormat.getMicrosecondLength() , Constant Field Values

type sample code for javax.sound.midi.MidiFileFormat.type

protected int type
The type of MIDI file.


divisionType sample code for javax.sound.midi.MidiFileFormat.divisionType

protected float divisionType
The division type of the MIDI file.

See Also:
Sequence.PPQ sample code for javax.sound.midi.Sequence.PPQ definition code for javax.sound.midi.Sequence.PPQ , Sequence.SMPTE_24 sample code for javax.sound.midi.Sequence.SMPTE_24 definition code for javax.sound.midi.Sequence.SMPTE_24 , Sequence.SMPTE_25 sample code for javax.sound.midi.Sequence.SMPTE_25 definition code for javax.sound.midi.Sequence.SMPTE_25 , Sequence.SMPTE_30DROP sample code for javax.sound.midi.Sequence.SMPTE_30DROP definition code for javax.sound.midi.Sequence.SMPTE_30DROP , Sequence.SMPTE_30 sample code for javax.sound.midi.Sequence.SMPTE_30 definition code for javax.sound.midi.Sequence.SMPTE_30

resolution sample code for javax.sound.midi.MidiFileFormat.resolution

protected int resolution
The timing resolution of the MIDI file.


byteLength sample code for javax.sound.midi.MidiFileFormat.byteLength

protected int byteLength
The length of the MIDI file in bytes.


microsecondLength sample code for javax.sound.midi.MidiFileFormat.microsecondLength

protected long microsecondLength
The duration of the MIDI file in microseconds.

Constructor Detail

MidiFileFormat sample code for javax.sound.midi.MidiFileFormat(int, float, int, int, long) definition code for javax.sound.midi.MidiFileFormat(int, float, int, int, long)

public MidiFileFormat(int type,
                      float divisionType,
                      int resolution,
                      int bytes,
                      long microseconds)
Constructs a MidiFileFormat.

Parameters:
type - the MIDI file type (0, 1, or 2)
divisionType - the timing division type (PPQ or one of the SMPTE types)
resolution - the timing resolution
bytes - the length of the MIDI file in bytes, or UNKNOWN_LENGTH if not known
microseconds - the duration of the file in microseconds, or UNKNOWN_LENGTH if not known
See Also:
UNKNOWN_LENGTH sample code for javax.sound.midi.MidiFileFormat.UNKNOWN_LENGTH definition code for javax.sound.midi.MidiFileFormat.UNKNOWN_LENGTH , Sequence.PPQ sample code for javax.sound.midi.Sequence.PPQ definition code for javax.sound.midi.Sequence.PPQ , Sequence.SMPTE_24 sample code for javax.sound.midi.Sequence.SMPTE_24 definition code for javax.sound.midi.Sequence.SMPTE_24 , Sequence.SMPTE_25 sample code for javax.sound.midi.Sequence.SMPTE_25 definition code for javax.sound.midi.Sequence.SMPTE_25 , Sequence.SMPTE_30DROP sample code for javax.sound.midi.Sequence.SMPTE_30DROP definition code for javax.sound.midi.Sequence.SMPTE_30DROP , Sequence.SMPTE_30 sample code for javax.sound.midi.Sequence.SMPTE_30 definition code for javax.sound.midi.Sequence.SMPTE_30

MidiFileFormat sample code for javax.sound.midi.MidiFileFormat(int, float, int, int, long, java.util.Map<java.lang.String, java.lang.Object>) definition code for javax.sound.midi.MidiFileFormat(int, float, int, int, long, java.util.Map<java.lang.String, java.lang.Object>)

public MidiFileFormat(int type,
                      float divisionType,
                      int resolution,
                      int bytes,
                      long microseconds,
                      Map sample code for java.util.Map definition code for java.util.Map <String sample code for java.lang.String definition code for java.lang.String ,Object sample code for java.lang.Object definition code for java.lang.Object > properties)
Construct a MidiFileFormat with a set of properties.

Parameters:
type - the MIDI file type (0, 1, or 2)
divisionType - the timing division type (PPQ or one of the SMPTE types)
resolution - the timing resolution
bytes - the length of the MIDI file in bytes, or UNKNOWN_LENGTH if not known
microseconds - the duration of the file in microseconds, or UNKNOWN_LENGTH if not known
properties - a Map<String,Object> object with properties
Since:
1.5
See Also:
UNKNOWN_LENGTH sample code for javax.sound.midi.MidiFileFormat.UNKNOWN_LENGTH definition code for javax.sound.midi.MidiFileFormat.UNKNOWN_LENGTH , Sequence.PPQ sample code for javax.sound.midi.Sequence.PPQ definition code for javax.sound.midi.Sequence.PPQ , Sequence.SMPTE_24 sample code for javax.sound.midi.Sequence.SMPTE_24 definition code for javax.sound.midi.Sequence.SMPTE_24 , Sequence.SMPTE_25 sample code for javax.sound.midi.Sequence.SMPTE_25 definition code for javax.sound.midi.Sequence.SMPTE_25 , Sequence.SMPTE_30DROP sample code for javax.sound.midi.Sequence.SMPTE_30DROP definition code for javax.sound.midi.Sequence.SMPTE_30DROP , Sequence.SMPTE_30 sample code for javax.sound.midi.Sequence.SMPTE_30 definition code for javax.sound.midi.Sequence.SMPTE_30
Method Detail

getType sample code for javax.sound.midi.MidiFileFormat.getType() definition code for javax.sound.midi.MidiFileFormat.getType()

public int getType()
Obtains the MIDI file type.

Returns:
the file's type (0, 1, or 2)

getDivisionType sample code for javax.sound.midi.MidiFileFormat.getDivisionType() definition code for javax.sound.midi.MidiFileFormat.getDivisionType()

public float getDivisionType()
Obtains the timing division type for the MIDI file.

Returns:
the division type (PPQ or one of the SMPTE types)
See Also:
Sequence.Sequence(float, int) sample code for javax.sound.midi.Sequence.Sequence(float, int) definition code for javax.sound.midi.Sequence.Sequence(float, int) , Sequence.PPQ sample code for javax.sound.midi.Sequence.PPQ definition code for javax.sound.midi.Sequence.PPQ , Sequence.SMPTE_24 sample code for javax.sound.midi.Sequence.SMPTE_24 definition code for javax.sound.midi.Sequence.SMPTE_24 , Sequence.SMPTE_25 sample code for javax.sound.midi.Sequence.SMPTE_25 definition code for javax.sound.midi.Sequence.SMPTE_25 , Sequence.SMPTE_30DROP sample code for javax.sound.midi.Sequence.SMPTE_30DROP definition code for javax.sound.midi.Sequence.SMPTE_30DROP , Sequence.SMPTE_30 sample code for javax.sound.midi.Sequence.SMPTE_30 definition code for javax.sound.midi.Sequence.SMPTE_30 , Sequence.getDivisionType() sample code for javax.sound.midi.Sequence.getDivisionType() definition code for javax.sound.midi.Sequence.getDivisionType()

getResolution sample code for javax.sound.midi.MidiFileFormat.getResolution() definition code for javax.sound.midi.MidiFileFormat.getResolution()

public int getResolution()
Obtains the timing resolution for the MIDI file. If the division type is PPQ, the resolution is specified in ticks per beat. For SMTPE timing, the resolution is specified in ticks per frame.

Returns:
the number of ticks per beat (PPQ) or per frame (SMPTE)
See Also:
getDivisionType() sample code for javax.sound.midi.MidiFileFormat.getDivisionType() definition code for javax.sound.midi.MidiFileFormat.getDivisionType() , Sequence.getResolution() sample code for javax.sound.midi.Sequence.getResolution() definition code for javax.sound.midi.Sequence.getResolution()

getByteLength sample code for javax.sound.midi.MidiFileFormat.getByteLength() definition code for javax.sound.midi.MidiFileFormat.getByteLength()

public int getByteLength()
Obtains the length of the MIDI file, expressed in 8-bit bytes.

Returns:
the number of bytes in the file, or UNKNOWN_LENGTH if not known
See Also:
UNKNOWN_LENGTH sample code for javax.sound.midi.MidiFileFormat.UNKNOWN_LENGTH definition code for javax.sound.midi.MidiFileFormat.UNKNOWN_LENGTH

getMicrosecondLength sample code for javax.sound.midi.MidiFileFormat.getMicrosecondLength() definition code for javax.sound.midi.MidiFileFormat.getMicrosecondLength()

public long getMicrosecondLength()
Obtains the length of the MIDI file, expressed in microseconds.

Returns:
the file's duration in microseconds, or UNKNOWN_LENGTH if not known
See Also:
Sequence.getMicrosecondLength() sample code for javax.sound.midi.Sequence.getMicrosecondLength() definition code for javax.sound.midi.Sequence.getMicrosecondLength() , getByteLength() sample code for javax.sound.midi.MidiFileFormat.getByteLength() definition code for javax.sound.midi.MidiFileFormat.getByteLength() , UNKNOWN_LENGTH sample code for javax.sound.midi.MidiFileFormat.UNKNOWN_LENGTH definition code for javax.sound.midi.MidiFileFormat.UNKNOWN_LENGTH

properties sample code for javax.sound.midi.MidiFileFormat.properties() definition code for javax.sound.midi.MidiFileFormat.properties()

public Map sample code for java.util.Map definition code for java.util.Map <String sample code for java.lang.String definition code for java.lang.String ,Object sample code for java.lang.Object definition code for java.lang.Object > properties()
Obtain an unmodifiable map of properties. The concept of properties is further explained in the class description sample code for javax.sound.midi.MidiFileFormat definition code for javax.sound.midi.MidiFileFormat .

Returns:
a Map<String,Object> object containing all properties. If no properties are recognized, an empty map is returned.
Since:
1.5
See Also:
getProperty(String) sample code for javax.sound.midi.MidiFileFormat.getProperty(java.lang.String) definition code for javax.sound.midi.MidiFileFormat.getProperty(java.lang.String)

getProperty sample code for javax.sound.midi.MidiFileFormat.getProperty(java.lang.String) definition code for javax.sound.midi.MidiFileFormat.getProperty(java.lang.String)

public Object sample code for java.lang.Object definition code for java.lang.Object  getProperty(String sample code for java.lang.String definition code for java.lang.String  key)
Obtain the property value specified by the key. The concept of properties is further explained in the class description sample code for javax.sound.midi.MidiFileFormat definition code for javax.sound.midi.MidiFileFormat .

If the specified property is not defined for a particular file format, this method returns null.

Parameters:
key - the key of the desired property
Returns:
the value of the property with the specified key, or null if the property does not exist.
Since:
1.5
See Also:
properties sample code for javax.sound.midi.MidiFileFormat.properties definition code for javax.sound.midi.MidiFileFormat.properties