Commit 2c1f5e5a authored by emerit's avatar emerit
Browse files

add generateCustomBinaryFile and normalized input hrir

parent 353214a9
Loading
Loading
Loading
Loading
Loading
+16 −4
Original line number Diff line number Diff line
@@ -47,8 +47,8 @@ addpath(genpath('../td_object_renderer/modeling_tool/'));
%% Set arguments
writeRomFileOutput = true; %% 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 

writeEachRendererBinaryOutput = true; %% generation of binary split files each containing binary data for individual renderer 
normalizeSofaInputData = false; %% if true SOFA IR are nomalized
%% Set ivas root path
ivas_path = ['..' filesep '..' filesep];

@@ -56,10 +56,12 @@ generateCustomBinaryFile = false;

%% Set input files
if generateCustomBinaryFile
    hrir_file_name = 'HRIR_128_Meth5_IRC_51_Q10_symL_Itrp1_48000.sofa';
    hrir_file_name_init = 'HRIR_128_Meth5_IRC_51_Q10_symL_Itrp1_48000.sofa';
    hrir_file_name = 'HRIR_128_Meth5_IRC_51_Q10_symL_Itrp1_48000_norm.sofa';
    output_bin_name = 'ivas_binaural_51_brir-lc';
else 
    hrir_file_name = 'HRIR_128_Meth5_IRC_53_Q10_symL_Itrp1_48000.sofa';
    hrir_file_name_init = 'HRIR_128_Meth5_IRC_53_Q10_symL_Itrp1_48000.sofa';
    hrir_file_name = 'HRIR_128_Meth5_IRC_53_Q10_symL_Itrp1_48000_norm.sofa';
    output_bin_name = 'ivas_binaural';
end
brir_file_name = 'IIS_BRIR_officialMPEG_Combined.sofa';
@@ -73,9 +75,19 @@ if ~(exist(binary_path, 'dir'))
  mkdir(binary_path);
end

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;
end

%% generate td binauralizer rom  or binary values

dataSpec.dataBase = 'IVAS';
+20 −2
Original line number Diff line number Diff line
@@ -35,6 +35,16 @@ function [outputArg1] = SOFA_save(IR,fs,latency_s, inputSofaTemplatePath,outputS
%   Detailed explanation goes here
outputArg1 = false;
inputAsLatencys = false;
outputFormatIsHOA = 0;
if (size(IR,3) == 4)
    outputFormatIsHOA = 1;
end
if (size(IR,3) == 9)
    outputFormatIsHOA = 1;
end
if (size(IR,3) == 16)
    outputFormatIsHOA = 1;
end

if isfile(inputSofaTemplatePath)
        if isfile(outputSofaPath)
@@ -92,7 +102,11 @@ if isfile(inputSofaTemplatePath)
            varId = netcdf.inqVarID(ncid_in,sofa_data.Variables(indVar).Name);
            [name,xtype,dimids,natts] = netcdf.inqVar(ncid_in,varId);
            netcdf.defVar(ncid, name , xtype, dimids);       
            if (outputFormatIsHOA == 0) 
                data = netcdf.getVar(ncid_in,varId);
            else
                data = zeros(sofa_data.Variables(indVar).Size);
            end
            netcdf.putVar(ncid, varId, data);
            if (strcmp(name, 'Data.IR'))
                netcdf.putVar(ncid, varId, IR);
@@ -120,6 +134,10 @@ if isfile(inputSofaTemplatePath)
       ncwriteatt(outputSofaPath,'/', 'ListenerShortName',ncreadatt(inputSofaTemplatePath,'/','ListenerShortName'));
       ncwriteatt(outputSofaPath,'/', 'DatabaseName',ncreadatt(inputSofaTemplatePath,'/','DatabaseName'));
       ncwriteatt(outputSofaPath,'/','Title' ,ncreadatt(inputSofaTemplatePath,'/','Title'));
       if (outputFormatIsHOA == 0) 
            ncwriteatt(outputSofaPath,'/', 'SOFAConventions', 'AmbisonicsBRIR');
       else
            ncwriteatt(outputSofaPath,'/', 'SOFAConventions', ncreadatt(inputSofaTemplatePath,'/','SOFAConventions'));
       end

end
 No newline at end of file