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

📄 aphearsaycommand.c

📁 本电子词典是名人928的学习机代码,主要是电子学习机AP,其他还没有传
💻 C
📖 第 1 页 / 共 2 页
字号:
/****************************************************************************/
/*                                                                          */
/*              Copyright (C) 2005 SHENZHEN MEIJIN CO.LTD                   */
/*                                                                          */
/* FILE NAME:   ApHearSayCommand.c                                          */
/* MODULE NAME: AP应用程序                                                  */
/* DESCRIPTION: Hearsya command                                             */
/*                                                                          */
/* FUNCTIONS:                                                               */
/*                                                                          */
/****************************************************************************/
/*    NAME         DATE               REMARKS                               */
/* ==========  ============   ==============================================*/
/*   DennyHan    2006-03-11         V1.00B                                  */
/****************************************************************************/

// 包含必要的头文件
#include	"Ap.h"
#include	"ApHearSay.h"
#include	"ApHearSaySet.h"

extern RrParam		g_RrParam;
extern MVoicePlayParam g_VoicePlayParam;
//============================================================================
INT  HearSayEvent_CPlay ( APGUI_STRUCT *pGui, UINT uEvent, UINT uParam )
{
   // DrawCurrentAp();
	if  (g_RrParam.wSndMode &APHS_REPEAT)
    {   // if repeat mode
        // Stop
        HearSayEvent_C2 (pGui, EVENT_COMMAND,CMD_HS_RPT_END);
    }

    if (!ApHsSndIsBusy())
    {
        ApHsClearRptMode();

		if ( g_RrParam.wRptMode & RR_MODE_MANUAL)
        { // if A-B Mode
            ApHsGetPlayTm(0);
    		if (g_RrParam.aPlay[0].dwPlayTm >= g_RrParam.aPlay[0].dwTotalTm)
            {
       	    	g_RrParam.aPlay[0].dwPlayTm = 0;
	    		ApHsSetPlayTm(0);
            }
    	}

        // Set Current Point to A
        //HearSayEvent_KeyAB( pGui,EVENT_KEY,APHS_KEY_A_EXP);
		HearSayEvent_KeyAB( pGui,EVENT_KEY,APHS_KEY_A);

        return HearSayEvent_C1 (pGui, uEvent, uParam );
    }

    return 1;
}

INT  HearSayEvent_CStop ( APGUI_STRUCT *pGui, UINT uEvent, UINT uParam )
{
    /*--------------------------------------------------------*/
	 //g_VoicePlayParam.dwPlayOffset-=500;
    /*---------------------------------------------------------*/
	if (ApHsSndIsBusy())
    {
        ApHsClearRptMode();
		
        return HearSayEvent_C1 (pGui, uEvent, uParam );
    }
    else
    {   
        ApHsHint((const char *)APHS_CUROP_FAIL);
    }
    return 1;
}

/****************************************************************************/
/* FUNCTION:   INT  HearSayEvent_C1( APGUI_STRUCT *pGui,                   */
/*                                            UINT uEvent, UINT uParam )    */
/* INPUTS:     NONE                                                        */
/* OUTPUTS:    NONE                                                        */
/****************************************************************************/
/*    NAME         DATE               REMARKS                               */
/* ==========  ============   ==============================================*/
/*   DennyHan    2006-03-15          First Issue                            */
/****************************************************************************/
// Command for Play or Stop
INT  HearSayEvent_C1 ( APGUI_STRUCT *pGui, UINT uEvent, UINT uParam )
{
UINT uParam2;
    APHsStopMark();

//    g_RrParam.wTmABSetFlag &=(~APHS_TMA_KEY_SET);

    // if follow mode
    if (g_RrParam.wSndMode&APHS_FOLLOW)
    {
        if ((g_RrParam.wSndMode & APHS_SOUND_REC) )
        {   // if record sound
            uParam2 = CMD_HS_FOLLOW_RECEND; //CMD_HS_FOLLOW_RECEND
        }
        else
        {   // if record sound, record end to play Sound
            uParam2=CMD_HS_FOLLOW_END;
            if (  (uParam==CMD_HS_STOP) )
            {
                if ((g_RrParam.wSndMode & APHS_SOUND_PLAYREC) )
                {   // if Play REC
                    uParam2=CMD_HS_FOLLOW_PLAYSND;
                }
                else if ((g_RrParam.wSndMode & APHS_SOUND_PLAY) )
                {   //
                    uParam2=CMD_HS_FOLLOW_PLAYREC;
                }
            }
        }
        return HearSayEvent_C3(pGui, EVENT_COMMAND, uParam2);
    }

    // if repeat mode
    if (g_RrParam.wSndMode&APHS_REPEAT)
    {
        return HearSayEvent_C2(pGui, EVENT_COMMAND, CMD_HS_RPT_END);
    }

    if (!APHsStopCurrentSound())
    {// if No sund is playing

		// check it is ending or not
		// if it is to the ending tail, reset to the head
		if ( APHsChkPlayM0Ending() )
		{// Ending of playing, reset the play to the head
	    	g_RrParam.aPlay[0].dwPlayTm = 0;
			ApHsSetPlayTm(0);
			// Reset the text to the head ??????
		}

        ApHsStartPlay(0);
//		NU_Sleep(20*10);
        g_RrParam.wSndMode |= (APHS_SOUND_PLAY);
    }

    DrawCurrentAp();

    return 1;
}

