Commit c0c23682 authored by emerit's avatar emerit
Browse files

bug fix and add BRIR optimisation configurations files

parent 134c6498
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
[brirOptimisationSettings]
optimize = true;
harmonizeLateReverbBinauralGain = true;
lateReverbCompensationGain  = [1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0];
directCutOffFreqThreshold = -20;
diffuseCutOffFreqThreshold = -20;
directEnergyThreshold = -25; 
diffuseEnergyThreshold = -25; 
beginEnergyThreshold = -50; 
endEnergyThreshold = -120;
+10 −0
Original line number Diff line number Diff line
[brirOptimisationSettings]
optimize = true;
harmonizeLateReverbBinauralGain = false;
lateReverbCompensationGain  = [1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0];
directCutOffFreqThreshold = -15;
diffuseCutOffFreqThreshold = -10;
directEnergyThreshold = -15; 
diffuseEnergyThreshold = -30; 
beginEnergyThreshold = -50; 
endEnergyThreshold = -120;
+2 −0
Original line number Diff line number Diff line
[brirOptimisationSettings]
optimize = false;
+8 −9
Original line number Diff line number Diff line
@@ -46,16 +46,15 @@

typedef struct ConfigReader
{
    uint32_t optimize;                                     /* optimise HRIR/BRIR or not ie reduce renderer complexity */
    uint32_t harmonizeLateReverbBinauralGain;              /* average left/right late reveberation energy or not */
    uint32_t optimize;                                     /* optimize HRIR/BRIR or not ie reduce renderer complexity */
    uint32_t harmonizeLateReverbBinauralGain;              /* average left/right late reverberation energy or not */
    float lateReverbCompensationGain[MAX_INTERN_CHANNELS]; /* user design additional compensation gain for late reverberation */
    float beginEnergyThreshold;                            /* use to find beginning of HRIR/BRIR. ratio between HRIR/BRIR energy before begin sample and after begin sample is = BeginEnergyThld. Remove zero at the beginning of the HRIR */
    float endEnergyThreshold;                              /* use to find end of HRIR. ratio between HRIR energy after end sample and before end sample is = EndEnergyThld. Remove zero at the end of the HRIR */
    float directEnergyThreshold;                           /* use to find the length direct and early part of HRIR/BRIR. ratio between HRIR/BRIR energy of diffuse part and complete HRIR/BRIR energy = BeginEnergyThld. Energy left in diffuse part */
    float diffuseEnergyThreshold;                          /* use to find the length diffuse part of HRIR/BRIR. Energy removed at the end of the diffuse part = DiffuseEnergyThld of total energy of whole diffuse part */
    float diffuseCutOffFreqThreshold;                      /* thresold to determine the cut off frequency for each slice of the diffuse IR*/
    float directCutOffFreqThreshold;                       /* thresold to determine the cut off frequency for each slice of the Direct of IR*/

    float beginEnergyThreshold;                            /* use to find beginning of HRIR/BRIR (tb). ratio in dB between HRIR/BRIR energy before begin sample (tb) and max of all HRIR/BRIR. Reduce complexity by Removing zero or low energy samples at the beginning of the HRIR */
    float endEnergyThreshold;                              /* use to find end of HRIR only (te). ratio inDb between HRIR energy after te sample and energy of the whole hrir. Remove zero or low energy samples at the end of the HRIR */
    float directEnergyThreshold;                           /* use to find the time limit between direct HRIR/BRIR part and diffuse part (tm). It is a ratio in dB between diffuse part and complete HRIR/BRIR energies. The more the value is near zero the smallest is tm, complexity decrease. */
    float diffuseEnergyThreshold;                          /* use to find the time end limit of the diffuse part (te).  diffuse part. It is a ratio in dB between diffuse part after te and complete diffuse HRIR/BRIR energies. The more the value is near zero the smallest is te, complexity decrease. */
    float diffuseCutOffFreqThreshold;                      /* threshold in dB to determine the cut off (fcdiff) frequency for each slice of the diffuse IR. ratio in dB between the energy after fcdiff and the total energy. The more the value is near zero the smallest is fcdiff, complexity decrease */
    float directCutOffFreqThreshold;                       /* threshold in dB to determine the cut off (fcdirect) frequency for each slice of the direct IR. Do not applied to first slice. ratio in dB between the energy after fcdirect and the total energy. The more the value is near zero the smallest is fcdirect, complexity decrease */
} ConfigReader, *ConfigReaderHandle;

