#ifndef LIBRARIES_AHI_H
#define LIBRARIES_AHI_H

/*
**	$VER: ahi.h 1.3 (2.1.96)
**
**	ahi.library definitions
**
**	(C) Copyright 1994-1996 Martin Blom
**	All Rights Reserved.
**
** (TAB SIZE: 8)
*/

/*****************************************************************************/

#ifndef EXEC_TYPES_H
#include <exec/types.h>
#endif

#ifndef EXEC_LIBRARIES_H
#include <exec/libraries.h>
#endif

#ifndef UTILITY_TAGITEM_H
#include <utility/tagitem.h>
#endif

/*****************************************************************************/

typedef LONG Fixed;				/* A fixed-point value, 16 bits
						   to the left of the point and
						   16 bits to the right */
typedef Fixed sposition;

/*** STRUCTURES */

 /* AHISoundMessage */
struct AHISoundMessage
{
 	UWORD	ahism_Channel;
};

 /* AHIRecordMessage */
struct AHIRecordMessage
{
	ULONG	ahirm_Type;			/* Format of buffer (object) */
	APTR	ahirm_Buffer;			/* Pointer to the sample array */
	ULONG	ahirm_Length;			/* Number of sample frames in buffer */
};

 /* AHISampleInfo */
struct AHISampleInfo
{
	ULONG	ahisi_Type;			/* Format of samples */
	APTR	ahisi_Address;			/* Address to array of samples */
	ULONG	ahisi_Length;			/* Number of samples in array */
};


/*
* An array of AHIMultiLoop structures are used to describe how to play multi-
* looped sounds. ahiml_Command can be a number from 1 to 65535 to play the
* segment that number of times before proceeding to the next structure in the
* array, or 0 to play the segment forever (terminating the array). If
* the last ahiml_Command in the array is ~0 the sound will be stopped
* (ahiml_Offset and ahiml_Length should be set to 0 in this case).
*/

 /* AHIMultiLoop */
struct AHIMultiLoop
{
	ULONG	ahiml_Command;
	ULONG	ahiml_Offset;			/* Offset in samples */
	ULONG	ahiml_Length;			/* Length in samples */
};

 /* AHILoopInfo (size is variable) */
struct AHILoopInfo
{
	UWORD		    ahili_Sound;	/* The source sound */
	UWORD		    ahili_Pad;
	struct AHIMultiLoop ahili_LoopArray[0];
};

 /* AHIAudioModeRequester */
struct AHIAudioModeRequester
{
	ULONG	ahiam_AudioID;			/* Selected audio mode */
	ULONG	ahiam_MixFreq;			/* Selected mixing/sampling frequency */
	
	WORD	ahiam_LeftEdge;			/* Coordinates of requester on exit */
	WORD	ahiam_TopEdge;
	WORD	ahiam_Width;
	WORD	ahiam_Height;

	BOOL	ahiam_InfoOpened;		/* Info window opened on exit? */
	WORD	ahiam_InfoLeftEdge;		/* Last coordinates of Info window */
	WORD	ahiam_InfoTopEdge;
	WORD	ahiam_InfoWidth;
	WORD	ahiam_InfoHeight;

	APTR	ahiam_UserData;			/* You can store your own data here */
};


/*** TAGS */

#define AHI_TagBase	   (TAG_USER)
#define AHI_TagBaseR	   (AHI_TagBase|0x8000)	/* Used if ti_Data is a pointer */

 /* AHI_AllocAudioA tags */
#define AHIA_AudioID	   (AHI_TagBase+1)	/* Desired audio mode */
#define AHIA_MixFreq	   (AHI_TagBase+2)	/* Suggested mixing frequency */
#define AHIA_Channels	   (AHI_TagBase+3)	/* Suggested number of channels */
#define AHIA_Sounds	   (AHI_TagBase+4)	/* Number of sounds to use */
#define AHIA_SoundFunc	   (AHI_TagBase+5)	/* End-of-Sound Hook */
#define AHIA_PlayerFunc	   (AHI_TagBase+6)	/* Player Hook */
#define AHIA_PlayerFreq	   (AHI_TagBase+7)	/* Frequency for player Hook */
#define AHIA_MinPlayerFreq (AHI_TagBase+8)	/* Minimum Frequency for player Hook */
#define AHIA_MaxPlayerFreq (AHI_TagBase+9)	/* Maximum Frequency for player Hook */
#define AHIA_RecordFunc	   (AHI_TagBase+10)	/* Sample recording Hook */

 /* AHI_ControlAudioA tags */
#define AHIC_Play	   (AHI_TagBase+80)	/* Boolean */
#define AHIC_Record	   (AHI_TagBase+81)	/* Boolean */

 /* AHI_GetAudioAttrsA tags */
#define AHIDB_BufferLen	   (AHI_TagBase+122)	/* Specifies the string buffer size */

