org.jaudiotagger.audio.generic
Class GenericAudioHeader

java.lang.Object
  extended by org.jaudiotagger.audio.generic.GenericAudioHeader
All Implemented Interfaces:
AudioHeader
Direct Known Subclasses:
Mp4AudioHeader

public class GenericAudioHeader
extends java.lang.Object
implements AudioHeader

This class represents a structure for storing and retrieving information about the codec respectively the encoding parameters.
Most of the parameters are available for nearly each audio format. Some others would result in standard values.
Consider: None of the setter methods will actually affect the audio file. This is just a structure for retrieving information, not manipulating the audio file.

Author:
Raphael Slinckx

Field Summary
protected  java.util.HashMap<java.lang.String,java.lang.Object> content
          This table containts the parameters.
static java.lang.String FIELD_BITRATE
          The key for the Bitrate.(Integer)
static java.lang.String FIELD_CHANNEL
          The key for the number of audio channels.(Integer)
static java.lang.String FIELD_INFOS
          The key for the extra encoding information.(String)
static java.lang.String FIELD_LENGTH
          The key for the audio clip duration in seconds.
static java.lang.String FIELD_SAMPLERATE
          The key for the audio sample rate in "Hz".
static java.lang.String FIELD_TYPE
          The key for the audio type.(String)
static java.lang.String FIELD_VBR
          The key for the VBR flag.
private  boolean isLossless
          Used for WMA files
 
Constructor Summary
GenericAudioHeader()
          Creates an instance with emtpy values.
 
Method Summary
 java.lang.String getBitRate()
           
 long getBitRateAsNumber()
          This method returns the bitrate of the represented audio clip in "Kbps".
 int getChannelNumber()
          This method returns the number of audio channels the clip contains.
(The stereo, mono thing).
 java.lang.String getChannels()
           
 java.lang.String getEncodingType()
          Returns the encoding type.
 java.lang.String getExtraEncodingInfos()
          This method returns some extra information about the encoding.
This may not contain anything for some audio formats.
 java.lang.String getFormat()
          Returns the format, same as encoding type
 float getPreciseLength()
          This method returns the duration of the represented audio clip in seconds (single-precision).
 java.lang.String getSampleRate()
          This method returns the sample rate, the audio clip was encoded with.
 int getSampleRateAsNumber()
           
 int getTrackLength()
          This method returns the duration of the represented audio clip in seconds.
 boolean isLossless()
          This method returns true, if the audio file is encoded with "Lossless".
 boolean isVariableBitRate()
          This method returns true, if the audio file is encoded with "Variable Bitrate".
 void setBitrate(int bitrate)
          This Method sets the bitrate in "Kbps".
 void setChannelNumber(int chanNb)
          Sets the number of channels.
 void setEncodingType(java.lang.String encodingType)
          Sets the type of the encoding.
This is a bit format specific.
eg:Layer I/II/III
 void setExtra(java.lang.String key, java.lang.Object value)
          Can be used to add additional information
 void setExtraEncodingInfos(java.lang.String infos)
          A string containing anything else that might be interesting
 void setLength(int length)
          This method sets the audio duration of the represented clip.
 void setLossless(boolean b)
          Sets the Lossless flag for the represented audio clip.
 void setPreciseLength(float seconds)
          This method sets the audio duration of the represented clip.
 void setSamplingRate(int samplingRate)
          Sets the Sampling rate in "Hz"
 void setVariableBitRate(boolean b)
          Sets the VBR flag for the represented audio clip.
 java.lang.String toString()
          Pretty prints this encoding info
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FIELD_BITRATE

public static final java.lang.String FIELD_BITRATE
The key for the Bitrate.(Integer)

See Also:
content, Constant Field Values

FIELD_CHANNEL

public static final java.lang.String FIELD_CHANNEL
The key for the number of audio channels.(Integer)

See Also:
content, Constant Field Values

FIELD_INFOS

public static final java.lang.String FIELD_INFOS
The key for the extra encoding information.(String)

See Also:
content, Constant Field Values

FIELD_LENGTH

public static final java.lang.String FIELD_LENGTH
The key for the audio clip duration in seconds. (Float)

See Also:
content, Constant Field Values

FIELD_SAMPLERATE

public static final java.lang.String FIELD_SAMPLERATE
The key for the audio sample rate in "Hz". (Integer)

See Also:
content, Constant Field Values

FIELD_TYPE

public static final java.lang.String FIELD_TYPE
The key for the audio type.(String)

See Also:
content, Constant Field Values