typedef enum
+22 −20
Original line number Diff line number Diff line
@@ -82,6 +82,8 @@
#define NUM_SAMPLES_PER_LINES_REVERB        9
#define DECLARATION_NAME                    "CRendBin"
#define TAB_WITH_SPACE_OR_NOT               "    " /* "\t" */
#define NUM_ITERATIONS_TO_ALLOW_OPTIM_5_MS  5      /* no optimisation if hrir length is lower then 20 ms*/
#define NUM_ITERATIONS_TO_ALLOW_OPTIM_20_MS 1      /* no optimisation if hrir length is lower then 20 ms*/

int32_t sample_rates[3] = { DEFAULT_SAMPLERATE, 32000, 16000 }; /* Hz */ /* 8000 Hz not supported by mdft */

@@ -319,7 +321,7 @@ int main( int argc, char *argv[] )
    char *sofa_file_path_for_reverb = NULL;
#endif
    bool add_define = false;
    int notEndingWithSeparator = 0;
    int notEndingWithFileSeparator = 0;
    char *sofa_name = NULL;

    int i;
@@ -352,7 +354,7 @@ int main( int argc, char *argv[] )
            lib_rend_path = malloc( strlen( argv[i] ) + 1 );
            convert_backslash( argv[i] );
            strcpy( lib_rend_path, argv[i] );
            notEndingWithSeparator = ( ( argv[i][strlen( argv[i] ) - 1] == '\\' ) || ( ( argv[i][strlen( argv[i] ) - 1] == '/' ) ) ) ? 0 : 1;
            notEndingWithFileSeparator = ( ( argv[i][strlen( argv[i] ) - 1] == '\\' ) || ( ( argv[i][strlen( argv[i] ) - 1] == '/' ) ) ) ? 0 : 1;
            i++;
        }
#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES
@@ -501,10 +503,10 @@ int main( int argc, char *argv[] )

    if ( lib_rend_path )
    {
        c_file_path = (char *) malloc( sizeof( char ) * ( strlen( lib_rend_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 + notEndingWithFileSeparator ) );
        if ( c_file_path )
        {
            if ( notEndingWithSeparator )
            if ( notEndingWithFileSeparator )
            {
#ifdef WIN32
                sprintf( c_file_path, "%s\\%s.c", lib_rend_path, ROM_FILE_NAME );
@@ -562,10 +564,10 @@ int main( int argc, char *argv[] )
        }
        fclose( fp );

        h_file_path = (char *) malloc( sizeof( char ) * ( strlen( lib_rend_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 + notEndingWithFileSeparator ) );
        if ( h_file_path )
        {
            if ( notEndingWithSeparator )
            if ( notEndingWithFileSeparator )
            {
#ifdef WIN32
                sprintf( h_file_path, "%s\\%s.h", lib_rend_path, ROM_FILE_NAME );
@@ -576,9 +578,9 @@ int main( int argc, char *argv[] )
            else
            {
#ifdef WIN32
                sprintf( h_file_path, "%s\\%s.h", lib_rend_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_rend_path, ROM_FILE_NAME );
                sprintf( h_file_path, "%s%s.h", lib_rend_path, ROM_FILE_NAME );
#endif
            }
        }
@@ -649,7 +651,7 @@ int main( int argc, char *argv[] )
            free( binary_file_path );
            binary_file_path = NULL;
        }
        binary_file_path = (char *) malloc( sizeof( char ) * ( strlen( binary_path ) + strlen( binary_common_file_name ) + 2 + 1 + notEndingWithSeparator ) );
        binary_file_path = (char *) malloc( sizeof( char ) * ( strlen( binary_path ) + strlen( binary_common_file_name ) + 2 + 1 + notEndingWithFileSeparator ) );

        if ( binary_file_path )
        {
@@ -1659,7 +1661,7 @@ int generate_crend_ivas_tables_from_sofa( const char *file_path, ConfigReader *c
            hrtf_data.latency_s = latency_48k_optim;
        }

        if ( ( hrtf_data.num_iterations[0][0] > 5 ) && ( cfgReader->optimize == 1 ) )
        if ( ( hrtf_data.num_iterations[0][0] > ( frame_len_ms == 5 ? NUM_ITERATIONS_TO_ALLOW_OPTIM_5_MS : NUM_ITERATIONS_TO_ALLOW_OPTIM_20_MS ) ) && ( cfgReader->optimize == 1 ) )
        {
            ivas_crend_binaural_filter_design_compute_filters_params( ivas_hrtf, frame_len, &hrtf_data, &index_start, &index_end, &max_ir_len, cfgReader );
            ivas_crend_binaural_filter_design_set_hrtf_fr( ivas_hrtf, frame_len, &hrtf_data, index_start, index_end, &max_ir_len, cfgReader );
Loading