Commit 1b4918b6 authored by emerit's avatar emerit
Browse files

version generating on windows with matlab 17 text exact rom tables for hrtf

parent b64aa5bb
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
clear -regexp ^((?!writeRomFileOutput|writeBinaryOutput|writeRomFileFx|makeFxFltBEgenerateBinaryFile|generateBinaryFile|generateCustomBinaryFile|writeEachRendererBinaryOutput|rom_file|bin_file|hrir_file|brir_file|ivas_path|binary_path|output_bin_name|param_bin_file|fastconv_bin_file|td_binary_file|binary_name|rom_path).)*$
clear -regexp ^((?!writeRomFileOutput|makeBE|performDiffuseFieldEq|normalize|writeBinaryOutput|writeRomFileFx|makeFxFltBE|generateBinaryFile|generateCustomBinaryFile|writeEachRendererBinaryOutput|fx_rom_file|rom_file|bin_file|hrir_file|brir_file|ivas_path|binary_path|output_bin_name|param_bin_file|fastconv_bin_file|td_binary_file|binary_name|rom_path).)*$
+19 −15
Original line number Diff line number Diff line
@@ -46,6 +46,9 @@ end
if ~exist("writeRomFileOutput",'var')
    writeRomFileOutput = true;
end
if ~exist("normalize",'var')
    normalize = true;
end
if ~exist("writeRomFileFx",'var')
    writeRomFileFx = false;
end
@@ -61,6 +64,9 @@ end
if ~exist("rom_file",'var')
    rom_file = fullfile('.', 'ivas_rom_binauralRenderer.c');
end
if ~exist("fx_rom_file",'var')
    fx_rom_file = fullfile('.', 'ivas_rom_binauralRenderer_fx.c');
end
if ~exist("bin_file",'var')
    bin_file = fullfile('.', 'fastconv_rom.bin');
end
@@ -79,30 +85,30 @@ end
%% Generate C-code tables for RENDERER_BINAURAL_FASTCONV (SHD)
if generateCustomBinaryFile
    disp('Processing HRIRs (FOA) for FastConv renderer...');
    FastConv_SHD_IR_FOA_float = SHD_2_ROM(hrir_file, 1, -1, 5);
    FastConv_SHD_IR_FOA_float = SHD_2_ROM(hrir_file, 1, -1, 5, normalize);
    
    disp('Processing HRIRs (HOA2) for FastConv renderer...');
    FastConv_SHD_IR_HOA2_float = SHD_2_ROM(hrir_file, 2, -1, 5);
    FastConv_SHD_IR_HOA2_float = SHD_2_ROM(hrir_file, 2, -1, 5, normalize);
    
    disp('Processing HRIRs (HOA3) for FastConv renderer...');
    FastConv_SHD_IR_HOA3_float = SHD_2_ROM(hrir_file, 3, -1, 5);
    FastConv_SHD_IR_HOA3_float = SHD_2_ROM(hrir_file, 3, -1, 5, normalize);

    %% Generate C-code tables for RENDERER_BINAURAL_FASTCONV (SD)
    disp('Processing HRIRs (SD) for FastConv renderer...');
    FastConv_SD_IR_float = SD_2_ROM(hrir_file, 5);    
    FastConv_SD_IR_float = SD_2_ROM(hrir_file, 5, normalize);    
else
    disp('Processing HRIRs (FOA) for FastConv renderer...');
    FastConv_SHD_IR_FOA_float = SHD_2_ROM(hrir_file, 1, 128);
    FastConv_SHD_IR_FOA_float = SHD_2_ROM(hrir_file, 1, 128,3, normalize);
    
    disp('Processing HRIRs (HOA2) for FastConv renderer...');
    FastConv_SHD_IR_HOA2_float = SHD_2_ROM(hrir_file, 2, 128);
    FastConv_SHD_IR_HOA2_float = SHD_2_ROM(hrir_file, 2, 128, 3,normalize);
    
    disp('Processing HRIRs (HOA3) for FastConv renderer...');
    FastConv_SHD_IR_HOA3_float = SHD_2_ROM(hrir_file, 3, 128);
    FastConv_SHD_IR_HOA3_float = SHD_2_ROM(hrir_file, 3, 128,3, normalize);

    %% Generate C-code tables for RENDERER_BINAURAL_FASTCONV (SD)
    disp('Processing HRIRs (SD) for FastConv renderer...');
    FastConv_SD_IR_float = SD_2_ROM(hrir_file);
    FastConv_SD_IR_float = SD_2_ROM(hrir_file,3,normalize);
