⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 melody_api.h

📁 是一个手机功能的模拟程序
💻 H
字号:
#ifndef _MELODY_API_H_
#define _MELODY_API_H_

#ifdef __cplusplus
extern "C" 
{
#endif

/* Melody API immediat return */
typedef SINT32 T_MELODY_RET;

/* T_MELODY_RET value */
#define MI_MELODY_OK				(0)		/* execute success */
#define MI_MELODY_ERROR				(-1)	/* general execute error, caused by invoking MA middleware API */
#define MI_MELODY_PARA_ERR			(-2)	/* parameter error */
#if (MELODY_FFS_SUPPORT == 1)
#define MI_MELODY_FILE_NOT_EXIST	(-3)	/* the flash file to be player is not exist */
#define MI_MELODY_FILE_SIZE_ZERO	(-4)	/* the length of the flash file to be played is zero */
#endif
#define MI_MELODY_FILE_TYPE_ERR		(-5)	/* not supported file type */
#define MI_MELODY_INITIALIZED		(-6)    /* initlize has done */
#define MI_MELODY_NOT_INIT			(-7)	/* sound device not init */
#if (MELODY_FFS_SUPPORT == 1)
#define MI_MELODY_FILE_SIZE_LARGE	(-8)	/* the length of the music file exceeds the system resource limitation */
#define MI_MELODY_FILE_READ_ERR		(-9)	/* load FFS music file error */
#define MI_MELODY_FILE_TYPE_UNKNOW	(-10)	/* file type unknow */
#endif


/* music ID and num of music */
#define MI_MELODY_MUSICNUM_TOTAL		(100)
#define MI_MELODY_MUSICID_INVALID		(0xff)	/* invalid music ID */
#if (MELODY_FFS_SUPPORT == 1)
#define MI_MELODY_MUSICID_FILE			(0xf0)	/* special ID for ffs files */
#endif

/* speaker volume level setting */
#define MI_MELODY_VOLUME_MIN		(0)	 /* minimal speaker volume setting level */
#define MI_MELODY_VOLUME_MAX		(5)  /* minimal speaker volume setting level */
/* default melody speaker value */
#define MI_MELODY_VOLUME_DEFAULT	MI_MELODY_VOLUME_MAX 

#if (MELODY_FFS_SUPPORT == 1)
#define LEN_MELODY_FILE_NAME		30
#endif

/* Currently melody playing state */
typedef struct PlayStateRet
{
	UINT8   	  musicID;		/* music file ID */	
	UINT8		  curVolume;	/* current speaker volume */
	UINT8		  remainCnt;	/* remained replay count */
	UINT32		  curPos;		/* current playing position */
#if (MELODY_FFS_SUPPORT ==1)	/* robert.chen, 2004-07-05 */
	UINT8		  name[LEN_MELODY_FILE_NAME];
#endif	
} T_MELODY_STATE_RET;

/* Melody initialization option */
typedef enum MelodyInitOpt
{
	MelInitNormal,	/* normal init, if init has done previosly, return */
	MelInitForced	/* init arbitrary */
} T_MELODY_INIT_OPT;

#define T_MELODY_VBR_STARET	T_MELODY_VBR_SETTING

/* Initialize the MA sound middleware and internal control block */
T_MELODY_RET MI_Melody_Initialize(T_MELODY_INIT_OPT option);

#if (MELODY_FFS_SUPPORT)
/* Start play a music saved as a FFS file */
T_MELODY_RET MI_PlayFile_Start(const char *musicName, UINT8 type, UINT8 count);
#endif

/* Start play a music according to specified replay count */
T_MELODY_RET MI_PlayMusic_Start(UINT8 musicNo, UINT8 count);

/* Stop the music that is playing currently */
T_MELODY_RET MI_PlayMusic_Stop(void);

/*
 * Pause the currently playing music, the returned current playing status will
 * be used as input parameter of function MI_PlayMusic_Resume() to resume a 
 * previously posted music
 */
T_MELODY_RET MI_PlayMusic_Pause(T_MELODY_STATE_RET * const staRet);

/*
 * Resume a previously posted music specified by playing state returned when the
 * music was paused
 */
T_MELODY_RET MI_PlayMusic_Resume(const T_MELODY_STATE_RET *staRet);

/* Set speaker volume with a specified level (0~5) */
T_MELODY_RET MI_Volume_Set(UINT8 spkVol);

/* Get current speaker volume level (0~5) */
T_MELODY_RET MI_Volume_Get(UINT8* spkVol);

/* 
 * Increase the speaker volume by one step, if the pointer curVol not equal NULL,
 * new volume setting after the operation returned
 */
T_MELODY_RET MI_Volume_Up(UINT8* curVol);

/* 
 * Decrease the speaker volume by one step, if the pointer curVol not equal NULL,
 * new volume setting after the operation returned
 */
T_MELODY_RET MI_Volume_Down(UINT8* curVol);

/* Set the vibrator control source and config blinking frequency */
T_MELODY_RET MI_Vibrator_SetMode(UINT8 ctrlSrc, UINT8 blkFreq);

/* Get the vibrator current setting and state */
T_MELODY_RET MI_Vibrator_GetMode(T_MELODY_VBR_SETTING *const vbrSet);

/* Forced the vibrator on/off */
T_MELODY_RET MI_Vibrator_ForcedCtrl(UINT8 ctrl);

#ifdef __cplusplus
}
#endif

#endif /* _MELODY_API_H_ */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -