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

📄 masndseq.c

📁 是一个手机功能的模拟程序
💻 C
📖 第 1 页 / 共 3 页
字号:
SINT32 MaSound_Control
(
	SINT32	func_id,					/* function id */
	SINT32	file_id,					/* file id */
	UINT8	ctrl_num,					/* control number */
	void *	prm,						/* parameter */
	void *	ext_args					/* for future extension */
)
{
	UINT32	start_point;				/* start point */
	UINT32	end_point;					/* end point */
	UINT32	position;					/* position */
	UINT32	play_length;				/* play length */
	SINT32	result;						/* result of function */
	UINT8	seq_type;
	UINT32	dPos;

	MASNDSEQ_DBGMSG(("MaSound_Control: id=%ld hd=%ld cn=%d\n", func_id, file_id, ctrl_num));

	if ( ( ma_sndseq_info.srmcnv_map & (UINT32)(1 << func_id) ) == 0 )
	{
		return MASMW_ERROR;
	}

	switch ( ctrl_num )
	{
	case MASMW_GET_STATE:
	
		return (UINT32)ma_sndseq_info.state[func_id][file_id];
	 /*	break; */

	case MASMW_GET_CONTENTSDATA:
	
		if ( ( ma_sndseq_info.state[func_id][file_id] < MASMW_STATE_LOADED )
		  && ( file_id != 0 ) )
		{
			return MASMW_ERROR;
		}
		if ( ((PMASMW_CONTENTSINFO)prm)->size == 0 )
		{
			return MASMW_ERROR_ARGUMENT;
		}
		break;
	
	case MASMW_GET_PHRASELIST:

		if ( ( ma_sndseq_info.state[func_id][file_id] < MASMW_STATE_LOADED )
		  && ( file_id != 0 ) )
		{
			return MASMW_ERROR;
		}
		break;

	case MASMW_SET_STARTPOINT:

		if ( ma_sndseq_info.state[func_id][file_id] != MASMW_STATE_OPENED )
		{
			return MASMW_ERROR;
		}

		start_point = *((UINT32 *)prm);
		play_length = ma_sndseq_info.play_length[func_id][file_id];
		if ( start_point > play_length )
		{
			return MASMW_ERROR;
		}
		else
		{
			ma_sndseq_info.start_point[func_id][file_id] = start_point;
			ma_sndseq_info.seek_point[func_id][file_id]  = start_point;
#if MASMW_SRMCNV_MUL
			if (func_id == MASMW_CNVID_MUL)
				break;
			else
				return MASMW_SUCCESS;
#else
			return MASMW_SUCCESS;
#endif
		}

	 /*	break; */

	case MASMW_SET_ENDPOINT:

		if ( ma_sndseq_info.state[func_id][file_id] != MASMW_STATE_OPENED )
		{
			return MASMW_ERROR;
		}

		end_point = *((UINT32 *)prm);
		play_length = ma_sndseq_info.play_length[func_id][file_id];
		if ( end_point > play_length )
		{
			return MASMW_ERROR;
		}
		else
		{
			ma_sndseq_info.end_point[func_id][file_id] = end_point;
		}

		break;

	case MASMW_GET_POSITION:

		if ( ma_sndseq_info.state[func_id][file_id] < MASMW_STATE_OPENED )
		{
			return MASMW_ERROR;
		}

		if ( ma_seqtype[func_id] == 0 )
		{
			result = ma_srmcnv_func[func_id].Control( file_id, ctrl_num, prm, ext_args );
			if ( result >= 0 )
			{
				position = ma_sndseq_info.seek_point[func_id][file_id] + result;
				play_length = ma_sndseq_info.loop_length[func_id][file_id];

				if ( (play_length != 0 ) && ( position > play_length ) )
					return play_length;
				else
					return position;
			}
			else
			{
				return result;
			}
		}

		break;

	case MASMW_SET_SPEEDWIDE:
	case MASMW_SET_VOLUME:
	case MASMW_SET_SPEED:
	case MASMW_SET_KEYCONTROL:
	case MASMW_GET_TIMEERROR:
	case MASMW_SEND_MIDIMSG:
	case MASMW_SEND_SYSEXMIDIMSG:
	case MASMW_SET_BIND:
	case MASMW_SET_PANPOT:
	case MASMW_GET_LEDSTATUS:
	case MASMW_GET_VIBSTATUS:
	case MASMW_SET_EVENTNOTE:
	case MASMW_GET_CONVERTTIME:
		if ( ma_sndseq_info.state[func_id][file_id] < MASMW_STATE_OPENED )
		{
			return MASMW_ERROR;
		}
		break;

	case MASMW_GET_LOADINFO:
		/* get file information */
		break;

	case MASMW_SET_LOADINFO:
		/* set file information */
		break;

	case MASMW_GET_LENGTH:
	
		if ( ( ma_sndseq_info.state[func_id][file_id] < MASMW_STATE_LOADED )
		  && ( file_id != 0 ) )
		{
			return MASMW_ERROR;
		}
		break;

	case MASMW_SET_REPEAT:
	
		seq_type = ma_seqtype[func_id];
		if ((( ma_sndseq_info.state[func_id][file_id] != MASMW_STATE_READY ) &&
			 ( ma_sndseq_info.state[func_id][file_id] != MASMW_STATE_PAUSE ))
		  || ( seq_type == 1 ) )
		{
			return MASMW_ERROR;
		}
		ma_sndseq_info.repeat_mode[seq_type][file_id] = (UINT16)*((UINT8*)prm);
		ma_sndseq_info.play_mode[seq_type][file_id] = (UINT16)*((UINT8*)prm);
		ma_sndseq_info.loop_count[seq_type][file_id] = (UINT16)*((UINT8*)prm);
		dPos = (seq_type == 2) ? 0 : MaSound_Control(func_id, file_id, MASMW_GET_POSITION, NULL, NULL);
		return (MaSound_Seek(func_id, file_id, dPos, 0, NULL));

	case MASMW_GET_CONTROL_VAL:
		if ( ma_sndseq_info.state[func_id][file_id] < MASMW_STATE_READY )
		{
			return MASMW_ERROR;
		}
		break;

	case MASMW_SET_CB_INTERVAL:
		if ( ma_sndseq_info.state[func_id][file_id] != MASMW_STATE_LOADED )
		{
			return MASMW_ERROR;
		}
		break;

	default:
		return MASMW_ERROR;
	}

	result = ma_srmcnv_func[func_id].Control( file_id, ctrl_num, prm, ext_args );


	return result;
}
/****************************************************************************
 *	MaSound_Standby
 *
 *	Function:
 *			Performs standby processing of Stream Converter.
 *	Argument:
 *			func_id		function id
 *			file_id		file id
 *			ext_args	for future extension
 *	Return:
 *			0			success
 *			< 0			error code
 *
 ****************************************************************************/
