"chunk" — IFFチャンクデータの読み込み
*************************************

このモジュールはEA IFF 85チャンクを使用しているファイルの読み込みのた
めのインターフェースを提供します。[1] このフォーマットは少なくとも、
Audio Interchange File Format (AIFF/AIFF-C) とReal Media File Format
(RMFF)で使われています。WAVEオーディオファイルフォーマットも厳密に対応
しているので、このモジュールで読み込みできます。

チャンクは以下の構造を持っています:

+-----------+----------+---------------------------------+
| Offset値  | 長さ     | 内容                            |
+===========+==========+=================================+
| 0         | 4        | チャンクID                      |
+-----------+----------+---------------------------------+
| 4         | 4        | big- endianで示したチャンクのサ |
|           |          | イズで、ヘッダは含みません      |
+-----------+----------+---------------------------------+
| 8         | *n*      | バイトデータで、*n* はこれより  |
|           |          | 先のフィールドのサイズ          |
+-----------+----------+---------------------------------+
| 8 + *n*   | 0 or 1   | *n* が奇数ならチャンクの整頓の  |
|           |          | ために埋められるバイト          |
+-----------+----------+---------------------------------+

IDはチャンクの種類を識別する4バイトの文字列です。

サイズフィールド（big-endianでエンコードされた32ビット値）は、8バイト
のヘッダを含まないチャンクデータのサイズを示します。

普通、IFFタイプのファイルは1個かそれ以上のチャンクからなります。このモ
ジュールで定義される "Chunk" クラスの使い方として提案しているのは、そ
れぞれのチャンクの始めにインスタンスを作り、終わりに達するまでそのイン
スタンスから読み取り、その後で新しいインスタンスを作るということです。
ファイルの終わりで新しいインスタンスを作ろうとすると、 "EOFError" の例
外が発生して失敗します。

class chunk.Chunk(file[, align, bigendian, inclheader])

   Class which represents a chunk.  The *file* argument is expected to
   be a file-like object.  An instance of this class is specifically
   allowed.  The only method that is needed is "read()".  If the
   methods "seek()" and "tell()" are present and don’t raise an
   exception, they are also used. If these methods are present and
   raise an exception, they are expected to not have altered the
   object.  If the optional argument *align* is true, chunks are
   assumed to be aligned on 2-byte boundaries.  If *align* is false,
   no alignment is assumed.  The default value is true.  If the
   optional argument *bigendian* is false, the chunk size is assumed
   to be in little-endian order. This is needed for WAVE audio files.
   The default value is true.  If the optional argument *inclheader*
   is true, the size given in the chunk header includes the size of
   the header.  The default value is false.

   "Chunk" オブジェクトには以下のメソッドが定義されています:

   getname()

      チャンクの名前（ID）を返します。これはチャンクの始めの4バイトで
      す。

   getsize()

      チャンクのサイズを返します。

   close()

      オブジェクトを閉じて、チャンクの終わりまで飛びます。これは元のフ
      ァイル自体は閉じません。

   The remaining methods will raise "IOError" if called after the
   "close()" method has been called.

   isatty()

      "False" を返します。

   seek(pos[, whence])

      チャンクの現在位置を設定します。引数 *whence* は省略可能で、デフ
      ォルト値は "0" （ファイルの絶対位置）です; 他に "1" （現在位置か
      ら相対的にシークします）と "2" （ファイルの末尾から相対的にシー
      クします）の値を取ります。何も値は返しません。もし元のファイルが
      シークに対応していなければ、前方へのシークのみが可能です。

   tell()

      チャンク内の現在位置を返します。

   read([size])

      Read at most *size* bytes from the chunk (less if the read hits
      the end of the chunk before obtaining *size* bytes).  If the
      *size* argument is negative or omitted, read all data until the
      end of the chunk.  The bytes are returned as a string object.
      An empty string is returned when the end of the chunk is
      encountered immediately.

   skip()

      Skip to the end of the chunk.  All further calls to "read()" for
      the chunk will return "''".  If you are not interested in the
      contents of the chunk, this method should be called so that the
      file points to the start of the next chunk.

-[ 脚注 ]-

[1] 「EA IFF 85」 Standard for Interchange Format Files, Jerry
    Morrison, Electronic Arts, January 1985.
