#ifndef GIMMELIB_SOUND_H
#define GIMMELIB_SOUND_H

#ifdef I_AM_SOUND
#define Mk(a,b,c,d)     (((ULONG)(a)<<24) | ((ULONG)(b)<<16) \
				| ((ULONG)(c)<<8) | (ULONG)(d))
#define EVEN(p)         ((p+1) & ~1)

#define ID_FORM 	Mk('F', 'O', 'R', 'M')
#define ID_8SVX 	Mk('8', 'S', 'V', 'X')
#define ID_VHDR 	Mk('V', 'H', 'D', 'R')
#define ID_NAME 	Mk('N', 'A', 'M', 'E')
#define ID_COPY 	Mk('(', 'c', ')', ' ')
#define ID_AUTH 	Mk('A', 'U', 'T', 'H')
#define ID_ANNO 	Mk('A', 'N', 'N', 'O')
#define ID_ATAK 	Mk('A', 'T', 'A', 'K')
#define ID_RLSE 	Mk('R', 'L', 'S', 'E')
#define ID_BODY 	Mk('B', 'O', 'D', 'Y')
#endif I_AM_SOUND


typedef LONG Fixed;	    /* fixed point value 16bits.16bits */

#define Unity 0x10000L	    /* Unity = Fixed 1.0 = maximum volume */

#define sCmpNone	0   /* not compressed */
#define sCmpFibDelta	1   /* Fibonacci delta encoding */

typedef struct _gim_v8h {
    ULONG oneShotHiSamples; /* # samples in the high octave 1-shot part */
    LONG repeatHiSamples;   /* # samples in the high octave repeat part */
    LONG samplesPerHiCycle; /* # samples/cycle in high octave, else 0 */
    UWORD samplesPerSec;    /* data sampling rate */
    UBYTE ctOctave;	    /* # octaves of waveform */
    UBYTE sCompression;     /* data compression technique used */
    Fixed volume;	    /* playback volume from 0 to Unity */
} Voice8Header;

typedef struct {
    UWORD duration;	    /* segment duration in milliseconds, >0 */
    Fixed dest; 	    /* destination volume factor */
} EGPoint;


typedef struct _gim_snd {
    Voice8Header    vh; 	/* info for this sound */
    BYTE	    *body;	/* pointer to body data */
    LONG	    bodylen;	/* actual body length from IFF file */
    void	    *memhead;	/* memory-chain allocated for this sound */
    struct _gim_snd *next;	/* next sound (for future use) */
} SOUND;

#endif !GIMMELIB_SOUND_H
