Commit 3e31178d authored by emerit's avatar emerit
Browse files

add new script for BE convolution

parent 692ecd29
Loading
Loading
Loading
Loading
+134 −0
Original line number Diff line number Diff line
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%   (C) 2022-2024 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.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%
% Generate tables from given HRIRs and BRIRs for IVAS binaural renderers
%
clear all;
close all;
clc;

if isfolder(['binaural_renderers_hrtf_data' filesep() 'IVAS_default'])
    rmdir(['binaural_renderers_hrtf_data' filesep() 'IVAS_default'],'s');
end
if isfolder(['binaural_renderers_hrtf_data' filesep() 'temp'])
    rmdir(['binaural_renderers_hrtf_data' filesep() 'temp'],'s');
end

%% Add path to routines needed scripts
addpath('./matlab_hrir_generation_scripts/');
addpath('./param_bin/');
addpath('./fastconv/');
addpath(genpath('../td_object_renderer/modeling_tool/'));

%% Set arguments
generateCustomBinaryFile = true;
writeRomFileOutput = true & ~generateCustomBinaryFile; %% generation of rom files if true
writeBinaryOutput = true; %% generation of binary files if true. Always true for TD renderer
writeEachRendererBinaryOutput = false; %% generation of binary split files each containing binary data for individual renderer 
%% Set ivas root path
ivas_path = ['..' filesep '..' filesep];

%% Set input files
if generateCustomBinaryFile
    output_bin_name = 'ivas_binaural_auditorium2';
    brir_file_name = 'BRIR_Auditorium_S2_R1_CICP19.sofa';
else 
    output_bin_name = 'ivas_binaural';
    brir_file_name = 'IIS_BRIR_officialMPEG_Combined.sofa';
end
brir_path = fullfile ('.','BRIRs_sofa');
%% Set output files
rom_path = [ivas_path 'lib_rend'];
output_binary_path = fullfile ('.','binaural_renderers_hrtf_data');

brir_file = fullfile( brir_path, brir_file_name);

binary_path = fullfile (output_binary_path,'temp');
binary_name = [erase(brir_file_name, '.sofa') ];
if ~(exist(binary_path, 'dir'))
  mkdir(binary_path);
end

%% generate crend rom  or binary values
SOFA_save_to_mat(brir_file,'Combined');

command = ['.' filesep() 'generate_crend_ivas_tables'];

if writeRomFileOutput == true
    command = [command ' -lib_rend_path ' rom_path];
end
if writeBinaryOutput == true
    command = [command ...
                    ' -binary_files_path ' binary_path ...
                    ' -binary_common_file_name ' binary_name ...
                ];
end

if generateCustomBinaryFile
    command = [command ...
                    ' -brir_optim_config_path' ...
                    ' brir_no_optim.cfg ' ...
                    ];
end                     
command = [command ...
                    ' 5 ' ...
                    erase(brir_file,'.sofa') '.mat ' ];

disp(command);

[status, cmdout] = system(command);
if status ~= 0
    error(cmdout)
    return
end


%% concatenate all previously generated binary files to binary file for IVAS decoder or renderer. One per sample rates

if writeBinaryOutput == true
        command = ['.' filesep() 'Table_Format_Converter' filesep() 'tables_format_converter'];
        command = [command ...
                    ' -output_file_path ' output_binary_path ...
                    ' -output_file_name ' output_bin_name ...
                    ' -input_mixerconv_brir_file_path ' binary_path ...
                    ' -input_mixerconv_brir_file_name ' binary_name ...
                    ];
    
        disp(command);
        [status, cmdout] = system(command);
        if status ~= 0
            error(cmdout)
            return
        end
end
 No newline at end of file
+0 −1
Original line number Diff line number Diff line
@@ -1280,7 +1280,6 @@ int generate_crend_ivas_tables_from_sofa( const char *file_path, ConfigReader *c
            latency_48k_optim = hrtf_data.latency_s;
        }


        int16_t factorQ[3];
        make_fx_be( &hrtf_data, lscfg, sample_rates[indSR], frame_len, factorQ );
        if ( lib_rend_path != NULL )