]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/audio-preprocessing.git/blob - file_demo/da830/test/src/bf_asnr_mss_vau.h
Resturcture the GIT repository for noise reduction demo:
[processor-sdk/audio-preprocessing.git] / file_demo / da830 / test / src / bf_asnr_mss_vau.h
1 /******************************************************************************\r
2  * FILE PURPOSE: \r
3  *               \r
4  ******************************************************************************\r
5  * FILE NAME:   bf_asnr_mss_vau.h\r
6  *\r
7  * DESCRIPTION: Based on compiler switch, include platform specific profile file\r
8  *\r
9  *        Copyright (c) 2016 Texas Instruments Incorporated                
10  *                                                                                
11  *              All rights reserved not granted herein.                           
12  *                                                                                
13  *                         Limited License.                                       
14  *                                                                                
15  *  Texas Instruments Incorporated grants a world-wide, royalty-free,             
16  *  non-exclusive license under copyrights and patents it now or hereafter owns   
17  *  or controls to make, have made, use, import, offer to sell and sell           
18  *  ("Utilize") this software subject to the terms herein.  With respect to the   
19  *  foregoing patent license, such license is granted solely to the extent that   
20  *  any such patent is necessary to Utilize the software alone.  The patent       
21  *  license shall not apply to any combinations which include this software,      
22  *  other than combinations with devices manufactured by or for TI (\93TI           
23  *  Devices\94).  No hardware patent is licensed hereunder.                         
24  *                                                                                
25  *  Redistributions must preserve existing copyright notices and reproduce this   
26  *  license (including the above copyright notice and the disclaimer and (if      
27  *  applicable) source code license limitations below) in the documentation       
28  *  and/or other materials provided with the distribution                         
29  *                                                                                
30  *  Redistribution and use in binary form, without modification, are permitted    
31  *  provided that the following conditions are met:                               
32  *                                                                                
33  *    *  No reverse engineering, decompilation, or disassembly of this software   
34  *  is permitted with respect to any software provided in binary form.            
35  *                                                                                
36  *    *  any redistribution and use are licensed by TI for use only with TI       
37  *  Devices.                                                                      
38  *                                                                                
39  *    *  Nothing shall obligate TI to provide you with source code for the        
40  *  software licensed and provided to you in object code.                         
41  *                                                                                
42  *  If software source code is provided to you, modification and redistribution   
43  *  of the source code are permitted provided that the following conditions are   
44  *  met:                                                                          
45  *                                                                                
46  *    *  any redistribution and use of the source code, including any resulting   
47  *  derivative works, are licensed by TI for use only with TI Devices.            
48  *                                                                                
49  *    *  any redistribution and use of any object code compiled from the source   
50  *  code and any resulting derivative works, are licensed by TI for use only      
51  *  with TI Devices.                                                              
52  *                                                                                
53  *  Neither the name of Texas Instruments Incorporated nor the names of its       
54  *  suppliers may be used to endorse or promote products derived from this        
55  *  software without specific prior written permission.                           
56  *                                                                                
57  *  DISCLAIMER.                                                                   
58  *                                                                                
59  *  THIS SOFTWARE IS PROVIDED BY TI AND TI\92S LICENSORS "AS IS" AND ANY EXPRESS    
60  *  OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED             
61  *  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        
62  *  DISCLAIMED. IN NO EVENT SHALL TI AND TI\92S LICENSORS BE LIABLE FOR ANY         
63  *  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    
64  *  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR            
65  *  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER    
66  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT            
67  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY     
68  *  OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH   
69  *  DAMAGE.                                                                       \r
70  *****************************************************************************/\r
71 #ifndef _BF_ASNR_MSS_VAU_H\r
72 #define _BF_ASNR_MSS_VAU_H\r
73 \r
74 /* demo includes */\r
75 #include <stdio.h>\r
76 #include <stdlib.h>\r
77 #include <string.h>\r
78 #include <xdc/std.h>\r
79 \r
80 /* RTSC headers */\r
81 #include <ti/mas/types/types.h>\r
82 #include <ti/mas/fract/fract.h>\r
83 #include <ti/mas/types/const.h>\r
84 #include <ti/mas/util/ecomem.h>\r
85 \r
86 /* for signal generator */\r
87 #include <ti/mas/sdk/sgn.h>\r
88 \r
89 /* VPE component and simulation headers */\r
90 #include <ti/mas/vpe/svd.h>\r
91 #include <ti/mas/vpe/asnr.h>\r
92 #include <ti/mas/bf_asnr_mss_vau/test/src/vausim.h>\r
93 #include <ti/mas/aer/bf.h>\r
94 #include <ti/mas/aer/mss.h>\r
95 \r
96 /* Constants and structures for Demo */\r
97 #define VPE_SIM_SAMPLE_FREQ_16000 16000    // Sampling frequency\r
98 #define VPE_SIM_SAMPLE_FREQ_8000  8000     // Sampling frequency\r
99 #define VPE_SIM_FRAME_SIZE_16000   160     /* 160 samples for a 10 msec frame */\r
100 #define VPE_SIM_FRAME_SIZE_8000     80     /*  80 samples for a 10 msec frame */\r
101 #define vpe_SIM_MAX_SAMPLES          320    // Maximum frame_size\r
102 #define vpe_SIM_MAX_ECOBUFS          12     // Maximum module buffers\r
103 #define vpe_SIM_MAX_STRING          256     // Maximum string size\r
104 \r
105 /* ASNR parameters */\r
106 typedef struct {\r
107   tint samp_rate;\r
108   tint delay;\r
109   tint band_bin1;\r
110   tint band_bin2;\r
111   tint band1_max_atten;\r
112   tint band2_max_atten;\r
113   tint band3_max_atten;\r
114   tint sig_upd_rate_max;\r
115   tint sig_upd_rate_min;\r
116   tint noise_thresh;\r
117   tint noise_hangover;\r
118 } vpeASNRPars_t;\r
119 \r
120 typedef struct {\r
121   tbool  bf_on;                     /* BF enable bit     */\r
122   tbool  nr_on;                     /* NR enable bit     */\r
123   tbool  mss_on;                    /* MSS enable bit    */\r
124   tbool  vau_on;                    /* VAU enable bit    */\r
125   tlong  sample_cnt;                  /* Sample count                               */\r
126   tint   Fs;                          /* Sampling rate in Hz                        */\r
127   bfSizeConfig_t bf_size_cfg;         /* BF size configure                          */\r
128   bfControl_t bf_ctl;                 /* BF control                                */\r
129   vpeASNRPars_t  asnrParam;           /* ASNR parameters                            */\r
130   mssControl_t  mss_ctl_cfg;          /* MSS control                               */\r
131   tbool  data;                        /* Flag indicating more samples for simulation*/\r
132   tuint  frame_size_in;               /* Simulation frame size, input               */\r
133   tuint  frame_size_out;              /* Simulation frame size, output              */\r
134   tlong     cyclesOverhead;           /* to measure fixed overhead in cycle measurement */\r
135   cycles_t  cyclesBf;                 /* BF's cycle statistics */\r
136   cycles_t  cyclesAsnr;               /* ASNR's cycle statistics */\r
137   cycles_t  cyclesMss;                /* MSS's cycle statistics */\r
138   cycles_t  cyclesVau;                /* VAU's cycle statistics */\r
139   FILE *outCyclesFilePtr;             /* cycle output file */\r
140 } vpeSimConfig_t;\r
141 \r
142 /* Constants and structures for BF */\r
143 #define MAX_NUM_BF_BUFFS 5\r
144 #define NUM_BF_ANALOG_MIC 8\r
145 #define NUM_BF_VIRTUAL_MIC 12\r
146 #define AUDIO_SMAPLE_FREQ 16000\r
147 #define AUDIO_FILE_IN_SEC 40\r
148 #define bf_INT_HEAP_SIZE 0x4800\r
149 #define bf_EXT_HEAP_SIZE 0x2000\r
150 \r
151 /* Constants and structures for ASNR */\r
152 #ifdef  __CCS_PROJECT_REL_PATH\r
153 #define vpe_SIM_DEF_BASE_DIR       "../../../vectors/"\r
154 #else\r
155 #ifdef AUTOMATE_PATH\r
156 #define vpe_SIM_DEF_BASE_DIR       "./"\r
157 #else\r
158 #define vpe_SIM_DEF_BASE_DIR       "../../vectors/"\r
159 #endif\r
160 #endif\r
161 /* Buffer sizes for NR - returned by nrGetSizes().\r
162    Buffer size is in unit of tword. For C64x+\C674x\C66x , tword is 8-bit. */\r
163 #define NR_SIM_BUF0_SIZE   88\r
164 #define NR_SIM_BUF1_SIZE   1548+4\r
165 #define NR_SIM_BUF2_SIZE   1032\r
166 #define NR_SIM_BUF3_SIZE   774+2\r
167 #define NR_SIM_BUF4_SIZE   384\r
168 #define NR_SIM_BUF5_SIZE   1032\r
169 #define NR_SIM_BUF6_SIZE   28+4\r
170 \r
171 /* Buffer alignment for NR - returned by nrGetSizes().\r
172    Buffers must be aligned on boundary of 2^(NR_SIM_BUFx_ALGN_LOG2) twords.\r
173    Also used to define macros used by #pragma DATA_ALIGN in nrbufs.c.\r
174    The pragma DATA_ALIGN (symbol, constant) aligns the symbol to an alignment\r
175    boundary. For C64x+\C674x\C66x, the boundary is the value of the constant in\r
176    bytes. For example, a constant of 4 specifies a 4-byte or 32-bit alignment.*/\r
177 #define NR_SIM_BUF0_ALGN_LOG2  3\r
178 #define NR_SIM_BUF1_ALGN_LOG2  3\r
179 #define NR_SIM_BUF2_ALGN_LOG2  3\r
180 #define NR_SIM_BUF3_ALGN_LOG2  3\r
181 #define NR_SIM_BUF4_ALGN_LOG2  2\r
182 #define NR_SIM_BUF5_ALGN_LOG2  2\r
183 #define NR_SIM_BUF6_ALGN_LOG2  3\r
184 /* common to all targets */\r
185 #define VPE_NR_NUM_BUFS   7\r
186 \r
187 #define NR_SIM_BUF0_ALGN  (1<<NR_SIM_BUF0_ALGN_LOG2)\r
188 #define NR_SIM_BUF1_ALGN  (1<<NR_SIM_BUF1_ALGN_LOG2)\r
189 #define NR_SIM_BUF2_ALGN  (1<<NR_SIM_BUF2_ALGN_LOG2)\r
190 #define NR_SIM_BUF3_ALGN  (1<<NR_SIM_BUF3_ALGN_LOG2)\r
191 #define NR_SIM_BUF4_ALGN  (1<<NR_SIM_BUF4_ALGN_LOG2)\r
192 #define NR_SIM_BUF5_ALGN  (1<<NR_SIM_BUF5_ALGN_LOG2)\r
193 #define NR_SIM_BUF6_ALGN  (1<<NR_SIM_BUF6_ALGN_LOG2)\r
194 \r
195 /* Constants and structures for MSS */\r
196 #define AER_SIM_MSS_INST_SIZE 50\r
197 #define AER_SIM_SVD_INST_SIZE 10\r
198 #define SIU_NUM_MSS_BUFFS 1        /* static buffer allocation */\r
199 \r
200 typedef struct {\r
201   LFract buf[AER_SIM_MSS_INST_SIZE];\r
202 } mssinstbuf_t;\r
203 \r
204 typedef struct {\r
205   LFract buf[AER_SIM_SVD_INST_SIZE];\r
206 } svdinstbuf_t;\r
207 \r
208 typedef struct {\r
209   mssinstbuf_t mss_inst;\r
210   svdinstbuf_t svd_inst[NUM_BF_VIRTUAL_MIC];\r
211 } mssbuf_t;\r
212 \r
213 /* Constants and structures for VAU */\r
214 #ifdef  __CCS_PROJECT_REL_PATH\r
215 #define nmu_SIM_OUTDEC_FNAME       "../../../vectors/outVauDecisions.txt"\r
216 #define nmu_SIM_LOGCYC_FNAME       "../../../logs/cycles.txt"\r
217 #define nmu_SIM_LOG_FNAME          "../../../logs/log.txt"\r
218 #else\r
219 #define nmu_SIM_OUTDEC_FNAME       "../../vectors/outVauDecisions.txt"\r
220 #define nmu_SIM_LOGCYC_FNAME       "../../logs/cycles.txt"\r
221 #define nmu_SIM_LOG_FNAME          "../../logs/log.txt"\r
222 #endif\r
223 \r
224 extern vpeSimConfig_t *vpeSim;\r
225 \r
226 #ifdef PROFILE_CYCLES\r
227 static inline void siu_process_cycles(tlong cycles, cycles_t * cyclesPtr)\r
228 {\r
229   if (cycles > cyclesPtr->max) {\r
230     cyclesPtr->max = cycles;\r
231   }\r
232 \r
233   cyclesPtr->avg = ((cyclesPtr->avg) * 255 + cycles) >> 8;\r
234 }\r
235 \r
236 static inline void siu_print_cycles_util(cycles_t * cyclesPtr, char *name,\r
237                                          tlong overhead)\r
238 {\r
239   printf("%s MaxCycles = %ld AvgCycles = %ld\n", name,\r
240          (long) cyclesPtr->max - (long) overhead,\r
241          (long) cyclesPtr->avg - (long) overhead);\r
242 }\r
243 \r
244 void siu_print_cycles(void);\r
245 #endif\r
246 \r
247 extern void  vpe_print             (char *str);\r
248 extern void  vpe_iprint            (char *str, tlong ivar);\r
249 extern void  vpe_sprint            (char *str, char *svar);\r
250 \r
251 #endif /* _BF_ASNR_MSS_VAU_H */\r
252 \r
253 /* Nothing past this point */\r