Class MidiFileFormat
java.lang.Object
javax.sound.midi.MidiFileFormat
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 | name of the author of this file | 
| "title" | String | title of this file | 
| "copyright" | String | copyright message | 
| "date" | Date | date of the recording or release | 
| "comment" | String | an arbitrary text | 
- See Also:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected intThe length of the MIDI file in bytes.protected floatThe division type of the MIDI file.protected longThe duration of the MIDI file in microseconds.protected intThe timing resolution of the MIDI file.protected intThe type of MIDI file.static final intRepresents unknown length.
- 
Constructor SummaryConstructorsConstructorDescriptionMidiFileFormat(int type, float divisionType, int resolution, int bytes, long microseconds) Constructs aMidiFileFormat.MidiFileFormat(int type, float divisionType, int resolution, int bytes, long microseconds, Map<String, Object> properties) Construct aMidiFileFormatwith a set of properties.
- 
Method SummaryModifier and TypeMethodDescriptionintObtains the length of the MIDI file, expressed in 8-bit bytes.floatObtains the timing division type for the MIDI file.longObtains the length of the MIDI file, expressed in microseconds.getProperty(String key) Obtain the property value specified by the key.intObtains the timing resolution for the MIDI file.intgetType()Obtains the MIDI file type.Obtain an unmodifiable map of properties.
- 
Field Details- 
UNKNOWN_LENGTHpublic static final int UNKNOWN_LENGTHRepresents unknown length.- See Also:
 
- 
typeprotected int typeThe type of MIDI file.
- 
divisionTypeprotected float divisionTypeThe division type of the MIDI file.- See Also:
 
- 
resolutionprotected int resolutionThe timing resolution of the MIDI file.
- 
byteLengthprotected int byteLengthThe length of the MIDI file in bytes.
- 
microsecondLengthprotected long microsecondLengthThe duration of the MIDI file in microseconds.
 
- 
- 
Constructor Details- 
MidiFileFormatpublic MidiFileFormat(int type, float divisionType, int resolution, int bytes, long microseconds) Constructs aMidiFileFormat.- 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_LENGTHif not known
- microseconds- the duration of the file in microseconds, or- UNKNOWN_LENGTHif not known
- See Also:
 
- 
MidiFileFormatpublic MidiFileFormat(int type, float divisionType, int resolution, int bytes, long microseconds, Map<String, Object> properties) Construct aMidiFileFormatwith 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_LENGTHif not known
- microseconds- the duration of the file in microseconds, or- UNKNOWN_LENGTHif not known
- properties- a- Map<String,Object>object with properties
- Since:
- 1.5
- See Also:
 
 
- 
- 
Method Details- 
getTypepublic int getType()Obtains the MIDI file type.- Returns:
- the file's type (0, 1, or 2)
 
- 
getDivisionTypepublic float getDivisionType()Obtains the timing division type for the MIDI file.- Returns:
- the division type (PPQ or one of the SMPTE types)
- See Also:
 
- 
getResolutionpublic 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 SMPTE timing, the resolution is specified in ticks per frame.- Returns:
- the number of ticks per beat (PPQ) or per frame (SMPTE)
- See Also:
 
- 
getByteLengthpublic int getByteLength()Obtains the length of the MIDI file, expressed in 8-bit bytes.- Returns:
- the number of bytes in the file, or UNKNOWN_LENGTHif not known
- See Also:
 
- 
getMicrosecondLengthpublic long getMicrosecondLength()Obtains the length of the MIDI file, expressed in microseconds.- Returns:
- the file's duration in microseconds, or UNKNOWN_LENGTHif not known
- See Also:
 
- 
propertiesObtain an unmodifiable map of properties. The concept of properties is further explained in theclass description.- Returns:
- a Map<String,Object>object containing all properties. If no properties are recognized, an empty map is returned.
- Since:
- 1.5
- See Also:
 
- 
getPropertyObtain the property value specified by the key. The concept of properties is further explained in theclass description.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 nullif the property does not exist
- Since:
- 1.5
- See Also:
 
 
-