javax.media.format
Class AudioFormat

java.lang.Object
  |
  +--javax.media.Format
        |
        +--javax.media.format.AudioFormat

public class AudioFormat
extends Format

Encapsulates format information for audio data. The attributes of an AudioFormat include the sample rate, bits per sample, and number of channels.

Since:
JMF 2.0
See Also:
Serialized Form

Field Summary
static java.lang.String ALAW
           
static int BIG_ENDIAN
           
protected  int channels
           
static java.lang.String DOLBYAC3
           
static java.lang.String DVI
           
static java.lang.String DVI_RTP
           
protected  int endian
           
protected  double frameRate
           
protected  int frameSizeInBits
           
static java.lang.String G723
           
static java.lang.String G723_RTP
           
static java.lang.String G728
           
static java.lang.String G728_RTP
           
static java.lang.String G729
           
static java.lang.String G729_RTP
           
static java.lang.String G729A
           
static java.lang.String G729A_RTP
           
static java.lang.String GSM
           
static java.lang.String GSM_MS
           
static java.lang.String GSM_RTP
           
static java.lang.String IMA4
           
static java.lang.String IMA4_MS
           
static java.lang.String LINEAR
           
static int LITTLE_ENDIAN
           
static java.lang.String MAC3
           
static java.lang.String MAC6
           
static java.lang.String MPEG
           
static java.lang.String MPEG_RTP
           
static java.lang.String MPEGLAYER3
           
static java.lang.String MSADPCM
           
static java.lang.String MSNAUDIO
           
static java.lang.String MSRT24
           
protected  double sampleRate
           
protected  int sampleSizeInBits
           
protected  int signed
           
static int SIGNED
           
static java.lang.String TRUESPEECH
           
static java.lang.String ULAW
           
static java.lang.String ULAW_RTP
           
static int UNSIGNED
           
static java.lang.String VOXWAREAC10
           
static java.lang.String VOXWAREAC16
           
static java.lang.String VOXWAREAC20
           
static java.lang.String VOXWAREAC8
           
static java.lang.String VOXWAREMETASOUND
           
static java.lang.String VOXWAREMETAVOICE
           
static java.lang.String VOXWARERT29H
           
static java.lang.String VOXWARETQ40
           
static java.lang.String VOXWARETQ60
           
static java.lang.String VOXWAREVR12
           
static java.lang.String VOXWAREVR18
           
 
Fields inherited from class javax.media.Format
byteArray, clz, dataType, encoding, FALSE, formatArray, intArray, NOT_SPECIFIED, shortArray, TRUE
 
Constructor Summary
AudioFormat(java.lang.String encoding)
          Constructs an AudioFormat with the specified encoding type.
AudioFormat(java.lang.String encoding, double sampleRate, int sampleSizeInBits, int channels)
          Constructs an AudioFormat with the specified attributes.
AudioFormat(java.lang.String encoding, double sampleRate, int sampleSizeInBits, int channels, int endian, int signed)
          Constructs an AudioFormat with the specified attributes.
AudioFormat(java.lang.String encoding, double sampleRate, int sampleSizeInBits, int channels, int endian, int signed, int frameSizeInBits, double frameRate, java.lang.Class dataType)
          Constructs an AudioFormat with the specified attributes.
 
Method Summary
 java.lang.Object clone()
          Creates a clone of this AudioFormat by copying each field to the clone.
 long computeDuration(long length)
          Returns the duration of the media based on the given length of the data.
protected  void copy(Format f)
          Copies the attributes from the specified Format into this AudioFormat.
 boolean equals(java.lang.Object format)
          Compares the specified Format with this AudioFormat.
 int getChannels()
          Gets the number of channels.
 int getEndian()
          Gets an integer that indicates whether the sample byte order is big endian or little endian.
 double getFrameRate()
          Gets the frame rate of this AudioFormat.
 int getFrameSizeInBits()
          Gets the frame size of this AudioFormat.
 double getSampleRate()
          Gets the audio sample rate.
 int getSampleSizeInBits()
          Gets the size of a sample.
 int getSigned()
          Gets a boolean that indicates whether the samples are stored in signed format or an unsigned format.
 Format intersects(Format format)
          Finds the attributes shared by two matching Format objects.
 boolean matches(Format format)
          Checks whether or not the specified Format matches this AudioFormat.
 java.lang.String toString()
          Gets a String representation of the attributes of this AudioFormat.
 
