/****************************************************
 *													*
 *	Dreamcast Sound Library							*
 *													*
 *		Copyright 1997-2000 (C)SEGA Enterprises		*
 *			Programmed By T.Jokagi					*
 *													*
 ****************************************************/

#ifndef	_SG_SD_H_
#define	_SG_SD_H_	(25013)

#include	<sg_xpt.h>

/*****************************************************
 *
 *	macro関数宣言
 *
 */

#define	SDD_INT32(data)							\
	( ( ( ( data >> 24) & 0x000000FF)      )	\
	| ( ( ( data >> 16) & 0x000000FF) <<  8)	\
	| ( ( ( data >>  8) & 0x000000FF) << 16)	\
	| ( ( ( data      ) & 0x000000FF) << 24))

#define	SDD_CHAR32(d1,d2,d3,d4)					\
	( ( d1      )								\
	| ( d2 <<  8)								\
	| ( d3 << 16)								\
	| ( d4 << 24))
#define	SDD_BIT(x)	(1<<x)

/*****************************************************
 *
 *	定数定義
 *
 */
/*
 *	version番号定義
 *	Number of version
 */
/*	数値での定義  */
#define	SDD_LIB_VER_MAJOR	(0x02)
#define	SDD_LIB_VER_MINOR	(0x50)
#define	SDD_LIB_VER_DEBUG	(0x13)
/*	文字列での定義  */
#define	SDD_LIB_VER_STRING	"2.50.13"

/*
 *	Memory Block関連定義
 *	Memory Block
 */
/*	Memory Block handle最大作成数  */
/*	Maximum of Memory Block handle  */
#define	SDD_MEMBLK_HANDLE_NUM	( 64)
/*	Memory Block handle queue最大作成数  */
/*	Maximum of Memory Block queue  */
#define	SDD_MEMBLK_QUEUE_NUM	( 64)
/*
 *	host command関係
 *	Host command
 */
/*	secondardy host command最大登録数  */
/*	Maximum of secondary buffer of host command  */
#define	SDD_HOST_CMD_2ND_BUF_NUM		( 256)

/*
 *	各種音源の確保可能な最大Port数
 *	Maximum of sound module port
 */
#define	SDD_MIDI_PORT_NUM		( 0x00000008)
#define	SDD_SHOT_PORT_NUM		( 0x00000040)
#define	SDD_PSTM_PORT_NUM		( 0x00000010)

/*
 *	PCM Stream portの1 portあたりの確保可能な最大slot数
 */
#define	SDD_PSTM_PORT_SLOT_NUM	( 0x00000004)

/*
 *	各種音源の最大発音数
 *	Maximum of sound slot number of sound sodule
 */
#define	SDD_MIDI_SLOT_NUM		( 0x00000040)
#define	SDD_SHOT_SLOT_NUM		( 0x00000040)
#define	SDD_PSTM_SLOT_NUM		( 0x00000010)

/*
 *	MIDI channel
 */
/*	MIDI channel数(Number of MIDI Channel)  */
#define	SDD_MIDI_CH_NUM		( 0x00000010)
/*	MIDI channel最少番号(Minimum limit of MIDI channel number)  */
#define	SDD_MIDI_CH_MIN		( 0x00000000)
/*	MIDI channel最大番号(Maximum limit of MIDI channel number)  */
#define	SDD_MIDI_CH_MAX		( 0x0000000F)
/*	MIDI音源のGM音源モード時のMIDI Drum channel番号(Drum MIDI channel of GM MIDI mode)  */
#define	SDD_MIDI_CH_DRM		( 0x00000009)

/*
 *	note number
 */
/*	MIDI note数(Number of MIDI note)  */
#define	SDD_MIDI_NOTE_NUM	( 0x00000080)
/*	MIDI note最少番号(Minimum limit of MIDI note number)  */
#define	SDD_MIDI_NOTE_MIN	( 0x00000000)
/*	MIDI note最大番号(Maximum limit of MIDI note number)  */
#define	SDD_MIDI_NOTE_MAX	( 0x0000007F)

/*
 *	MIDI messageの定義
 *	define of MIDI message
 */
#define	SDD_MIDI_MES_NOTE_OFF	( 0x00000080)
#define	SDD_MIDI_MES_NOTE_ON	( 0x00000090)
#define	SDD_MIDI_MES_MONO_PRES	( 0x000000A0)
#define	SDD_MIDI_MES_CTL_CHG	( 0x000000B0)
#define	SDD_MIDI_MES_PRG_CHG	( 0x000000C0)
#define	SDD_MIDI_MES_POLY_PRES	( 0x000000D0)
#define	SDD_MIDI_MES_PITCH_BEND	( 0x000000E0)

#define	SDD_MIDI_CTL_CHG_LSB	( 0x00000000)
#define	SDD_MIDI_CTL_CHG_MSB	( 0x00000020)

/*	programBank change  */
#define	SDD_MIDI_CTL_CHG_BANK		( 0x00000000)
/*	modulatiion change  */
#define	SDD_MIDI_CTL_CHG_MODULATION	( 0x00000001)
/*	volume change  */
#define	SDD_MIDI_CTL_CHG_VOL		( 0x00000007)
/*	panpot change  */
#define	SDD_MIDI_CTL_CHG_PAN		( 0x0000000A)
/*	expression change  */
#define	SDD_MIDI_CTL_CHG_EXPRES		( 0x0000000B)