end


@@ -111,6 +117,7 @@ disp('Processing BRIRs (SD) for FastConv renderer...');
FastConv_SD_BRIR_float = generate_BRIR_CLDFB_FASTCONV(brir_file);
if generateCustomBinaryFile == false
    FastConv_SD_BRIR_float.rev_param.rt60 = [0.420013, 0.206696, 0.203613, 0.207458, 0.217255, 0.236176, 0.230164, 0.228912, 0.228210, 0.219788, 0.225983, 0.220184, 0.222015, 0.223114, 0.223572, 0.227478, 0.227905, 0.223450, 0.219910, 0.218597, 0.220428, 0.218262, 0.213257, 0.210327, 0.207428, 0.198761, 0.196259, 0.194916, 0.190338, 0.184509, 0.180328, 0.176178, 0.176514, 0.177582, 0.183594, 0.195923, 0.203247, 0.208405, 0.214661, 0.220001, 0.222931, 0.230408, 0.233917, 0.233643, 0.236328, 0.237427, 0.241638, 0.241119, 0.238861, 0.242371, 0.247253, 0.245941, 0.248566, 0.245392, 0.243958, 0.244110, 0.239014, 0.241791, 0.234833, 0.253052];
    FastConv_SD_BRIR_float.rev_param.nrgLr = [0.000579833984, 0.000213623047, 0.000244140625, 0.000213623047, 0.000244140625, 0.00152587891, 0.00115966797, 0.00109863281, 0.0012512207, 0.00131225586, 0.00231933594, 0.00244140625, 0.00268554688, 0.00271606445, 0.00262451172, 0.00256347656, 0.00274658203, 0.00271606445, 0.00259399414, 0.00253295898, 0.00341796875, 0.00177001953, 0.0009765625, 0.000701904296, 0.000610351563, 0.000549316406, 0.000518798828, 0.000579833984, 0.000610351563, 0.000549316406, 0.0012512207, 0.00122070313, 0.000946044921, 0.000610351563, 0.000274658203, 0.0000915527343, 0.0000610351563, 0.0000610351563, 0.0000305175781, 0.0000305175781, 0.0000305175781, 0.0000305175781, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
end

%% compute scaling factor and set floating point precision to int16_t
@@ -134,16 +141,13 @@ FastConv_SD_BRIR = FastConv_SD_BRIR_float;
[FastConv_SD_BRIR.rev_param.nrgLr, FastConv_SD_BRIR.rev_param.factorQ_nrgLr] = make_be_with_fx(FastConv_SD_BRIR_float.rev_param.nrgLr,15);

if writeRomFileOutput
    if writeRomFileFx
        write_fastconv_rom_table_fx(rom_file, FastConv_SHD_IR_FOA, FastConv_SHD_IR_HOA2, FastConv_SHD_IR_HOA3, FastConv_SD_IR, FastConv_SD_BRIR);
    else
    write_fastconv_rom_table_fx(fx_rom_file, FastConv_SHD_IR_FOA, FastConv_SHD_IR_HOA2, FastConv_SHD_IR_HOA3, FastConv_SD_IR, FastConv_SD_BRIR);
    if makeFxFltBE
        write_fastconv_rom_table_flt(rom_file, FastConv_SHD_IR_FOA, FastConv_SHD_IR_HOA2, FastConv_SHD_IR_HOA3, FastConv_SD_IR, FastConv_SD_BRIR);
    else
        write_fastconv_rom_table_flt(rom_file, FastConv_SHD_IR_FOA_float, FastConv_SHD_IR_HOA2_float, FastConv_SHD_IR_HOA3_float, FastConv_SD_IR_float, FastConv_SD_BRIR_float);
    end
end
end

% binary format is always FX
if writeBinaryOutput
+31 −31
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.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
/%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   (C) 2022-2025 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.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%/


%
+34 −4
Original line number Diff line number Diff line
@@ -53,7 +53,9 @@ addpath(genpath('../td_object_renderer/modeling_tool/'));

%% Set arguments
generateCustomBinaryFile = false;
writeRomFileFx = true;
normalize = true; % put a true to normalize input HRTF file. Diffuse field spectrum will be equal to one at 1 khz. Shall not be used with BRIR
makeBE = true; % put at true to generate BE rom table and at false to support more type of sofa file
performDiffuseFieldEq = true; % at true perform diffuse field equalization during param bin taps computation. Should not by used when HRIR are alredy diffuse field equalized
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 
@@ -118,7 +120,7 @@ end
dataSpec.hrfInDir = hrir_file;
dataSpec.hrfOutDir = binary_path;
dataSpec.genRomFile = writeRomFileOutput;
dataSpec.genRomFileFx = writeRomFileFx;
dataSpec.genRomFileFx = true;
dataSpec.genBinaryFile = writeBinaryOutput;
dataSpec.makeFxFltBE = true;
dataSpec.romOutDir = rom_path;
@@ -129,9 +131,9 @@ SOFA_save_to_mat(hrir_file);
SOFA_save_to_mat(brir_file,'Combined');

if generateCustomBinaryFile
    convert_SD2SHD_HRIRs(hrir_path,hrir_file_name,-1);
    convert_SD2SHD_HRIRs(hrir_path,hrir_file_name,-1,normalize);
else
    convert_SD2SHD_HRIRs(hrir_path,hrir_file_name,128);
    convert_SD2SHD_HRIRs(hrir_path,hrir_file_name,128,normalize);
end

command = ['.' filesep() 'generate_crend_ivas_tables'];
@@ -177,6 +179,7 @@ bin_file = fullfile('.',binary_path, fastconv_bin_file );

if writeRomFileOutput == true
    rom_file = fullfile(rom_path, 'ivas_rom_binauralRenderer.c');
    fx_rom_file = fullfile(rom_path, 'ivas_rom_binauralRenderer_fx.c');
    
    copyfile('ivas_license_header.template',rom_file,'f');
    
@@ -194,6 +197,24 @@ if writeRomFileOutput == true
    '#define WMC_TOOL_SKIP');
    
    fclose(fp);

    copyfile('ivas_license_header.template',fx_rom_file,'f');
    
    fp_fx = fopen(fx_rom_file,'at');
    fprintf(fp_fx,"\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n\n%s\n\n%s\n\n%s\n%s\n%s\n\n%s\n%s\n%s\n", ...
    '#include <stdint.h>', ...
    '#include "options.h"', ...
    '#ifdef DEBUGGING', ...
    '#include "debug.h"', ...
    '#endif', ...
    '#include "cnst.h"', ...
    '#include "ivas_cnst.h"', ...
    '#include "wmc_auto.h"', ...
    '/* clang-format off */', ...
    '#define WMC_TOOL_SKIP');
    
    fclose(fp_fx);