#define AHIDB_AudioID	   (AHI_TagBase+100)	/* Private! */
#define AHIDB_Driver	   (AHI_TagBaseR+101)	/* Pointer to name of driver */
#define AHIDB_Flags	   (AHI_TagBase+102)	/* Private! */
#define AHIDB_Volume	   (AHI_TagBase+103)	/* Boolean */
#define AHIDB_Panning	   (AHI_TagBase+104)	/* Boolean */
#define AHIDB_Stereo	   (AHI_TagBase+105)	/* Boolean */
#define AHIDB_HiFi	   (AHI_TagBase+106)	/* Boolean */
#define AHIDB_PingPong	   (AHI_TagBase+107)	/* Boolean */
#define AHIDB_MultTable	   (AHI_TagBase+108)	/* Private! */
#define AHIDB_Name	   (AHI_TagBaseR+109)	/* Pointer to name of this mode */
#define AHIDB_Bits	   (AHI_TagBase+110)	/* Output bits */
#define AHIDB_MaxChannels  (AHI_TagBase+111)	/* Max supported channels */
#define AHIDB_MinMixFreq   (AHI_TagBase+112)	/* Min mixing freq. supported */
#define AHIDB_MaxMixFreq   (AHI_TagBase+113)	/* Max mixing freq. supported */
#define AHIDB_Record	   (AHI_TagBase+114)	/* Boolean */
#define AHIDB_Frequencies  (AHI_TagBase+115)
#define AHIDB_FrequencyArg (AHI_TagBase+116)	/* ti_Data is index number! */
#define AHIDB_Frequency	   (AHI_TagBase+117)
#define AHIDB_Author	   (AHI_TagBase+118)	/* Pointer to driver author name */
#define AHIDB_Copyright	   (AHI_TagBase+119)	/* Pointer to driver copyright notice */
#define AHIDB_Version	   (AHI_TagBase+120)	/* Pointer to driver version string */
#define AHIDB_Annotation   (AHI_TagBase+121)	/* Pointer to driver annotation text */
#define AHIDB_IndexArg	   (AHI_TagBase+123)	/* ti_Data is frequency! */
#define AHIDB_Index	   (AHI_TagBase+124)


 /* AHI_AudioRequestA tags */
   /* Window control */
#define AHIR_Window	   (AHI_TagBase+130)	/* Parent window */
#define AHIR_Screen	   (AHI_TagBase+131)	/* Screen to open on if no window */
#define AHIR_PubScreenName (AHI_TagBase+132)	/* Name of public screen */
#define AHIR_PrivateIDCMP  (AHI_TagBase+133)	/* Allocate private IDCMP? */
#define AHIR_IntuiMsgFunc  (AHI_TagBase+134)	/* Function to handle IntuiMessages */
#define AHIR_SleepWindow   (AHI_TagBase+135)	/* Block input in AHIR_Window? */
#define AHIR_UserData	   (AHI_TagBase+136)	/* What to put in ahiam_UserData */
   /* Text display */
#define AHIR_TextAttr	   (AHI_TagBase+137)	/* Text font to use for gadget text */
#define AHIR_Locale	   (AHI_TagBase+138)	/* Locale to use for text */
#define AHIR_TitleText	   (AHI_TagBase+139)	/* Title of requester */
#define AHIR_PositiveText  (AHI_TagBase+140)	/* Positive gadget text */
#define AHIR_NegativeText  (AHI_TagBase+141)	/* Negative gadget text */
   /* Initial settings */
#define AHIR_InitialLeftEdge  (AHI_TagBase+142)	/* Initial requester coordinates */
#define AHIR_InitialTopEdge   (AHI_TagBase+143)
#define AHIR_InitialWidth     (AHI_TagBase+144)	/* Initial requester dimensions */
#define AHIR_InitialHeight    (AHI_TagBase+145)
#define AHIR_InitialAudioID   (AHI_TagBase+146)	/* Initial audio mode id */
#define AHIR_InitialMixFreq   (AHI_TagBase+147)	/* Initial mixing/sampling frequency */
#define AHIR_InitialInfoOpened (AHI_TagBase+148)/* Info window initially opened? */
#define AHIR_InitialInfoLeftEdge (AHI_TagBase+149)/* Initial Info window coords. */
#define AHIR_InitialInfoTopEdge (AHI_TagBase+150)
#define AHIR_InitialInfoWidth (AHI_TagBase+151)
#define AHIR_InitialInfoHeight (AHI_TagBase+152)
   /* Options */
#define AHIR_DoMixFreq	   (AHI_TagBase+153)	/* Allow selection of mixing frequency? */
   /* Filtering */
#define AHIR_FilterTags	   (AHI_TagBase+154)	/* Pointer to filter taglist */
#define AHIR_FilterFunc	   (AHI_TagBase+155)	/* Function to filter mode id's */


/*** DEFS */

#define AHINAME			"ahi.library"
#define AHI_INVALID_ID		(~0)		/* Invalid Audio ID */
#define AHI_LOOPBACK_ID		0x00000001	/* Special sample render Audio ID */
#define AHI_MIXFREQ		0xffffffff	/* Special frequency for AHI_SetFreq() */
#define AHI_NOSOUND		0xffff		/* Turns a channel off */

 /* Set#? Flags */
#define AHISF_IMM	(1<<0)
#define AHISB_IMM	0

 /* Effect Types */

 /* Sound Types */
#define AHIST_NOTYPE	(~0)			/* Private */
#define AHIST_SAMPLE	0			/* 8 or 16 bit sample */
#define AHIST_DYNAMICSAMPLE 1			/* Dynamic sample */
#define AHIST_INPUT	257			/* The input from your sampler */
#define AHIST_LOOP	(1<<31)			/* Multi-loop sound */

 /* Sample types */
/* Note that only AHIST_M8S, AHIST_M8U and AHIST_M16S */
/* are supported by AHI_LoadSound(). */
#define AHIST_M8S	0			/* Mono, 8 bit signed (BYTE) */
#define AHIST_M16S	1			/* Mono, 16 bit signed (WORD) */
#define AHIST_S16S	3			/* Stereo 16 bit signed (2ŚWORD) */
/* The following are not native to ahi.library, and requires */
/* on the fly conversion. Try to avoid them if possible! */
#define AHIST_M8U	4			/* Mono, 8 bit unsigned (UBYTE) */

 /* Error codes */
#define AHIE_OK			0
#define AHIE_NOMEM		1
#define AHIE_BADSOUNDTYPE	2
#define AHIE_BADSAMPLETYPE	3

#endif /* LIBRARIES_AHI_H */
