001 /* MidiFileFormat.java -- Information about a MIDI file
002 Copyright (C) 2005 Free Software Foundation, Inc.
003
004 This file is part of GNU Classpath.
005
006 GNU Classpath is free software; you can redistribute it and/or modify
007 it under the terms of the GNU General Public License as published by
008 the Free Software Foundation; either version 2, or (at your option)
009 any later version.
010
011 GNU Classpath is distributed in the hope that it will be useful, but
012 WITHOUT ANY WARRANTY; without even the implied warranty of
013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014 General Public License for more details.
015
016 You should have received a copy of the GNU General Public License
017 along with GNU Classpath; see the file COPYING. If not, write to the
018 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
019 02110-1301 USA.
020
021 Linking this library statically or dynamically with other modules is
022 making a combined work based on this library. Thus, the terms and
023 conditions of the GNU General Public License cover the whole
024 combination.
025
026 As a special exception, the copyright holders of this library give you
027 permission to link this library with independent modules to produce an
028 executable, regardless of the license terms of these independent
029 modules, and to copy and distribute the resulting executable under
030 terms of your choice, provided that you also meet, for each linked
031 independent module, the terms and conditions of the license of that
032 module. An independent module is a module which is not derived from
033 or based on this library. If you modify this library, you may extend
034 this exception to your version of the library, but you are not
035 obligated to do so. If you do not wish to do so, delete this
036 exception statement from your version. */
037
038
039 package javax.sound.midi;
040
041 /**
042 * Describe a MIDI file, including specifics about its type, length and timing.
043 *
044 * @author Anthony Green (green@redhat.com)
045 * @since 1.3
046 *
047 */
048 public class MidiFileFormat
049 {
050 /**
051 * The MIDI file type. This is either 0, 1 or 2.
052 *
053 * Type 0 files contain a single track and represents a single song
054 * performance.
055 * Type 1 may contain multiple tracks for a single song performance.
056 * Type 2 may contain multiple tracks, each representing a
057 * separate song performance.
058 *
059 * See http://en.wikipedia.org/wiki/MIDI#MIDI_file_formats for more
060 * information.
061 */
062 protected int type;
063
064 /**
065 * The division type of the MIDI file.
066 */
067 protected float divisionType;
068
069 /**
070 * The timing resolution of the MIDI file.
071 */
072 protected int resolution;
073
074 /**
075 * The size of the MIDI file in bytes.
076 */
077 protected int byteLength = UNKNOWN_LENGTH;
078
079 /**
080 * The length of the MIDI file in microseconds.
081 */
082 protected long microsecondLength = UNKNOWN_LENGTH;
083
084 /**
085 * A special value indicating an unknown quantity.
086 */
087 public static final int UNKNOWN_LENGTH = -1; // FIXME is this really -1?
088
089 /**
090 * Create a MidiFileFormat object from the given parameters.
091 *
092 * @param type the MIDI file type (0, 1, or 2)
093 * @param divisionType the MIDI file division type
094 * @param resolution the MIDI file timing resolution
095 * @param bytes the MIDI file size in bytes
096 * @param microseconds the MIDI file length in microseconds
097 */
098 public MidiFileFormat(int type, float divisionType,
099 int resolution, int bytes, long microseconds)
100 {
101 this.type = type;
102 this.divisionType = divisionType;
103 this.resolution = resolution;
104 this.byteLength = bytes;
105 this.microsecondLength = microseconds;
106 }
107
108 /**
109 * Get the MIDI file type (0, 1, or 2).
110 *
111 * @return the MIDI file type (0, 1, or 2)
112 */
113 public int getType()
114 {
115 return type;
116 }
117
118 /**
119 * Get the file division type.
120 *
121 * @return the file divison type
122 */
123 public float getDivisionType()
124 {
125 return divisionType;
126 }
127
128 /**
129 * Get the file timing resolution. If the division type is PPQ, then this
130 * is value represents ticks per beat, otherwise it's ticks per frame (SMPTE).
131 *
132 * @return the timing resolution in ticks per beat or ticks per frame
133 */
134 public int getResolution()
135 {
136 return resolution;
137 }
138
139 /**
140 * Get the file length in bytes.
141 *
142 * @return the file length in bytes or UNKNOWN_LENGTH
143 */
144 public int getByteLength()
145 {
146 return byteLength;
147 }
148
149 /**
150 * Get the file length in microseconds.
151 *
152 * @return the file length in microseconds or UNKNOWN_LENGTH
153 */
154 public long getMicrosecondLength()
155 {
156 return microsecondLength;
157 }
158 }