SINT32 MaSound_Standby
(
	SINT32	func_id,					/* function id */
	SINT32	file_id,					/* file id */
	void *	ext_args					/* for future extension */
)
{
	UINT8	seq_type;					/* type of sequence */
	UINT32	pos;						/* position */
	SINT32	result;						/* result of function */
	SINT32	result2;

	MASNDSEQ_DBGMSG(("MaSound_Standby: id=%ld hd=%ld\n", func_id, file_id));

	if ( ( ma_sndseq_info.srmcnv_map & (UINT32)(1 << func_id) ) == 0 )
	{
		return MASMW_ERROR;
	}

	if ( ma_sndseq_info.state[func_id][file_id] != MASMW_STATE_OPENED )
	{
		return MASMW_ERROR;
	}

	result = ma_srmcnv_func[func_id].Standby( file_id, ext_args );

	if ( result >= MASMW_SUCCESS )
	{
		seq_type = ma_seqtype[func_id];
		ma_sndseq_info.repeat_mode[seq_type][file_id] = 0xFFFF ;
		ma_sndseq_info.play_mode[seq_type][file_id]  = 0xFFFF;
		ma_sndseq_info.save_mode[seq_type][file_id]  = 0xFFFF;
		ma_sndseq_info.loop_count[seq_type][file_id] = 0xFFFF;

		pos = ma_sndseq_info.start_point[func_id][file_id];
		result2 = ma_srmcnv_func[func_id].Seek( file_id, pos, 0, ext_args );
		if ( result2 < MASMW_SUCCESS )
		{
			return result2;
		}

		ma_sndseq_info.seek_pos0[func_id][file_id]  = (UINT32)result2;
		ma_sndseq_info.seek_point[func_id][file_id] = (UINT32)(pos + (UINT32)result2);

		ma_sndseq_info.state[func_id][file_id] = MASMW_STATE_READY;
	}

	return result;
}
/****************************************************************************
 *	MaSound_Seek
 *
 *	Function:
 *			Performs seeking processing of Stream Converter.
 *	Argument:
 *			func_id		function id
 *			file_id		file id
 *			pos			playing position from top or start point [ms]
 *			flag		wait(0: wait without before play, 1: wait with before play)
 *			ext_args	for future extension
 *	Return:
 *			0			success
 *			< 0 		error code
 *
 ****************************************************************************/