FIELD_VBR

public static final java.lang.String FIELD_VBR
The key for the VBR flag. (Boolean)

See Also:
content, Constant Field Values

isLossless

private boolean isLossless
Used for WMA files


content

protected java.util.HashMap<java.lang.String,java.lang.Object> content
This table containts the parameters.

Constructor Detail

GenericAudioHeader

public GenericAudioHeader()
Creates an instance with emtpy values.

Method Detail

getBitRate

public java.lang.String getBitRate()
Specified by:
getBitRate in interface AudioHeader
Returns:
the BitRate of the Audio

getBitRateAsNumber

public long getBitRateAsNumber()
This method returns the bitrate of the represented audio clip in "Kbps".

Specified by:
getBitRateAsNumber in interface AudioHeader
Returns:
The bitrate in Kbps.

getChannelNumber

public int getChannelNumber()
This method returns the number of audio channels the clip contains.
(The stereo, mono thing).

Returns:
The number of channels. (2 for stereo, 1 for mono)

getChannels

public java.lang.String getChannels()
Specified by:
getChannels in interface AudioHeader
Returns:

getEncodingType

public java.lang.String getEncodingType()
Returns the encoding type.

Specified by:
getEncodingType in interface AudioHeader
Returns:
The encoding type

getFormat

public java.lang.String getFormat()
Returns the format, same as encoding type

Specified by:
getFormat in interface AudioHeader
Returns:
The encoding type

getExtraEncodingInfos

public java.lang.String getExtraEncodingInfos()
This method returns some extra information about the encoding.
This may not contain anything for some audio formats.

Returns:
Some extra information.

getTrackLength

public int getTrackLength()
This method returns the duration of the represented audio clip in seconds.

Specified by:
getTrackLength in interface AudioHeader
Returns:
The duration in seconds.
See Also:
getPreciseLength()

getPreciseLength

public float getPreciseLength()
This method returns the duration of the represented audio clip in seconds (single-precision).

Returns:
The duration in seconds.
See Also:
getTrackLength()

getSampleRate

public java.lang.String getSampleRate()
This method returns the sample rate, the audio clip was encoded with.

Specified by:
getSampleRate in interface AudioHeader
Returns:
Sample rate of the audio clip in "Hz".

getSampleRateAsNumber

public int getSampleRateAsNumber()
Specified by:
getSampleRateAsNumber in interface AudioHeader
Returns:

isVariableBitRate

public boolean isVariableBitRate()
This method returns true, if the audio file is encoded with "Variable Bitrate".

Specified by:
isVariableBitRate in interface AudioHeader
Returns:
true if audio clip is encoded with VBR.

isLossless

public boolean isLossless()
This method returns true, if the audio file is encoded with "Lossless".

Returns:
true if audio clip is encoded with VBR.

setBitrate

public void setBitrate(int bitrate)
This Method sets the bitrate in "Kbps".

Parameters:
bitrate - bitrate in kbps.

setChannelNumber

public void setChannelNumber(int chanNb)
Sets the number of channels.

Parameters:
chanNb - number of channels (2 for stereo, 1 for mono).

setEncodingType

public void setEncodingType(java.lang.String encodingType)
Sets the type of the encoding.
This is a bit format specific.
eg:Layer I/II/III

Parameters:
encodingType - Encoding type.

setExtraEncodingInfos

public void setExtraEncodingInfos(java.lang.String infos)
A string containing anything else that might be interesting

Parameters:
infos - Extra information.

setLength

public void setLength(int length)
This method sets the audio duration of the represented clip.

Parameters:
length - The duration of the audio clip in seconds.

setPreciseLength

public void setPreciseLength(float seconds)
This method sets the audio duration of the represented clip.

Parameters:
seconds - The duration of the audio clip in seconds (single-precision).

setSamplingRate

public void setSamplingRate(int samplingRate)
Sets the Sampling rate in "Hz"

Parameters:
samplingRate - Sample rate.

setVariableBitRate

public void setVariableBitRate(boolean b)
Sets the VBR flag for the represented audio clip.

Parameters:
b - true if VBR.

setLossless

public void setLossless(boolean b)
Sets the Lossless flag for the represented audio clip.

Parameters:
b - true if Lossless.

setExtra

public void setExtra(java.lang.String key,
                     java.lang.Object value)
Can be used to add additional information

Parameters:
key -
value -

toString

public java.lang.String toString()
Pretty prints this encoding info

Overrides:
toString in class java.lang.Object
See Also:
Object.toString()