realtime_demo_bios: change project name to K2G_bf_rt, add DRC processing code
authorMing Wei <a0868762@ti.com>
Wed, 18 Jan 2017 18:37:17 +0000 (12:37 -0600)
committerMing Wei <a0868762@ti.com>
Wed, 18 Jan 2017 18:37:17 +0000 (12:37 -0600)
Signed-off-by: Ming Wei <a0868762@ti.com>
realtime_demo_bios/k2g/.project
realtime_demo_bios/k2g/K2G_bf_rt.cfg [moved from realtime_demo_bios/k2g/audioAnalogLoopbackTest.cfg with 100% similarity]
realtime_demo_bios/k2g/build/makefile
realtime_demo_bios/k2g/build/subdir_rules.mk
realtime_demo_bios/k2g/build/subdir_vars.mk
realtime_demo_bios/k2g/src/main.c
realtime_demo_bios/k2g/src/makefile.libs
realtime_demo_bios/k2g/src/mcasp_cfg.c

index 8443184bf69ab7e614ca9899dd8ba736fc41447c..3c96c504ec8eeba6811a2e4a3911bf79c43e9096 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>\r
 <projectDescription>\r
-       <name>audioAnalogLoopbackTest</name>\r
+       <name>K2G_bf_rt</name>\r
        <comment></comment>\r
        <projects>\r
        </projects>\r
index 570fb1eee7e8d8ec025315f2137527180ee01cdc..8624c09d925e0a3eab289361830dfbfbdebe3881 100644 (file)
@@ -172,32 +172,32 @@ endif
 \r
 # Add inputs and outputs from these tool invocations to the build variables \r
 EXE_OUTPUTS += \
-audioAnalogLoopbackTest.out \
+K2G_bf_rt.out \\r
 \r
 EXE_OUTPUTS__QUOTED += \
-"audioAnalogLoopbackTest.out" \
+"K2G_bf_rt.out" \\r
 \r
 BIN_OUTPUTS += \
-audioAnalogLoopbackTest.hex \
+K2G_bf_rt.hex \\r
 \r
 BIN_OUTPUTS__QUOTED += \
-"audioAnalogLoopbackTest.hex" \
+"K2G_bf_rt.hex" \\r
 \r
 \r
 # All Target\r
-all: audioAnalogLoopbackTest.out\r
+all: K2G_bf_rt.out\r
 \r
 # Tool invocations\r
-audioAnalogLoopbackTest.out: $(OBJS) $(CMD_SRCS) $(GEN_CMDS)\r
+K2G_bf_rt.out: $(OBJS) $(CMD_SRCS) $(GEN_CMDS)\r
        @echo 'Building target: $@'\r
        @echo 'Invoking: C6000 Linker'\r
-       "$(C6X_GEN_INSTALL_PATH)/bin/cl6x" -mv6600 --abi=eabi --opt_for_speed=5 -g --define=DEVICE_K2G --define=SOC_K2G --define=evmK2G --define=PLATFORM_INIT_IN --define=BUILD_DSP --diag_warning=225 --diag_wrap=off --display_error_number -z -m"audioAnalogLoopbackTest.map" --stack_size=0x2000 -i"${C6X_GEN_INSTALL_PATH}/lib" -i"${C6X_GEN_INSTALL_PATH}/include" -i"${PDK_INSTALL_PATH}/ti/board/lib/evmK2G/c66/release" -i"${PDK_INSTALL_PATH}/ti/addon/cmbk2g/lib/k2g/c66/release" -i"${PDK_INSTALL_PATH}/ti/drv/mcasp/lib/k2g/c66/release" -i"${AER_INSTALL_PATH}/packages/ti/mas/aer/lib" -i"${VOLIB_INSTALL_PATH}/packages/ti/mas/" --reread_libs --diag_wrap=off --display_error_number --warn_sections --xml_link_info="audioAnalogLoopbackTest_linkInfo.xml" --rom_model -o "audioAnalogLoopbackTest.out" $(ORDERED_OBJS)\r
+       "$(C6X_GEN_INSTALL_PATH)/bin/cl6x" -mv6600 --abi=eabi --opt_for_speed=5 -g --define=DEVICE_K2G --define=SOC_K2G --define=evmK2G --define=PLATFORM_INIT_IN --define=BUILD_DSP --diag_warning=225 --diag_wrap=off --display_error_number -z -m"K2G_bf_rt.map" --stack_size=0x2000 -i"${C6X_GEN_INSTALL_PATH}/lib" -i"${C6X_GEN_INSTALL_PATH}/include" -i"${PDK_INSTALL_PATH}/ti/board/lib/evmK2G/c66/release" -i"${PDK_INSTALL_PATH}/ti/addon/cmbk2g/lib/k2g/c66/release" -i"${PDK_INSTALL_PATH}/ti/drv/mcasp/lib/k2g/c66/release" -i"${AER_INSTALL_PATH}/packages/ti/mas/aer/lib" -i"${VOLIB_INSTALL_PATH}/packages/ti/mas/" --reread_libs --diag_wrap=off --display_error_number --warn_sections --xml_link_info="K2G_bf_rt_linkInfo.xml" --rom_model -o "K2G_bf_rt.out" $(ORDERED_OBJS)\r
        @echo 'Finished building target: $@'\r
        @echo ' '\r
 \r
