/*------------------------------------------------------------------------------

    File    :	AIFF.h

    Author  :	Stéphane TAVENARD

    $VER:   AIFF.h  1.0  (23/06/1995)

    (C) Copyright 1995-1995 Stéphane TAVENARD
	All Rights Reserved

    #Rev|   Date   |			  Comment
    ----|----------|--------------------------------------------------------
    0	|05/06/1995| Initial revision from file common.h of
	|	   | MPEG/audio software simulation group		  ST
    1	|23/06/1995| Aminet release					  ST

    ------------------------------------------------------------------------

    AIFF definitions and utilities

------------------------------------------------------------------------------*/

#ifndef AIFF_H
#define AIFF_H

/* AIFF Definitions */

#define MAKE_ID(a,b,c,d) ((a<<24)|(b<<16)|(c<<8)|(d))

#define IFF_ID_FORM MAKE_ID( 'F','O','R','M' )
#define IFF_ID_AIFF MAKE_ID( 'A','I','F','F' )
#define IFF_ID_COMM MAKE_ID( 'C','O','M','M' )
#define IFF_ID_SSND MAKE_ID( 'S','S','N','D' )
#define IFF_ID_MPEG MAKE_ID( 'M','P','E','G' )

#define MIN(A, B) ((A) < (B) ? (A) : (B))
#define MAX(A, B) ((A) > (B) ? (A) : (B))

/* Double and SANE Floating Point Type Definitions */

typedef struct	IEEE_DBL_struct {
    unsigned long   hi;
    unsigned long   lo;
} IEEE_DBL;

typedef struct	SANE_EXT_struct {
    unsigned long   l1;
    unsigned long   l2;
    unsigned short  s1;
} SANE_EXT;

/* AIFF Type Definitions */

typedef long ID;

typedef struct	ChunkHeader_struct {
    ID	    ckID;
    long    ckSize;
} ChunkHeader;

typedef struct	Chunk_struct {
    ID	    ckID;
    long    ckSize;
    ID	    formType;
} Chunk;

typedef struct	CommonChunk_struct {
    ID		    ckID;
    long	    ckSize;
    short	    numChannels;
    unsigned long   numSampleFrames;
    short	    sampleSize;
    char	    sampleRate[10];
} CommonChunk;

typedef struct	SoundDataChunk_struct {
    ID		    ckID;
    long	    ckSize;
    unsigned long   offset;
    unsigned long   blockSize;
} SoundDataChunk;

typedef struct	blockAlign_struct {
    unsigned long   offset;
    unsigned long   blockSize;
} blockAlign;

typedef struct	IFF_AIFF_struct {
    short	    numChannels;
    unsigned long   numSampleFrames;
    short	    sampleSize;
    double	    sampleRate;
    unsigned long   sampleType;
    blockAlign	    blkAlgn;
} IFF_AIFF;


int AIFF_read_headers( FILE *file_ptr, IFF_AIFF *aiff_ptr );
int AIFF_seek_to_sound_data( FILE *file_ptr );
int AIFF_write_headers( FILE *file_ptr, IFF_AIFF *aiff_ptr );


#endif /* AIFF_H */
