mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-02 11:06:31 +00:00
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
This commit is contained in:
1
utils/.gitignore
vendored
1
utils/.gitignore
vendored
@@ -23,3 +23,4 @@ stereorize
|
||||
strcompat.c
|
||||
streamplayer
|
||||
threadstorage.c
|
||||
conf_bridge_binaural_hrir_importer
|
||||
|
@@ -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
|
||||
|
@@ -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("{");
|
||||
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]);
|
||||
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("}};");
|
||||
}
|
||||
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("{");
|
||||
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]);
|
||||
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("}};");
|
||||
}
|
||||
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);
|
||||
|
46
utils/conf_bridge_binaural_hrir_importer.h
Normal file
46
utils/conf_bridge_binaural_hrir_importer.h
Normal file
@@ -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\
|
||||
"
|
@@ -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>
|
||||
|
Reference in New Issue
Block a user