-audioAnalogLoopbackTest.hex: $(EXE_OUTPUTS)\r
+K2G_bf_rt.hex: $(EXE_OUTPUTS)\r
        @echo 'Invoking: C6000 Hex Utility'\r
-       "${C6X_GEN_INSTALL_PATH}/bin/hex6x"  -o "audioAnalogLoopbackTest.hex" $(EXE_OUTPUTS__QUOTED)\r
+       "${C6X_GEN_INSTALL_PATH}/bin/hex6x"  -o "K2G_bf_rt.hex" $(EXE_OUTPUTS__QUOTED)\r
        @echo 'Finished building: $@'\r
        @echo ' '\r
 \r
index 76368cb7558fdef77740d915b27f322f7d10d90f..27eb034cc47fc649a37f72872b4ce66c49dfdf8c 100644 (file)
@@ -3,7 +3,7 @@
 ################################################################################\r
 \r
 # Each subdirectory must supply rules for building sources it contributes\r
-configPkg/linker.cmd: ../audioAnalogLoopbackTest.cfg\r
+configPkg/linker.cmd: ../K2G_bf_rt.cfg\r
        @echo 'Building file: $<'\r
        @echo 'Invoking: XDCtools'\r
        "${XDC_INSTALL_PATH}/xs" --xdcpath="${EDMA3LLD_BIOS6_INSTALLDIR}/packages;C:/ti/ccsv6/ccs_base;${BIOS_INSTALL_PATH}/packages;${UIA_INSTALL_PATH}/packages;${PDK_INSTALL_PATH};${AER_INSTALL_PATH}/packages;${VOLIB_INSTALL_PATH}/packages;${XDAIS_INSTALL_PATH}/packages;${XDAIS_INSTALL_PATH}/examples;../../../realtime_demo_bios/platforms/packages;" xdc.tools.configuro -o configPkg -t ti.targets.elf.C66 -p evmTCI66AK2G02Custom -r debug -c "${C6X_GEN_INSTALL_PATH}" "$<"\r
index f6076f7aef4b51334c8a6ef4f44d27d386a686e7..21d678a0efb617f9a87e6ac34fc18ab93589a0d7 100644 (file)
@@ -7,7 +7,7 @@ CMD_SRCS += \
 ../bflinker.cmd 
 
 CFG_SRCS += \
-../audioAnalogLoopbackTest.cfg 
+../K2G_bf_rt.cfg 
 
 C_SRCS += \
 ../../../common/components/fil.c \
index 260b2a30df7ee226f672b21966d519553c6344ce..8da48c4e4b33b132594535c55ea5d81739f60c3f 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2015, Texas Instruments Incorporated\r
+ * Copyright (c) 2017, Texas Instruments Incorporated\r
  * All rights reserved.\r
  *\r
  * Redistribution and use in source and binary forms, with or without\r
 sysConfig_t sysConfig = {\r
   SYS_MICS_MAX,   /* #microphones */\r
   SYS_VMICS_MAX,  /* #virtual microphones */\r
+  5,              /* 5ms ASNR delay */\r
+  { 12, 9, 6},    /* ASNR band1=12dB, band2=9dB, band3=6dB */\r
+  TRUE,           /* Enable ASNR */\r
   FALSE,          /* Do not use file I/O to load files (must use GEL to load into memory) */\r
-  TRUE            /* Use default angles for microphone configurations */\r
+  TRUE,           /* Use default angles for microphone configurations */\r
+  FALSE,           /* Enable VAD */\r
+  -50,            /* drc expansion knee point in dBm0 (dBFS is dBm0-3dB */\r
+  6,              /* drc max gain in dB */\r
+  FALSE           /* Disable DRC */\r
 };\r
 \r
 /* Global FILE I/O Configuration Structure (must be configured even when file I/O not used */\r