SINT32 MaSound_Seek
(
	SINT32	func_id,					/* function id */
	SINT32	file_id,					/* file id */
	UINT32	pos,						/* start position (msec) */
	UINT8	flag,						/* flag */
	void *	ext_args					/* for future extension */
)
{
	UINT8	seq_type;					/* type of sequence */
	UINT16	loop_count;					/* loop count */
	UINT32	start_point;				/* start point */
	UINT32	end_point;					/* end point */
	UINT32	play_length;				/* play length */
	SINT32	result;						/* result of function */
	
	MASNDSEQ_DBGMSG(("MaSound_Seek: id=%ld hd=%ld pos=%ld fg=%d\n", func_id, file_id, pos, flag));

	if ( ( ma_sndseq_info.srmcnv_map & (UINT32)(1 << func_id) ) == 0 )
	{
		return MASMW_ERROR;
	}

	if ( ( ma_sndseq_info.state[func_id][file_id] != MASMW_STATE_READY )
	  && ( ma_sndseq_info.state[func_id][file_id] != MASMW_STATE_PAUSE ) )
	{
		return MASMW_ERROR;
	}

	start_point = ma_sndseq_info.start_point[func_id][file_id];
	end_point   = ma_sndseq_info.end_point[func_id][file_id];
	play_length = ma_sndseq_info.play_length[func_id][file_id];

	pos += start_point;

	if ( ( pos > end_point ) || ( pos > play_length ) )
	{
		return MASMW_ERROR;
	}

	result = ma_srmcnv_func[func_id].Seek( file_id, pos, flag, ext_args );

	if ( result >= MASMW_SUCCESS )
	{
		ma_sndseq_info.seek_point[func_id][file_id] = (UINT32)(pos + (UINT32)result);

		seq_type = ma_seqtype[func_id];
		
		if ( seq_type != 1 )
		{
			loop_count = ma_sndseq_info.loop_count[seq_type][file_id];
			ma_sndseq_info.play_mode[seq_type][file_id] = loop_count;
		}
		
		result = MASMW_SUCCESS;
	}


	return result;
}
/****************************************************************************
 *	MaSound_Start
 *
 *	Function:
 *			Performs starting process of Stream Converter.
 *	Argument:
 *			func_id		function id
 *			file_id		file id
 *			play_mode	playing mode
 *			ext_args	for future extension
 *	Return:
 *			0			success
 *			< 0 		error code
 *
 ****************************************************************************/
SINT32 MaSound_Start
(
	SINT32	func_id,					/* function id */
	SINT32	file_id,					/* file id */
	UINT16	play_mode,					/* playing mode */
	void * 	ext_args					/* for future extension */
)
{
	UINT8	seq_type;					/* type of sequence */
	UINT16	save_play_mode = 0;
	SINT32	save_func_id = 0;
	SINT32	save_file_id = 0;
	UINT32	start_point;				/* start point */
	UINT32	end_point;					/* end point */
	SINT32	result;						/* result of function */
	
	MASNDSEQ_DBGMSG(("MaSound_Start: id=%ld hd=%ld pm=%d\n", func_id, file_id, play_mode));

	if ( ( ma_sndseq_info.srmcnv_map & (UINT32)(1 << func_id) ) == 0 )
	{
		return MASMW_ERROR;
	}

	if ( ma_sndseq_info.state[func_id][file_id] != MASMW_STATE_READY )
	{
		return MASMW_ERROR;
	}

	start_point = ma_sndseq_info.start_point[func_id][file_id];
	end_point   = ma_sndseq_info.end_point[func_id][file_id];
	if ( start_point >= end_point )
	{
		return MASMW_ERROR;
	}

	if ( (end_point - start_point) <= MA_MIN_LENGTH )
	{
		return MASMW_ERROR;
	}

	seq_type = ma_seqtype[func_id];

#if MA_PLAYMODE_CHECK
	if ( ( ma_sndseq_info.save_mode[seq_type][file_id] != 0xFFFF ) &&
		 ( ma_sndseq_info.save_mode[seq_type][file_id] != play_mode ) &&
		 ( ma_sndseq_info.repeat_mode[seq_type][file_id] == 0xFFFF ) )
	{
		return MASMW_ERROR;
	}
#endif

	save_func_id = ma_sndseq_info.func_id[seq_type];
	save_file_id = ma_sndseq_info.file_id[seq_type];
	save_play_mode = play_mode;

	ma_sndseq_info.func_id[seq_type] = func_id;
	ma_sndseq_info.file_id[seq_type] = file_id;

	ma_sndseq_info.state[func_id][file_id] = MASMW_STATE_PLAYING;

	ma_sndseq_info.start_extargs[func_id][file_id] = ext_args;

	if ( seq_type != 1 )
	{
		if ( ( ma_sndseq_info.play_mode[seq_type][file_id] == 0xFFFF )
		  && ( ma_sndseq_info.loop_count[seq_type][file_id] == 0xFFFF ) )

⌨️ 快捷键说明

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