/*
 *	PCM Streamのslot別名
 *	aliase of PCM Stream slot
 */
#define	SDD_PSTM_PORT_SLOT_ALL		( ( Sint8)0xFF)
#define	SDD_PSTM_PORT_SLOT_LEFT		( ( Sint8)0x00)
#define	SDD_PSTM_PORT_SLOT_RIGHT	( ( Sint8)0x01)

/*
 *	PCM Streamのslot filter
 *	Filter of PCM Stream slot
 */
#define	SDD_PSTM_PORT_SLOT_FILTER_THROUGH	( ( Sint16)-1)

/*
 *	portのFlagのbit assign
 */
#define	SDD_PORT_FLG_PLAY		( ( Uint32)SDD_BIT(0))
#define	SDD_PORT_FLG_PAUSE		( ( Uint32)SDD_BIT(1))
#define	SDD_PORT_FLG_CHG_VOL	( ( Uint32)SDD_BIT(2))
#define	SDD_PORT_FLG_CHG_SPEED	( ( Uint32)SDD_BIT(3))
#define	SDD_PORT_FLG_CHG_PAN	( ( Uint32)SDD_BIT(4))
#define	SDD_PORT_FLG_CHG_PITCH	( ( Uint32)SDD_BIT(5))
#define	SDD_PORT_FLG_TROUBLE	( ( Uint32)SDD_BIT(7))

/*
 *	portのerrorのbit assign
 */
#define	SDD_PORT_ERR_REQUEST_NUM			( ( Uint32)SDD_BIT(2))
#define	SDD_PORT_ERR_MIDI_BUF_NO_ENOUGH		( ( Uint32)SDD_BIT(5))
#define	SDD_PORT_ERR_MIDI_SEQ_BUF_NO_ENOUGH	( ( Uint32)SDD_BIT(6))
#define	SDD_PORT_ERR_SLOT_NO_ENOUGH			( ( Uint32)SDD_BIT(7))
#define	SDD_PORT_ERR_BANK_NOT_FOUND			( ( Uint32)SDD_BIT(8))
#define	SDD_PORT_ERR_PRIORITY_LOW			( ( Uint32)SDD_BIT(9))
#define	SDD_PORT_ERR_BANK_ILLEGAL_VER		( ( Uint32)SDD_BIT(11))
#define	SDD_PORT_ERR_BANK_ILLEGAL_NUM		( ( Uint32)SDD_BIT(12))
#define	SDD_PORT_ERR_BANK_ILLEGAL_ID		( ( Uint32)SDD_BIT(13))
#define	SDD_PORT_ERR_BANK_ILLEGAL_SZ		( ( Uint32)SDD_BIT(14))

/*
 *	globalなerrorのbit assignの定義
 *	define of bit assign of global error
 */
#define	SDD_DRV_ERR_BANK_NO_DOWNLOAD	( ( Uint32)SDD_BIT(3))
#define	SDD_DRV_ERR_BANK_ILLEGAL_ID		( ( Uint32)SDD_BIT(4))
#define	SDD_DRV_ERR_BANK_ILLEGAL_END_ID	( ( Uint32)SDD_BIT(5))
#define	SDD_DRV_ERR_BANK_ILLEGAL_VER	( ( Uint32)SDD_BIT(6))
#define	SDD_DRV_ERR_BANK_ILLEGAL_NUM	( ( Uint32)SDD_BIT(7))

/*
 *	Memory Block handleの動作設定の定義
 *	define mode of Memory Block handle
 */
/*	Memory Block転送で関数を登録しない場合  */
#define	SDD_MEMBLK_NO_FUNC		( ( SD_MEMBLK_CALLBACK_FUNC)0x00000000)
/*	Memory Block転送で同期modeを行う場合  */
#define	SDD_MEMBLK_SYNC_FUNC	( ( SD_MEMBLK_CALLBACK_FUNC)0xFFFFFFFF)
/*	ローカルにmemory確保定数する時  */
#define	SDD_MEMBLK_LOCAL_ALLOCATE	( ( SDMEMBLK)0xF0000000)
/*	自動で確保するBufferサイズ  */
#define	SDD_MEM_AUTO_ALOCATE_BUF_SZ	( 0x800)

#define	SDD_MIDI_WHOLE_NOTE	( 0x1000000)

#define	SDD_MIDI_NO_CHAIN	(0xFF)

/*****************************************************
 *
 *	data type定義
 *
 */

/********************************
 *
 *	列挙体type定義
 *
 */
/*
 *	sound error型定義
 */
enum SDE_ERR
{
	SDE_ERR_NOTHING					= 0x00000000,	/*	no error.  */

	SDE_ERR_PRM_OVER_RANGE			= 0x03000001,	/*	parameter range over.  */
	SDE_ERR_PRM_ILLEGAL_VALUE		= 0x03000002,	/*	parameter is bad value.  */

	SDE_ERR_MODULE_SLOT_NO_ENOUGH	= 0x05000001,	/*	音源のslotが足りない  */

	SDE_ERR_MEMBLK_ALREADY_TRANSFER	= 0x06000001,	/*	二重転送error  */
	SDE_ERR_MEMBLK_QUEUE_NO_ENOUGH	= 0x06000101,	/*	Memory Block queueの空きが無い  */

	SDE_ERR_HANDLE_NO_ENOUGH		= 0x07000101,	/*	handleの空きが無い  */
	SDE_ERR_HANDLE_ILLEGAL_VALUE	= 0x07000102,	/*	handle is bad value.  */
	SDE_ERR_HANDLE_NULL				= 0x07000103,	/*	Handle is 0 address.  */

	SDE_ERR_PTR_ILLEGAL_VALUE		= 0x07000202,	/*	pointer is bad value  */
	SDE_ERR_PTR_NULL				= 0x07000203,	/*	pointer is 0 address.  */

	SDE_ERR_BANK_ILLEGAL_TYPE		= 0x09000001,	/*	bad bank type.  */
	SDE_ERR_BANK_ILLEGAL_VER		= 0x09000002,	/*	bad bank version.  */
	SDE_ERR_BANK_NOTHING			= 0x09000003,	/*	bank not exist or no assign.  */
	SDE_ERR_BANK_ILLEGAL_NUM		= 0x09000004,   /*	bad bank number.  */
	SDE_ERR_BANK_ILLEGAL_SZ			= 0x09000005,   /*	bad bank size.  */
	SDE_ERR_BANK_ILLEGAL_CHECK_SUM	= 0x09000006,	/*	bad check sum in bank.  */
	SDE_ERR_BANK_NO_MAPPING			= 0x09000110,	/*	bank is not mapping.  */

	SDE_ERR_DATA_ILLEGAL_TYPE		= 0x09000101,	/*	bad data type.  */
	SDE_ERR_DATA_ILLEGAL_VER		= 0x09000102,	/*	bad data version.  */
	SDE_ERR_DATA_NOTHING			= 0x09000103,	/*	data not exist or no assign.  */
	SDE_ERR_DATA_ILLEGAL_NUM		= 0x09000104,   /*	bad data number.  */

	SDE_ERR_HOST_CMD_BUF_NO_ENOUGH	= 0x0A000001,	/*	host command buffer full.  */

	SDE_ERR_DRV_PROBLEM				= 0x0B000001,	/*	sound driverの動作不良  */	/*	2.02.00(add)  */
	SDE_ERR_DRV_ILLEGAL_VER			= 0x0B000002,	/*	sound driverとのversion不一致  */	/*	2.02.00(add)  */
	SDE_ERR_DRV_BUSY				= 0x0B000003,	/*	sound driver is busy.  */	/*	2.02.00(add)  */

	SDE_ERR_NO_INIT					= 0x0D000001,	/*	未初期化  */
	SDE_ERR_ALREADY_INIT			= 0x0D000002,	/*	すでに初期化済み  */

	SDE_ERR_HARD_WARE				= 0x0F000001,	/*	hardware動作不良  */
	SDE_ERR_MAIN_MEM_ADR_ERR		= 0x0F010001,	/*	main memory address error.  */
	SDE_ERR_SND_MEM_ADR_ERR			= 0x0F010101,	/*	sound memory address error.  */

	SDE_ERR_UNKNOW_NUM				= 0x7FFFFFFF	/*	unknow error.  */
};
typedef enum SDE_ERR	SDE_ERR;

/*
 *	SoundData型定義
 */
enum SDE_DATA_TYPE
{
	SDE_DATA_TYPE_DRV			= SDD_CHAR32('S','D','R','V'),	/*	SDRV  */	/*	2.02.00(add)  */
	SDE_DATA_TYPE_MLT			= SDD_CHAR32('S','M','L','T'),	/*	SMLT  */	/*	2.50.03(modified)  */
	SDE_DATA_TYPE_MIDI_DRM_BANK	= SDD_CHAR32('S','M','D','B'),	/*	SMDB  */
	SDE_DATA_TYPE_MIDI_SEQ_BANK	= SDD_CHAR32('S','M','S','B'),	/*	SMSB  */
	SDE_DATA_TYPE_MIDI_PRG_BANK	= SDD_CHAR32('S','M','P','B'),	/*	SMPB  */
	SDE_DATA_TYPE_SHOT_BANK		= SDD_CHAR32('S','O','S','B'),	/*	SOSB  */
	SDE_DATA_TYPE_PSTM_RING_BUF	= SDD_CHAR32('S','P','S','R'),	/*	SPSR  */
	SDE_DATA_TYPE_FX_OUT_BANK	= SDD_CHAR32('S','F','O','B'),	/*	SFOB  */
	SDE_DATA_TYPE_FX_PRG_BANK	= SDD_CHAR32('S','F','P','B'),	/*	SFPB  */
	SDE_DATA_TYPE_FX_PRG_WRK	= SDD_CHAR32('S','F','P','W')	/*	SFPW  */
};
typedef enum SDE_DATA_TYPE	SDE_DATA_TYPE;

/*
 *	panpotのmode設定data type
 */
enum SDE_PAN_MODE
{
	SDE_PAN_MODE_MONO,	/*	monaural  */
	SDE_PAN_MODE_STEREO	/*	s tereo  */
};
typedef enum SDE_PAN_MODE	SDE_PAN_MODE;

/*
 *	MIDI portのGM modeの型定義
 */
enum SDE_MIDI_GM_MODE
{
	SDE_MIDI_GM_MODE_ON = ON,	/*	MIDI音源をGMモードにする(change GM mode on)  */
	SDE_MIDI_GM_MODE_OFF = OFF	/*	MIDI音源のGMモードを解除する(change GM mode off)  */
};
typedef enum SDE_MIDI_GM_MODE	SDE_MIDI_GM_MODE;

/*
 *	One Shotのの再生時間設定modeの型定義
 */
enum SDE_SHOT_PLAY_TIME
{
	SDE_SHOT_PLAY_TIME_RELATIVE,	/*	相対値指定(relative value)  */
	SDE_SHOT_PLAY_TIME_RATIO,		/*	割合指定(ratio value)  */
	SDE_SHOT_PLAY_TIME_ABSOLUTE		/*	絶対値指定(absolute)  */
};
typedef enum SDE_SHOT_PLAY_TIME	SDE_SHOT_PLAY_TIME;

/*
 *	PCMのencodeの種類の型定義
 *	define of PCM encode type
 */
enum SDE_PCM_TYPE
{
	SDE_PCM_TYPE_8BIT_LINEAR,	/*	8bit 非圧縮形式(no compress 8bit format)  */
	SDE_PCM_TYPE_16BIT_LINEAR,	/*	16bit 非圧縮形式(no compress 16bit format)  */
	SDE_PCM_TYPE_4BIT_ADPCM		/*	4bit ADPCM圧縮形式(ADPCM compress 4bit format)  */
};
typedef enum SDE_PCM_TYPE	SDE_PCM_TYPE;

/*
 *	Memory Block転送status型定義
 *	define status of memory block.
 */
enum SDE_MEMBLK_STAT
{
	SDE_MEMBLK_STAT_TRANSFER_REMAIN,	/*	未転送(no transfer)  */
	SDE_MEMBLK_STAT_TRANSFER_FINISHED,	/*	転送終了(end of transfer)  */
	SDE_MEMBLK_STAT_TRANSFER_PROGRESS	/*	転送中(progress of transfer)  */
};
typedef enum SDE_MEMBLK_STAT	SDE_MEMBLK_STAT;

/*
 *	Memory Block転送mode型定義
 *	define mode of memory block transfer.
 */
enum SDE_MEMBLK_TRANSFER_MODE
{
	SDE_MEMBLK_TRANSFER_MODE_CPU,	/*	Memory BlockはCPU(PIO)転送(use CPU transfer)  */
	SDE_MEMBLK_TRANSFER_MODE_DMA	/*	Memory BlockはDMA転送(use DMA transfer)  */
};
typedef enum SDE_MEMBLK_TRANSFER_MODE	SDE_MEMBLK_TRANSFER_MODE;

/*
 *	portの再生停止時のrelease mode型定義
 */
enum SDE_PORT_RELEASE_MODE
{
	SDE_PORT_RELEASE_MODE_DISABLE = OFF,	/*	再生停止・一時停止時はrelease無効  */	/*	2.50.03(modified)  */
	SDE_PORT_RELEASE_MODE_ENABLE = ON		/*	再生停止・一時停止時はrelease有効  */	/*	2.50.03(modified)  */
};
typedef enum SDE_PORT_RELEASE_MODE	SDE_PORT_RELEASE_MODE;

/*
 *	Host CommandのFlushの種類の型定義
 */
enum SDE_HOST_CMD_FLUSH_MODE	/*	2.02.00(add)  */
{
	SDE_HOST_CMD_FLUSH_MODE_NORMAL,		/*	可能ならHost Commandを1回送信  */
	SDE_HOST_CMD_FLUSH_MODE_FORCE,		/*	強制的にHost Commandを1回送信  */
	SDE_HOST_CMD_FLUSH_MODE_FORCE_ALL	/*	強制的にBufferringされた全てのHost Commandを送信  */
};
typedef enum SDE_HOST_CMD_FLUSH_MODE	SDE_HOST_CMD_FLUSH_MODE;

/*
 *	外部MIDI I/Fのモード
 */
enum SDE_MIDI_IF_MODE
{
	SDE_MIDI_IF_MODE_DISABLE = OFF,	/*	MIDI Interfaceを無効にする  */	/*	2.50.03(modified)  */
	SDE_MIDI_IF_MODE_ENABLE = ON	/*	MIDI Interfaceを有効にする  */	/*	2.50.03(modified)  */
};
typedef enum SDE_MIDI_IF_MODE	SDE_MIDI_IF_MODE;

/********************************
 *
 *	単純type定義
 *
 */
/*	Error trapping callback  */
typedef Void	( *SD_ERR_CALLBACK_FUNC)( Void *func, SDE_ERR result, char *msg);	/*	2.02.00(add)  */
/*	Memory Block callback  */
typedef Void	( *SD_MEMBLK_CALLBACK_FUNC)( Void *first_arg);

/********************************
 *
 *	構造体type定義
 *
 */
/*
 *	version型定義
 */
struct SDS_VER
{
	Uint8	m_Major;	/*	major version  */
	Uint8	m_Minor;	/*	minor version  */
	Uint8	m_Debug;	/*	debug version  */
	Uint8	rsv;		/*	system reserve  */
};
typedef struct SDS_VER	SDS_VER;

/*
 *	MIDI message型定義
 */
struct SDS_MIDI_MES
{
	Uint8	m_Member[ 0x04];
};
typedef struct SDS_MIDI_MES	SDS_MIDI_MES;

