|
Préférences
Moteurs de recherche
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
JavaTM 2 Platform Std. Ed. v1.5.0
javax.sound.sampled
|
Property key | Value type | Description |
---|---|---|
"bitrate" | Integer |
average bit rate in bits per second |
"vbr" | Boolean |
true , if the file is encoded in variable bit
rate (VBR) |
"quality" | Integer |
encoding/conversion quality, 1..100 |
Vendors of service providers (plugins) are encouraged to seek information about other already established properties in third party plugins, and follow the same conventions.
DataLine.getFormat()
,
AudioInputStream.getFormat()
,
AudioFileFormat
,
FormatConversionProvider
Nested Class Summary | |
---|---|
static class |
AudioFormat.Encoding
The Encoding class names the specific type of data representation
used for an audio stream. |
Field Summary | |
---|---|
protected boolean |
bigEndian
Indicates whether the audio data is stored in big-endian or little-endian order. |
protected int |
channels
The number of audio channels in this format (1 for mono, 2 for stereo). |
protected AudioFormat.Encoding |
encoding
The audio encoding technique used by this format. |
protected float |
frameRate
The number of frames played or recorded per second, for sounds that have this format. |
protected int |
frameSize
The number of bytes in each frame of a sound that has this format. |
protected float |
sampleRate
The number of samples played or recorded per second, for sounds that have this format. |
protected int |
sampleSizeInBits
The number of bits in each sample of a sound that has this format. |
Constructor Summary | |
---|---|
AudioFormat(AudioFormat.Encoding encoding,
float sampleRate,
int sampleSizeInBits,
int channels,
int frameSize,
float frameRate,
boolean bigEndian)
Constructs an AudioFormat with the given parameters. |
|
AudioFormat(AudioFormat.Encoding encoding,
float sampleRate,
int sampleSizeInBits,
int channels,
int frameSize,
float frameRate,
boolean bigEndian,
Map<String,Object> properties)
Constructs an AudioFormat with the given parameters. |
|
AudioFormat(float sampleRate,
int sampleSizeInBits,
int channels,
boolean signed,
boolean bigEndian)
Constructs an AudioFormat with a linear PCM encoding and
the given parameters. |
Method Summary | |
---|---|
int |
getChannels()
Obtains the number of channels. |
AudioFormat.Encoding |
getEncoding()
Obtains the type of encoding for sounds in this format. |
float |
getFrameRate()
Obtains the frame rate in frames per second. |
int |
getFrameSize()
Obtains the frame size in bytes. |
Object |
getProperty(String key)
Obtain the property value specified by the key. |
float |
getSampleRate()
Obtains the sample rate. |
int |
getSampleSizeInBits()
Obtains the size of a sample. |
boolean |
isBigEndian()
Indicates whether the audio data is stored in big-endian or little-endian byte order. |
boolean |
matches(AudioFormat format)
Indicates whether this format matches the one specified. |
Map<String,Object> |
properties()
Obtain an unmodifiable map of properties. |
String |
toString()
Returns a string that describes the format, such as: "PCM SIGNED 22050 Hz 16 bit mono big-endian". |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected AudioFormat.Encoding encoding
protected float sampleRate
protected int sampleSizeInBits
protected int channels
protected int frameSize
protected float frameRate
protected boolean bigEndian
Constructor Detail |
---|
public AudioFormat(AudioFormat.Encoding encoding, float sampleRate, int sampleSizeInBits, int channels, int frameSize, float frameRate, boolean bigEndian)
AudioFormat
with the given parameters.
The encoding specifies the convention used to represent the data.
The other parameters are further explained in the class description
.
encoding
- the audio encoding techniquesampleRate
- the number of samples per secondsampleSizeInBits
- the number of bits in each samplechannels
- the number of channels (1 for mono, 2 for stereo, and so on)frameSize
- the number of bytes in each frameframeRate
- the number of frames per secondbigEndian
- indicates whether the data for a single sample
is stored in big-endian byte order (false
means little-endian)public AudioFormat(AudioFormat.Encoding encoding, float sampleRate, int sampleSizeInBits, int channels, int frameSize, float frameRate, boolean bigEndian, Map<String,Object> properties)
AudioFormat
with the given parameters.
The encoding specifies the convention used to represent the data.
The other parameters are further explained in the class description
.
encoding
- the audio encoding techniquesampleRate
- the number of samples per secondsampleSizeInBits
- the number of bits in each samplechannels
- the number of channels (1 for mono, 2 for
stereo, and so on)frameSize
- the number of bytes in each frameframeRate
- the number of frames per secondbigEndian
- indicates whether the data for a single sample
is stored in big-endian byte order
(false
means little-endian)properties
- a Map<String,Object>
object
containing format propertiespublic AudioFormat(float sampleRate, int sampleSizeInBits, int channels, boolean signed, boolean bigEndian)
AudioFormat
with a linear PCM encoding and
the given parameters. The frame size is set to the number of bytes
required to contain one sample from each channel, and the frame rate
is set to the sample rate.
sampleRate
- the number of samples per secondsampleSizeInBits
- the number of bits in each samplechannels
- the number of channels (1 for mono, 2 for stereo, and so on)signed
- indicates whether the data is signed or unsignedbigEndian
- indicates whether the data for a single sample
is stored in big-endian byte order (false
means little-endian)Method Detail |
---|
public AudioFormat.Encoding getEncoding()
AudioFormat.Encoding.PCM_SIGNED
,
AudioFormat.Encoding.PCM_UNSIGNED
,
AudioFormat.Encoding.ULAW
,
AudioFormat.Encoding.ALAW
public float getSampleRate()
AudioSystem.isConversionSupported
) or capabilities (e.g. DataLine.Info.getFormats
), a sample rate of
AudioSystem.NOT_SPECIFIED
means that any sample rate is
acceptable. AudioSystem.NOT_SPECIFIED
is also returned when
the sample rate is not defined for this audio format.
AudioSystem.NOT_SPECIFIED
getFrameRate()
,
AudioSystem.NOT_SPECIFIED
public int getSampleSizeInBits()
AudioSystem.isConversionSupported
) or capabilities (e.g. DataLine.Info.getFormats
), a sample size of
AudioSystem.NOT_SPECIFIED
means that any sample size is
acceptable. AudioSystem.NOT_SPECIFIED
is also returned when
the sample size is not defined for this audio format.
AudioSystem.NOT_SPECIFIED
getFrameSize()
,
AudioSystem.NOT_SPECIFIED
public int getChannels()
AudioSystem.isConversionSupported
) or capabilities (e.g. DataLine.Info.getFormats
), a return value of
AudioSystem.NOT_SPECIFIED
means that any (positive) number of channels is
acceptable.
AudioSystem.NOT_SPECIFIED
AudioSystem.NOT_SPECIFIED
public int getFrameSize()
AudioSystem.isConversionSupported
) or capabilities (e.g. DataLine.Info.getFormats
), a frame size of
AudioSystem.NOT_SPECIFIED
means that any frame size is
acceptable. AudioSystem.NOT_SPECIFIED
is also returned when
the frame size is not defined for this audio format.
AudioSystem.NOT_SPECIFIED
getSampleSizeInBits()
,
AudioSystem.NOT_SPECIFIED
public float getFrameRate()
AudioSystem.isConversionSupported
) or capabilities (e.g. DataLine.Info.getFormats
), a frame rate of
AudioSystem.NOT_SPECIFIED
means that any frame rate is
acceptable. AudioSystem.NOT_SPECIFIED
is also returned when
the frame rate is not defined for this audio format.
AudioSystem.NOT_SPECIFIED
getSampleRate()
,
AudioSystem.NOT_SPECIFIED
public boolean isBigEndian()
true
if the data is stored in big-endian byte order,
false
if little-endianpublic Map<String,Object> properties()
class description
.
Map<String,Object>
object containing
all properties. If no properties are recognized, an empty map is
returned.getProperty(String)
public Object getProperty(String key)
class description
.
If the specified property is not defined for a
particular file format, this method returns
null
.
key
- the key of the desired property
null
if the property does not exist.properties
public boolean matches(AudioFormat format)
AudioSystem.NOT_SPECIFIED
,
which any sample rate will match. The frame rates must
similarly be equal, unless the specified format has the frame rate
value AudioSystem.NOT_SPECIFIED
. The byte order (big-endian or little-endian)
must match if the sample size is greater than one byte.
format
- format to test for match
true
if this format matches the one specified,
false
otherwise.public String toString()