Methods inherited from class javax.media.Format
getDataType, getEncoding, relax
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BIG_ENDIAN

public static final int BIG_ENDIAN

LITTLE_ENDIAN

public static final int LITTLE_ENDIAN

SIGNED

public static final int SIGNED

UNSIGNED

public static final int UNSIGNED

sampleRate

protected double sampleRate

sampleSizeInBits

protected int sampleSizeInBits

channels

protected int channels

endian

protected int endian

signed

protected int signed

frameRate

protected double frameRate

frameSizeInBits

protected int frameSizeInBits

LINEAR

public static final java.lang.String LINEAR

ULAW

public static final java.lang.String ULAW

ULAW_RTP

public static final java.lang.String ULAW_RTP

ALAW

public static final java.lang.String ALAW

IMA4

public static final java.lang.String IMA4

IMA4_MS

public static final java.lang.String IMA4_MS

MSADPCM

public static final java.lang.String MSADPCM

DVI

public static final java.lang.String DVI

DVI_RTP

public static final java.lang.String DVI_RTP

G723

public static final java.lang.String G723

G723_RTP

public static final java.lang.String G723_RTP

G728

public static final java.lang.String G728

G728_RTP

public static final java.lang.String G728_RTP

G729

public static final java.lang.String G729

G729_RTP

public static final java.lang.String G729_RTP

G729A

public static final java.lang.String G729A

G729A_RTP

public static final java.lang.String G729A_RTP

GSM

public static final java.lang.String GSM

GSM_MS

public static final java.lang.String GSM_MS

GSM_RTP

public static final java.lang.String GSM_RTP

MAC3

public static final java.lang.String MAC3

MAC6

public static final java.lang.String MAC6

TRUESPEECH

public static final java.lang.String TRUESPEECH

MSNAUDIO

public static final java.lang.String MSNAUDIO

MPEGLAYER3

public static final java.lang.String MPEGLAYER3

VOXWAREAC8

public static final java.lang.String VOXWAREAC8

VOXWAREAC10

public static final java.lang.String VOXWAREAC10

VOXWAREAC16

public static final java.lang.String VOXWAREAC16

VOXWAREAC20

public static final java.lang.String VOXWAREAC20

VOXWAREMETAVOICE

public static final java.lang.String VOXWAREMETAVOICE

VOXWAREMETASOUND

public static final java.lang.String VOXWAREMETASOUND

VOXWARERT29H

public static final java.lang.String VOXWARERT29H

VOXWAREVR12

public static final java.lang.String VOXWAREVR12

VOXWAREVR18

public static final java.lang.String VOXWAREVR18

VOXWARETQ40

public static final java.lang.String VOXWARETQ40

VOXWARETQ60

public static final java.lang.String VOXWARETQ60

MSRT24

public static final java.lang.String MSRT24

MPEG

public static final java.lang.String MPEG

MPEG_RTP

public static final java.lang.String MPEG_RTP

DOLBYAC3

public static final java.lang.String DOLBYAC3
Constructor Detail

AudioFormat

public AudioFormat(java.lang.String encoding)
Constructs an AudioFormat with the specified encoding type.
Parameters:
encoding - The audio encoding type.

AudioFormat

public AudioFormat(java.lang.String encoding,
                   double sampleRate,
                   int sampleSizeInBits,
                   int channels)
Constructs an AudioFormat with the specified attributes.
Parameters:
encoding - A String that describes the encoding type for this AudioFormat.
sampleRate - The sample rate.
sampleSizeInBits - The sample size in bits.
channels - The number of channels as an integer. For example, 1 for mono, 2 for stereo.

AudioFormat

public AudioFormat(java.lang.String encoding,
                   double sampleRate,
                   int sampleSizeInBits,
                   int channels,
                   int endian,
                   int signed)
Constructs an AudioFormat with the specified attributes.
Parameters:
encoding - A String that describes the encoding type for this AudioFormat.
sampleRate - The sample rate.
sampleSizeInBits - The sample size in bits.
channels - The number of channels.
endian - The sample byte ordering used for this AudioFormat--BIG_ENDIAN or LITTLE_ENDIAN.
signed - Indicates whether the samples are stored in a signed or unsigned format. Specify true if the AudioFormat is signed, false if the AudioFormat is unsigned.