/*
 *	MIDI portのstatus型定義
 */
struct SDS_MIDI_STAT
{
	Sint16	rsv;				/*	system reserve  */
	Sint8	m_Vol;				/*	volume  */
	Sint8	m_Pan;				/*	panpot  */
	Sint8	m_FxInLev;			/*	FX input level  */	/*	2.50.03(modified)  */
	Sint8	m_DrctLev;			/*	Direct level  */
	Sint16	m_Pitch;			/*	pitch  */
	Sint16	m_SeqSpeed;			/*	speed  */
	Uint32	m_SeqTotalBeatTime;	/*	総演奏拍数  */
	Sint32	m_SeqCurAdr;		/*	current play address  */
	Uint32	m_Err;				/*	error status  */
	Uint32	m_Flg;				/*	flags  */
};
typedef struct SDS_MIDI_STAT	SDS_MIDI_STAT;

/*
 *	One Shot portのstatus型定義
 */
struct SDS_SHOT_STAT
{
	Sint16	rsv;				/*	system reserve  */
	Sint8	m_Vol;				/*	volume  */
	Sint8	m_Pan;				/*	panpot  */
	Sint8	m_FxInLev;			/*	FX input level  */
	Sint8	m_DrctLev;			/*	Direct level  */
	Sint16	m_Pitch;			/*	pitch  */
	Sint16	rsv2;				/*	system reserve  */
	Uint32	m_TotalSmpFrame;	/*	総演奏sample数  */
	Sint32	m_CurAdr;			/*	current play address  */
	Uint32	m_Err;				/*	error status  */
	Uint32	m_Flg;				/*	flags  */
};
typedef struct SDS_SHOT_STAT	SDS_SHOT_STAT;

/*
 *	PCM Stream portのstatus型定義
 */
struct SDS_PSTM_STAT
{
	Sint16	rsv;				/*	system reserve  */
	Sint8	m_Vol;				/*	volume  */
	Sint8	m_Pan;				/*	panpot  */
	Sint8	m_FxInLev;			/*	FX input level  */
	Sint8	m_DrctLev;			/*	Direct level  */
	Sint16	m_Pitch;			/*	pitch  */
	Sint16	rsv2;				/*	system reserve  */
	Uint32	m_TotalSmpFrame;	/*	総演奏sample数  */
	Sint32	m_CurAdr;			/*	current play address  */
	Uint32	m_Err;				/*	error status  */
	Uint32	m_Flg;				/*	flags  */
};
typedef struct SDS_PSTM_STAT	SDS_PSTM_STAT;

/*
 *	GDDAのstatus型定義
 */
struct SDS_GDDA_STAT
{
	Sint16	rsv;				/*	system reserve  */
	Sint8	m_LeftVol;			/*	左channelのvolume  */
	Sint8	m_RightVol;			/*	右channelのvolume  */
	Sint8	m_LeftPan;			/*	左channelのpanpot  */
	Sint8	m_RightPan;			/*	右channelのpanpot  */
	Uint32	m_Err;				/*	error status  */
	Uint32	m_Flg;				/*	各種flag  */
};
typedef struct SDS_GDDA_STAT	SDS_GDDA_STAT;

/*
 *	Memory Block型定義
 */
struct SDS_MEMBLK
{
	Uint32	m_Member[ 16];
};
typedef struct SDS_MEMBLK	SDS_MEMBLK;
typedef struct SDS_MEMBLK	*SDMEMBLK;		/*	Memory Block handle  */

/*
 *	port handle型定義
 */
struct SDS_PORT_REF
{
	Void	*m_Ref;
};
typedef struct SDS_PORT_REF	SDS_PORT_REF;
typedef struct SDS_PORT_REF	*SDHANDLE;

typedef SDHANDLE	SDMIDI;	/*	MIDI port handle  */		/*	2.50.03(modified)  */
typedef SDHANDLE	SDSHOT;	/*	One Shot port handle  */	/*	2.50.03(modified)  */
typedef SDHANDLE	SDPSTM;	/*	PCM Stream port handle  */	/*	2.50.03(modified)  */

/*****************************************************
 *
 *	prototype宣言
 *	define of prototype
 *
 */
/*
 *	sound system API
 */
EXTERN SDE_ERR	sdDrvCheckExecute( Void);
EXTERN SDE_ERR	sdDrvGetBuildinImage( Void **drv_ptr, Sint32 *drv_sz, SDS_VER *drv_ver);
EXTERN SDE_ERR	sdDrvGetErr( Uint32 *err);
EXTERN SDE_ERR	sdDrvGetExecCounter( Uint32 *count_num);	/*	2.50.03(modified)  */
EXTERN SDE_ERR	sdDrvGetVer( SDS_VER *drv_ver);
EXTERN SDE_ERR	sdDrvHostCmdIsScan( Bool *flg);	/*	2.02.00(add) */
EXTERN SDE_ERR	sdDrvInit( SDMEMBLK handle);
EXTERN SDE_ERR	sdLibGetVer( SDS_VER *lib_ver);
EXTERN SDE_ERR	sdLibInit( Void *arg1, Sint32 arg2, Sint32 arg3);
EXTERN SDE_ERR	sdSysFinish( Void);
EXTERN SDE_ERR	sdSysHostCmdBufFlush( const SDE_HOST_CMD_FLUSH_MODE mode);	/*	2.02.00(add) */
EXTERN SDE_ERR	sdSysHostCmdBufIsLock( Bool *flg);	/*	2.02.00(add) */
EXTERN SDE_ERR	sdSysGetUsedHostCmd( Sint32 *percent);	/*	2.50.13(add) */
EXTERN SDE_ERR	sdSysServer( Void);
EXTERN SDE_ERR	sdSysSetErrCallback( const SD_ERR_CALLBACK_FUNC callback);	/*	2.02.00(add) */
EXTERN SDE_ERR	sdSysSetMidiIfMode( const SDE_MIDI_IF_MODE mode);	/*	2.02.00(add) */	/*	2.50.03(modified)  */
EXTERN SDE_ERR	sdSysSetSlotNum( const Sint32 midi_slot_num, const Sint32 shot_slot_num, const Sint32 pstm_slot_num);	/*	2.50.03(modified)  */

