diff --git a/lib_rend/ivas_rom_binaural_crend_head.c b/lib_rend/ivas_rom_binaural_crend_head.c index 082a29c3910c73da00178b5e9bb0d2ff3ba7abfc..a57d7803783d776b3e8d3541622d72ec654092d5 100644 --- a/lib_rend/ivas_rom_binaural_crend_head.c +++ b/lib_rend/ivas_rom_binaural_crend_head.c @@ -37,8 +37,10 @@ *------------------------------------------------------------------------*/ /* Binaural rendering data set based on HRIRs */ -/* Tables generated by the exe at "scripts/binauralRenderer_interface/generate_cren_ivas_tables*.* */ -/* Can be replaced by your own generated HRIR or BRIRI tables */ +/* Tables generated by scripts/binauralRenderer_interface/generate_cren_ivas_tables.c, see mixer_conv_sofa_to_rom_table_converter_readme.txt */ +/* Can be replaced by your own generated HRIR or BRIR tables */ + + #include #include @@ -47,8 +49,11 @@ /********************** CRendBin_Combined_HRIR **********************/ - +#ifdef FIX_BINAURAL_DELAY_PRECISION +const float CRendBin_Combined_HRIR_latency_s = 0.000020834f; +#else const float CRendBin_Combined_HRIR_latency_s = 0.000020833333110f; +#endif /* Sample Rate = 48000 */ @@ -640,7 +645,11 @@ const float *CRendBin_Combined_HRIR_coeff_diffuse_im_16kHz[BINAURAL_CHANNELS]={N /********************** CRendBin_HOA3_HRIR **********************/ +#ifdef FIX_BINAURAL_DELAY_PRECISION +const float CRendBin_HOA3_HRIR_latency_s = 0.001333334f; +#else const float CRendBin_HOA3_HRIR_latency_s = 0.001333333319053f; +#endif /* Sample Rate = 48000 */ @@ -1588,7 +1597,11 @@ const float *CRendBin_HOA3_HRIR_coeff_diffuse_im_16kHz[BINAURAL_CHANNELS]={NULL, /********************** CRendBin_Combined_BRIR **********************/ +#ifdef FIX_BINAURAL_DELAY_PRECISION +const float CRendBin_Combined_BRIR_latency_s = 0.000145834f; +#else const float CRendBin_Combined_BRIR_latency_s = 0.000145833328133f; +#endif /* Sample Rate = 48000 */ diff --git a/lib_rend/ivas_rom_binaural_crend_head.h b/lib_rend/ivas_rom_binaural_crend_head.h index 4a9570f23f47c9d7cfa96579bb21c9f530194b9e..64582a16723b9f0dd5956d6c213fa4f5ab0d44f7 100644 --- a/lib_rend/ivas_rom_binaural_crend_head.h +++ b/lib_rend/ivas_rom_binaural_crend_head.h @@ -37,8 +37,8 @@ *------------------------------------------------------------------------*/ /* Binaural rendering data set based on HRIRs */ -/* Tables generated by the exe at "scripts/binauralRenderer_interface/generate_cren_ivas_tables*.* */ -/* Can be replaced by your own generated HRIR or BRIRI tables */ +/* Tables generated by scripts/binauralRenderer_interface/generate_cren_ivas_tables.c, see mixer_conv_sofa_to_rom_table_converter_readme.txt */ +/* Can be replaced by your own generated HRIR or BRIR tables */ diff --git a/scripts/binauralRenderer_interface/generate_crend_ivas_tables_from_sofa.c b/scripts/binauralRenderer_interface/generate_crend_ivas_tables_from_sofa.c index 73d99d76a7f6e7ebb1d1bb14242d5484117e0c3c..0aae3c6cabb404550c52e0fd7df00bb946dfce69 100644 --- a/scripts/binauralRenderer_interface/generate_crend_ivas_tables_from_sofa.c +++ b/scripts/binauralRenderer_interface/generate_crend_ivas_tables_from_sofa.c @@ -62,6 +62,7 @@ #define FORMAT_FLOAT "%8.6f" #define NUM_SAMPLES_PER_LINES 96 #define DECLARATION_NAME "CRendBin" +#define TAB_WITH_SPACE_OR_NOT " " /* "\t" */ int32_t sample_rates[3] = { DEFAULT_SAMPLERATE, 32000, 16000 }; /* Hz */ /* 8000 Hz not supported by mdft */ @@ -129,12 +130,12 @@ void usage_gen_crend_tables( void ) fprintf( stdout, "Mandatory parameters:\n" ); fprintf( stdout, "---------------------\n" ); + fprintf( stdout, "frame_length_ms : frame size in ms (5 or 20)" ); fprintf( stdout, "sofa_file_path1 sofa_file_path2 ... : paths of the sofa files to process %ld Hz sample rate mandatory\n", (long) DEFAULT_SAMPLERATE ); - fprintf( stdout, "frame_length_ms : path where header and c files will be created (lib_dec forlder for example, default = './')\n" ); fprintf( stdout, "Options:\n" ); fprintf( stdout, "--------\n" ); - fprintf( stdout, "-lib_dec_path path : path where header and c files will be created (lib_dec forlder for example, default = './')\n" ); + fprintf( stdout, "-lib_rend_path path : path where header and c files will be created (lib_dec forlder for example, default = './')\n" ); fprintf( stdout, "-no_optim : if present no BRIR optimisation is perfromed \n" ); fprintf( stdout, "\n" ); } @@ -166,7 +167,7 @@ int main( int argc, char *argv[] ) FILE *fp = NULL; - char *lib_dec_path = NULL; + char *lib_rend_path = NULL; bool no_optim = false; int notEndingWithSeparator = 0; @@ -174,7 +175,7 @@ int main( int argc, char *argv[] ) /* Optional arguments */ while ( argv[i][0] == '-' ) { - if ( strcmp( to_upper( argv[i] ), "-LIB_DEC_PATH" ) == 0 ) + if ( strcmp( to_upper( argv[i] ), "-LIB_REND_PATH" ) == 0 ) { i++; if ( strlen( argv[i] ) == 0 ) @@ -183,8 +184,8 @@ int main( int argc, char *argv[] ) usage_gen_crend_tables(); return -1; } - lib_dec_path = malloc( strlen( argv[i] ) + 1 ); - strcpy( lib_dec_path, argv[i] ); + lib_rend_path = malloc( strlen( argv[i] ) + 1 ); + strcpy( lib_rend_path, argv[i] ); notEndingWithSeparator = ( ( argv[i][strlen( argv[i] ) - 1] == '\\' ) || ( ( argv[i][strlen( argv[i] ) - 1] == '/' ) ) ) ? 0 : 1; i++; } @@ -205,8 +206,8 @@ int main( int argc, char *argv[] ) { fprintf( stderr, "Unknown option: %s need to specify frame length in ms\n\n", argv[i] ); usage_gen_crend_tables(); - if ( lib_dec_path ) - free( lib_dec_path ); + if ( lib_rend_path ) + free( lib_rend_path ); return -1; } frame_len_ms = atoi( argv[i] ); @@ -216,8 +217,8 @@ int main( int argc, char *argv[] ) { fprintf( stderr, "Unknown option: %s need to specify frame length in ms 5 or 20\n\n", argv[i] ); usage_gen_crend_tables(); - if ( lib_dec_path ) - free( lib_dec_path ); + if ( lib_rend_path ) + free( lib_rend_path ); return -1; } @@ -231,30 +232,30 @@ int main( int argc, char *argv[] ) { fprintf( stderr, "Memory issue for rom file temporary name\n\n" ); usage_gen_crend_tables(); - if ( lib_dec_path ) - free( lib_dec_path ); + if ( lib_rend_path ) + free( lib_rend_path ); return -1; } - if ( lib_dec_path ) + if ( lib_rend_path ) { - c_file_path = (char *) malloc( sizeof( char ) * ( strlen( lib_dec_path ) + strlen( ROM_FILE_NAME ) + 2 + 1 + notEndingWithSeparator ) ); + c_file_path = (char *) malloc( sizeof( char ) * ( strlen( lib_rend_path ) + strlen( ROM_FILE_NAME ) + 2 + 1 + notEndingWithSeparator ) ); if ( c_file_path ) { if ( notEndingWithSeparator ) { #ifdef WIN32 - sprintf( c_file_path, "%s\\%s.c", lib_dec_path, ROM_FILE_NAME ); + sprintf( c_file_path, "%s\\%s.c", lib_rend_path, ROM_FILE_NAME ); #else - sprintf( c_file_path, "%s/%s.c", lib_dec_path, ROM_FILE_NAME ); + sprintf( c_file_path, "%s/%s.c", lib_rend_path, ROM_FILE_NAME ); #endif } else { #ifdef WIN32 - sprintf( c_file_path, "%s%s.c", lib_dec_path, ROM_FILE_NAME ); + sprintf( c_file_path, "%s%s.c", lib_rend_path, ROM_FILE_NAME ); #else - sprintf( c_file_path, "%s%s.c", lib_dec_path, ROM_FILE_NAME ); + sprintf( c_file_path, "%s%s.c", lib_rend_path, ROM_FILE_NAME ); #endif } } @@ -262,40 +263,40 @@ int main( int argc, char *argv[] ) { fprintf( stderr, "Memory issue for c file path\n\n" ); usage_gen_crend_tables(); - if ( lib_dec_path ) - free( lib_dec_path ); + if ( lib_rend_path ) + free( lib_rend_path ); return -1; } fp = fopen( c_file_path, "w" ); if ( fp == NULL ) { - fprintf( stderr, "Wrong lib_dec path: %s\n\n", lib_dec_path ); + fprintf( stderr, "Wrong lib_dec path: %s\n\n", lib_rend_path ); usage_gen_crend_tables(); if ( c_file_path ) free( c_file_path ); - if ( lib_dec_path ) - free( lib_dec_path ); + if ( lib_rend_path ) + free( lib_rend_path ); return -1; } fclose( fp ); - h_file_path = (char *) malloc( sizeof( char ) * ( strlen( lib_dec_path ) + strlen( ROM_FILE_NAME ) + 2 + 1 + notEndingWithSeparator ) ); + h_file_path = (char *) malloc( sizeof( char ) * ( strlen( lib_rend_path ) + strlen( ROM_FILE_NAME ) + 2 + 1 + notEndingWithSeparator ) ); if ( h_file_path ) { if ( notEndingWithSeparator ) { #ifdef WIN32 - sprintf( h_file_path, "%s\\%s.h", lib_dec_path, ROM_FILE_NAME ); + sprintf( h_file_path, "%s\\%s.h", lib_rend_path, ROM_FILE_NAME ); #else - sprintf( h_file_path, "%s/%s.h", lib_dec_path, ROM_FILE_NAME ); + sprintf( h_file_path, "%s/%s.h", lib_rend_path, ROM_FILE_NAME ); #endif } else { #ifdef WIN32 - sprintf( h_file_path, "%s\\%s.h", lib_dec_path, ROM_FILE_NAME ); + sprintf( h_file_path, "%s\\%s.h", lib_rend_path, ROM_FILE_NAME ); #else - sprintf( h_file_path, "%s/%s.h", lib_dec_path, ROM_FILE_NAME ); + sprintf( h_file_path, "%s/%s.h", lib_rend_path, ROM_FILE_NAME ); #endif } } @@ -305,21 +306,21 @@ int main( int argc, char *argv[] ) usage_gen_crend_tables(); if ( c_file_path ) free( c_file_path ); - if ( lib_dec_path ) - free( lib_dec_path ); + if ( lib_rend_path ) + free( lib_rend_path ); return -1; } fp = fopen( h_file_path, "w" ); if ( fp == NULL ) { - fprintf( stderr, "Wrong lib_dec path: %s\n\n", lib_dec_path ); + fprintf( stderr, "Wrong lib_dec path: %s\n\n", lib_rend_path ); usage_gen_crend_tables(); if ( h_file_path ) free( h_file_path ); if ( c_file_path ) free( c_file_path ); - if ( lib_dec_path ) - free( lib_dec_path ); + if ( lib_rend_path ) + free( lib_rend_path ); return -1; } fclose( fp ); @@ -327,17 +328,17 @@ int main( int argc, char *argv[] ) if ( c_file_path == NULL ) { - size_t len = ( strlen( ROM_FILE_NAME ) + 5 + ( no_optim ? strlen( "_no_optim" ) : 0 ) + 2 + 1); + size_t len = ( strlen( ROM_FILE_NAME ) + 5 + ( no_optim ? strlen( "_no_optim" ) : 0 ) + 2 + 1 ); c_file_path = (char *) malloc( sizeof( char ) * len ); sprintf( c_file_path, "%s_%02dms%s.c", ROM_FILE_NAME, frame_len_ms, ( no_optim ? "_no_optim" : "" ) ); - c_file_path[len-1] = '\0'; + c_file_path[len - 1] = '\0'; } if ( h_file_path == NULL ) { - size_t len = ( strlen( ROM_FILE_NAME ) + 5 + ( no_optim ? strlen( "_no_optim" ) : 0 ) + 2 + 1); + size_t len = ( strlen( ROM_FILE_NAME ) + 5 + ( no_optim ? strlen( "_no_optim" ) : 0 ) + 2 + 1 ); h_file_path = (char *) malloc( sizeof( char ) * len ); sprintf( h_file_path, "%s_%02dms%s.h", ROM_FILE_NAME, frame_len_ms, ( no_optim ? "_no_optim" : "" ) ); - h_file_path[len-1] = '\0'; + h_file_path[len - 1] = '\0'; } FILE *fpt = fopen( TEMPLTATE_C_ROM_FILE_NAME, "rb" ); @@ -811,6 +812,10 @@ int generate_crend_ivas_tables_from_sofa( const char *file_path, bool no_optim ) ivas_set_hrtf_fr( &hrtf_data, ivas_hrtf, frame_len ); } +#ifdef FIX_BINAURAL_DELAY_PRECISION + hrtf_data.latency_s += 0.000000001f; +#endif + if ( ( hrtf_data.num_iterations[0][0] > 2 ) ) { strcpy( &lscfg.name[len_ls_cfg_name], "_BRIR" ); @@ -862,7 +867,7 @@ int generate_crend_ivas_tables_from_sofa( const char *file_path, bool no_optim ) /*---------------------------------------------------------------------* *write_array_float_to_file(); *---------------------------------------------------------------------*/ -void write_array_float_to_file( FILE *fp, float *vec, int32_t size_vec, int32_t sample_per_ligne, const char *format, const int num_tab ) +void write_array_float_to_file( FILE *fp, float *vec, int32_t size_vec, int32_t sample_per_ligne, const char *format, const int num_tab, const char *tab ) { int32_t k, l, num_iter, remaining_samples; int16_t i; @@ -876,7 +881,7 @@ void write_array_float_to_file( FILE *fp, float *vec, int32_t size_vec, int32_t } for ( i = 0; i < num_tab; i++ ) { - fprintf( fp, "\t" ); + fprintf( fp, "%s", tab ); } fprintf( fp, "{" ); @@ -886,7 +891,7 @@ void write_array_float_to_file( FILE *fp, float *vec, int32_t size_vec, int32_t { for ( i = 0; i < num_tab; i++ ) { - fprintf( fp, "\t" ); + fprintf( fp, "%s", tab ); } } for ( l = 0; l < sample_per_ligne; l++ ) @@ -898,7 +903,7 @@ void write_array_float_to_file( FILE *fp, float *vec, int32_t size_vec, int32_t } for ( i = 0; i < num_tab; i++ ) { - fprintf( fp, "\t" ); + fprintf( fp, "%s", tab ); } for ( l = 0; l < remaining_samples - 1; l++ ) { @@ -912,7 +917,7 @@ void write_array_float_to_file( FILE *fp, float *vec, int32_t size_vec, int32_t /*---------------------------------------------------------------------* *write_array_float_to_file(); *---------------------------------------------------------------------*/ -void write_array_uint16_to_file( FILE *fp, uint16_t *vec, int32_t size_vec, int32_t sample_per_ligne, const int num_tab ) +void write_array_uint16_to_file( FILE *fp, uint16_t *vec, int32_t size_vec, int32_t sample_per_ligne, const int num_tab, const char *tab ) { int32_t k, l, num_iter, remaining_samples; int16_t i; @@ -926,7 +931,7 @@ void write_array_uint16_to_file( FILE *fp, uint16_t *vec, int32_t size_vec, int3 } for ( i = 0; i < num_tab; i++ ) { - fprintf( fp, "\t" ); + fprintf( fp, "%s", tab ); } fprintf( fp, "{" ); @@ -936,7 +941,7 @@ void write_array_uint16_to_file( FILE *fp, uint16_t *vec, int32_t size_vec, int3 { for ( i = 0; i < num_tab; i++ ) { - fprintf( fp, "\t" ); + fprintf( fp, "%s", tab ); } } for ( l = 0; l < sample_per_ligne; l++ ) @@ -948,7 +953,7 @@ void write_array_uint16_to_file( FILE *fp, uint16_t *vec, int32_t size_vec, int3 } for ( i = 0; i < num_tab; i++ ) { - fprintf( fp, "\t" ); + fprintf( fp, "%s", tab ); } for ( l = 0; l < remaining_samples - 1; l++ ) { @@ -958,7 +963,7 @@ void write_array_uint16_to_file( FILE *fp, uint16_t *vec, int32_t size_vec, int3 fprintf( fp, "%u", vec[k * sample_per_ligne + l] ); for ( i = 0; i < num_tab; i++ ) { - fprintf( fp, "\t" ); + fprintf( fp, "%s", tab ); } fprintf( fp, "}" ); } @@ -987,7 +992,11 @@ void update_c_file( HRTFS_DATA *hrtf, struct ivas_layout_config lscfg, const int { /* float latency_s; */ fprintf( fp, "\n\n/********************** %s_%s **********************/\n", DECLARATION_NAME, lscfg.name ); +#ifdef FIX_BINAURAL_DELAY_PRECISION + fprintf( fp, "\nconst float %s_%s_latency_s = %10.9ff;", DECLARATION_NAME, lscfg.name, hrtf->latency_s ); +#else fprintf( fp, "\nconst float %s_%s_latency_s = %16.15ff;", DECLARATION_NAME, lscfg.name, hrtf->latency_s ); +#endif } fprintf( fp, "\n\n/* Sample Rate = %ld */\n", (long) samplerate ); @@ -1054,15 +1063,15 @@ void update_c_file( HRTFS_DATA *hrtf, struct ivas_layout_config lscfg, const int for ( i = 0; i < hrtf->max_num_ir - 1; i++ ) { fprintf( fp, "{" ); - write_array_uint16_to_file( fp, hrtf->pIndex_frequency_max[i][0], hrtf->max_num_iterations, hrtf->max_num_iterations, 0 ); + write_array_uint16_to_file( fp, hrtf->pIndex_frequency_max[i][0], hrtf->max_num_iterations, hrtf->max_num_iterations, 0, TAB_WITH_SPACE_OR_NOT ); fprintf( fp, "," ); - write_array_uint16_to_file( fp, hrtf->pIndex_frequency_max[i][1], hrtf->max_num_iterations, hrtf->max_num_iterations, 0 ); + write_array_uint16_to_file( fp, hrtf->pIndex_frequency_max[i][1], hrtf->max_num_iterations, hrtf->max_num_iterations, 0, TAB_WITH_SPACE_OR_NOT ); fprintf( fp, "}," ); } fprintf( fp, "{" ); - write_array_uint16_to_file( fp, hrtf->pIndex_frequency_max[i][0], hrtf->max_num_iterations, hrtf->max_num_iterations, 0 ); + write_array_uint16_to_file( fp, hrtf->pIndex_frequency_max[i][0], hrtf->max_num_iterations, hrtf->max_num_iterations, 0, TAB_WITH_SPACE_OR_NOT ); fprintf( fp, "," ); - write_array_uint16_to_file( fp, hrtf->pIndex_frequency_max[i][1], hrtf->max_num_iterations, hrtf->max_num_iterations, 0 ); + write_array_uint16_to_file( fp, hrtf->pIndex_frequency_max[i][1], hrtf->max_num_iterations, hrtf->max_num_iterations, 0, TAB_WITH_SPACE_OR_NOT ); fprintf( fp, "}" ); fprintf( fp, "};" ); @@ -1071,7 +1080,7 @@ void update_c_file( HRTFS_DATA *hrtf, struct ivas_layout_config lscfg, const int /* float inv_diffuse_weight[MAX_INTERN_CHANNELS]; */ fprintf( fp, "\nconst float %s_%s_inv_diffuse_weight_%2dkHz[%u]=", DECLARATION_NAME, lscfg.name, samplerate / 1000, hrtf->max_num_ir ); - write_array_float_to_file( fp, hrtf->inv_diffuse_weight, hrtf->max_num_ir, hrtf->max_num_ir, FORMAT_FLOAT, 0 ); + write_array_float_to_file( fp, hrtf->inv_diffuse_weight, hrtf->max_num_ir, hrtf->max_num_ir, FORMAT_FLOAT, 0, TAB_WITH_SPACE_OR_NOT ); fprintf( fp, ";" ); /* uint16_t *pIndex_frequency_max_diffuse[BINAURAL_CHANNELS];*/ @@ -1082,9 +1091,9 @@ void update_c_file( HRTFS_DATA *hrtf, struct ivas_layout_config lscfg, const int else { fprintf( fp, "\nconst uint16_t %s_%s_pIndex_frequency_max_diffuse_%2dkHz[BINAURAL_CHANNELS][%u]={", DECLARATION_NAME, lscfg.name, samplerate / 1000, ( hrtf->num_iterations_diffuse[0] > hrtf->num_iterations_diffuse[1] ) ? hrtf->num_iterations_diffuse[0] : hrtf->num_iterations_diffuse[1] ); - write_array_uint16_to_file( fp, hrtf->pIndex_frequency_max_diffuse[0], hrtf->num_iterations_diffuse[0], hrtf->num_iterations_diffuse[0], 0 ); + write_array_uint16_to_file( fp, hrtf->pIndex_frequency_max_diffuse[0], hrtf->num_iterations_diffuse[0], hrtf->num_iterations_diffuse[0], 0, TAB_WITH_SPACE_OR_NOT ); fprintf( fp, "," ); - write_array_uint16_to_file( fp, hrtf->pIndex_frequency_max_diffuse[1], hrtf->num_iterations_diffuse[1], hrtf->num_iterations_diffuse[1], 0 ); + write_array_uint16_to_file( fp, hrtf->pIndex_frequency_max_diffuse[1], hrtf->num_iterations_diffuse[1], hrtf->num_iterations_diffuse[1], 0, TAB_WITH_SPACE_OR_NOT ); fprintf( fp, "};" ); } @@ -1092,33 +1101,33 @@ void update_c_file( HRTFS_DATA *hrtf, struct ivas_layout_config lscfg, const int fprintf( fp, "\nconst float %s_%s_coeff_re_%2dkHz[%d][BINAURAL_CHANNELS][%u]={", DECLARATION_NAME, lscfg.name, samplerate / 1000, hrtf->max_num_ir, maxTotalNumFreqSampPerIterations ); for ( i = 0; i < hrtf->max_num_ir - 1; i++ ) { - fprintf( fp, "\n\t{\n" ); - write_array_float_to_file( fp, hrtf->pOut_to_bin_re[i][0], pTotalNumFreqSampPerIterations[0][i], NUM_SAMPLES_PER_LINES, FORMAT_FLOAT, 2 ); + fprintf( fp, "\n%s{\n", TAB_WITH_SPACE_OR_NOT ); + write_array_float_to_file( fp, hrtf->pOut_to_bin_re[i][0], pTotalNumFreqSampPerIterations[0][i], NUM_SAMPLES_PER_LINES, FORMAT_FLOAT, 2, TAB_WITH_SPACE_OR_NOT ); fprintf( fp, ",\n" ); - write_array_float_to_file( fp, hrtf->pOut_to_bin_re[i][1], pTotalNumFreqSampPerIterations[1][i], NUM_SAMPLES_PER_LINES, FORMAT_FLOAT, 2 ); - fprintf( fp, "\n\t}," ); + write_array_float_to_file( fp, hrtf->pOut_to_bin_re[i][1], pTotalNumFreqSampPerIterations[1][i], NUM_SAMPLES_PER_LINES, FORMAT_FLOAT, 2, TAB_WITH_SPACE_OR_NOT ); + fprintf( fp, "\n%s},", TAB_WITH_SPACE_OR_NOT ); } - fprintf( fp, "\n\t{\n" ); - write_array_float_to_file( fp, hrtf->pOut_to_bin_re[i][0], pTotalNumFreqSampPerIterations[0][i], NUM_SAMPLES_PER_LINES, FORMAT_FLOAT, 2 ); + fprintf( fp, "\n%s{\n", TAB_WITH_SPACE_OR_NOT ); + write_array_float_to_file( fp, hrtf->pOut_to_bin_re[i][0], pTotalNumFreqSampPerIterations[0][i], NUM_SAMPLES_PER_LINES, FORMAT_FLOAT, 2, TAB_WITH_SPACE_OR_NOT ); fprintf( fp, ",\n" ); - write_array_float_to_file( fp, hrtf->pOut_to_bin_re[i][1], pTotalNumFreqSampPerIterations[1][i], NUM_SAMPLES_PER_LINES, FORMAT_FLOAT, 2 ); - fprintf( fp, "\n\t}" ); + write_array_float_to_file( fp, hrtf->pOut_to_bin_re[i][1], pTotalNumFreqSampPerIterations[1][i], NUM_SAMPLES_PER_LINES, FORMAT_FLOAT, 2, TAB_WITH_SPACE_OR_NOT ); + fprintf( fp, "\n%s}", TAB_WITH_SPACE_OR_NOT ); fprintf( fp, "\n};" ); fprintf( fp, "\nconst float %s_%s_coeff_im_%2dkHz[%d][BINAURAL_CHANNELS][%u]={", DECLARATION_NAME, lscfg.name, samplerate / 1000, hrtf->max_num_ir, maxTotalNumFreqSampPerIterations ); for ( i = 0; i < hrtf->max_num_ir - 1; i++ ) { - fprintf( fp, "\n\t{\n" ); - write_array_float_to_file( fp, hrtf->pOut_to_bin_im[i][0], pTotalNumFreqSampPerIterations[0][i], NUM_SAMPLES_PER_LINES, FORMAT_FLOAT, 2 ); + fprintf( fp, "\n%s{\n", TAB_WITH_SPACE_OR_NOT ); + write_array_float_to_file( fp, hrtf->pOut_to_bin_im[i][0], pTotalNumFreqSampPerIterations[0][i], NUM_SAMPLES_PER_LINES, FORMAT_FLOAT, 2, TAB_WITH_SPACE_OR_NOT ); fprintf( fp, ",\n" ); - write_array_float_to_file( fp, hrtf->pOut_to_bin_im[i][1], pTotalNumFreqSampPerIterations[1][i], NUM_SAMPLES_PER_LINES, FORMAT_FLOAT, 2 ); - fprintf( fp, "\n\t}," ); + write_array_float_to_file( fp, hrtf->pOut_to_bin_im[i][1], pTotalNumFreqSampPerIterations[1][i], NUM_SAMPLES_PER_LINES, FORMAT_FLOAT, 2, TAB_WITH_SPACE_OR_NOT ); + fprintf( fp, "\n%s},", TAB_WITH_SPACE_OR_NOT ); } - fprintf( fp, "\n\t{\n" ); - write_array_float_to_file( fp, hrtf->pOut_to_bin_im[i][0], pTotalNumFreqSampPerIterations[0][i], NUM_SAMPLES_PER_LINES, FORMAT_FLOAT, 2 ); + fprintf( fp, "\n%s{\n", TAB_WITH_SPACE_OR_NOT ); + write_array_float_to_file( fp, hrtf->pOut_to_bin_im[i][0], pTotalNumFreqSampPerIterations[0][i], NUM_SAMPLES_PER_LINES, FORMAT_FLOAT, 2, TAB_WITH_SPACE_OR_NOT ); fprintf( fp, ",\n" ); - write_array_float_to_file( fp, hrtf->pOut_to_bin_im[i][1], pTotalNumFreqSampPerIterations[1][i], NUM_SAMPLES_PER_LINES, FORMAT_FLOAT, 2 ); - fprintf( fp, "\n\t}" ); + write_array_float_to_file( fp, hrtf->pOut_to_bin_im[i][1], pTotalNumFreqSampPerIterations[1][i], NUM_SAMPLES_PER_LINES, FORMAT_FLOAT, 2, TAB_WITH_SPACE_OR_NOT ); + fprintf( fp, "\n%s}", TAB_WITH_SPACE_OR_NOT ); fprintf( fp, "\n};" ); /* float *pOut_to_bin_diffuse_re[BINAURAL_CHANNELS];*/ @@ -1129,9 +1138,9 @@ void update_c_file( HRTFS_DATA *hrtf, struct ivas_layout_config lscfg, const int else { fprintf( fp, "\nconst float %s_%s_coeff_diffuse_re_%2dkHz[BINAURAL_CHANNELS][%u]={", DECLARATION_NAME, lscfg.name, samplerate / 1000, maxTotalNumFreqSampPerIterationsDiffuse ); - write_array_float_to_file( fp, hrtf->pOut_to_bin_diffuse_re[0], pTotalNumFreqSampPerIterationsDiffuse[0], NUM_SAMPLES_PER_LINES, FORMAT_FLOAT, 2 ); + write_array_float_to_file( fp, hrtf->pOut_to_bin_diffuse_re[0], pTotalNumFreqSampPerIterationsDiffuse[0], NUM_SAMPLES_PER_LINES, FORMAT_FLOAT, 2, TAB_WITH_SPACE_OR_NOT ); fprintf( fp, ",\n" ); - write_array_float_to_file( fp, hrtf->pOut_to_bin_diffuse_re[1], pTotalNumFreqSampPerIterationsDiffuse[1], NUM_SAMPLES_PER_LINES, FORMAT_FLOAT, 2 ); + write_array_float_to_file( fp, hrtf->pOut_to_bin_diffuse_re[1], pTotalNumFreqSampPerIterationsDiffuse[1], NUM_SAMPLES_PER_LINES, FORMAT_FLOAT, 2, TAB_WITH_SPACE_OR_NOT ); fprintf( fp, "\n};" ); } @@ -1143,9 +1152,9 @@ void update_c_file( HRTFS_DATA *hrtf, struct ivas_layout_config lscfg, const int else { fprintf( fp, "\nconst float %s_%s_coeff_diffuse_im_%2dkHz[BINAURAL_CHANNELS][%u]={", DECLARATION_NAME, lscfg.name, samplerate / 1000, maxTotalNumFreqSampPerIterationsDiffuse ); - write_array_float_to_file( fp, hrtf->pOut_to_bin_diffuse_im[0], pTotalNumFreqSampPerIterationsDiffuse[0], NUM_SAMPLES_PER_LINES, FORMAT_FLOAT, 2 ); + write_array_float_to_file( fp, hrtf->pOut_to_bin_diffuse_im[0], pTotalNumFreqSampPerIterationsDiffuse[0], NUM_SAMPLES_PER_LINES, FORMAT_FLOAT, 2, TAB_WITH_SPACE_OR_NOT ); fprintf( fp, ",\n" ); - write_array_float_to_file( fp, hrtf->pOut_to_bin_diffuse_im[1], pTotalNumFreqSampPerIterationsDiffuse[1], NUM_SAMPLES_PER_LINES, FORMAT_FLOAT, 2 ); + write_array_float_to_file( fp, hrtf->pOut_to_bin_diffuse_im[1], pTotalNumFreqSampPerIterationsDiffuse[1], NUM_SAMPLES_PER_LINES, FORMAT_FLOAT, 2, TAB_WITH_SPACE_OR_NOT ); fprintf( fp, "\n};" ); } diff --git a/scripts/binauralRenderer_interface/ivas_rom_binaural_crend_head.template b/scripts/binauralRenderer_interface/ivas_rom_binaural_crend_head.template new file mode 100644 index 0000000000000000000000000000000000000000..9aacf9688a0380efd749f7373d2dc26d84657865 --- /dev/null +++ b/scripts/binauralRenderer_interface/ivas_rom_binaural_crend_head.template @@ -0,0 +1,43 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +/* clang-format off */ + +/*------------------------------------------------------------------------- + * Binaural rendering related ROM tables + *------------------------------------------------------------------------*/ + +/* Binaural rendering data set based on HRIRs */ +/* Tables generated by scripts/binauralRenderer_interface/generate_cren_ivas_tables.c, see mixer_conv_sofa_to_rom_table_converter_readme.txt */ +/* Can be replaced by your own generated HRIR or BRIR tables */ + + diff --git a/scripts/binauralRenderer_interface/mixer_conv_sofa_to_rom_table_converter_readme.txt b/scripts/binauralRenderer_interface/mixer_conv_sofa_to_rom_table_converter_readme.txt new file mode 100644 index 0000000000000000000000000000000000000000..ead4b2d4374b4c829aa00a14c948ca19fc775aaa --- /dev/null +++ b/scripts/binauralRenderer_interface/mixer_conv_sofa_to_rom_table_converter_readme.txt @@ -0,0 +1,56 @@ +/****************************************************************************************************** + + (C) 2022 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +Mixer conv sofa to rom table converter program +------------------------------ + +The sofa to rom format converter is used to generate the c files (*.h,*.c) containing the binary representation of the binaural +filters for renderer MIXER_CONV and MIXER_CONV_ROOM + +First, build the converter under scripts/binauralRenderer_interface in VSCode (using CMakeList). + +Usage: +------ +generate_crend_ivas_tables [Options] + +Mandatory parameters : + - Frame size in ms (5 or 20) + - list of sofa files (one with HRIR that directions of IVAS combined speakers configuration or more, one with HOA to binaura filters at least order 3, one with BRIR filters that directions of IVAS combined speakers configuration or more) + +Options : + -lib_rend_path : Path where output file will be created (with separator, default = './'). + -no_optim : if present the BRIR filters are not optimised the renderer will perform perfect convolution with the complete size of the BRIR (high files size and high complexity). It is useful for debug purpose + +For example : + +./build/generate_crend_ivas_tables.exe -lib_rend_path ../../lib_rend 5 ./HRIRs_sofa/HRIR_128_Meth5_IRC_53_Q10_symL_Itrp1_48000.sofa ./HRIRs_sofa/ORANGE_HRIR_53_HOA3S_48000.sofa ./BRIRs_sofa/IIS_BRIR_officialMPEG_Combined.sofa +./build/generate_crend_ivas_tables -lib_rend_path ../../lib_rend 5 ./HRIRs_sofa/HRIR_128_Meth5_IRC_53_Q10_symL_Itrp1_48000.sofa ./HRIRs_sofa/ORANGE_HRIR_53_HOA3S_48000.sofa ./BRIRs_sofa/IIS_BRIR_officialMPEG_Combined.sofa \ No newline at end of file