Commit f8299033 authored by emerit's avatar emerit
Browse files

add missing file for prevoius commit

parent f27dcb64
Loading
Loading
Loading
Loading
+66 −264

File changed.

Preview size limit exceeded, changes collapsed.

+425 −1213

File changed.

Preview size limit exceeded, changes collapsed.

+30 −89
Original line number Diff line number Diff line
@@ -53,31 +53,19 @@ addpath(genpath('../td_object_renderer/modeling_tool/'));

%% Set arguments
generateCustomBinaryFile = false;
generateBinaryFile_fx = true;
generate_BE = false;
writeRomFileOutput = true & ~generateCustomBinaryFile; %% generation of rom files if true
writeBinaryOutput = true; %% generation of binary files if true. Always true for TD renderer
writeEachRendererBinaryOutput = true; %% generation of binary split files each containing binary data for individual renderer 
normalizeSofaInputData = false; %% if true SOFA IR are nomalized
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
    hrir_file_name = 'HRIR_128_Meth5_IRC_51_Q10_symL_Itrp1_48000.sofa';
    % hrir_file_name = 'FABIAN_HRIR_measured_HATO_0.sofa';
    % hrir_file_name = 'ari-dtf_nh2.sofa'; % fail for TD renderer
    % hrir_file_name = 'BiLi-IRC_1101_C_HRIR_96000.sofa'; % fail for TD renderer
    % hrir_file_name = 'cipic-subject_003.sofa'; % fail for TD renderer
    % hrir_file_name = 'Listen-IRC_1002_C_44100.sofa'; % fail for TD renderer
    % hrir_file_name = 'mit_kemar_normal_pinna.sofa'; % fail for TD renderer
    %hrir_file_name = 'RIEC_hrir_subject_001.sofa'; % fail for TD renderer
    hrir_file_name_init = hrir_file_name;
    output_bin_name = 'ivas_binaural_custom';
    brir_file_name = 'bbcrdlr_all_speakers.sofa';
    brir_file_name = 'IIS_BRIR_officialMPEG_Combined.sofa';
else 
    hrir_file_name = 'HRIR_128_Meth5_IRC_53_Q10_symL_Itrp1_48000.sofa';
    hrir_file_name_init = hrir_file_name;
    output_bin_name = 'ivas_binaural';
    brir_file_name = 'IIS_BRIR_officialMPEG_Combined.sofa';
end
@@ -85,25 +73,18 @@ hrir_path = fullfile ('.','HRIRs_sofa');
brir_path = fullfile ('.','BRIRs_sofa');
%% Set output files
rom_path = [ivas_path 'lib_rend'];
binary_path = fullfile ('.','binaural_renderers_hrtf_data');
binary_name = [erase(hrir_file_name,'.sofa') '+' erase(brir_file_name, '.sofa') ];
if ~(exist(binary_path, 'dir'))
  mkdir(binary_path);
end
output_binary_path = fullfile ('.','binaural_renderers_hrtf_data');

hrir_file_init = fullfile( hrir_path, hrir_file_name_init);
hrir_file = fullfile( hrir_path, hrir_file_name);
brir_file = fullfile( brir_path, brir_file_name);

%% normalize input HRTF

if (normalizeSofaInputData)
    SOFA_normalize(hrir_file_init,hrir_file);
else
    hrir_file_name = hrir_file_name_init;
    hrir_file = hrir_file_init;
binary_path = fullfile (output_binary_path,'temp');
binary_name = [erase(hrir_file_name,'.sofa') '+' erase(brir_file_name, '.sofa') ];
if ~(exist(binary_path, 'dir'))
  mkdir(binary_path);
end


%% generate td binauralizer rom  or binary values

dataSpec.dataBase = 'IVAS';
@@ -113,16 +94,14 @@ else
    dataSpec.subjId = 'default';
end
% specify HR filter directory
dataSpec.hrfInDir = hrir_path;
dataSpec.hrfInDir = hrir_file;
dataSpec.hrfOutDir = binary_path;
dataSpec.genRomFile = writeRomFileOutput;
dataSpec.fx_binary = generateBinaryFile_fx & writeBinaryOutput;
dataSpec.float_binary = writeBinaryOutput;
dataSpec.be = generate_BE;
dataSpec.genBinaryFile = writeBinaryOutput;
dataSpec.makeFxFltBE = true;
dataSpec.romOutDir = rom_path;
Mod_Hrf_Itd_Main(dataSpec);