/*
 *	global sound control API
 */
EXTERN SDE_ERR	sdSndClearFxPrg( Void);
EXTERN SDE_ERR	sdSndGetFxOut( Sint8 *cur_fx_out_num);
EXTERN SDE_ERR	sdSndGetFxPrg( Sint8 *cur_fx_prg_num);
EXTERN SDE_ERR	sdSndGetPanMode( SDE_PAN_MODE *cur_pan_mode);
EXTERN SDE_ERR	sdSndSetFxOut( const Sint8 new_fx_out_num);
EXTERN SDE_ERR	sdSndSetFxPrg( const Sint8 new_fx_prg_num, const Sint8 new_fx_out_num);
EXTERN SDE_ERR	sdSndSetFxOutPrm( const Sint8 out_num, const Sint8 out_pan, const Sint8 out_lev);
EXTERN SDE_ERR	sdSndSetMasterVol( const Sint8 vol);
EXTERN SDE_ERR	sdSndSetPanMode( const SDE_PAN_MODE pan_mode);
EXTERN SDE_ERR	sdSndSetQsndPos( const Uint8 *pos);
EXTERN SDE_ERR	sdSndStopAll( Void);

/*
 *	sound data utility API
 */
EXTERN SDE_ERR	sdBankDownload( SDMEMBLK handle, const SDE_DATA_TYPE bank_type, const Sint8 bank_num);
EXTERN SDE_ERR	sdBankDownloadEx( SDMEMBLK handle, const SDE_DATA_TYPE bank_type, const Sint8 bank_num);	/*	2.50.02(add)  */
EXTERN SDE_ERR  sdBankDownloadSetDivSz( const Sint32 diz_sz);	/*	2.50.02(add)  */
EXTERN SDE_ERR	sdMltDownload( SDMEMBLK handle);
EXTERN SDE_ERR	sdMltDownloadEx( SDMEMBLK handle);	/*	2.50.02(add)  */

/*
 *	sound memory control API
 *
 */
EXTERN SDE_ERR	sdSndMemBlockClearAll( Void);	/*	2.50.03(add)  */
EXTERN SDE_ERR	sdSndMemBlockClear( SDE_DATA_TYPE block_type, Sint8 block_num);	/*	2.50.03(add)  */
EXTERN SDE_ERR	sdSndMemBlockFreeAll( Void);	/*	2.50.03(modified)  */
EXTERN SDE_ERR	sdSndMemBlockFree( SDE_DATA_TYPE block_type, Sint8 block_num);	/*	2.50.03(modified)  */
EXTERN SDE_ERR	sdSndMemBlockGetMap( const SDE_DATA_TYPE bank_type, const Sint8 bank_num, Sint32 *allocate_ptr, Sint32 *allocate_sz);	/*	2.50.03(modified)  */

/*
 *	Memory Block transfer API
 */
EXTERN SDE_ERR	sdMemBlkCheck( const SDMEMBLK handle);	/*	2.50.03(modified)  */
EXTERN SDE_ERR	sdMemBlkCreate( SDMEMBLK *handle);
EXTERN SDE_ERR	sdMemBlkDestroy( SDMEMBLK handle);
EXTERN SDE_ERR	sdMemBlkDestroyAll( Void);	/*	2.02.00(add)  */
EXTERN SDE_ERR	sdMemBlkGetStat( const SDMEMBLK handle, SDE_MEMBLK_STAT *stat);	/*	2.50.03(modified)  */
EXTERN SDE_ERR	sdMemBlkSetPrm( SDMEMBLK handle, const Void *src_blk_ptr, const Sint32 src_blk_sz, const SD_MEMBLK_CALLBACK_FUNC callback_func, const Void *callback_first_arg);
EXTERN SDE_ERR	sdMemBlkTransfer( SDMEMBLK handle, Sint32 dst_adr);
EXTERN SDE_ERR	sdMemBlkSetTransferMode( const SDE_MEMBLK_TRANSFER_MODE transfer_mode);	/*	2.50.03(modified)  */

/*	GD-DA  */
EXTERN SDE_ERR	sdGddaGetStat( SDS_GDDA_STAT *stat);
EXTERN SDE_ERR	sdGddaResetPrm( Void);
EXTERN SDE_ERR	sdGddaSetPan( const Sint8 left_pan, const Sint8 right_pan);
EXTERN SDE_ERR	sdGddaSetVol( const Sint8 left_vol, const Sint8 right_vol);

