jdk/src/java.desktop/share/classes/javax/sound/midi/MidiFileFormat.java
author ddehaven
Tue, 19 Aug 2014 10:32:16 -0700
changeset 26037 508779ce6619
parent 26003 jdk/src/share/classes/javax/sound/midi/MidiFileFormat.java@d630c97424bd
parent 25859 jdk/src/share/classes/javax/sound/midi/MidiFileFormat.java@3317bb8137f4
child 40444 afabcfc2f3ef
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 19207
diff changeset
     2
 * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package javax.sound.midi;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.util.Collections;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.util.HashMap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.util.Map;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
/**
26003
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
    33
 * A {@code MidiFileFormat} object encapsulates a MIDI file's type, as well as
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
    34
 * its length and timing information.
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
    35
 * <p>
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
    36
 * A {@code MidiFileFormat} object can include a set of properties. A property
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
    37
 * is a pair of key and value: the key is of type {@code String}, the associated
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
    38
 * property value is an arbitrary object. Properties specify additional
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
    39
 * informational meta data (like a author, or copyright). Properties are
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
    40
 * optional information, and file reader and file writer implementations are not
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
    41
 * required to provide or recognize properties.
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
    42
 * <p>
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
    43
 * The following table lists some common properties that should be used in
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
    44
 * implementations:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * <table border=1>
19207
3448b0cb4077 8022174: Fix doclint warnings in javax.sound
darcy
parents: 5506
diff changeset
    47
    <caption>MIDI File Format Properties</caption>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 *  <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 *   <th>Property key</th>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 *   <th>Value type</th>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 *   <th>Description</th>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 *  </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 *  <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 *   <td>&quot;author&quot;</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 *   <td>{@link java.lang.String String}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 *   <td>name of the author of this file</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 *  </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 *  <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 *   <td>&quot;title&quot;</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 *   <td>{@link java.lang.String String}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 *   <td>title of this file</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 *  </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 *  <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 *   <td>&quot;copyright&quot;</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 *   <td>{@link java.lang.String String}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 *   <td>copyright message</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 *  </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 *  <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 *   <td>&quot;date&quot;</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 *   <td>{@link java.util.Date Date}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 *   <td>date of the recording or release</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 *  </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 *  <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 *   <td>&quot;comment&quot;</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 *   <td>{@link java.lang.String String}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 *   <td>an arbitrary text</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 *  </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 * </table>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 * @author Kara Kytle
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 * @author Florian Bomers
26003
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
    82
 * @see MidiSystem#getMidiFileFormat(java.io.File)
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
    83
 * @see Sequencer#setSequence(java.io.InputStream stream)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
public class MidiFileFormat {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * Represents unknown length.
26003
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
    89
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * @see #getByteLength
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * @see #getMicrosecondLength
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    public static final int UNKNOWN_LENGTH = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * The type of MIDI file.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    protected int type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * The division type of the MIDI file.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * @see Sequence#PPQ
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * @see Sequence#SMPTE_24
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * @see Sequence#SMPTE_25
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * @see Sequence#SMPTE_30DROP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * @see Sequence#SMPTE_30
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    protected float divisionType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * The timing resolution of the MIDI file.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    protected int resolution;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * The length of the MIDI file in bytes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    protected int byteLength;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * The duration of the MIDI file in microseconds.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    protected long microsecondLength;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
26003
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
   126
    /**
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
   127
     * The set of properties.
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
   128
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    private HashMap<String, Object> properties;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    /**
26003
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
   132
     * Constructs a {@code MidiFileFormat}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     *
26003
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
   134
     * @param  type the MIDI file type (0, 1, or 2)
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
   135
     * @param  divisionType the timing division type (PPQ or one of the SMPTE
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
   136
     *         types)
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
   137
     * @param  resolution the timing resolution
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
   138
     * @param  bytes the length of the MIDI file in bytes, or UNKNOWN_LENGTH if
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
   139
     *         not known
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
   140
     * @param  microseconds the duration of the file in microseconds, or
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
   141
     *         UNKNOWN_LENGTH if not known
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * @see #UNKNOWN_LENGTH
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * @see Sequence#PPQ
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * @see Sequence#SMPTE_24
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * @see Sequence#SMPTE_25
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * @see Sequence#SMPTE_30DROP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * @see Sequence#SMPTE_30
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    public MidiFileFormat(int type, float divisionType, int resolution, int bytes, long microseconds) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        this.type = type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        this.divisionType = divisionType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        this.resolution = resolution;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        this.byteLength = bytes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        this.microsecondLength = microseconds;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        this.properties = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    /**
26003
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
   160
     * Construct a {@code MidiFileFormat} with a set of properties.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     *
26003
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
   162
     * @param  type the MIDI file type (0, 1, or 2)
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
   163
     * @param  divisionType the timing division type (PPQ or one of the SMPTE
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
   164
     *         types)
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
   165
     * @param  resolution the timing resolution
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
   166
     * @param  bytes the length of the MIDI file in bytes, or UNKNOWN_LENGTH if
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
   167
     *         not known
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
   168
     * @param  microseconds the duration of the file in microseconds, or
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
   169
     *         UNKNOWN_LENGTH if not known
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
   170
     * @param  properties a {@code Map<String,Object>} object with properties
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * @see #UNKNOWN_LENGTH
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     * @see Sequence#PPQ
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * @see Sequence#SMPTE_24
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * @see Sequence#SMPTE_25
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * @see Sequence#SMPTE_30DROP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * @see Sequence#SMPTE_30
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    public MidiFileFormat(int type, float divisionType,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
                          int resolution, int bytes,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
                          long microseconds, Map<String, Object> properties) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        this(type, divisionType, resolution, bytes, microseconds);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        this.properties = new HashMap<String, Object>(properties);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * Obtains the MIDI file type.
26003
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
   188
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * @return the file's type (0, 1, or 2)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    public int getType() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        return type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * Obtains the timing division type for the MIDI file.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * @return the division type (PPQ or one of the SMPTE types)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     * @see Sequence#Sequence(float, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * @see Sequence#PPQ
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * @see Sequence#SMPTE_24
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * @see Sequence#SMPTE_25
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * @see Sequence#SMPTE_30DROP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * @see Sequence#SMPTE_30
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * @see Sequence#getDivisionType()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    public float getDivisionType() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        return divisionType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    /**
26003
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
   212
     * Obtains the timing resolution for the MIDI file. If the division type is
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
   213
     * PPQ, the resolution is specified in ticks per beat. For SMTPE timing, the
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
   214
     * resolution is specified in ticks per frame.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * @return the number of ticks per beat (PPQ) or per frame (SMPTE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * @see #getDivisionType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     * @see Sequence#getResolution()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    public int getResolution() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        return resolution;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * Obtains the length of the MIDI file, expressed in 8-bit bytes.
26003
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
   226
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * @return the number of bytes in the file, or UNKNOWN_LENGTH if not known
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     * @see #UNKNOWN_LENGTH
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    public int getByteLength() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        return byteLength;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     * Obtains the length of the MIDI file, expressed in microseconds.
26003
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
   236
     *
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
   237
     * @return the file's duration in microseconds, or UNKNOWN_LENGTH if not
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
   238
     *         known
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     * @see Sequence#getMicrosecondLength()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * @see #getByteLength
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * @see #UNKNOWN_LENGTH
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    public long getMicrosecondLength() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        return microsecondLength;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    /**
26003
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
   248
     * Obtain an unmodifiable map of properties. The concept of properties is
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
   249
     * further explained in the {@link MidiFileFormat class description}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     *
26003
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
   251
     * @return a {@code Map<String,Object>} object containing all properties. If
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
   252
     *         no properties are recognized, an empty map is returned.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     * @see #getProperty(String)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     */
25131
49006bd0e69d 8044553: Fix raw and unchecked lint warnings in javax.sound.*
darcy
parents: 22584
diff changeset
   256
    @SuppressWarnings("unchecked") // Cast of result of clone
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    public Map<String,Object> properties() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        Map<String,Object> ret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        if (properties == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
            ret = new HashMap<String,Object>(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
            ret = (Map<String,Object>) (properties.clone());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        }
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 19207
diff changeset
   264
        return Collections.unmodifiableMap(ret);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
    /**
26003
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
   268
     * Obtain the property value specified by the key. The concept of properties
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
   269
     * is further explained in the {@link MidiFileFormat class description}.
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
   270
     * <p>
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
   271
     * If the specified property is not defined for a particular file format,
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
   272
     * this method returns {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     *
26003
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
   274
     * @param  key the key of the desired property
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
   275
     * @return the value of the property with the specified key, or {@code null}
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 25131
diff changeset
   276
     *         if the property does not exist
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     * @see #properties()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
    public Object getProperty(String key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        if (properties == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        return properties.get(key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
}