%% generate crend rom  or binary values
SOFA_save_to_mat(hrir_file);
SOFA_save_to_mat(brir_file,'Combined');
@@ -190,13 +169,7 @@ if writeRomFileOutput == true
    '#include "ivas_cnst.h"', ...
    '#include "wmc_auto.h"', ...
    '/* clang-format off */', ...
    '#define WMC_TOOL_SKIP', ...
    '/*-------------------------------------------------------------------------', ...
    ' * Binaural rendering related ROM tables', ...
    ' *------------------------------------------------------------------------*/', ...
    '/* Binaural rendering data set based on HRIRs */', ...
    '/* Tables generated by the script at "scripts/binauralRenderer_interface/fastconv/generate_tables_for_fastconv.m */', ...
    '/* Can be replaced by your own generated HRIR tables */');
    '#define WMC_TOOL_SKIP');
    
    fclose(fp);
end
@@ -218,13 +191,14 @@ if writeRomFileOutput == true
    
    fclose(fp);
end

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

if writeBinaryOutput == true
    td_binary_file = ['td_' erase(hrir_file_name,'.sofa') '_model_v003'];
        command = ['.' filesep() 'Table_Format_Converter' filesep() 'tables_format_converter'];
        command = [command ...
        ' -output_file_path ' binary_path ...
                    ' -output_file_path ' output_binary_path ...
                    ' -output_file_name ' output_bin_name ...
                    ' -input_mixerconv_hrir_file_path ' binary_path ...
                    ' -input_mixerconv_hrir_file_name ' binary_name ...
@@ -245,39 +219,6 @@ if writeBinaryOutput == true
            error(cmdout)
            return
        end
    
    if generateBinaryFile_fx
        td_binary_file_fx = ['td_' erase(hrir_file_name,'.sofa') '_model_v003_fx'];
        binary_name_fx = [binary_name  '_fx'];
        fastconv_bin_file_fx = [erase(fastconv_bin_file,'.bin') '_fx.bin'];
        param_bin_file_fx = [erase(param_bin_file,'.bin') '_fx.bin'];
        output_bin_name_fx = [output_bin_name  '_fx'];
        command = ['.' filesep() 'Table_Format_Converter' filesep() 'tables_format_converter'];
        command = [command ...
            ' -output_file_path ' binary_path ...
            ' -output_file_name ' output_bin_name_fx ...
            ' -input_mixerconv_hrir_file_path ' binary_path ...
            ' -input_mixerconv_hrir_file_name ' binary_name_fx ...
            ' -input_mixerconv_brir_file_path ' binary_path ...
            ' -input_mixerconv_brir_file_name ' binary_name_fx ...
            ' -input_reverb_file_path ' binary_path ...
            ' -input_reverb_file_name ' binary_name_fx ...
            ' -input_td_file_path ' fullfile(binary_path, 'IVAS_default') ...
            ' -input_td_file_name ' td_binary_file_fx ...
            ' -input_param_file_path ' binary_path ...
            ' -input_param_file_name ' param_bin_file_fx ...
            ' -input_fastconv_file_path ' binary_path ...
            ' -input_fastconv_file_name ' fastconv_bin_file_fx ...
            ];
        
        [status, cmdout] = system(command);
        if status ~= 0
            error(cmdout)
            return
        end
    end


end

%% Foa all previously generated binary files, convert to binary files for IVAS decoder or renderer. One per sample rates and per renderers
@@ -303,7 +244,7 @@ if writeBinaryOutput == true && writeEachRendererBinaryOutput == true
        pos = strfind(commandRendererList{indList},"_");
        pos(2) = strfind(commandRendererList{indList},"_file_name");
        output_bin_name_list = [output_bin_name commandRendererList{indList}(pos(1):pos(2)-1) ];
        cmdl = [command ' -output_file_path ' binary_path ' -output_file_name ' output_bin_name_list];
        cmdl = [command ' -output_file_path ' output_binary_path ' -output_file_name ' output_bin_name_list];
            cmdl2 = [cmdl ...
                         commandRendererList{indList - 2} ...
                         commandRendererList{indList - 1} ...