/*
 *	sound module control API
 */
/*	MIDI port  */
EXTERN SDE_ERR	sdMidiClose( SDMIDI handle);	/*	2.50.03(modified)  */
EXTERN SDE_ERR	sdMidiCloseAll( Void);	/*	2.02.00(add)  */	/*	2.50.03(modified)  */
EXTERN SDE_ERR	sdMidiGetStat( const SDMIDI handle, SDS_MIDI_STAT *midi_stat);	/*	2.50.03(modified)  */
EXTERN SDE_ERR	sdMidiGetCtlValue( const SDMIDI handle, const Sint8 control_num, Sint8 *value);	/*	2.50.03(modified)  */
EXTERN SDE_ERR	sdMidiOpen( SDMIDI *handle);	/*	2.50.03(modified)  */
EXTERN SDE_ERR	sdMidiResetPrm( SDMIDI handle);
EXTERN SDE_ERR	sdMidiResetAllPrm( Void);
EXTERN SDE_ERR	sdMidiSeqChainLoopOut( SDMIDI handle, const Sint8 bank_num, const Sint8 data_num);
EXTERN SDE_ERR	sdMidiSeqContinue( SDMIDI handle);
EXTERN SDE_ERR	sdMidiSeqGetCurAdr( const SDMIDI handle, Sint32 *cur_adr);	/*	2.50.03(modified)  */
EXTERN SDE_ERR	sdMidiSeqGetTotalBeatTime( const SDMIDI handle, Uint32 *cur_beat_time);	/*	2.50.03(modified)  */
EXTERN SDE_ERR	sdMidiSeqPause( SDMIDI handle);
EXTERN SDE_ERR	sdMidiSeqPlay( SDMIDI handle, const Sint8 bank_num, const Sint8 data_num, const Sint8 priority);
EXTERN SDE_ERR	sdMidiSeqSetBeatReso( SDMIDI handle, const Sint32 reso);
EXTERN SDE_ERR	sdMidiSeqSetSpeed( SDMIDI handle, const Sint16 speed, const Sint32 fade_time);
EXTERN SDE_ERR	sdMidiSeqStop( SDMIDI handle);
EXTERN SDE_ERR	sdMidiSeqStopAll( Void);
EXTERN SDE_ERR	sdMidiSendMes( SDMIDI handle, const SDS_MIDI_MES *midi_mes_ptr, const Sint8 priority);
EXTERN SDE_ERR	sdMidiSetDrctLev( SDMIDI handle, const Sint8 lev);
EXTERN SDE_ERR	sdMidiSetFxInLev( SDMIDI handle, const Sint8 fx_lev);
EXTERN SDE_ERR	sdMidiSetGmMode( SDMIDI handle, const SDE_MIDI_GM_MODE gm_mode);
EXTERN SDE_ERR	sdMidiSetMes( SDMIDI handle, SDS_MIDI_MES *midi_mes_ptr, const Uint8 midi_mes,... );
EXTERN SDE_ERR	sdMidiSetMuteCh( SDMIDI handle, const Uint16 mask);
EXTERN SDE_ERR	sdMidiSetPan( SDMIDI handle, const Sint8 pan, const Sint32 fade_time);
EXTERN SDE_ERR	sdMidiSetPitch( SDMIDI handle, const Sint16 pitch, const Sint32 fade_time);
EXTERN SDE_ERR	sdMidiSetReleaseMode( SDMIDI handle, const SDE_PORT_RELEASE_MODE release_mode);
EXTERN SDE_ERR	sdMidiSetVol( SDMIDI handle, const Sint8 vol, const Sint32 fade_time);

