org.kc7bfi.jflac
Class FLACDecoder

java.lang.Object
  extended by org.kc7bfi.jflac.FLACDecoder

public class FLACDecoder
extends Object

A Java FLAC decoder.

Author:
kc7bfi

Constructor Summary
FLACDecoder(InputStream inputStream)
          The constructor.
 
Method Summary
 void addFrameListener(FrameListener listener)
          Add a frame listener.
 void addPCMProcessor(PCMProcessor processor)
          Add a PCM processor.
 void decode()
          Decode the FLAC file.
 void decode(SeekPoint from, SeekPoint to)
          Decode the data frames between two seek points.
 ByteData decodeFrame(Frame frame, ByteData pcmData)
          Fill the given ByteData object with PCM data from the frame.
 void decodeFrames()
          Decode the data frames.
 int getBadFrames()
           
 BitInputStream getBitInputStream()
          Return the input but stream.
 ChannelData[] getChannelData()
          Return the ChannelData object.
 long getSamplesDecoded()
          Get the number of samples decoded.
 StreamInfo getStreamInfo()
          Return the parsed StreamInfo Metadata record.
 long getTotalBytesRead()
          Bytes read.
 boolean isEOF()
           
 void readFrame()
          Read the next data frame.
 Metadata[] readMetadata()
          Read an array of metadata blocks.
 Metadata[] readMetadata(StreamInfo streamInfo)
          Read an array of metadata blocks.
 Frame readNextFrame()
          Read the next data frame.
 Metadata readNextMetadata()
          Read a single metadata record.
 StreamInfo readStreamInfo()
          Read the FLAC stream info.
 void removeFrameListener(FrameListener listener)
          Remove a frame listener.
 void removePCMProcessor(PCMProcessor processor)
          Remove a PCM processor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FLACDecoder

public FLACDecoder(InputStream inputStream)
The constructor.

Parameters:
inputStream - The input stream to read data from
Method Detail

getStreamInfo

public StreamInfo getStreamInfo()
Return the parsed StreamInfo Metadata record.

Returns:
The StreamInfo

getChannelData

public ChannelData[] getChannelData()
Return the ChannelData object.

Returns:
The ChannelData object

getBitInputStream

public BitInputStream getBitInputStream()
Return the input but stream.

Returns:
The bit stream

addFrameListener

public void addFrameListener(FrameListener listener)
Add a frame listener.

Parameters:
listener - The frame listener to add

removeFrameListener

public void removeFrameListener(FrameListener listener)
Remove a frame listener.

Parameters:
listener - The frame listener to remove

addPCMProcessor

public void addPCMProcessor(PCMProcessor processor)
Add a PCM processor.

Parameters:
processor - The processor listener to add

removePCMProcessor

public void removePCMProcessor(PCMProcessor processor)
Remove a PCM processor.

Parameters:
processor - The processor listener to remove

decodeFrame

public ByteData decodeFrame(Frame frame,
                            ByteData pcmData)
Fill the given ByteData object with PCM data from the frame.

Parameters:
frame - the frame to send to the PCM processors
pcmData - the byte data to be filled, or null if it should be allocated
Returns:
the ByteData that was filled (may be a new instance from space)

readStreamInfo

public StreamInfo readStreamInfo()
                          throws IOException
Read the FLAC stream info.

Returns:
The FLAC Stream Info record
Throws:
IOException - On read error

readMetadata

public Metadata[] readMetadata()
                        throws IOException
Read an array of metadata blocks.

Returns:
The array of metadata blocks
Throws:
IOException - On read error

readMetadata

public Metadata[] readMetadata(StreamInfo streamInfo)
                        throws IOException
Read an array of metadata blocks.

Parameters:
streamInfo - The StreamInfo metadata block previously read
Returns:
The array of metadata blocks
Throws:
IOException - On read error

decode

public void decode()
            throws IOException
Decode the FLAC file.

Throws:
IOException - On read error

decodeFrames

public void decodeFrames()
                  throws IOException
Decode the data frames.

Throws:
IOException - On read error

decode

public void decode(SeekPoint from,
                   SeekPoint to)
            throws IOException
Decode the data frames between two seek points.

Parameters:
from - The starting seek point
to - The ending seek point (non-inclusive)
Throws:
IOException - On read error

readNextFrame

public Frame readNextFrame()
                    throws IOException
Read the next data frame.

Returns:
The next frame
Throws:
IOException - on read error

getTotalBytesRead

public long getTotalBytesRead()
Bytes read.

Returns:
The number of bytes read

readNextMetadata

public Metadata readNextMetadata()
                          throws IOException
Read a single metadata record.

Returns:
The next metadata record
Throws:
IOException - on read error

readFrame

public void readFrame()
               throws IOException,
                      FrameDecodeException
Read the next data frame.

Throws:
IOException - On read error
FrameDecodeException - On frame decoding error

getSamplesDecoded

public long getSamplesDecoded()
Get the number of samples decoded.

Returns:
Returns the samples Decoded.

getBadFrames

public int getBadFrames()
Returns:
Returns the number of bad frames decoded.

isEOF

public boolean isEOF()
Returns:
Returns true if end-of-file.


Copyright © 2004-2011. All Rights Reserved.