summaryrefslogtreecommitdiffstats
path: root/all_pairs/source/audiobeam
diff options
context:
space:
mode:
authorJoshua Bakita <bakitajoshua@gmail.com>2019-10-07 19:13:39 -0400
committerJoshua Bakita <bakitajoshua@gmail.com>2019-10-07 19:13:39 -0400
commit386b7d3366f1359a265da207a9cafa3edf553b64 (patch)
treec76120c2c138faed822e4ae386be6ef22a738a78 /all_pairs/source/audiobeam
parent54a3f7091a2146b29c73a6fdc4b62a5c4ad7a3d8 (diff)
Reorganize and commit all the modified TACLeBench code and run scripts
Diffstat (limited to 'all_pairs/source/audiobeam')
-rw-r--r--all_pairs/source/audiobeam/README86
-rw-r--r--all_pairs/source/audiobeam/audiobeam.c594
-rw-r--r--all_pairs/source/audiobeam/audiobeam.h50
-rw-r--r--all_pairs/source/audiobeam/audiobeaminput.c5784
-rw-r--r--all_pairs/source/audiobeam/audiobeamlibm.c423
-rw-r--r--all_pairs/source/audiobeam/audiobeamlibm.h59
-rw-r--r--all_pairs/source/audiobeam/audiobeamlibmalloc.c14
-rw-r--r--all_pairs/source/audiobeam/audiobeamlibmalloc.h27
-rw-r--r--all_pairs/source/audiobeam/audiobeamlibmath.h69
-rw-r--r--all_pairs/source/audiobeam/changeLog.txt36
-rw-r--r--all_pairs/source/audiobeam/license.txt21
11 files changed, 7163 insertions, 0 deletions
diff --git a/all_pairs/source/audiobeam/README b/all_pairs/source/audiobeam/README
new file mode 100644
index 0000000..e228eda
--- /dev/null
+++ b/all_pairs/source/audiobeam/README
@@ -0,0 +1,86 @@
1Readme file for Oxygen beamforming source code distribution
2-----------------------------------------------------------
3
4This is a very very beta distribution of beamforming source code from
5MIT LCS.
6
7There is only one source file, main.c, and one header file,
8main.h. You can compile everything using the Makefile included in the
9distribution.
10
11The input to the program is a text file containing floating
12point values for the signal read on each of the microphones. For n
13microphones, each line of the text files represents a temporal sample
14and should contain n floating point values separated by spaces, e.g.:
15
16-1.8569790e-004 -9.0919049e-004 3.6711283e-004 -1.0073081e-005 ...
17
18There are several modes of operation for the program:
19
201. The most basic mode is to process the microphone data and to
21calculate the output based on one beam focused on a particular point
22in space. The coordinates for the microphones and the focus point are
23specified inside main.c (eventually to be moved to a separate file).
24
252. Far field search mode. This mode assumes a far-field source (which
26means we have a planar wavefront) and a linear array, and sweeps over
27180 degrees in the plane of the array. The microphone coordinates are
28specified in main.c, and the NUM_ANGLES constant defines how many
29angle values should be tested (a value of 180 means one beam per each
30degree). The energy of the signal over a particular window
31(ANGLE_ENERGY_WINDOW_SIZE) is computed for each beam. The direction
32with maximum energy is considered the direction that the speech signal
33is coming from, and is printed out by the program.
34
353. Near-field hill climbing mode. This mode accepts a starting
36coordinate and attempts to "hill-climb" through the space seeking the
37maximum energy. Each of the x, y, and z coordinates are perturbed in
38the positive and negative directions at each time interval
39(GRID_ENERGY_WINDOW_SIZE) by a step size (GRID_STEP_SIZE). This
40perturbation, along with the original coordinate, produces seven
41coordinates to be tested. The direction with the maximum energy
42replaces the current reference coordinate. For instance, if we have a
43starting reference coordinate of (1,1,0) and our step size is 0.01, we
44will evaluate the energy for the following seven beams:
45
46(1,1,0)
47(0.99,1,0)
48(1.01,1,0)
49(1,0.99,0)
50(1,1.01,0)
51(1,1,-0.01)
52(1,1,0.01)
53
54Now let's say the beam (1,1.01,0) has the maximum energy; then this
55coordinate will replace the original reference coordinate of (1,1,0).
56
57For methods 2, and 3, we are not outputting anything to disk, we are
58just printing the result. This is because we have just started to work
59with these methods, and have not applied them in real systems. This
60code is currently being ported to RAW.
61
62To get a list of parameters for the delay_and_sum executable that is
63generated when the source is compiled, just type ./delay_and_sum .
64
65There is some sample data included with the program, in the data
66directory. There is some data for a near-field and far-field
67source. The README.txt file in each directory specifies the microphone
68and source position. The data1 file, when processed with a beamformer
69aligned in the proper direction should produce something like a sinc
70function (see
71http://ccrma-www.stanford.edu/~jos/Interpolation/sinc_function.html).
72
73The data2 file should produce an audio signal of a woman saying "the
74simplest method". If the beamformer is aligned properly, the noise
75should be reduced significantly over the source signal from only one
76of the microphones (use print_datafile.pl to isolate one
77microphone). You can convert the data file that the program produces
78to wave files using sox.
79
80
81
82
83
84---------------------------------
85Eugene Weinstein
86ecoder@mit.edu \ No newline at end of file
diff --git a/all_pairs/source/audiobeam/audiobeam.c b/all_pairs/source/audiobeam/audiobeam.c
new file mode 100644
index 0000000..ed5d656
--- /dev/null
+++ b/all_pairs/source/audiobeam/audiobeam.c
@@ -0,0 +1,594 @@
1/*
2
3 This program is part of the TACLeBench benchmark suite.
4 Version V 2.0
5
6 Name: audiobeam
7
8 Author: Eugene Weinstein
9
10 Function: Audio beam former
11
12 Source: StreamIt
13 http://groups.csail.mit.edu/cag/streamit/
14
15 Changes: no functional changes
16
17 License: see license.txt
18
19*/
20
21
22/*
23 Include section
24*/
25
26#include "../extra.h"
27#include "audiobeamlibm.h"
28#include "audiobeamlibmalloc.h"
29#include "audiobeam.h"
30
31/*
32 Forward declaration of functions
33*/
34
35void audiobeam_init();
36int audiobeam_return();
37void audiobeam_main( void );
38//int main( void );
39void audiobeam_preprocess_delays( struct audiobeam_PreprocessedDelays
40 prep_delays[], float *delays );
41float *audiobeam_parse_line( float *float_arr, int num_mic );
42long int audiobeam_find_max_in_arr( float *arr, int size );
43long int audiobeam_find_min_in_arr( float *arr, int size );
44int audiobeam_wrapped_inc_offset( int i, int offset, int max_i );
45int audiobeam_wrapped_dec_offset( int i, int offset, int max_i );
46int audiobeam_wrapped_inc( int i, int max_i );
47int audiobeam_wrapped_dec( int i, int max_i );
48struct audiobeam_DataQueue *audiobeam_init_data_queue( int max_delay,
49 int num_mic );
50struct audiobeam_Delays *audiobeam_init_delays ( int num_angles, int num_mic );
51void audiobeam_calc_distances( float *source_location,
52 float audiobeam_mic_locations[15][3],
53 float *distances,
54 int num_mic );
55void audiobeam_calc_delays( float *distances, float *delays, int sound_speed,
56 int sampling_rate, int num_mic );
57void audiobeam_adjust_delays( float *delays, int num_mic );
58float *audiobeam_calc_weights_lr ( int num_mic );
59float *audiobeam_calc_weights_left_only ( int num_mic );
60float audiobeam_calculate_energy( float *samples, int num_samples );
61float audiobeam_do_beamforming( struct audiobeam_PreprocessedDelays
62 preprocessed_delays[],
63 float **sample_queue,
64 int queue_head,
65 long int max_delay,
66 int num_mic,
67 float *weights );
68int audiobeam_process_signal( struct audiobeam_Delays *delays, int num_mic,
69 float sampling_rate, float **beamform_results,
70 struct audiobeam_DataQueue *queue,
71 int num_beams, int window, float *weights );
72int audiobeam_calc_beamforming_result( struct audiobeam_Delays *delays,
73 float **beamform_results,
74 float *energies,
75 struct audiobeam_DataQueue *queue,
76 int num_beams, int window,
77 int hamming );
78void audiobeam_calc_single_pos( float source_location[3],
79 float audiobeam_mic_locations[15][3],
80 int hamming );
81
82
83/*
84 Declaration of global variables
85*/
86
87extern float audiobeam_input[5760];
88extern float audiobeam_mic_locations[15][3];