/*	PCM Stream port  */
EXTERN SDE_ERR	sdPstmClose( SDPSTM handle);	/*	2.50.03(modified)  */
EXTERN SDE_ERR	sdPstmCloseAll( Void);	/*	2.02.00(add)  */	/*	2.50.03(modified)  */
EXTERN SDE_ERR	sdPstmGetCurAdr( const SDPSTM handle, const Sint8 target_slot, Sint32 *cur_smp_adr);	/*	2.50.03(modified)  */
EXTERN SDE_ERR	sdPstmGetStat( const SDPSTM handle, const Sint8 target_slot, SDS_PSTM_STAT *pstm_stat);	/*	2.50.03(modified)  */
EXTERN SDE_ERR	sdPstmGetTotalSmpFrame( const SDPSTM handle, const Sint8 target_slot, Uint32 *cur_smp_frame);	/*	2.50.03(modified)  */
EXTERN SDE_ERR	sdPstmGetCurTransferWaveDataAdr( const SDPSTM handle, const Sint8 target_slot, Sint32 *adr);
EXTERN SDE_ERR	sdPstmIsTransferWaveData( const SDPSTM handle, const Sint8 target_slot, const Sint32 data_sz, Bool *flg);
EXTERN SDE_ERR	sdPstmOpen( SDPSTM *handle, const Sint8 use_slot_num, ...);	/*	2.50.03(modified)  */
EXTERN SDE_ERR	sdPstmPlay( SDPSTM handle, const SDE_PCM_TYPE pcm_type, const Uint16 freq);
EXTERN SDE_ERR	sdPstmPlayF( SDPSTM handle, const SDE_PCM_TYPE pcm_type, const Float freq);
EXTERN SDE_ERR	sdPstmOnMemGetCurTransferAdr( const SDPSTM handle, const Sint8 target_slot, Void **adr);	/*	2.02.00(add)  */
EXTERN SDE_ERR	sdPstmOnMemPlay( SDPSTM handle, const SDE_PCM_TYPE pcm_type, const Uint16 pcm_freq, const Sint32 transfer_sz, const Bool loop_flg);
EXTERN SDE_ERR	sdPstmOnMemSetWaveData( SDPSTM handle, const Sint8 target_slot, SDMEMBLK src_handle);
EXTERN SDE_ERR	sdPstmResetPrm( SDPSTM handle, const Sint8 target_slot);
EXTERN SDE_ERR	sdPstmResetAllPrm( Void);
EXTERN SDE_ERR	sdPstmTransferWaveData( SDPSTM handle, const Sint8 target_slot, SDMEMBLK memblk);
EXTERN SDE_ERR	sdPstmSetBasePrm( SDPSTM handle, const Sint8 target_slot, const Sint8 base_vol, const Sint8 base_pan, const Sint8 fx_in_ch, const Sint8 base_fx_lev, const Sint8 base_drct_lev, const Sint16 base_filter_lev, const Sint8 base_filter_q);
EXTERN SDE_ERR	sdPstmSetDrctLev( SDPSTM handle, const Sint8 target_slot, const Sint8 drct_lev);
EXTERN SDE_ERR	sdPstmSetFxInCh( SDPSTM handle, const Sint8 target_slot, const Sint8 fx_in_ch, const Sint8 fx_base_lev);
EXTERN SDE_ERR	sdPstmSetFxInLev( SDPSTM handle, const Sint8 target_slot, const Sint8 fx_lev);
EXTERN SDE_ERR	sdPstmSetPan( SDPSTM handle, const Sint8 target_slot, const Sint8 pan, const Sint32 fade_time);
EXTERN SDE_ERR	sdPstmSetPitch( SDPSTM handle, const Sint8 target_slot, const Sint16 pitch, const Sint32 fade_time);
EXTERN SDE_ERR	sdPstmSetUseSlotNum( SDPSTM handle, const Sint8 use_slot_num);
EXTERN SDE_ERR	sdPstmSetVol( SDPSTM handle, const Sint8 target_slot, const Sint8 vol, const Sint32 fade_time);
EXTERN SDE_ERR	sdPstmStop( SDPSTM handle);
EXTERN SDE_ERR	sdPstmStopAll( Void);

/*	One Shot port  */
EXTERN SDE_ERR	sdShotClose( SDSHOT handle);	/*	2.50.03(modified)  */
EXTERN SDE_ERR	sdShotCloseAll( Void);	/*	2.02.00(add)  */	/*	2.50.03(modified)  */
EXTERN SDE_ERR	sdShotGetCurAdr( const SDSHOT handle, Sint32 *cur_smp_adr);	/*	2.50.03(modified)  */
EXTERN SDE_ERR	sdShotGetStat( const SDSHOT handle, SDS_SHOT_STAT *shot_stat);	/*	2.50.03(modified)  */
EXTERN SDE_ERR	sdShotGetTotalSmpFrame( const SDSHOT handle, Uint32 *cur_smp_frame);	/*	2.50.03(modified)  */
EXTERN SDE_ERR	sdShotOpen( SDSHOT *handle);	/*	2.50.03(modified)  */
EXTERN SDE_ERR	sdShotPlay( SDSHOT handle, const Sint8 bank_num, const Sint8 data_num, const Sint8 priority);
EXTERN SDE_ERR	sdShotResetPrm( SDSHOT handle);
EXTERN SDE_ERR	sdShotResetAllPrm( Void);
EXTERN SDE_ERR	sdShotSetDrctLev( SDSHOT handle, const Sint8 drct_lev);
EXTERN SDE_ERR	sdShotSetFxInCh( SDSHOT handle, const Sint8 fx_in_ch, const Sint8 fx_base_lev);	/*	2.50.03(modified)  */
EXTERN SDE_ERR	sdShotSetFxInLev( SDSHOT handle, const Sint8 fx_lev);	/*	2.50.03(modified)  */
EXTERN SDE_ERR	sdShotSetPan( SDSHOT handle, const Sint8 pan, const Sint32 fade_time);
EXTERN SDE_ERR	sdShotSetPitch( SDSHOT handle, const Sint16 pitch, const Sint32 fade_time);
EXTERN SDE_ERR	sdShotSetPlayTime( SDSHOT handle, const SDE_SHOT_PLAY_TIME scale_type, const Sint32 time_value);	/*	2.50.03(modified)  */
EXTERN SDE_ERR	sdShotSetReleaseMode( SDSHOT handle, const SDE_PORT_RELEASE_MODE release_mode);
EXTERN SDE_ERR	sdShotSetVol( SDSHOT handle, const Sint8 vol, const Sint32 fade_time);
EXTERN SDE_ERR	sdShotStop( SDSHOT handle);
EXTERN SDE_ERR	sdShotStopAll( Void);

/*****************************************************
 *
 *	外部変数宣言
 *
 */

#endif	/*	#ifndef	_SG_SD_H_  */

/*EOF*/
