diff options
author | frahaase <fra.haase@googlemail.com> | 2016-08-12 18:23:18 +0200 |
---|---|---|
committer | George Joseph <gjoseph@digium.com> | 2017-02-23 10:34:58 -0700 |
commit | 094c26aa689664177e156d17bf5e9ab67c442a53 (patch) | |
tree | 29a03da022373e1b90804dbc30c9a927848a9217 /utils/conf_bridge_binaural_hrir_importer.c | |
parent | 9ad1df71b363d1b3c92622873bb193dca5ddbb8c (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/conf_bridge_binaural_hrir_importer.c')
-rw-r--r-- | utils/conf_bridge_binaural_hrir_importer.c | 61 |
1 files changed, 30 insertions, 31 deletions
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); |