FileDocCategorySizeDatePackage
GenericAudioHeader.javaAPI DocJaudiotagger 2.0.49709Wed Mar 30 16:11:52 BST 2011org.jaudiotagger.audio.generic

GenericAudioHeader

public class GenericAudioHeader extends Object implements org.jaudiotagger.audio.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

Fields Summary
public static final String
FIELD_BITRATE
The key for the Bitrate.({@link Integer})
public static final String
FIELD_CHANNEL
The key for the number of audio channels.({@link Integer})
public static final String
FIELD_INFOS
The key for the extra encoding information.({@link String})
public static final String
FIELD_LENGTH
The key for the audio clip duration in seconds. ({@link Float})
public static final String
FIELD_SAMPLERATE
The key for the audio sample rate in "Hz". ({@link Integer})
public static final String
FIELD_TYPE
The key for the audio type.({@link String})
public static final String
FIELD_VBR
The key for the VBR flag. ({@link Boolean})
private boolean
isLossless
Used for WMA files
protected HashMap
content
This table containts the parameters.
Constructors Summary
public GenericAudioHeader()
Creates an instance with emtpy values.


               
     
    
        content = new HashMap<String, Object>(6);
        content.put(FIELD_BITRATE, -1);
        content.put(FIELD_CHANNEL, -1);
        content.put(FIELD_TYPE, "");
        content.put(FIELD_INFOS, "");
        content.put(FIELD_SAMPLERATE, -1);
        content.put(FIELD_LENGTH, (float) -1);
        content.put(FIELD_VBR, true);
    
Methods Summary
public java.lang.StringgetBitRate()

        return content.get(FIELD_BITRATE).toString();
    
public longgetBitRateAsNumber()
This method returns the bitrate of the represented audio clip in "Kbps".

return
The bitrate in Kbps.

        return ((Integer) content.get(FIELD_BITRATE)).longValue();
    
public intgetChannelNumber()
This method returns the number of audio channels the clip contains.
(The stereo, mono thing).

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

        return (Integer) content.get(FIELD_CHANNEL);
    
public java.lang.StringgetChannels()

return

        return String.valueOf(getChannelNumber());
    
public java.lang.StringgetEncodingType()
Returns the encoding type.

return
The encoding type

        return (String) content.get(FIELD_TYPE);
    
public java.lang.StringgetExtraEncodingInfos()
This method returns some extra information about the encoding.
This may not contain anything for some audio formats.

return
Some extra information.

        return (String) content.get(FIELD_INFOS);
    
public java.lang.StringgetFormat()
Returns the format, same as encoding type

return
The encoding type

        return (String) content.get(FIELD_TYPE);
    
public floatgetPreciseLength()
This method returns the duration of the represented audio clip in seconds (single-precision).

return
The duration in seconds.
see
#getTrackLength()

        return (Float) content.get(FIELD_LENGTH);
    
public java.lang.StringgetSampleRate()
This method returns the sample rate, the audio clip was encoded with.

return
Sample rate of the audio clip in "Hz".

        return content.get(FIELD_SAMPLERATE).toString();
    
public intgetSampleRateAsNumber()

        return (Integer) content.get(FIELD_SAMPLERATE);
    
public intgetTrackLength()
This method returns the duration of the represented audio clip in seconds.

return
The duration in seconds.
see
#getPreciseLength()

        return (int) getPreciseLength();
    
public booleanisLossless()
This method returns true, if the audio file is encoded with "Lossless".

return
true if audio clip is encoded with VBR.

        return isLossless;
    
public booleanisVariableBitRate()
This method returns true, if the audio file is encoded with "Variable Bitrate".

return
true if audio clip is encoded with VBR.

        return (Boolean) content.get(FIELD_VBR);
    
public voidsetBitrate(int bitrate)
This Method sets the bitrate in "Kbps".

param
bitrate bitrate in kbps.

        content.put(FIELD_BITRATE, bitrate);
    
public voidsetChannelNumber(int chanNb)
Sets the number of channels.

param
chanNb number of channels (2 for stereo, 1 for mono).

        content.put(FIELD_CHANNEL, chanNb);
    
public voidsetEncodingType(java.lang.String encodingType)
Sets the type of the encoding.
This is a bit format specific.
eg:Layer I/II/III

param
encodingType Encoding type.

        content.put(FIELD_TYPE, encodingType);
    
public voidsetExtra(java.lang.String key, java.lang.Object value)
Can be used to add additional information

param
key
param
value

        content.put(key, value);
    
public voidsetExtraEncodingInfos(java.lang.String infos)
A string containing anything else that might be interesting

param
infos Extra information.

        content.put(FIELD_INFOS, infos);
    
public voidsetLength(int length)
This method sets the audio duration of the represented clip.

param
length The duration of the audio clip in seconds.

        content.put(FIELD_LENGTH, (float) length);
    
public voidsetLossless(boolean b)
Sets the Lossless flag for the represented audio clip.

param
b true if Lossless.

        isLossless = b;
    
public voidsetPreciseLength(float seconds)
This method sets the audio duration of the represented clip.

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

        content.put(FIELD_LENGTH, seconds);
    
public voidsetSamplingRate(int samplingRate)
Sets the Sampling rate in "Hz"

param
samplingRate Sample rate.

        content.put(FIELD_SAMPLERATE, samplingRate);
    
public voidsetVariableBitRate(boolean b)
Sets the VBR flag for the represented audio clip.

param
b true if VBR.

        content.put(FIELD_VBR, b);
    
public java.lang.StringtoString()
Pretty prints this encoding info

see
java.lang.Object#toString()

        StringBuffer out = new StringBuffer(50);
        out.append("Encoding infos content:\n");
        Set<String> set = content.keySet();
        for (String key : set)
        {
            Object val = content.get(key);
            out.append("\t");
            out.append(key);
            out.append(" : ");
            out.append(val);
            out.append("\n");
        }
        return out.toString().substring(0, out.length() - 1);