/*
* Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.sound.midi;
import java.io.InputStream;
import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
/**
* 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" | *{@link java.lang.String String} | *name of the author of this file | *
"title" | *{@link java.lang.String String} | *title of this file | *
"copyright" | *{@link java.lang.String String} | *copyright message | *
"date" | *{@link java.util.Date Date} | *date of the recording or release | *
"comment" | *{@link java.lang.String String} | *an arbitrary text | *
MidiFileFormat
.
*
* @param type the MIDI file type (0, 1, or 2)
* @param divisionType the timing division type (PPQ or one of the SMPTE types)
* @param resolution the timing resolution
* @param bytes the length of the MIDI file in bytes, or UNKNOWN_LENGTH if not known
* @param microseconds the duration of the file in microseconds, or UNKNOWN_LENGTH if not known
* @see #UNKNOWN_LENGTH
* @see Sequence#PPQ
* @see Sequence#SMPTE_24
* @see Sequence#SMPTE_25
* @see Sequence#SMPTE_30DROP
* @see Sequence#SMPTE_30
*/
public MidiFileFormat(int type, float divisionType, int resolution, int bytes, long microseconds) {
this.type = type;
this.divisionType = divisionType;
this.resolution = resolution;
this.byteLength = bytes;
this.microsecondLength = microseconds;
this.properties = null;
}
/**
* Construct a MidiFileFormat
with a set of properties.
*
* @param type the MIDI file type (0, 1, or 2)
* @param divisionType the timing division type
* (PPQ or one of the SMPTE types)
* @param resolution the timing resolution
* @param bytes the length of the MIDI file in bytes,
* or UNKNOWN_LENGTH if not known
* @param microseconds the duration of the file in microseconds,
* or UNKNOWN_LENGTH if not known
* @param properties a Map<String,Object>
object
* with properties
*
* @see #UNKNOWN_LENGTH
* @see Sequence#PPQ
* @see Sequence#SMPTE_24
* @see Sequence#SMPTE_25
* @see Sequence#SMPTE_30DROP
* @see Sequence#SMPTE_30
* @since 1.5
*/
public MidiFileFormat(int type, float divisionType,
int resolution, int bytes,
long microseconds, MapMap<String,Object>
object containing
* all properties. If no properties are recognized, an empty map is
* returned.
*
* @see #getProperty(String)
* @since 1.5
*/
public MapIf the specified property is not defined for a
* particular file format, this method returns
* null
.
*
* @param key the key of the desired property
* @return the value of the property with the specified key,
* or null
if the property does not exist.
*
* @see #properties()
* @since 1.5
*/
public Object getProperty(String key) {
if (properties == null) {
return null;
}
return properties.get(key);
}
}