1 /*
2 * Copyright (c) 2017, Texas Instruments Incorporated
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * * Neither the name of Texas Instruments Incorporated nor the names of
17 * its contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 */
33 \r
34 /*
35 * ======== main.c ========
36 */
39 /* System header files */
40 #include <xdc/std.h>
42 #include <xdc/runtime/Error.h>
43 #include <xdc/runtime/System.h>
45 /*----------------------------------------
46 * BIOS header files
47 *----------------------------------------*/
49 #include <ti/sysbios/BIOS.h> /* mandatory - if you call APIs like BIOS_start() */
51 /* Portable data types */
52 #include <ti/mas/types/types.h>
53 #include <ti/mas/util/ecomem.h>
55 #include "../../common/components/fil.h"
56 #include "../../common/components/sys.h"
58 /* Global System Configuration Structure */
59 sysConfig_t sysConfig = {
60 SYS_MICS_MAX, /* #microphones */
61 SYS_VMICS_MAX, /* #virtual microphones */
62 5, /* 5ms ASNR delay */
63 { 12, 9, 6}, /* ASNR band1=12dB, band2=9dB, band3=6dB */
64 TRUE, /* Enable ASNR */
65 FALSE, /* Do not use file I/O to load files (must use GEL to load into memory) */
66 TRUE, /* Use default angles for microphone configurations */
67 FALSE, /* Enable VAD */
68 -50, /* drc expansion knee point in dBm0 (dBFS is dBm0-3dB */
69 6, /* drc max gain in dB */
70 FALSE /* Disable DRC */
71 };
73 /* Global FILE I/O Configuration Structure (must be configured even when file I/O not used */
74 filConfig_t filConfig = {
75 FIL_LENGTH_MAX, /* number of samples to load from a file */
76 SYS_MICS_MAX, /* number of files to use */
77 TRUE, /* big endian */
78 FALSE, /* do not wrap around */
79 40*SYS_FS_HZ /* Process 40s of the signal (current mic input file length */
80 };
82 /* Miocrophone input files names (in case we want to use FILE I/O to load into memory */
83 char *filNames[FIL_MAX] = {
84 #if FIL_MAX==8
85 "../../../common/t8/y16L8g3m7090_1.pcm",
86 "../../../common/t8/y16L8g3m7090_2.pcm",
87 "../../../common/t8/y16L8g3m7090_3.pcm",
88 "../../../common/t8/y16L8g3m7090_4.pcm",
89 "../../../common/t8/y16L8g3m7090_5.pcm",
90 "../../../common/t8/y16L8g3m7090_6.pcm",
91 "../../../common/t8/y16L8g3m7090_7.pcm",
92 "../../../common/t8/y16L8g3m7090_8.pcm"
93 #else
94 "../../../common/t8/y16L7g3m7090_1.pcm",
95 "../../../common/t8/y16L7g3m7090_2.pcm",
96 "../../../common/t8/y16L7g3m7090_3.pcm",
97 "../../../common/t8/y16L7g3m7090_4.pcm",
98 "../../../common/t8/y16L7g3m7090_5.pcm",
99 "../../../common/t8/y16L7g3m7090_6.pcm",
100 "../../../common/t8/y16L7g3m7090_7.pcm",
101 #endif
102 };
104 /* Acoustic environment */
105 /* Room Size (X,Y,Z) in meters */
106 /* 5.2000 4.3000 2.7000 */
108 /* Table size (X,Y,Z) in meters */
109 /* 3.0000 2.4000 0.7600 */
111 /* "Echo" generating speaker position (X,Y,Z) in meters */
112 /* 0 2.1500 1.2172 180 -90 VM-9 */
114 /* People positions (X,Y,Z) in meters and angles relative to the table and array */
115 /* 1.8200 0.6452 1.2172 position#1 (person#1) -123.6056 -146.3944 VM-7
116 2.8200 0.6452 1.2172 -not used- -90.0000 180.0000 VM-6
117 3.8200 0.6452 1.2172 (person#2) -56.3944 146.3944 VM-5
118 1.8200 3.6548 1.2172 (person#3) 123.6056 -33.6056 VM-11
119 2.8200 3.6548 1.2172 -not used- 90.0000 0.0000 VM-0
120 3.8200 3.6548 1.2172 position#6 (person#4) 56.3944 33.6056 VM-1
121 */
123 /* Microphone array mic positions (X,Y,Z) in meters */
124 /* 2.7922 2.1500 0.7600 mic#1 ("left" most) 180
125 2.8004 2.1304 0.7600 -135
126 2.8200 2.1222 0.7600 ("lower" most) -90
127 2.8396 2.1304 0.7600 -45
128 2.8478 2.1500 0.7600 ("right" most) 0
129 2.8396 2.1696 0.7600 45
130 2.8200 2.1778 0.7600 ("upper" most) 90
131 2.8004 2.1696 0.7600 mic#8 135
132 */
133 /* Array Center = (2.82, 2.15, 0.76) (same as table center) */
135 /* Noise source position (X,Y,Z) in meters */
136 /* 2.6000 2.1500 2.3000 */
138 /* Initialize FILE I/O, system context */
139 static void system_init(void)
140 {
141 int k, err;
142 tlong n;
143 void *fid;
145 fid = (void*)0xBABA; /* Just to test if we're providing fid correctly */
146 err = filCreate(&fid, &filConfig); /* Create FILE I/O context */
147 SYS_CHECK_ERROR(err);
149 err = sysCreate(&sysConfig); /* Create system context */
150 SYS_CHECK_ERROR(err);
152 err = sysPrintConfig(SYSM_SCOPE_STATIC|SYSM_SCOPE_DYNAMIC);
153 SYS_CHECK_ERROR(err);
155 if (sysContext.use_fileio) { /* In case we want to read directly from file (slow) */
156 for (k = 0; k < filConfig.nfiles; k++) {
157 n = filLoad(filNames[k], filConfig.length, k);
158 System_printf("Read %ld samples from %s\n", n, filNames[k]);
159 }
160 }
161 System_flush();
162 /* If we are not using FILE I/O to load mic files, we need to use GEL to load into memory. */
164 } /* system_init */
166 /*
167 * =============== main ==============
168 */
169 int main(void)
170 {
171 system_init(); /* initialize system context, etc. */
173 sysBfCreate(); /* Create beamformers */
174 sysAsnrCreate(); /* Create ASNR's */
175 sysMssCreate(); /* Create MSS */
176 #if (SYS_USE_DRC)
177 sysDrcCreate(); /* Create DRC */
178 #endif
179 //sysVauCreate(); /* Create VAU */
181 BIOS_start();
183 return(0); /* Never to return here */
184 } /* main */
186 /* nothing past this point */