@@ -277,6 +284,9 @@ void main (void)
        sysBfCreate();      /* Create beamformers */\r
        sysAsnrCreate();    /* Create ASNR's */\r
        sysMssCreate();     /* Create MSS */\r
+#if (SYS_USE_DRC)\r
+       sysDrcCreate();     /* Create DRC */\r
+#endif\r
        ///sysVauCreate();     /* Create VAU */\r
 \r
 \r
index 624c2385645dd92c2011b88d000ad1bb55794ebd..da0f39d64a864a9020aee24e38a4eff6e902177d 100644 (file)
@@ -1,6 +1,6 @@
 #
 # This file was generated based on the configuration script:
-#     C:\ti\processor_sdk_rtos_k2g_3_03_00_00\demos\audio-preprocessing\realtime_demo_bios\k2g\audioAnalogLoopbackTest.cfg
+#     C:\ti\processor_sdk_rtos_k2g_3_03_00_00\demos\audio-preprocessing\realtime_demo_bios\k2g\K2G_bf_rt.cfg
 #
 # This makefile may be included in other makefiles that need to build
 # the libraries containing the compiled source files generated as
index 7e9d322574544d524dc872350b422f815fba6523..318f2eb93629ce292bfcf8eac438396eb1d279e2 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2015, Texas Instruments Incorporated\r
+ * Copyright (c) 2017, Texas Instruments Incorporated\r
  * All rights reserved.\r
  *\r
  * Redistribution and use in source and binary forms, with or without\r
  *\r
  */\r
 \r
+#include "fil.h"                      /* FILE I/O implementation */\r
+#include "sys.h"                      /* System API and structures */\r
+#include "sysbfflt.h"                 /* System support for BF filters */\r
+\r
 #include "mcasp_cfg.h"\r
 #include "../include/cmbk2g.h"\r
 \r
 #include <ti/mas/aer/bf.h>\r
 #include "../../../common/components/mss/mss.h"              /* local version used */\r
 #include <ti/mas/vpe/asnr.h>\r
+#if (SYS_USE_DRC)\r
+#include <ti/mas/vau/vau.h>\r
+#include <ti/mas/aer/drc.h>\r
+#endif\r
 \r
 /*----------------------------------------\r
  *  BIOS header files\r
 \r
 #include <ti/sysbios/knl/Semaphore.h> /* this looks obvious */\r
 \r
-#include "fil.h"                      /* FILE I/O implementation */\r
-#include "sys.h"                      /* System API and structures */\r
-#include "sysbfflt.h"                 /* System support for BF filters */\r
-\r
 #define Timestamp_get Timestamp_get32 /* use 32-bit time stamps */\r
 \r
 #define MIN(a,b)    (((a)>(b))?(b):(a))     /* Min/Max macros */\r
@@ -235,6 +239,16 @@ Mcasp_ChanParams  mcaspTxChanParam =
 };\r
 #endif\r
 \r
