/*====================================================================================
    3GPP TS26.258 Nov 20, 2025. IVAS Codec Version IVAS-FL-3.0
  ====================================================================================*/

Mixer conv sofa to rom table or binary files converter program
------------------------------

The sofa to rom format or binary files converter is used to generate the c files (*.h,*.c) or binary files 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) or using the following command lines :
   - mkdir build
   - cd build
   - cmake ..
   - cmake --build . (option --config=release)
   - cd ..
   - Test :
      - run py run.py (require matplotlib) -> no error and a figure with impulse response shall appear

Requirements:
------------
   - Python version 3.9.* with pip
   - numpy (pip install numpy)
   - netCDF4 (pip install netCDF4)
   - SofaReader.py file must be in the same folder as the executable generate_crend_ivas_tables

Usage: 
------
generate_crend_ivas_tables [Options]

Mandatory parameters : 
   - Frame size in ms (5 or 20)
   - list of sofa files at least one. For rom files generation it is needed :
      - one with HRIR with directions of IVAS combined speakers configuration or more
      - one with FOA to binaural filters, can be obtain from HRIR using ./matlab_hrir_generation_scripts/convert_SD2SHD_HRIRs.m matlab script
      - one with HOA order 2 to binaural filters, can be obtain from HRIR using ./matlab_hrir_generation_scripts/convert_SD2SHD_HRIRs.m matlab script 
      - one with HOA order 3 to binaural filters, can be obtain from HRIR using ./matlab_hrir_generation_scripts/convert_SD2SHD_HRIRs.m matlab script
      - one with BRIR filters that directions of IVAS combined speakers configuration or more

Options :
   -lib_rend_path             : path where header and c files will be created (if missing rom files not generated).
   -binary_files_path                        : path where binary files will be created (if missing binary files not generated)\n
   -binary_common_file_name                  : common name for binary files that will be created (crend_hrir-53_brir-Fhg for example
   -compute_reverb_rom sofa_file_path        : if present reverb rom tables and binary files are computed using sofa_file_path as input HRIRs
   -brir_optim_config_path config_file_path  : if present brir optimisation process uses parameters stored in config_file_path 
                                                Configuration example files are provided in folder :
                                                   -brir_no_optim.cfg : for exact convolution of the BRIR by IVAS decoder or renderer
                                                   -brir_default_optim.cfg : default values BRIR optimisation used by IVAS decoder or renderer
                                                   -brir_low_complexity_optim.cfg : values for BRIR optimisation reducing IVAS decoder or renderer complexity

For example :

.\\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/HRIR_128_Meth5_IRC_53_Q10_symL_Itrp1_48000_FOA.sofa ./HRIRs_sofa/HRIR_128_Meth5_IRC_53_Q10_symL_Itrp1_48000_HOA2.sofa ./HRIRs_sofa/HRIR_128_Meth5_IRC_53_Q10_symL_Itrp1_48000_HOA3.sofa ./BRIRs_sofa/IIS_BRIR_officialMPEG_Combined.sofa
./generate_crend_ivas_tables -lib_rend_path ../../lib_rend 5 ./HRIRs_sofa/HRIR_128_Meth5_IRC_53_Q10_symL_Itrp1_48000.sofa ./HRIRs_sofa/HRIR_128_Meth5_IRC_53_Q10_symL_Itrp1_48000_FOA.sofa ./HRIRs_sofa/HRIR_128_Meth5_IRC_53_Q10_symL_Itrp1_48000_HAO2.sofa ./HRIRs_sofa/HRIR_128_Meth5_IRC_53_Q10_symL_Itrp1_48000_HOA3.sofa ./BRIRs_sofa/IIS_BRIR_officialMPEG_Combined.sofa