AudioFormat

public AudioFormat(java.lang.String encoding,
                   double sampleRate,
                   int sampleSizeInBits,
                   int channels,
                   int endian,
                   int signed,
                   int frameSizeInBits,
                   double frameRate,
                   java.lang.Class dataType)
Constructs an AudioFormat with the specified attributes.
Parameters:
encoding - A String that describes the encoding type for this AudioFormat.
sampleRate - The sample rate.
sampleSizeInBits - The sample size.
channels - The number of channels.
endian - The sample byte ordering used for this AudioFormat--BIG_ENDIAN or LITTLE_ENDIAN.
signed - Indicates whether the samples are stored in a signed or unsigned format. Specify true if the AudioFormat is signed, false if the AudioFormat is unsigned.
frameSizeInBits - The frame size.
frameRate - The frame rate.
dataType - The type of the data. For example, byte array.
Method Detail

getSampleRate

public double getSampleRate()
Gets the audio sample rate.
Returns:
The sample rate.

getSampleSizeInBits

public int getSampleSizeInBits()
Gets the size of a sample.
Returns:
The sample size in bits.

getChannels

public int getChannels()
Gets the number of channels.
Returns:
The number of channels as an integer.

getEndian

public int getEndian()
Gets an integer that indicates whether the sample byte order is big endian or little endian.
Returns:
The sample byte order of this AudioFormat, BIG_ENDIAN or LITTLE_ENDIAN.

getSigned

public int getSigned()
Gets a boolean that indicates whether the samples are stored in signed format or an unsigned format.
Returns:
SIGNED if this VideoFormat is signed, UNSIGNED if it is not.

getFrameSizeInBits

public int getFrameSizeInBits()
Gets the frame size of this AudioFormat. This method is used primarily for compressed audio.
Returns:
The frame size of this AudioFormat in bits.

getFrameRate

public double getFrameRate()
Gets the frame rate of this AudioFormat.
Returns:
The frame rate.

computeDuration

public long computeDuration(long length)
Returns the duration of the media based on the given length of the data.
Parameters:
length - length of the data in this format.
Returns:
the duration in nanoseconds computed from the length of the data in this format. Returns -1 if the duration cannot be computed.

toString

public java.lang.String toString()
Gets a String representation of the attributes of this AudioFormat. For example: "PCM, 44.1 KHz, Stereo, Signed".
Overrides:
toString in class Format
Returns:
A String that describes the AudioFormat attributes.

equals

public boolean equals(java.lang.Object format)
Compares the specified Format with this AudioFormat. Returns true only if the specified Format is an AudioFormat and all of its attributes are identical to this AudioFormat.
Overrides:
equals in class Format
Parameters:
format - The Format to compare with this one.
Returns:
true if the specified Format is the same, false if it is not.

matches

public boolean matches(Format format)
Checks whether or not the specified Format matches this AudioFormat. Matches only compares the attributes that are defined in the specified Format, unspecified attributes are ignored.

The two Format objects do not have to be of the same class to match. For example, if "A" are "B" are being compared, a match is possible if "A" is derived from "B" or "B" is derived from "A". (The compared attributes must still match, or matches fails.)

Overrides:
matches in class Format
Parameters:
format - The Format to compare with this one.
Returns:
true if the specified Format matches this one, false if it does not.

intersects

public Format intersects(Format format)
Finds the attributes shared by two matching Format objects. If the specified Format does not match this one, the result is undefined.
Overrides:
intersects in class Format
Parameters:
The - matching Format to intersect with this AudioFormat.
Returns:
A Format object with its attributes set to those attributes common to both Format objects.
See Also:
matches(javax.media.Format)

clone

public java.lang.Object clone()
Creates a clone of this AudioFormat by copying each field to the clone.
Overrides:
clone in class Format
Returns:
A clone of this AudioFormat.

copy

protected void copy(Format f)
Copies the attributes from the specified Format into this AudioFormat.
Overrides:
copy in class Format
Parameters:
f - The Format to copy the attributes from.


Submit a bug or feature
Copyright 1999-2000 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved. See the Specification License for more details.
Sun, Sun Microsystems, and Java are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.