[asterisk-commits] Binaural synthesis (confbridge): Adds utils/conf bridge bina... (asterisk[master])
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Feb 20 10:24:55 CST 2017
Joshua Colp has submitted this change and it was merged. ( https://gerrit.asterisk.org/4654 )
Change subject: Binaural synthesis (confbridge): Adds utils/conf_bridge_binaural_hrir_importer
......................................................................
Binaural synthesis (confbridge): Adds utils/conf_bridge_binaural_hrir_importer
Adds the import tool for converting a HRIR database to hrirs.h
ASTERISK-26292
Change-Id: I51eb31b54c23ffd9b544bdc6a09d20c112c8a547
---
M build_tools/menuselect-deps.in
M configure
M configure.ac
M include/asterisk/autoconfig.h.in
M makeopts.in
M utils/Makefile
A utils/conf_bridge_binaural_hrir_importer.c
M utils/utils.xml
8 files changed, 324 insertions(+), 82 deletions(-)
Approvals:
Anonymous Coward #1000019: Verified
Matthew Fredrickson: Looks good to me, approved
Joshua Colp: Looks good to me, but someone else must approve
diff --git a/build_tools/menuselect-deps.in b/build_tools/menuselect-deps.in
index 9f1aa70..ec70be0 100644
--- a/build_tools/menuselect-deps.in
+++ b/build_tools/menuselect-deps.in
@@ -57,6 +57,7 @@
FFTW3=@PBX_FFTW3@
RADIUS=@PBX_RADIUS@
LAUNCHD=@PBX_LAUNCHD@
+SNDFILE=@PBX_SNDFILE@
SPANDSP=@PBX_SPANDSP@
SPEEX=@PBX_SPEEX@
SPEEXDSP=@PBX_SPEEXDSP@
diff --git a/configure b/configure
index 7e72074..ba8d593 100755
--- a/configure
+++ b/configure
@@ -835,6 +835,10 @@
SDL_DIR
SDL_INCLUDE
SDL_LIB
+PBX_SNDFILE
+SNDFILE_DIR
+SNDFILE_INCLUDE
+SNDFILE_LIB
PBX_RESAMPLE
RESAMPLE_DIR
RESAMPLE_INCLUDE
@@ -1258,7 +1262,6 @@
FIND
PYTHON
FLEX
-CUT
CAT
CMP
BISON
@@ -1345,7 +1348,6 @@
docdir
oldincludedir
includedir
-runstatedir
localstatedir
sharedstatedir
sysconfdir
@@ -1432,6 +1434,7 @@
with_radius
with_fftw3
with_resample
+with_sndfile
with_sdl
with_SDL_image
with_spandsp
@@ -1528,7 +1531,6 @@
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
-runstatedir='${localstatedir}/run'
includedir='${prefix}/include'
oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@@ -1781,15 +1783,6 @@
| -silent | --silent | --silen | --sile | --sil)
silent=yes ;;
- -runstatedir | --runstatedir | --runstatedi | --runstated \
- | --runstate | --runstat | --runsta | --runst | --runs \
- | --run | --ru | --r)
- ac_prev=runstatedir ;;
- -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
- | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
- | --run=* | --ru=* | --r=*)
- runstatedir=$ac_optarg ;;
-
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1927,7 +1920,7 @@
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
datadir sysconfdir sharedstatedir localstatedir includedir \
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
- libdir localedir mandir runstatedir
+ libdir localedir mandir
do
eval ac_val=\$$ac_var
# Remove trailing slashes.
@@ -2080,7 +2073,6 @@
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
- --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
@@ -2194,6 +2186,7 @@
--with-radius=PATH use Radius Client files in PATH
--with-fftw3=PATH use LIBFFTW3 files in PATH
--with-resample=PATH use LIBRESAMPLE files in PATH
+ --with-sndfile=PATH use libsndfile files in PATH
--with-sdl=PATH use Sdl files in PATH
--with-SDL_image=PATH use Sdl Image files in PATH
--with-spandsp=PATH use SPANDSP files in PATH
@@ -6848,47 +6841,6 @@
fi
-# Extract the first word of "cut", so it can be a program name with args.
-set dummy cut; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_path_CUT+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- case $CUT in
- [\\/]* | ?:[\\/]*)
- ac_cv_path_CUT="$CUT" # Let the user override the test with a path.
- ;;
- *)
- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_path_CUT="$as_dir/$ac_word$ac_exec_ext"
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
- done
-IFS=$as_save_IFS
-
- test -z "$ac_cv_path_CUT" && ac_cv_path_CUT=":"
- ;;
-esac
-fi
-CUT=$ac_cv_path_CUT
-if test -n "$CUT"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CUT" >&5
-$as_echo "$CUT" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
# Extract the first word of "flex", so it can be a program name with args.
set dummy flex; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
@@ -9338,7 +9290,7 @@
as_fn_error $? "nm is required to build bundled pjproject" "$LINENO" 5
fi
if test "${MD5}" = ":" ; then
- as_fn_error $? "md5dum is required to build bundled pjproject" "$LINENO" 5
+ as_fn_error $? "md5sum is required to build bundled pjproject" "$LINENO" 5
fi
if test "${CAT}" = ":" ; then
as_fn_error $? "cat is required to build bundled pjproject" "$LINENO" 5
@@ -12052,6 +12004,38 @@
*)
RESAMPLE_DIR="${withval}"
ac_mandatory_list="${ac_mandatory_list} RESAMPLE"
+ ;;
+ esac
+
+fi
+
+
+
+
+
+
+
+
+ SNDFILE_DESCRIP="libsndfile"
+ SNDFILE_OPTION="sndfile"
+ PBX_SNDFILE=0
+
+# Check whether --with-sndfile was given.
+if test "${with_sndfile+set}" = set; then :
+ withval=$with_sndfile;
+ case ${withval} in
+ n|no)
+ USE_SNDFILE=no
+ # -1 is a magic value used by menuselect to know that the package
+ # was disabled, other than 'not found'
+ PBX_SNDFILE=-1
+ ;;
+ y|ye|yes)
+ ac_mandatory_list="${ac_mandatory_list} SNDFILE"
+ ;;
+ *)
+ SNDFILE_DIR="${withval}"
+ ac_mandatory_list="${ac_mandatory_list} SNDFILE"
;;
esac
@@ -14838,7 +14822,7 @@
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@@ -14884,7 +14868,7 @@
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@@ -14908,7 +14892,7 @@
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@@ -14953,7 +14937,7 @@
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@@ -14977,7 +14961,7 @@
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@@ -17084,21 +17068,6 @@
AST_ASTERISKSSL=yes
fi
-
-
-# https support (in main/http.c) uses funopen on BSD systems,
-# fopencookie on linux
-for ac_func in funopen fopencookie
-do :
- as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
-ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
- cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-done
for ac_func in inet_aton
@@ -29413,6 +29382,112 @@
fi
+if test "x${PBX_SNDFILE}" != "x1" -a "${USE_SNDFILE}" != "no"; then
+ pbxlibdir=""
+ # if --with-SNDFILE=DIR has been specified, use it.
+ if test "x${SNDFILE_DIR}" != "x"; then
+ if test -d ${SNDFILE_DIR}/lib; then
+ pbxlibdir="-L${SNDFILE_DIR}/lib"
+ else
+ pbxlibdir="-L${SNDFILE_DIR}"
+ fi
+ fi
+ pbxfuncname="sf_open"
+ if test "x${pbxfuncname}" = "x" ; then # empty lib, assume only headers
+ AST_SNDFILE_FOUND=yes
+ else
+ ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+ CFLAGS="${CFLAGS} "
+ as_ac_Lib=`$as_echo "ac_cv_lib_sndfile_${pbxfuncname}" | $as_tr_sh`
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${pbxfuncname} in -lsndfile" >&5
+$as_echo_n "checking for ${pbxfuncname} in -lsndfile... " >&6; }
+if eval \${$as_ac_Lib+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lsndfile ${pbxlibdir} -lsndfile $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char ${pbxfuncname} ();
+int
+main ()
+{
+return ${pbxfuncname} ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ eval "$as_ac_Lib=yes"
+else
+ eval "$as_ac_Lib=no"
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+eval ac_res=\$$as_ac_Lib
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then :
+ AST_SNDFILE_FOUND=yes
+else
+ AST_SNDFILE_FOUND=no
+fi
+
+ CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
+ fi
+
+ # now check for the header.
+ if test "${AST_SNDFILE_FOUND}" = "yes"; then
+ SNDFILE_LIB="${pbxlibdir} -lsndfile -lsndfile"
+ # if --with-SNDFILE=DIR has been specified, use it.
+ if test "x${SNDFILE_DIR}" != "x"; then
+ SNDFILE_INCLUDE="-I${SNDFILE_DIR}/include"
+ fi
+ SNDFILE_INCLUDE="${SNDFILE_INCLUDE} "
+ if test "xsndfile.h" = "x" ; then # no header, assume found
+ SNDFILE_HEADER_FOUND="1"
+ else # check for the header
+ ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
+ CPPFLAGS="${CPPFLAGS} ${SNDFILE_INCLUDE}"
+ ac_fn_c_check_header_mongrel "$LINENO" "sndfile.h" "ac_cv_header_sndfile_h" "$ac_includes_default"
+if test "x$ac_cv_header_sndfile_h" = xyes; then :
+ SNDFILE_HEADER_FOUND=1
+else
+ SNDFILE_HEADER_FOUND=0
+fi
+
+
+ CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
+ fi
+ if test "x${SNDFILE_HEADER_FOUND}" = "x0" ; then
+ SNDFILE_LIB=""
+ SNDFILE_INCLUDE=""
+ else
+ if test "x${pbxfuncname}" = "x" ; then # only checking headers -> no library
+ SNDFILE_LIB=""
+ fi
+ PBX_SNDFILE=1
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_SNDFILE 1
+_ACEOF
+
+ fi
+ fi
+fi
+
+
+
+
+
if test "x${PBX_SPANDSP}" != "x1" -a "${USE_SPANDSP}" != "no"; then
if test "xminimum version of SpanDSP" != "x"; then
diff --git a/configure.ac b/configure.ac
index d604d47..982412e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -551,6 +551,7 @@
AST_EXT_LIB_SETUP([RADIUS], [Radius Client], [radius])
AST_EXT_LIB_SETUP([FFTW3], [LIBFFTW3], [fftw3])
AST_EXT_LIB_SETUP([RESAMPLE], [LIBRESAMPLE], [resample])
+AST_EXT_LIB_SETUP([SNDFILE], [libsndfile], [sndfile])
AST_EXT_LIB_SETUP([SDL], [Sdl], [sdl])
AST_EXT_LIB_SETUP([SDL_IMAGE], [Sdl Image], [SDL_image])
AST_EXT_LIB_SETUP([SPANDSP], [SPANDSP], [spandsp])
@@ -2284,6 +2285,9 @@
if test "$PBX_FFTW3" = "1"; then
AC_DEFINE([HAVE_FFTW], 1, [Define 1 if your system has fftw.])
fi
+AST_EXT_LIB_CHECK([SNDFILE], [sndfile], [sf_open], [sndfile.h], [-lsndfile])
+
+
AST_C_COMPILE_CHECK([SPANDSP], [
#if SPANDSP_RELEASE_DATE < 20080516
diff --git a/include/asterisk/autoconfig.h.in b/include/asterisk/autoconfig.h.in
index e8bd811..3468492 100644
--- a/include/asterisk/autoconfig.h.in
+++ b/include/asterisk/autoconfig.h.in
@@ -254,9 +254,6 @@
/* Define to 1 if you have the `fmodl' function. */
#undef HAVE_FMODL
-/* Define to 1 if you have the `fopencookie' function. */
-#undef HAVE_FOPENCOOKIE
-
/* Define to 1 if you have the `fork' function. */
#undef HAVE_FORK
@@ -268,9 +265,6 @@
/* Define to 1 if you have the `ftruncate' function. */
#undef HAVE_FTRUNCATE
-
-/* Define to 1 if you have the `funopen' function. */
-#undef HAVE_FUNOPEN
/* Define to 1 if your GCC C compiler provides atomic operations. */
#undef HAVE_GCC_ATOMICS
@@ -828,6 +822,9 @@
/* Define to 1 if you have the `sinl' function. */
#undef HAVE_SINL
+/* Define to 1 if you have the libsndfile library. */
+#undef HAVE_SNDFILE
+
/* Define to 1 if you have the `socket' function. */
#undef HAVE_SOCKET
diff --git a/makeopts.in b/makeopts.in
index c67e2f2..6a1164c 100644
--- a/makeopts.in
+++ b/makeopts.in
@@ -380,3 +380,6 @@
# if poll is not present, let the makefile know.
POLL_AVAILABLE=@HAS_POLL@
TIMERFD_INCLUDE=@TIMERFD_INCLUDE@
+
+SNDFILE_INCLUDE=@SNDFILE_INCLUDE@
+SNDFILE_LIB=@SNDFILE_LIB@
diff --git a/utils/Makefile b/utils/Makefile
index 97b0e2f..b6618e1 100644
--- a/utils/Makefile
+++ b/utils/Makefile
@@ -70,6 +70,10 @@
UTILS:=$(filter-out conf2ael,$(UTILS))
endif
+ifeq ($(SNDFILE_LIB),)
+ UTILS:=$(filter-out conf_bridge_binaural_hrir_importer,$(UTILS))
+endif
+
all: $(UTILS)
install:
@@ -92,6 +96,7 @@
rm -f utils.c strings.c poll.c version.c sha1.c astobj2.c refcounter
rm -f db1-ast/.*.d
@$(MAKE) -C db1-ast clean
+
md5.c: $(ASTTOPDIR)/main/md5.c
$(ECHO_PREFIX) echo " [CP] $(subst $(ASTTOPDIR)/,,$<) -> $@"
@@ -188,6 +193,10 @@
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))
diff --git a/utils/conf_bridge_binaural_hrir_importer.c b/utils/conf_bridge_binaural_hrir_importer.c
new file mode 100644
index 0000000..5690d86
--- /dev/null
+++ b/utils/conf_bridge_binaural_hrir_importer.c
@@ -0,0 +1,148 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2016, Digium, Inc.
+ *
+ * Frank Haase <fra.haase at gmail.com>
+ * Dennis Guse <dennis.guse at alumni.tu-berlin.de>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*!
+ * \file
+ * Converts a Head Related Impulse Response (HRIR) database (a multi-channel wave) into a C header file.
+ * HRIR for the left ear and HRIR for right ear have to be interleaved.
+ * No further signal processing is applied (e.g., resampling).
+ *
+ * Info messages are printed to stderror and the generated header file to output.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <sndfile.h>
+
+int main (int argc, char **argv)
+{
+ char *hrir_filename;
+ unsigned int binaural_index_start;
+ unsigned int binaural_index_end;
+
+ SNDFILE *hrir_file;
+ SF_INFO hrir_info;
+ float *hrir_data;
+
+ unsigned int impulse_response_index_start;
+ unsigned int impulse_response_index_end;
+
+ int j;
+ int ir_current;
+
+ if(argc != 4) {
+ puts("HRIR database to C header file converter.");
+ puts("Usage: conf_bridge_binaural_hrir_importer HRIR.wav INDEX_START INDEX_END > OUTPUT.h");
+ puts("Example: conf_bridge_binaural_hrir_importer hrirs.wav 0 180 > ../bridges/bridge_softmix/include/hrirs.h");
+
+ return -1;
+ }
+
+ /* Parse arguments */
+ hrir_filename = argv[1];
+ binaural_index_start = atoi(argv[2]);
+ binaural_index_end = atoi(argv[3]);
+
+ /* Read HRIR database */
+ hrir_file = sf_open(hrir_filename, SFM_READ, &hrir_info);
+ if(hrir_file == NULL) {
+ fprintf(stderr, "ERROR: Could not open HRIR database (%s).\n", hrir_filename);
+
+ return -1;
+ }
+ fprintf(stderr, "INFO: Opened HRIR database (%s) with: number channels: %d; samplerate: %d; samples per channel: %ld\n", hrir_filename, hrir_info.channels, hrir_info.samplerate, hrir_info.frames);
+
+ hrir_data = (float *)malloc(hrir_info.channels * hrir_info.frames * sizeof(float));
+ if(hrir_data == NULL) {
+ fprintf(stderr, "ERROR: Out of memory!");
+
+ return -1;
+ }
+
+ /* Channels are interleaved */
+ sf_read_float(hrir_file, hrir_data, hrir_info.channels * hrir_info.frames);
+ sf_close(hrir_file);
+
+ if(binaural_index_start >= binaural_index_end) {
+ fprintf(stderr, "ERROR: INDEX_START (%d) must be smaller than INDEX_END (%d).", binaural_index_start, binaural_index_end);
+ free(hrir_data);
+
+ return -1;
+ }
+
+ if (binaural_index_end * 2 >= hrir_info.channels) {
+ fprintf(stderr, "ERROR: END_INDEX (%d) is out of range for HRIR database (%s).\n", binaural_index_end, hrir_filename);
+ free(hrir_data);
+
+ return -1;
+ }
+
+ /* Convert indices */
+ impulse_response_index_start = 2 * binaural_index_start;
+ 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("#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("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("\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("}};");
+ }
+ }
+
+ fprintf(stderr, "INFO: Successfully converted: imported %d impulse responses.\n", impulse_response_index_end - impulse_response_index_start);
+ free(hrir_data);
+
+ return 0;
+}
diff --git a/utils/utils.xml b/utils/utils.xml
index 909406e..498929a 100644
--- a/utils/utils.xml
+++ b/utils/utils.xml
@@ -20,6 +20,11 @@
<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>
--
To view, visit https://gerrit.asterisk.org/4654
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I51eb31b54c23ffd9b544bdc6a09d20c112c8a547
Gerrit-PatchSet: 3
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Dennis Guse <dennis.guse at alumni.tu-berlin.de>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Dennis Guse <dennis.guse at alumni.tu-berlin.de>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Matthew Fredrickson <creslin at digium.com>
More information about the asterisk-commits
mailing list