FileDocCategorySizeDatePackage
AudioStreamChunk.javaAPI DocJaudiotagger 2.0.49100Wed Mar 30 16:11:50 BST 2011org.jaudiotagger.audio.asf.data

AudioStreamChunk

public final class AudioStreamChunk extends StreamChunk
This class represents the stream chunk describing an audio stream.
author
Christian Laireiter

Fields Summary
public static final String[]
CODEC_DESCRIPTIONS
Stores the hex values of codec identifiers to their descriptions.
public static final long
WMA
Stores the audio codec number for WMA
public static final long
WMA_CBR
Stores the audio codec number for WMA (CBR)
public static final long
WMA_LOSSLESS
Stores the audio codec number for WMA_LOSSLESS
public static final long
WMA_PRO
Stores the audio codec number for WMA_PRO
public static final long
WMA_VBR
Stores the audio codec number for WMA (VBR)
private long
averageBytesPerSec
Stores the average amount of bytes used by audio stream.
This value is a field within type specific data of audio stream. Maybe it could be used to calculate the KBPs.
private int
bitsPerSample
Amount of bits used per sample.
private long
blockAlignment
The block alignment of the audio data.
private long
channelCount
Number of channels.
private byte[]
codecData
Some data which needs to be interpreted if the codec is handled.
private long
compressionFormat
The audio compression format code.
private GUID
errorConcealment
this field stores the error concealment type.
private long
samplingRate
Sampling rate of audio stream.
Constructors Summary
public AudioStreamChunk(BigInteger chunkLen)
Creates an instance.

param
chunkLen Length of the entire chunk (including guid and size)


                                   
        
        super(GUID.GUID_AUDIOSTREAM, chunkLen);
    
Methods Summary
public longgetAverageBytesPerSec()

return
Returns the averageBytesPerSec.

        return this.averageBytesPerSec;
    
public intgetBitsPerSample()

return
Returns the bitsPerSample.

        return this.bitsPerSample;
    
public longgetBlockAlignment()

return
Returns the blockAlignment.

        return this.blockAlignment;
    
public longgetChannelCount()

return
Returns the channelCount.

        return this.channelCount;
    
public byte[]getCodecData()

return
Returns the codecData.

        return this.codecData.clone();
    
public java.lang.StringgetCodecDescription()
This method will take a look at {@link #compressionFormat}and returns a String with its hex value and if known a textual note on what coded it represents.

return
A description for the used codec.

        final StringBuilder result = new StringBuilder(Long
                .toHexString(getCompressionFormat()));
        String furtherDesc = " (Unknown)";
        for (final String[] aCODEC_DESCRIPTIONS : CODEC_DESCRIPTIONS) {
            if (aCODEC_DESCRIPTIONS[0].equalsIgnoreCase(result.toString())) {
                furtherDesc = aCODEC_DESCRIPTIONS[1];
                break;
            }
        }
        if (result.length() % 2 == 0) {
            result.insert(0, "0x");
        } else {
            result.insert(0, "0x0");
        }
        result.append(furtherDesc);
        return result.toString();
    
public longgetCompressionFormat()

return
Returns the compressionFormat.

        return this.compressionFormat;
    
public GUIDgetErrorConcealment()

return
Returns the errorConcealment.

        return this.errorConcealment;
    
public intgetKbps()
This method takes the value of {@link #getAverageBytesPerSec()}and calculates the kbps out of it, by simply multiplying by 8 and dividing by 1000.

return
amount of bits per second in kilo bits.

        return (int) getAverageBytesPerSec() * 8 / 1000;
    
public longgetSamplingRate()

return
Returns the samplingRate.

        return this.samplingRate;
    
public booleanisErrorConcealed()
This mehtod returns whether the audio stream data is error concealed.
For now only interleaved concealment is known.

return
true if error concealment is used.

        return getErrorConcealment().equals(
                GUID.GUID_AUDIO_ERROR_CONCEALEMENT_INTERLEAVED);
    
public java.lang.StringprettyPrint(java.lang.String prefix)
{@inheritDoc}

        final StringBuilder result = new StringBuilder(super.prettyPrint(prefix));
        result.append(prefix).append("  |-> Audio info:").append(
                Utils.LINE_SEPARATOR);
        result.append(prefix).append("  |  : Bitrate : ").append(getKbps())
                .append(Utils.LINE_SEPARATOR);
        result.append(prefix).append("  |  : Channels : ").append(
                getChannelCount()).append(" at ").append(getSamplingRate())
                .append(" Hz").append(Utils.LINE_SEPARATOR);
        result.append(prefix).append("  |  : Bits per Sample: ").append(
                getBitsPerSample()).append(Utils.LINE_SEPARATOR);
        result.append(prefix).append("  |  : Formatcode: ").append(
                getCodecDescription()).append(Utils.LINE_SEPARATOR);
        return result.toString();
    
public voidsetAverageBytesPerSec(long avgeBytesPerSec)

param
avgeBytesPerSec The averageBytesPerSec to set.

        this.averageBytesPerSec = avgeBytesPerSec;
    
public voidsetBitsPerSample(int bps)
Sets the bitsPerSample

param
bps

        this.bitsPerSample = bps;
    
public voidsetBlockAlignment(long align)
Sets the blockAlignment.

param
align

        this.blockAlignment = align;
    
public voidsetChannelCount(long channels)

param
channels The channelCount to set.

        this.channelCount = channels;
    
public voidsetCodecData(byte[] codecSpecificData)
Sets the codecData

param
codecSpecificData

        if (codecSpecificData == null) {
            throw new IllegalArgumentException();
        }
        this.codecData = codecSpecificData.clone();
    
public voidsetCompressionFormat(long cFormatCode)

param
cFormatCode The compressionFormat to set.

        this.compressionFormat = cFormatCode;
    
public voidsetErrorConcealment(GUID errConc)
This method sets the error concealment type which is given by two GUIDs.

param
errConc the type of error concealment the audio stream is stored as.

        this.errorConcealment = errConc;
    
public voidsetSamplingRate(long sampRate)

param
sampRate The samplingRate to set.

        this.samplingRate = sampRate;