summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorfrahaase <fra.haase@googlemail.com>2016-08-12 18:23:18 +0200
committerGeorge Joseph <gjoseph@digium.com>2017-02-23 10:34:58 -0700
commit094c26aa689664177e156d17bf5e9ab67c442a53 (patch)
tree29a03da022373e1b90804dbc30c9a927848a9217 /utils
parent9ad1df71b363d1b3c92622873bb193dca5ddbb8c (diff)
Binaural synthesis (confbridge): Adds binaural synthesis to bridge_softmix.
Adds binaural synthesis to bridge_softmix (via convolution using libfftw3). Binaural synthesis is conducted at 48kHz. For a conference, only one spatial representation is rendered. The default rendering is applied for mono-capable channels. ASTERISK-26292 Change-Id: Iecdb381b6adc17c961049658678f6219adae1ddf
Diffstat (limited to 'utils')
-rw-r--r--utils/.gitignore1
-rw-r--r--utils/Makefile11
-rw-r--r--utils/conf_bridge_binaural_hrir_importer.c61
-rw-r--r--utils/conf_bridge_binaural_hrir_importer.h46
-rw-r--r--utils/utils.xml13
5 files changed, 88 insertions, 44 deletions
diff --git a/utils/.gitignore b/utils/.gitignore
index 8e95c8df8..dbdc6b6d2 100644
--- a/utils/.gitignore
+++ b/utils/.gitignore
@@ -23,3 +23,4 @@ stereorize
strcompat.c
streamplayer
threadstorage.c
+conf_bridge_binaural_hrir_importer
diff --git a/utils/Makefile b/utils/Makefile
index b6618e195..5d3119aee 100644
--- a/utils/Makefile
+++ b/utils/Makefile
@@ -70,10 +70,6 @@ ifneq ($(filter pbx_ael,$(MENUSELECT_PBX)),)
UTILS:=$(filter-out conf2ael,$(UTILS))
endif
-ifeq ($(SNDFILE_LIB),)
- UTILS:=$(filter-out conf_bridge_binaural_hrir_importer,$(UTILS))
-endif
-
all: $(UTILS)
install:
@@ -193,10 +189,6 @@ smsq: LIBS+=$(POPT_LIB)
streamplayer: streamplayer.o
-conf_bridge_binaural_hrir_importer: LIBS+=$(SNDFILE_LIB)
-conf_bridge_binaural_hrir_importer: _ASTCFLAGS+=$(SNDFILE_INCLUDE)
-conf_bridge_binaural_hrir_importer: conf_bridge_binaural_hrir_importer.o
-
muted: muted.o
muted: LIBS+=$(AUDIO_LIBS)
muted: _ASTCFLAGS:=$(filter-out -Werror,$(_ASTCFLAGS))
@@ -213,6 +205,9 @@ astdb2bdb: LIBS+=$(SQLITE3_LIB)
astdb2bdb: _ASTCFLAGS+=$(SQLITE3_INCLUDE)
astdb2bdb: db1-ast/libdb1.a
+conf_bridge_binaural_hrir_importer: LIBS+=$(SNDFILE_LIB)
+conf_bridge_binaural_hrir_importer.o: _ASTCFLAGS+=$(SNDFILE_INCLUDE)
+
ifneq ($(wildcard .*.d),)
include .*.d
endif
diff --git a/utils/conf_bridge_binaural_hrir_importer.c b/utils/conf_bridge_binaural_hrir_importer.c
index 5690d86ea..c1e5458db 100644
--- a/utils/conf_bridge_binaural_hrir_importer.c
+++ b/utils/conf_bridge_binaural_hrir_importer.c
@@ -1,7 +1,7 @@
/*
* Asterisk -- An open source telephony toolkit.
*
- * Copyright (C) 2016, Digium, Inc.
+ * Copyright (C) 2016, Frank Haase, Dennis Guse
*
* Frank Haase <fra.haase@gmail.com>
* Dennis Guse <dennis.guse@alumni.tu-berlin.de>
@@ -30,6 +30,7 @@
#include <string.h>
#include <stdlib.h>
#include <sndfile.h>
+#include "conf_bridge_binaural_hrir_importer.h"
int main (int argc, char **argv)
{
@@ -99,46 +100,44 @@ int main (int argc, char **argv)
impulse_response_index_end = (binaural_index_end + 1) * 2;
/* Write header */
- printf("//Used hrirs database: %s\n", hrir_filename);
- printf("//Start index in database: %d\n", impulse_response_index_start);
- printf("//End index in database: %d\n", impulse_response_index_end);
+ printf(FILE_HEADER, hrir_filename, binaural_index_start, binaural_index_end);
printf("#define HRIRS_IMPULSE_LEN %ld\n", hrir_info.frames);
printf("#define HRIRS_IMPULSE_SIZE %d\n", binaural_index_end - binaural_index_start + 1);
- printf("#define HRIRS_SAMPLE_RATE %d\n", hrir_info.samplerate);
+ printf("#define HRIRS_SAMPLE_RATE %d\n\n", hrir_info.samplerate);
printf("float hrirs_left[HRIRS_IMPULSE_SIZE][HRIRS_IMPULSE_LEN] = {\n");
for (ir_current = impulse_response_index_start; ir_current < impulse_response_index_end; ir_current += 2) {
- printf("{");
-
- for (j = 0; j < hrir_info.frames - 1; j++) {
- printf("%.16f,", hrir_data[ir_current * hrir_info.frames + j]);
- }
- /* Write last without trailing "," */
- printf("%.16f", hrir_data[ir_current * hrir_info.frames + hrir_info.frames - 1]);
-
- if (ir_current + 2 < impulse_response_index_end) {
- printf("},\n");
- } else {
- printf("}};");
- }
+ printf("{");
+
+ for (j = 0; j < hrir_info.frames - 1; j++) {
+ printf("%.16f,%s", hrir_data[ir_current * hrir_info.frames + j], ((j + 1) % 4 ? " " : "\n"));
+ }
+ /* Write last without trailing "," */
+ printf("%.16f", hrir_data[ir_current * hrir_info.frames + hrir_info.frames - 1]);
+
+ if (ir_current + 2 < impulse_response_index_end) {
+ printf("},\n");
+ } else {
+ printf("}};");
+ }
}
printf("\nfloat hrirs_right[HRIRS_IMPULSE_SIZE][HRIRS_IMPULSE_LEN] = {\n");
for (ir_current = impulse_response_index_start + 1; ir_current < impulse_response_index_end + 1; ir_current += 2) {
- printf("{");
-
- for (j = 0; j < hrir_info.frames - 1; j++) {
- printf("%.16f,", hrir_data[ir_current * hrir_info.frames + j]);
- }
- /* Write last without trailing "," */
- printf("%.16f", hrir_data[ir_current * hrir_info.frames + hrir_info.frames - 1]);
-
- if (ir_current + 2 < impulse_response_index_end) {
- printf("},\n");
- } else {
- printf("}};");
- }
+ printf("{");
+
+ for (j = 0; j < hrir_info.frames - 1; j++) {
+ printf("%.16f,%s", hrir_data[ir_current * hrir_info.frames + j], ((j + 1) % 4 ? " " : "\n"));
+ }
+ /* Write last without trailing "," */
+ printf("%.16f", hrir_data[ir_current * hrir_info.frames + hrir_info.frames - 1]);
+
+ if (ir_current + 2 < impulse_response_index_end) {
+ printf("},\n");
+ } else {
+ printf("}};");
+ }
}
fprintf(stderr, "INFO: Successfully converted: imported %d impulse responses.\n", impulse_response_index_end - impulse_response_index_start);
diff --git a/utils/conf_bridge_binaural_hrir_importer.h b/utils/conf_bridge_binaural_hrir_importer.h
new file mode 100644
index 000000000..b8acc3051
--- /dev/null
+++ b/utils/conf_bridge_binaural_hrir_importer.h
@@ -0,0 +1,46 @@
+#define FILE_HEADER "\
+ * Asterisk -- An open source telephony toolkit.\n\
+ *\n\
+ * Copyright (C) 2016, Frank Haase, Dennis Guse\n\
+ *\n\
+ * Frank Haase <fra.haase@gmail.com>\n\
+ * Dennis Guse <dennis.guse@alumni.tu-berlin.de>\n\
+ *\n\
+ * See http://www.asterisk.org for more information about\n\
+ * the Asterisk project. Please do not directly contact\n\
+ * any of the maintainers of this project for assistance;\n\
+ * the project provides a web site, mailing lists and IRC\n\
+ * channels for your use.\n\
+ *\n\
+ * Copyright (c) 2001 The Regents of the University of California. All Rights Reserved.\n\
+ *\n\
+ * The HRIRs used here are obtained from The CIPIC HRTF Database\n\
+ * (http://interface.cipic.ucdavis.edu/CIL_html/CIL_HRTF_database.htm)\n\
+ * Note that the above mentioned material is Copyright (c) 2001 The\n\
+ * Regents of the University of California. All Rights Reserved.\n\
+ *\n\
+ * Download the file\n\
+ * http://interface.cipic.ucdavis.edu/data/special_kemar_hrir.tar and\n\
+ * uncompress it in the folder where this Matlab script resides. Finally,\n\
+ * run the script.\n\
+ *\n\
+ * This program is free software, distributed under the terms of\n\
+ * the GNU General Public License Version 2. See the LICENSE file\n\
+ * at the top of the source tree.\n\
+ */\n\
+\n\
+/*! \\file\n\
+ *\n\
+ * \\brief Multi-party software binaural channel HRIRS\n\
+ *\n\
+ * \\author Frank Haase <fra.haase@googlemail.com>\n\
+ * \\author Dennis Guse <dennis.guse@alumni.tu-berlin.de>\n\
+ *\n\
+ * \\ingroup bridges\n\
+ */\n\
+\n\
+/*\n\
+ * This file was created with command:\n\
+ * $ conf_bridge_binaural_hrir_importer %s %d %d\n\
+ */\n\
+"
diff --git a/utils/utils.xml b/utils/utils.xml
index 498929a27..5b3a27ae3 100644
--- a/utils/utils.xml
+++ b/utils/utils.xml
@@ -20,11 +20,6 @@
<depend>newt</depend>
<support_level>extended</support_level>
</member>
- <member name="conf_bridge_binaural_hrir_importer">
- <defaultenabled>no</defaultenabled>
- <depend>sndfile</depend>
- <support_level>extended</support_level>
- </member>
<member name="check_expr">
<defaultenabled>no</defaultenabled>
<support_level>extended</support_level>
@@ -54,4 +49,12 @@
<defaultenabled>no</defaultenabled>
<support_level>extended</support_level>
</member>
+ <member name="conf_bridge_binaural_hrir_importer"
+ displayname="Impulse Noise wav to hrirs.h generator"
+ remove_on_change="conf_bridge_binaural_hrir_importer">
+ <defaultenabled>no</defaultenabled>
+ <depend>sndfile</depend>
+ <support_level>extended</support_level>
+ <defaultenabled>no</defaultenabled>
+ </member>
</category>