end

generate_tables_for_fastconv
@@ -202,6 +223,7 @@ generate_tables_for_fastconv

param_bin_file = ['parambin_' erase(hrir_file_name, '.sofa') '_' erase(brir_file_name, '.sofa') '.bin'];
bin_file = fullfile('.',binary_path, param_bin_file );

generate_tables_for_parametric_binauralizer

if writeRomFileOutput == true
@@ -212,6 +234,14 @@ if writeRomFileOutput == true
    fprintf(fp,"\n%s\n\n%s\n", '#undef WMC_TOOL_SKIP', '/* clang-format on */');
    
    fclose(fp);

    fx_rom_file = fullfile(rom_path, 'ivas_rom_binauralRenderer_fx.c');
    
    fp_fx = fopen(fx_rom_file,'at');
    
    fprintf(fp_fx,"\n%s\n\n%s\n", '#undef WMC_TOOL_SKIP', '/* clang-format on */');
    
    fclose(fp_fx);
end

%% concatenate all previously generated binary files to binary file for IVAS decoder or renderer. One per sample rates
+2 −2
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@
%   the United Nations Convention on Contracts on the International Sales of Goods.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function FastConv_SD_IR = SD_2_ROM(sofa_file, num_cldfb_taps)
function FastConv_SD_IR = SD_2_ROM(sofa_file, num_cldfb_taps, normalize)
% SD_2_ROM( rom_c_file, sofa_file, ambisonics_order, hrir_length )
%
% Derived from SHD_2_ROM.m
@@ -46,7 +46,7 @@ if ~exist('num_cldfb_taps','var')
end
%% load SD HRIRs
H = hrtf_library_loader();
H.readSOFA(char(sofa_file),'',false);
H.readSOFA(char(sofa_file),'',normalize);
ls_struct = get_ls_layout_config('Combined');
IR_SD = H.XYZ_to_IR_SD([deg2rad(ls_struct.azi); deg2rad(ls_struct.ele)]);

Loading