1 /*
2 * Copyright (c) 2016, 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 "components/fil.h"
56 #include "components/sys.h"
58 /* Global System Configuration Structure */
59 sysConfig_t sysConfig = {
60 SYS_MICS_MAX, /* #microphones */
61 SYS_VMICS_MAX, /* #virtual microphones */
62 FALSE, /* Do not use file I/O to load files (must use GEL to load into memory) */
63 TRUE /* Use default angles for microphone configurations */
64 };
66 /* Global FILE I/O Configuration Structure (must be configured even when file I/O not used */
67 filConfig_t filConfig = {
68 FIL_LENGTH_MAX, /* number of samples to load from a file */
69 SYS_MICS_MAX, /* number of files to use */
70 TRUE, /* big endian */
71 FALSE, /* do not wrap around */
72 40*SYS_FS_HZ /* Process 40s of the signal (current mic input file length */
73 };
75 /* Miocrophone input files names (in case we want to use FILE I/O to load into memory */
76 char *filNames[FIL_MAX] = {
77 "../t8/y16L8g3m7090_1.pcm",
78 "../t8/y16L8g3m7090_2.pcm",
79 "../t8/y16L8g3m7090_3.pcm",
80 "../t8/y16L8g3m7090_4.pcm",
81 "../t8/y16L8g3m7090_5.pcm",
82 "../t8/y16L8g3m7090_6.pcm",
83 "../t8/y16L8g3m7090_7.pcm",
84 "../t8/y16L8g3m7090_8.pcm"
85 };
87 /* Acoustic environment */
88 /* Room Size (X,Y,Z) in meters */
89 /* 5.2000 4.3000 2.7000 */
91 /* Table size (X,Y,Z) in meters */
92 /* 3.0000 2.4000 0.7600 */
94 /* "Echo" generating speaker position (X,Y,Z) in meters */
95 /* 0 2.1500 1.2172 180 -90 VM-9 */
97 /* People positions (X,Y,Z) in meters and angles relative to the table and array */
98 /* 1.8200 0.6452 1.2172 position#1 (person#1) -123.6056 -146.3944 VM-7
99 2.8200 0.6452 1.2172 -not used- -90.0000 180.0000 VM-6
100 3.8200 0.6452 1.2172 (person#2) -56.3944 146.3944 VM-5
101 1.8200 3.6548 1.2172 (person#3) 123.6056 -33.6056 VM-11
102 2.8200 3.6548 1.2172 -not used- 90.0000 0.0000 VM-0
103 3.8200 3.6548 1.2172 position#6 (person#4) 56.3944 33.6056 VM-1
104 */
106 /* Microphone array mic positions (X,Y,Z) in meters */
107 /* 2.7922 2.1500 0.7600 mic#1 ("left" most) 180
108 2.8004 2.1304 0.7600 -135
109 2.8200 2.1222 0.7600 ("lower" most) -90
110 2.8396 2.1304 0.7600 -45
111 2.8478 2.1500 0.7600 ("right" most) 0
112 2.8396 2.1696 0.7600 45
113 2.8200 2.1778 0.7600 ("upper" most) 90
114 2.8004 2.1696 0.7600 mic#8 135
115 */
116 /* Array Center = (2.82, 2.15, 0.76) (same as table center) */
118 /* Noise source position (X,Y,Z) in meters */
119 /* 2.6000 2.1500 2.3000 */
121 /* Initialize FILE I/O, system context */
122 static void system_init(void)
123 {
124 int k, err;
125 tlong n;
126 void *fid;
128 fid = (void*)0xBABA; /* Just to test if we're providing fid correctly */
129 err = filCreate(&fid, &filConfig); /* Create FILE I/O context */
130 SYS_CHECK_ERROR(err);
132 err = sysCreate(&sysConfig); /* Create system context */
133 SYS_CHECK_ERROR(err);
135 err = sysPrintConfig(SYSM_SCOPE_STATIC|SYSM_SCOPE_DYNAMIC);
136 SYS_CHECK_ERROR(err);
138 if (sysContext.use_fileio) { /* In case we want to read directly from file (slow) */
139 for (k = 0; k < filConfig.nfiles; k++) {
140 n = filLoad(filNames[k], filConfig.length, k);
141 System_printf("Read %ld samples from %s\n", n, filNames[k]);
142 }
143 }
144 ///System_flush();
145 /* If we are not using FILE I/O to load mic files, we need to use GEL to load into memory. */
147 } /* system_init */
149 /*
150 * =============== main ==============
151 */
152 int main(void)
153 {
154 system_init(); /* initialize system context, etc. */
156 sysBfCreate(); /* Create beamformers */
157 sysAsnrCreate(); /* Create ASNR's */
158 sysMssCreate(); /* Create MSS */
159 sysVauCreate(); /* Create VAU */
161 BIOS_start();
163 return(0); /* Never to return here */
164 } /* main */
166 /* nothing past this point */