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

📄 guievents.c

📁 DSP 基于 TMS320C6711 DSK 的功能演示程序
💻 C
字号:
/*
 *  Copyright 2001 by Texas Instruments Incorporated.
 *  All rights reserved. Property of Texas Instruments Incorporated.
 *  Restricted rights to use, duplicate or disclose this code are
 *  granted through contract.
 *  U.S. Patent Nos. 5,283,900  5,392,448
 */
/* "@(#) XDAS 2.12 05-21-01 (__imports)" */
/*
 *  ======== guiEvents.c ========
 */  
 
#include <demo.h> 
#include <std.h>

extern Bool encodeEnable;   /* vocoder toggle/switch  */
extern Bool cancelEnable;   /* line-echo canceler toggle/switch  */
extern LOG_Obj trace;       /* application printf() log */

ChannelObject  channel[DEMO_MAX_CHANNELS];  /* each channel's alg's objects */     
/* THESE 2 host variables MUST BE ADJACENT to match the GUI plugin */
volatile Int hostUpdate;
volatile Int hostState[2][DEMO_NUM_OPTIONS];

/*
 *  ======== hostPollFxn ========
 */
Void hostPollFxn(Void)
{
    Int i;
    Int c;

    /* if options were not changed then there is nothing to do */
    if (hostUpdate == 0) return;
    
    c = 0;
    
    channel[c].LECstatus.size = sizeof(channel[c].LECstatus);  
    
    /* 
     *  Record current algorithm (LEC & G723) state info in channel state structures.
     */
    LEC_control(channel[c].lec, ILEC_GETSTATUS, &(channel[c].LECstatus));

    G723ENC_control(channel[c].enc, IG723_GETSTATUS, (IG723ENC_Status *)&(channel[c].encoderStatus));
    G723DEC_control(channel[c].dec, IG723_GETSTATUS, (IG723DEC_Status *)&(channel[c].decoderStatus));




    /*
     *  hostState[0][i] : set to 1 if option<i> has changed
     *  hostState[1][i] : carries the new value for option<i> --if applicable  
     */
                
    for (i=0; i<DEMO_NUM_OPTIONS; i++) {
        /* option 'i' has changed */
        if (hostState[0][i] != 0) {
            switch (i)   {
                        
            case DEMO_G165_OPTION:
                {
                /* toggle the LEC(G165) option */
                channel[c].selections = hostState[1][i]; //channel[c].selections ^ DEMO_G165_ENABLE;
                LOG_printf(&trace, "G165 option set to %s.\n", (hostState[1][i])? "ON" : "OFF");
                cancelEnable = (hostState[1][i])? TRUE : FALSE;
                break;
                }
            case DEMO_G723_OPTION:
                {
                /* toggle the G723 option */
                channel[c].selections = hostState[1][i]; //channel[c].selections ^ DEMO_G723_ENABLE;
                LOG_printf(&trace, "VOCODER option set to %s.\n", (hostState[1][i])? "ON" : "OFF");
                encodeEnable = (hostState[1][i])? TRUE : FALSE;
                break;
                }
            
            case DEMO_G165_NLP_OPTION:
                {
                /* toggle the G165 LEC Non-linear processor option */
                channel[c].LECstatus.nonLPEnable = (hostState[1][i])? TRUE : FALSE;
                LOG_printf(&trace, "G165 NLP option set to %s.\n", (channel[c].LECstatus.nonLPEnable)? "ON" : "OFF");
                break;
                }

            case DEMO_G723_HPF_OPTION:
                {
                /* toggle the G.723.1 Encoder High pass filter option */
                channel[c].encoderStatus.hpfEnable = (hostState[1][i])? TRUE : FALSE;
                LOG_printf(&trace, "G723E HPF option set to %s.\n", (channel[c].encoderStatus.hpfEnable)? "ON" : "OFF");
                break;
                }
            case DEMO_G723_VAD_CNG_OPTION:
                {
                /* toggle the G.723.1 Encoder VAD/CNG option */
                channel[c].encoderStatus.vadEnable = (hostState[1][i])? TRUE : FALSE;
                LOG_printf(&trace, "G723E VAD/CNG option set to %s.\n", (channel[c].encoderStatus.vadEnable)? "ON" : "OFF");
                break;
                }
            case DEMO_G723_RATE_OPTION:
                {
                /* this sets the G.723.1 Encoder Rate option */
                channel[c].encoderStatus.rate = (hostState[1][i]) ?
                         IG723_6300BPS : IG723_5300BPS;
                if (channel[c].encoderStatus.rate == IG723_6300BPS) {
                    LOG_printf(&trace, "G723 rate option set to 6300\n");
                }
                else {
                    LOG_printf(&trace, "G723 rate option set to 5300\n");
                }
                break;
                }
            case DEMO_G723_POSTFILTER_OPTION:
                {
                /* toggle the G.723.1 Decoder Postfilter option */
                channel[c].decoderStatus.pfoEnable = (hostState[1][i])? TRUE : FALSE;
                LOG_printf(&trace, "G723D Postfilter option set to %s.\n", (channel[c].decoderStatus.pfoEnable)? "ON" : "OFF");
                break;
            }  



            }
        }
    }  
    
    /* 
     *  Update algorithm (LEC & G723) state with any changed state info learned from GUI
     *  in the channel state structures.
     */
    LEC_control(channel[c].lec, ILEC_SETSTATUS, &(channel[c].LECstatus));

    G723ENC_control(channel[c].enc, IG723_SETSTATUS, (IG723ENC_Status *)&(channel[c].encoderStatus));
    G723DEC_control(channel[c].dec, IG723_SETSTATUS, (IG723DEC_Status *)&(channel[c].decoderStatus));




    /* clear hostUpdate flag */
    hostUpdate = 0;
}

/*
 *  ======== getInstanceMemorySize ========
 */ 
Int getInstanceMemorySize(IALG_Fxns *fxn, IALG_Params *algParams)
{
    Uint32 i, numBlocks, totalMemSize;
    IALG_MemRec memTab[DEMO_MAXMEMRECS];

    /*
     * call standard xDAIS interface (IALG) function  algAlloc()
     * to obtain the number and size of memory blocks requested by Algorithm
     */
    numBlocks = fxn->algAlloc(algParams, NULL, memTab);

    totalMemSize = 0;

    /* 
     *  Tally up sizes for each requested block.
     */
    for (i=0;i<numBlocks;i++) {
        totalMemSize += memTab[i].size;
    }

    return (totalMemSize);
}

⌨️ 快捷键说明

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