+#if (SYS_USE_DRC)\r
+/* Output frame for MSS, input for DRC */\r
+#pragma DATA_ALIGN(txOutFrame1,8)\r
+linSample txOutFrame1[SYS_FRAME_LENGTH];\r
+\r
+/* Output frame for DRC, input for VAU */\r
+#pragma DATA_ALIGN(txOutFrame2,8)\r
+linSample txOutFrame2[SYS_FRAME_LENGTH];\r
+#endif\r
+\r
 typedef struct txBfDebug_stc {\r
  tulong frmcnt;     /* normal frames */\r
  tulong silcnt;     /* silence frames */\r
@@ -261,12 +275,14 @@ typedef struct txTaskProfile_stc {
   txTaskProfileData_t   bf;       /* Beamformer profile */\r
   txTaskProfileData_t   asnr;     /* ASNR profile */\r
   txTaskProfileData_t   mss;      /* MSS profile */\r
+  txTaskProfileData_t   drc;      /* DRC profile */\r
   txTaskProfileData_t   vau;      /* VAU profile */\r
 } txTaskProfile_t;\r
 volatile txTaskProfile_t  txTaskProfile = {\r
   {~(0uL), 0, 0, 0.0f},\r
   {~(0uL), 0, 0, 0.0f},\r
   {~(0uL), 0, 0, 0.0f},\r
+  {~(0uL), 0, 0, 0.0f},\r
   {~(0uL), 0, 0, 0.0f}\r
 };\r
 \r
@@ -581,6 +597,7 @@ Void Audio_echo_Task(void)
     void      *inst_p;\r
     linSample *in_r;                      /* pointer to current microphone input buffer */\r
     linSample *frame_p;                   /* pointer to signal frame */\r
+    linSample *outframe_p;                /* Output frame pointer for VAU */\r
     linSample *mics_in[SYS_MICS_MAX+1];     /* pointers to microphone inputs */\r
 \r
     mssDebugStat_t  mssDbg;\r
@@ -663,6 +680,7 @@ Void Audio_echo_Task(void)
            /* Here comes a lot of work */\r
            /* We start with beamformers */\r
 \r
+           /* Start the beamformers */\r
            // get the number of virtual mics\r
            nvmics = sysContext.nvmics;\r
            t1 = Timestamp_get();\r
@@ -687,10 +705,9 @@ Void Audio_echo_Task(void)
             * any protection to prevent the swiDataIn from stepping over while we were doing this.\r
             * We could let this task to handle the read pointer and SWI to handle write pointer which\r
             * could be used to detect if such overrun would happen. */\r
-\r
            /* Done with the beamformers */\r
-           /* Start ASNR's */\r
 \r
+           /* Start ASNR's */\r
            t1 = Timestamp_get();\r
            for (k = 0; k < nvmics; k++) {\r
              inst_p  = sysContext.asnrInst_p[k];   /* fetch the bf instance pointer */\r
@@ -708,13 +725,16 @@ Void Audio_echo_Task(void)
            txTaskProfile.asnr.max = MAX(txTaskProfile.asnr.max,delta);\r
            txTaskProfile.asnr.n++;\r
            txTaskProfile.asnr.total += (float)delta;\r
-\r
            /* Done with the ASNR's */\r
-           /* Run MSS */\r
 \r
+           /* Run MSS */\r
            t1 = Timestamp_get();\r
            inst_p  = sysContext.mssInst_p;         /* fetch the MSS instance pointer */\r
+#if (SYS_USE_DRC)\r
+           frame_p = txOutFrame1;                  /* point to the output frame buffer */\r
+#else\r
            frame_p = outBuf[gtxFrameIndexCount];    /* point to the output frame buffer */\r
+#endif\r
 \r
            err = mssProcess(inst_p,                            /* instance */\r
                                         (void*)frame_p,                /* output frame pointers */\r
@@ -761,15 +781,35 @@ Void Audio_echo_Task(void)
              angle = sysBfFilterAngles[sysBfVMicAngles[mssDbgNewSrc.index]];\r
              ///Log_write6(UIAEvt_intWithKey, angle, 1, mssDbgNewSrc.index, (IArg)"MSS-N: %d, G:%d", 1, mssDbgNewSrc.group);\r
            }\r
-\r
            /* Done with MSS */\r
 \r
+#if (SYS_USE_DRC)\r
+               /* Run DRC */\r
+               t1 = Timestamp_get();\r
+               inst_p      = sysContext.drcInst_p;     /* fetch the DRC instance pointer */\r
+               frame_p     = txOutFrame1;              /* point to the MSS output frame buffer and use it as input */\r
+               outframe_p  = txOutFrame2;              /* point to DRC output frame */\r
+               err = drcProcess(inst_p, frame_p,       /* instance and input frame pointers */\r
+                                                                outframe_p);  /* pointer to output buffer pointer */\r
+               t2 = Timestamp_get();\r
+               delta = t2-t1;\r
+               txTaskProfile.drc.min = MIN(txTaskProfile.drc.min,delta);\r
+               txTaskProfile.drc.max = MAX(txTaskProfile.drc.max,delta);\r
+               txTaskProfile.drc.n++;\r
+               txTaskProfile.drc.total += (float)delta;\r
+               /* Done with DRC */\r
+#endif\r
+\r
            /*---------------------------------*/\r
            /* Save samples to the TX buffer */\r
            /*---------------------------------*/\r
                // copy MSS output to TX left channel and RX mic 5 to TX right channel\r
                // set the tempOutPtr to MSS output\r
+#if (SYS_USE_DRC)\r
+       tempOutPtr = txOutFrame2;\r
+#else\r
        tempOutPtr = outBuf[gtxFrameIndexCount];\r
+#endif\r
                // set the tempMicPtr to mic_in[4]\r
        tempMicPtr = (unsigned char *)mics_in[4];\r
        // set the TX pointer to left cahhnel\r