< prev index next >
src/java.desktop/share/classes/javax/sound/sampled/AudioFormat.java
Print this page
*** 38,47 ****
--- 38,48 ----
* Every data line has an audio format associated with its data stream. The
* audio format of a source (playback) data line indicates what kind of data the
* data line expects to receive for output. For a target (capture) data line,
* the audio format specifies the kind of the data that can be read from the
* line.
+ * <p>
* Sound files also have audio formats, of course. The {@link AudioFileFormat}
* class encapsulates an {@code AudioFormat} in addition to other, file-specific
* information. Similarly, an {@link AudioInputStream} has an
* {@code AudioFormat}.
* <p>
*** 91,122 ****
*
* <table class="striped">
* <caption>Audio Format Properties</caption>
* <thead>
* <tr>
! * <th>Property key</th>
! * <th>Value type</th>
! * <th>Description</th>
! * </tr>
* </thead>
* <tbody>
* <tr>
! * <td>"bitrate"</td>
! * <td>{@link java.lang.Integer Integer}</td>
! * <td>average bit rate in bits per second</td>
! * </tr>
* <tr>
! * <td>"vbr"</td>
! * <td>{@link java.lang.Boolean Boolean}</td>
! * <td>{@code true}, if the file is encoded in variable bit
! * rate (VBR)</td>
! * </tr>
* <tr>
! * <td>"quality"</td>
! * <td>{@link java.lang.Integer Integer}</td>
! * <td>encoding/conversion quality, 1..100</td>
! * </tr>
* </tbody>
* </table>
* <p>
* Vendors of service providers (plugins) are encouraged to seek information
* about other already established properties in third party plugins, and follow
--- 92,118 ----
*
* <table class="striped">
* <caption>Audio Format Properties</caption>
* <thead>
* <tr>
! * <th>Property key
! * <th>Value type
! * <th>Description
* </thead>
* <tbody>
* <tr>
! * <td>"bitrate"
! * <td>{@link java.lang.Integer Integer}
! * <td>average bit rate in bits per second
* <tr>
! * <td>"vbr"
! * <td>{@link java.lang.Boolean Boolean}
! * <td>{@code true}, if the file is encoded in variable bit rate (VBR)
* <tr>
! * <td>"quality"
! * <td>{@link java.lang.Integer Integer}
! * <td>encoding/conversion quality, 1..100
* </tbody>
* </table>
* <p>
* Vendors of service providers (plugins) are encouraged to seek information
* about other already established properties in third party plugins, and follow
*** 181,192 ****
* are further explained in the {@link AudioFormat class description}.
*
* @param encoding the audio encoding technique
* @param sampleRate the number of samples per second
* @param sampleSizeInBits the number of bits in each sample
! * @param channels the number of channels (1 for mono, 2 for stereo,
! * and so on)
* @param frameSize the number of bytes in each frame
* @param frameRate the number of frames per second
* @param bigEndian indicates whether the data for a single sample is
* stored in big-endian byte order ({@code false} means
* little-endian)
--- 177,188 ----
* are further explained in the {@link AudioFormat class description}.
*
* @param encoding the audio encoding technique
* @param sampleRate the number of samples per second
* @param sampleSizeInBits the number of bits in each sample
! * @param channels the number of channels (1 for mono, 2 for stereo, and so
! * on)
* @param frameSize the number of bytes in each frame
* @param frameRate the number of frames per second
* @param bigEndian indicates whether the data for a single sample is
* stored in big-endian byte order ({@code false} means
* little-endian)
*** 215,225 ****
* @param channels the number of channels (1 for mono, 2 for stereo, and so
* on)
* @param frameSize the number of bytes in each frame
* @param frameRate the number of frames per second
* @param bigEndian indicates whether the data for a single sample is
! * stored in big-endian byte order ({@code false} means little-endian)
* @param properties a {@code Map<String, Object>} object containing format
* properties
* @since 1.5
*/
public AudioFormat(Encoding encoding, float sampleRate,
--- 211,222 ----
* @param channels the number of channels (1 for mono, 2 for stereo, and so
* on)
* @param frameSize the number of bytes in each frame
* @param frameRate the number of frames per second
* @param bigEndian indicates whether the data for a single sample is
! * stored in big-endian byte order ({@code false} means
! * little-endian)
* @param properties a {@code Map<String, Object>} object containing format
* properties
* @since 1.5
*/
public AudioFormat(Encoding encoding, float sampleRate,
*** 274,286 ****
return encoding;
}
/**
* Obtains the sample rate. For compressed formats, the return value is the
! * sample rate of the uncompressed audio data. When this AudioFormat is used
! * for queries (e.g. {@link AudioSystem#isConversionSupported(AudioFormat,
! * AudioFormat) AudioSystem.isConversionSupported}) or capabilities (e.g.
* {@link DataLine.Info#getFormats DataLine.Info.getFormats}), a sample rate
* of {@code AudioSystem.NOT_SPECIFIED} means that any sample rate is
* acceptable. {@code AudioSystem.NOT_SPECIFIED} is also returned when the
* sample rate is not defined for this audio format.
*
--- 271,284 ----
return encoding;
}
/**
* Obtains the sample rate. For compressed formats, the return value is the
! * sample rate of the uncompressed audio data. When this {@code AudioFormat}
! * is used for queries (e.g.
! * {@link AudioSystem#isConversionSupported(AudioFormat, AudioFormat)
! * AudioSystem.isConversionSupported}) or capabilities (e.g.
* {@link DataLine.Info#getFormats DataLine.Info.getFormats}), a sample rate
* of {@code AudioSystem.NOT_SPECIFIED} means that any sample rate is
* acceptable. {@code AudioSystem.NOT_SPECIFIED} is also returned when the
* sample rate is not defined for this audio format.
*
*** 294,307 ****
return sampleRate;
}
/**
* Obtains the size of a sample. For compressed formats, the return value is
! * the sample size of the uncompressed audio data. When this AudioFormat is
! * used for queries (e.g. {@link AudioSystem#isConversionSupported(
! * AudioFormat,AudioFormat) AudioSystem.isConversionSupported}) or
! * capabilities (e.g.
* {@link DataLine.Info#getFormats DataLine.Info.getFormats}), a sample size
* of {@code AudioSystem.NOT_SPECIFIED} means that any sample size is
* acceptable. {@code AudioSystem.NOT_SPECIFIED} is also returned when the
* sample size is not defined for this audio format.
*
--- 292,305 ----
return sampleRate;
}
/**
* Obtains the size of a sample. For compressed formats, the return value is
! * the sample size of the uncompressed audio data. When this
! * {@code AudioFormat} is used for queries (e.g.
! * {@link AudioSystem#isConversionSupported(AudioFormat,AudioFormat)
! * AudioSystem.isConversionSupported}) or capabilities (e.g.
* {@link DataLine.Info#getFormats DataLine.Info.getFormats}), a sample size
* of {@code AudioSystem.NOT_SPECIFIED} means that any sample size is
* acceptable. {@code AudioSystem.NOT_SPECIFIED} is also returned when the
* sample size is not defined for this audio format.
*
*** 314,326 ****
return sampleSizeInBits;
}
/**
! * Obtains the number of channels. When this AudioFormat is used for queries
! * (e.g. {@link AudioSystem#isConversionSupported(AudioFormat, AudioFormat)
! * AudioSystem.isConversionSupported}) or capabilities (e.g.
* {@link DataLine.Info#getFormats DataLine.Info.getFormats}), a return
* value of {@code AudioSystem.NOT_SPECIFIED} means that any (positive)
* number of channels is acceptable.
*
* @return The number of channels (1 for mono, 2 for stereo, etc.), or
--- 312,324 ----
return sampleSizeInBits;
}
/**
! * Obtains the number of channels. When this {@code AudioFormat} is used for
! * queries (e.g. {@link AudioSystem#isConversionSupported(AudioFormat,
! * AudioFormat) AudioSystem.isConversionSupported}) or capabilities (e.g.
* {@link DataLine.Info#getFormats DataLine.Info.getFormats}), a return
* value of {@code AudioSystem.NOT_SPECIFIED} means that any (positive)
* number of channels is acceptable.
*
* @return The number of channels (1 for mono, 2 for stereo, etc.), or
*** 331,342 ****
return channels;
}
/**
! * Obtains the frame size in bytes. When this AudioFormat is used for
! * queries (e.g. {@link AudioSystem#isConversionSupported(AudioFormat,
* AudioFormat) AudioSystem.isConversionSupported}) or capabilities (e.g.
* {@link DataLine.Info#getFormats DataLine.Info.getFormats}), a frame size
* of {@code AudioSystem.NOT_SPECIFIED} means that any frame size is
* acceptable. {@code AudioSystem.NOT_SPECIFIED} is also returned when the
* frame size is not defined for this audio format.
--- 329,340 ----
return channels;
}
/**
! * Obtains the frame size in bytes. When this {@code AudioFormat} is used
! * for queries (e.g. {@link AudioSystem#isConversionSupported(AudioFormat,
* AudioFormat) AudioSystem.isConversionSupported}) or capabilities (e.g.
* {@link DataLine.Info#getFormats DataLine.Info.getFormats}), a frame size
* of {@code AudioSystem.NOT_SPECIFIED} means that any frame size is
* acceptable. {@code AudioSystem.NOT_SPECIFIED} is also returned when the
* frame size is not defined for this audio format.
*** 350,363 ****
return frameSize;
}
/**
! * Obtains the frame rate in frames per second. When this AudioFormat is
! * used for queries (e.g. {@link AudioSystem#isConversionSupported(
! * AudioFormat,AudioFormat) AudioSystem.isConversionSupported}) or
! * capabilities (e.g.
* {@link DataLine.Info#getFormats DataLine.Info.getFormats}), a frame rate
* of {@code AudioSystem.NOT_SPECIFIED} means that any frame rate is
* acceptable. {@code AudioSystem.NOT_SPECIFIED} is also returned when the
* frame rate is not defined for this audio format.
*
--- 348,361 ----
return frameSize;
}
/**
! * Obtains the frame rate in frames per second. When this
! * {@code AudioFormat} is used for queries (e.g.
! * {@link AudioSystem#isConversionSupported(AudioFormat,AudioFormat)
! * AudioSystem.isConversionSupported}) or capabilities (e.g.
* {@link DataLine.Info#getFormats DataLine.Info.getFormats}), a frame rate
* of {@code AudioSystem.NOT_SPECIFIED} means that any frame rate is
* acceptable. {@code AudioSystem.NOT_SPECIFIED} is also returned when the
* frame rate is not defined for this audio format.
*
*** 549,561 ****
* The numbers may be signed or unsigned integers or floats. Besides PCM,
* other encodings include mu-law and a-law, which are nonlinear mappings of
* the sound amplitude that are often used for recording speech.
* <p>
* You can use a predefined encoding by referring to one of the static
! * objects created by this class, such as PCM_SIGNED or PCM_UNSIGNED.
! * Service providers can create new encodings, such as compressed audio
! * formats, and make these available through the {@link AudioSystem} class.
* <p>
* The {@code Encoding} class is static, so that all {@code AudioFormat}
* objects that have the same encoding will refer to the same object (rather
* than different instances of the same class). This allows matches to be
* made by checking that two format's encodings are equal.
--- 547,560 ----
* The numbers may be signed or unsigned integers or floats. Besides PCM,
* other encodings include mu-law and a-law, which are nonlinear mappings of
* the sound amplitude that are often used for recording speech.
* <p>
* You can use a predefined encoding by referring to one of the static
! * objects created by this class, such as {@code PCM_SIGNED} or
! * {@code PCM_UNSIGNED}. Service providers can create new encodings, such as
! * compressed audio formats, and make these available through the
! * {@link AudioSystem} class.
* <p>
* The {@code Encoding} class is static, so that all {@code AudioFormat}
* objects that have the same encoding will refer to the same object (rather
* than different instances of the same class). This allows matches to be
* made by checking that two format's encodings are equal.
*** 607,617 ****
public Encoding(final String name) {
this.name = name;
}
/**
! * Finalizes the equals method.
*/
@Override
public final boolean equals(final Object obj) {
if (this == obj) {
return true;
--- 606,621 ----
public Encoding(final String name) {
this.name = name;
}
/**
! * Indicates whether the specified object is equal to this encoding,
! * returning {@code true} if the objects are the same.
! *
! * @param obj the reference object with which to compare
! * @return {@code true} if this encoding is the same as the {@code obj}
! * argument; {@code false} otherwise
*/
@Override
public final boolean equals(final Object obj) {
if (this == obj) {
return true;
*** 621,631 ****
}
return Objects.equals(name, ((Encoding) obj).name);
}
/**
! * Finalizes the hashCode method.
*/
@Override
public final int hashCode() {
return name != null ? name.hashCode() : 0;
}
--- 625,637 ----
}
return Objects.equals(name, ((Encoding) obj).name);
}
/**
! * Returns a hash code value for this encoding.
! *
! * @return a hash code value for this encoding
*/
@Override
public final int hashCode() {
return name != null ? name.hashCode() : 0;
}
< prev index next >