/****************************************************************************/
/* FUNCTION:   INT  HearSayEvent_C2( APGUI_STRUCT *pGui,                   */
/*                                            UINT uEvent, UINT uParam )    */
/* INPUTS:     NONE                                                        */
/* OUTPUTS:    NONE                                                        */
/****************************************************************************/
/*    NAME         DATE               REMARKS                               */
/* ==========  ============   ==============================================*/
/*   DennyHan    2006-03-15          First Issue                            */
/****************************************************************************/
// Repeat Command
static BOOL HearSayEvent_SetRptTime(VOID)
{
UINT16  wNode;
    if (g_RrParam.wRptMode& RR_MODE_MANUAL)
	{   // Manual
        if (  (g_RrParam.wTmABSetFlag&APHS_TMA_SET)
           &&(g_RrParam.wTmABSetFlag&APHS_TMB_SET)  )
        {
    	    g_RrParam.dwRptTmA=g_RrParam.dwTmA;
	    	g_RrParam.dwRptTmB=g_RrParam.dwTmB;
        }
        else
        {	// if no set AB Time stamp point
            return FALSE;
        }
	}
	else
	{   // Auto
	    wNode=ApHsGetTextTimeNode();

		// Not this time is 0.1s
	    g_RrParam.dwRptTmA=ApHsGetTextNodeTime(wNode);
		//g_RrParam.dwRptTmB=ApHsGetTextNodeTime((UINT16)(wNode+1));
        g_RrParam.dwRptTmB=ApHsGetTextNodeTimeLength((UINT16)(wNode))
                            +g_RrParam.dwRptTmA;
        if (wNode)
        {
        UINT16 wPrevNode;
        UINT32  dwPreTim;

            wPrevNode = wNode -1;
            dwPreTim = ApHsGetTextNodeTime(wPrevNode);
            dwPreTim += ApHsGetTextNodeTimeLength(wPrevNode);
            dwPreTim = (g_RrParam.dwRptTmA-dwPreTim);
#if 1
            if (dwPreTim<=100)
            {
//                if ( dwPreTim > 10 )
//                {
                    g_RrParam.dwRptTmA -= (dwPreTim-10);
//                }
            }
#endif
//            else if (dwPreTim<500)
//            {
//                g_RrParam.dwRptTmA -= dwPreTim/2;
//            }
        }
	}
    return TRUE;
}

//---------------------------------
// Repeat
INT  HearSayEvent_C2 ( APGUI_STRUCT *pGui, UINT uEvent, UINT uParam )
{
INT		nRet;
    nRet=1;

    if (g_RrParam.wSndMode&APHS_SOUND_REC)
    {   // error for record, if record sound, do not
        ApHsHint( (const char *)APHS_CUROP_INVALID);
    }
    else
    {   // if Not in record mode

		if (   (g_RrParam.wTmABSetFlag&APHS_TMA_SET)
			&& (g_RrParam.wTmABSetFlag&APHS_TMB_SET) )
		{
			if (g_RrParam.dwTmB <= g_RrParam.dwTmA)
			{	//  B <=A
				if ( g_RrParam.wSndMode &APHS_REPEAT )
				{
					ApHsGetPlayTm(0);
					g_RrParam.aPlay[0].dwPrevTm = g_RrParam.aPlay[0].dwPlayTm;
					uEvent = EVENT_COMMAND;
					uParam = CMD_HS_RPT_END;
					ApHsHint((const char *)APHS_RPT_AB_SHORTFAIL);
				}
				else
				{
					ApHsHint((const char *)APHS_RPT_FAIL);
					return 1;
				}
			}
		}

        if (uParam==HEARSAY_BTN2_CMD)
		{
			if (g_RrParam.wRptMode& RR_MODE_MANUAL)
            {
			    if (    !(g_RrParam.wTmABSetFlag&APHS_TMA_SET)
					||  !(g_RrParam.wTmABSetFlag&APHS_TMB_SET) )
			    {
					// if sound is stop status
                    if (!ApHsRestoreBakABPlay())
					{   // if No AB Backup
               			ApHsHint((const char *)APHS_AB_REQUIRED);
						return 1;
                    }
                }
			}
		}

        // Stop sound first first
        APHsStopCurrentSound();
        APHsStopMark();

        switch(uParam)
        {
        case CMD_HS_RPT_END:
            // if repeat ending
            g_RrParam.wSndMode &= (~APHS_REPEAT);

            ApHsGetPlayTm(0);
			if (! (g_RrParam.wRptMode& RR_MODE_MANUAL))
            { // if MST auto Mode
				if (g_RrParam.aPlay[0].dwPlayTm >= g_RrParam.aPlay[0].dwTotalTm)
                {
                    break;
                }
			}
  		    g_RrParam.aPlay[0].dwPlayTm=g_RrParam.aPlay[0].dwPrevTm;
	    	ApHsSetPlayTm(0);
            break;
        default:
        case HEARSAY_BTN2_CMD:
            // if start repeat
			ApHsSetBakABPlay();

	        g_RrParam.wRptCycles=g_RrParam.wRptTotalCycles;     //当前复读环数

			ApHsGetPlayTm(0);

			if (! (g_RrParam.wRptMode& RR_MODE_MANUAL))
			{// if MST auto Mode
				g_RrParam.aPlay[0].dwPrevTm = g_RrParam.aPlay[0].dwPlayTm;
			}
			else
			{
	            g_RrParam.aPlay[0].dwPrevTm = g_RrParam.dwTmB;
			}

            if (!HearSayEvent_SetRptTime())
            {
                HearSayEvent_C2( pGui,uEvent,CMD_HS_RPT_END);
                ApHsHint((const char *)APHS_AB_REQUIRED);
                break;
            }
            // Show One Repeat Mode

⌨️ 快捷键说明

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