com.softsynth.jsyn
Class ParseIFF

java.lang.Object
  extended by com.softsynth.jsyn.ParseIFF
Direct Known Subclasses:
ParseRIFF

public class ParseIFF
extends java.lang.Object

Parse EA style IFF File IFF is a file format that allows "chunks" of data to be placed in a hierarchical file. It was designed by Jerry Morrison at Electronic Arts for the Amiga computer and is now used extensively by Apple Computer and other companies.

Author:
(C) 1997 Phil Burk, SoftSynth.com, All Rights Reserved
See Also:
ParseRIFF, SynthSampleAIFF

Field Summary
static int FORM_ID
           
static int LIST_ID
           
 
Constructor Summary
ParseIFF(java.io.InputStream stream)
           
 
Method Summary
 long getFileSize()
          Size of file based on outermost chunk size plus 8.
 long getOffset()
          Since IFF files use chunks with explicit size, it is important to keep track of how many bytes have been read from the file.
static java.lang.String IDToString(int ID)
          Convert a 4 character IFF ID to a String
 boolean isForm(int ckid)
          Does the following chunk ID correspond to a container type like FORM?
 void parse(ChunkHandler handler)
          Parse the stream and pass the forms and chunks to the ChunkHandler
 int read()
           
 int read(byte[] bar)
           
 byte readByte()
          Read 8 bit signed byte.
 int readChunkSize()
          Read 32 bit signed int assuming IFF order.
 int readIntBig()
          Read 32 bit signed integer assuming Big Endian byte order.
 int readIntLittle()
          Read 32 bit signed integer assuming Little Endian byte order.
 short readShortBig()
          Read 16 bit signed short assuming Big Endian byte order.
 short readShortLittle()
          Read 16 bit signed short assuming Little Endian byte order.
 long skip(long numBytes)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LIST_ID

public static final int LIST_ID
See Also:
Constant Field Values

FORM_ID

public static final int FORM_ID
See Also:
Constant Field Values
Constructor Detail

ParseIFF

public ParseIFF(java.io.InputStream stream)
Method Detail

getFileSize

public long getFileSize()
Size of file based on outermost chunk size plus 8. Can be used to report progress when loading samples.

Returns:
Number of bytes in outer chunk plus header.

getOffset

public long getOffset()
Since IFF files use chunks with explicit size, it is important to keep track of how many bytes have been read from the file. Can be used to report progress when loading samples.

Returns:
Number of bytes read from stream, or skipped.

read

public int read()
         throws java.io.IOException
Returns:
Next byte from stream. Increment offset by 1.
Throws:
java.io.IOException

read

public int read(byte[] bar)
         throws java.io.IOException
Returns:
Next byte array from stream. Increment offset by bar.length.
Throws:
java.io.IOException

skip

public long skip(long numBytes)
          throws java.io.IOException
Returns:
Skip forward in stream and add numBytes to offset.
Throws:
java.io.IOException

readIntBig

public int readIntBig()
               throws java.io.IOException
Read 32 bit signed integer assuming Big Endian byte order.

Throws:
java.io.IOException

readShortBig

public short readShortBig()
                   throws java.io.IOException
Read 16 bit signed short assuming Big Endian byte order.

Throws:
java.io.IOException

readIntLittle

public int readIntLittle()
                  throws java.io.IOException
Read 32 bit signed integer assuming Little Endian byte order.

Throws:
java.io.IOException

readShortLittle

public short readShortLittle()
                      throws java.io.IOException
Read 16 bit signed short assuming Little Endian byte order.

Throws:
java.io.IOException

readByte

public byte readByte()
              throws java.io.IOException
Read 8 bit signed byte.

Throws:
java.io.IOException

readChunkSize

public int readChunkSize()
                  throws java.io.IOException
Read 32 bit signed int assuming IFF order.

Throws:
java.io.IOException

IDToString

public static java.lang.String IDToString(int ID)
Convert a 4 character IFF ID to a String


parse

public void parse(ChunkHandler handler)
           throws java.io.IOException
Parse the stream and pass the forms and chunks to the ChunkHandler

Throws:
java.io.IOException

isForm

public boolean isForm(int ckid)
               throws java.io.IOException
Does the following chunk ID correspond to a container type like FORM?

Throws:
java.io.IOException