/*------------ Telecommunications & Signal Processing Lab --------------
                         McGill University

Routine:
  AIpar.h

Description:
  Declarations for AIFF and AIFF-C audio file headers

Author / revision:
  P. Kabal  Copyright (C) 1998
  $Revision: 1.11 $  $Date: 1998/06/15 18:17:01 $

----------------------------------------------------------------------*/

#ifndef AIpar_h_
#define AIpar_h_

#include <libtsp/UTtypes.h>		/* typedef for uint2_t, etc */

/* AIFF or AIFF-C file layout
  FORM chunk           8 + 4 + FVER/COMM/SSND chunks
  FVER chunk           8 + 4  (AIFF-C files only)
  COMM chunk           8 + 18 + compressionType (4 bytes)
                         + compressionName (min length 2)
  SSND chunk           8 + 8 + data

  AIFF files do not have the compressionType and compressionName fields in the
  COMM chunk.  The minimum length AIFF file is 54 bytes long; the minimum
  length AIFF-C file is 72 bytes long.
*/

#define AI_LHMIN	54

/* File magic in file byte order */
#define FM_IFF		"FORM"
#  define FM_AIFF	"AIFF"
#  define FM_AIFF_C	"AIFC"
#define CKID_COMM	"COMM"
#define CKID_FVER	"FVER"
#define CKID_SSND	"SSND"
#define CKID_NAME	"NAME"
#define CKID_AUTHOR	"AUTH"
#define CKID_COPYRIGHT	"(c) "
#define CKID_ANNOTATION	"ANNO"

#define CT_NONE		"NONE"
#define CT_ULAW		"ULAW"
#define CT_ALAW		"ALAW"

/* Pascal strings: length byte followed by string */
#define CN_NONE		"\016not compressed"
#define CN_ULAW		"\022ITU-T G.711 mu-law"
#define CN_ALAW		"\021ITU-T G.711 A-law"

#define AI_SF_ULAW	(1.)
#define AI_SF_ALAW	(1.)
#define AI_SF_NONE8	(128.)
#define AI_SF_NONE16	(1.)

#define AIFCVersion1	0xA2805140	/* AIFF-C Version 1 identifier */

struct AI_CkPreamb {
  char ckID[4];
  uint4_t ckDataSize;
};

struct AI_CkCOMM {
  uint2_t numChannels;
  uint4_t numSampleFrames;
  uint2_t sampleSize;
  unsigned char sampleRate[10];
  char compressionType[4];
  char compressionName[33];	/* Room for a 32 character string */
};

struct AI_CkFVER {
  uint4_t timestamp;
};

struct AI_CkSSND {
  uint4_t offset;
  uint4_t blockSize;
};

#endif	/* AIpar_h_ */
