/*
* @(#)AudioFormat.java 1.36 05/11/17
*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package javax.sound.sampled;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
/**
* <code>AudioFormat</code> is the class that specifies a particular arrangement of data in a sound stream.
* By examing the information stored in the audio format, you can discover how to interpret the bits in the
* binary sound data.
* <p>
* 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.
* Sound files also have audio formats, of course. The <code>{@link AudioFileFormat}</code>
* class encapsulates an <code>AudioFormat</code> in addition to other,
* file-specific information. Similarly, an <code>{@link AudioInputStream}</code> has an
* <code>AudioFormat</code>.
* <p>
* The <code>AudioFormat</code> class accommodates a number of common sound-file encoding techniques, including
* pulse-code modulation (PCM), mu-law encoding, and a-law encoding. These encoding techniques are predefined,
* but service providers can create new encoding types.
* The encoding that a specific format uses is named by its <code>encoding</code> field.
*<p>
* In addition to the encoding, the audio format includes other properties that further specify the exact
* arrangement of the data.
* These include the number of channels, sample rate, sample size, byte order, frame rate, and frame size.
* Sounds may have different numbers of audio channels: one for mono, two for stereo.
* The sample rate measures how many "snapshots" (samples) of the sound pressure are taken per second, per channel.
* (If the sound is stereo rather than mono, two samples are actually measured at each instant of time: one for the left
channel,
* and another for the right channel; however, the sample rate still measures the number per channel, so the rate is the same
* regardless of the number of channels. This is the standard use of the term.)
* The sample size indicates how many bits are used to store each snapshot; 8 and 16 are typical values.
* For 16-bit samples (or any other sample size larger than a byte),
* byte order is important; the bytes in each sample are arranged in
* either the "little-endian" or "big-endian" style.
* For encodings like PCM, a frame consists of the set of samples for all channels at a given
* point in time, and so the size of a frame (in bytes) is always equal to the size of a sample (in bytes) times
* the number of channels. However, with some other sorts of encodings a frame can contain
* a bundle of compressed data for a whole series of samples, as well as additional, non-sample
* data. For such encodings, the sample rate and sample size refer to the data after it is decoded into PCM,
* and so they are completely different from the frame rate and frame size.
*
* <p>An <code>AudioFormat</code> object can include a set of
* properties. A property is a pair of key and value: the key
* is of type <code>String</code>, the associated property
* value is an arbitrary object. Properties specify
* additional format specifications, like the bit rate for
* compressed formats. Properties are mainly used as a means
* to transport additional information of the audio format
* to and from the service providers. Therefore, properties
* are ignored in the {@link #matches(AudioFormat)} method.
* However, methods which rely on the installed service
* providers, like {@link AudioSystem#isConversionSupported
* (AudioFormat, AudioFormat) isConversionSupported} may consider
* properties, depending on the respective service provider
* implementation.
*
* <p>The following table lists some common properties which
* service providers should use, if applicable:
*
* <table border=0>
* <tr>
* <th>Property key</th>
* <th>Value type</th>
* <th>Description</th>
* </tr>
* <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</code>, 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>
* </table>
*
* <p>Vendors of service providers (plugins) are encouraged
* to seek information about other already established
* properties in third party plugins, and follow the same
* conventions.
*
* @author Kara Kytle
* @author Florian Bomers
* @version 1.36 05/11/17
=1= |