Commit 5f1d3739 authored by vaclav's avatar vaclav
Browse files

Merge remote-tracking branch 'remotes/origin/main' into 1161-unused-heap-in-omasa

# Conflicts:
#	scripts/binauralRenderer_interface/fastconv/write_fastconv_binary_data_old.m
#	scripts/binauralRenderer_interface/fastconv/write_fastconv_rom_table_flt.m
#	scripts/binauralRenderer_interface/fastconv/write_fastconv_rom_table_fx.m
parents 845cc9c7 28b5a33d
Loading
Loading
Loading
Loading
Loading
+294 −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.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function write_fastconv_binary_data(ivas_path, bin_file, FastConv_SHD_IR_FOA, FastConv_SHD_IR_HOA2, FastConv_SHD_IR_HOA3, FastConv_SD_IR, FastConv_SD_BRIR)
%
% Writes HRIR & BRIR based data for FastConv binaural renderer into a binary file. 
%
% write_fastconv_binary_data(rom_file, FastConv_SHD_IR_FOA, FastConv_SHD_IR_HOA2, FastConv_SHD_IR_HOA3, FastConv_SD_IR, FastConv_SD_BRIR)
%
% filename : string
%   name of the file to be written
%
%
% Output file format:
%   Header [Declaration of the HRTF]
%       Renderer type          (int32_t) : See "RENDERER_TYPE"
%       Decoder output format  (int32_t) : See "BINAURAL_INPUT_AUDIO_CONFIG"
%       Sampling Frequency     (int32_t)
%       Raw data size          (uint32_t)
%
%   HRIRs
%       latency_s           => float32
%       BINAURAL_CONVBANDS  => uint16_t
%       num_channels        => uint16_t
%       BINAURAL_NTAPS      => uint16_t
%       leftHRIRReal        => float32[BINAURAL_CONVBANDS][num_channels][num_taps]
%       leftHRIRImag        => float32[BINAURAL_CONVBANDS][num_channels][num_taps]
%       rightHRIRReal       => float32[BINAURAL_CONVBANDS][num_channels][num_taps]
%       rightHRIRImag       => float32[BINAURAL_CONVBANDS][num_channels][num_taps]
%
%   BRIRs
%       latency_s                           => float32
%       num_channels                        => uint16_t
%       BINAURAL_NTAPS_MAX                  => uint16_t
%       leftBRIRReal                        => float32[BINAURAL_CONVBANDS][num_channels][num_taps]
%       leftBRIRImag                        => float32[BINAURAL_CONVBANDS][num_channels][num_taps]
%       rightBRIRReal                       => float32[BINAURAL_CONVBANDS][num_channels][num_taps]
%       rightBRIRImag                       => float32[BINAURAL_CONVBANDS][num_channels][num_taps]
%       CLDFB_NO_CHANNELS_MAX               => uint16_t
%       fastConvReverberationTimes          => float32[CLDFB_NO_CHANNELS_MAX]
%       fastConvReverberationEneCorrections => float32[CLDFB_NO_CHANNELS_MAX]
%

[f_id, err_msg] = fopen(bin_file, 'wb');

if f_id == -1
    error('Could not open file %s for writing. Error message:\n%s', filename, err_msg);
end

%% File header
% We need to get the chunksize of all IRs to get total size
% SHD HRIRs
% FOA
IR = FastConv_SHD_IR_FOA;
[~, binaural_convbands, num_channels, binaural_ntaps] = size(IR.IR);

header = get_ivas_binary_header(ivas_path,'HRTF_READER_RENDERER_BINAURAL_FASTCONV', ['BINAURAL_INPUT_AUDIO_CONFIG_' IR.order]);
header.chunksize = header.chunksize + 4; % latency_s
header.chunksize = header.chunksize + 2; % BINAURAL_CONVBANDS
header.chunksize = header.chunksize + 2; % num_channels
header.chunksize = header.chunksize + 2; % num_taps
header.chunksize = header.chunksize + 4 * (binaural_convbands * num_channels * binaural_ntaps * 4 ); % HRTF L/R Re/Im

IR.header = header;
FastConv_SHD_IR_FOA = IR;

% HOA2
IR = FastConv_SHD_IR_HOA2;
[~, binaural_convbands, num_channels, binaural_ntaps] = size(IR.IR);

header = get_ivas_binary_header(ivas_path, 'HRTF_READER_RENDERER_BINAURAL_FASTCONV', ['BINAURAL_INPUT_AUDIO_CONFIG_' IR.order]);
header.chunksize = header.chunksize + 4; % latency_s
header.chunksize = header.chunksize + 2; % BINAURAL_CONVBANDS
header.chunksize = header.chunksize + 2; % num_channels
header.chunksize = header.chunksize + 2; % num_taps
header.chunksize = header.chunksize + 4 * (binaural_convbands * num_channels * binaural_ntaps * 4 ); % HRTF L/R Re/Im

IR.header = header;
FastConv_SHD_IR_HOA2 = IR;

% HOA3
IR = FastConv_SHD_IR_HOA3;
[~, binaural_convbands, num_channels, binaural_ntaps] = size(IR.IR);

header = get_ivas_binary_header(ivas_path, 'HRTF_READER_RENDERER_BINAURAL_FASTCONV', ['BINAURAL_INPUT_AUDIO_CONFIG_' IR.order]);
header.chunksize = header.chunksize + 4; % latency_s
header.chunksize = header.chunksize + 2; % BINAURAL_CONVBANDS
header.chunksize = header.chunksize + 2; % num_channels
header.chunksize = header.chunksize + 2; % num_taps
header.chunksize = header.chunksize + 4 * (binaural_convbands * num_channels * binaural_ntaps * 4 ); % HRTF L/R Re/Im

IR.header = header;
FastConv_SHD_IR_HOA3 = IR;

% SD HRIRs
IR = FastConv_SD_IR;
[~, binaural_convbands, num_channels, binaural_ntaps] = size(IR.IR);

header = get_ivas_binary_header(ivas_path, 'HRTF_READER_RENDERER_BINAURAL_FASTCONV', 'BINAURAL_INPUT_AUDIO_CONFIG_COMBINED');
header.chunksize = header.chunksize + 4; % latency_s
header.chunksize = header.chunksize + 2; % BINAURAL_CONVBANDS
header.chunksize = header.chunksize + 2; % num_channels
header.chunksize = header.chunksize + 2; % num_taps
header.chunksize = header.chunksize + 4 * (binaural_convbands * num_channels * binaural_ntaps * 4 ); % HRTF L/R Re/Im

IR.header = header;
FastConv_SD_IR = IR;
    
% SD BRIRs
IR = FastConv_SD_BRIR;
[~, binaural_convbands, num_channels, ~] = size(IR.IR);
cldfb_no_channels_max = IR.rev_param.kAna;

header = get_ivas_binary_header(ivas_path, 'HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM', 'BINAURAL_INPUT_AUDIO_CONFIG_COMBINED');
header.chunksize = header.chunksize + 4; % latency_s
header.chunksize = header.chunksize + 2; % BINAURAL_CONVBANDS
header.chunksize = header.chunksize + 2; % num_channels
header.chunksize = header.chunksize + 2; % num_taps
header.chunksize = header.chunksize + 4 * (binaural_convbands * num_channels * IR.rev_param.NFilter * 4 ); % HRTF L/R Re/Im
header.chunksize = header.chunksize + 2; % CLDFB_NO_CHANNELS_MAX
header.chunksize = header.chunksize + cldfb_no_channels_max * 4; % rt60
header.chunksize = header.chunksize + cldfb_no_channels_max * 4; % nrgLr

IR.header = header;
FastConv_SD_BRIR = IR;

% calculate the size of all chunks
HRTFs = {FastConv_SHD_IR_FOA, FastConv_SHD_IR_HOA2, FastConv_SHD_IR_HOA3, FastConv_SD_IR, FastConv_SD_BRIR};
hrtf_data_size = 0;
total_file_size = 0;
for i = 1:length(HRTFs)
    hrtf_data_size = hrtf_data_size + HRTFs{i}.header.chunksize;
    total_file_size = total_file_size + 4 * 4; % chunk header 4 (u)int32 values
end

total_file_size = total_file_size + 8; % 'IVASHRTF' (char[8])
total_file_size = total_file_size + 4; % file size (int32)
total_file_size = total_file_size + 2; % number of HRTFs in file (int16)
total_file_size = total_file_size + 4; % HRTF size (int32)
total_file_size = total_file_size + hrtf_data_size;      % size of all HRTF data chunks 

fwrite(f_id, 'IVASHRTF', 'char'); % identifier
fwrite(f_id, total_file_size, 'int32'); % file size
fwrite(f_id, length(HRTFs), 'int16'); % number of HRTFs
fwrite(f_id, hrtf_data_size, 'int32'); % max data size (bytes to read after this header)

%% HRIRs

%  SHD HRIRs
SHD_HRIRs = {FastConv_SHD_IR_FOA, FastConv_SHD_IR_HOA2, FastConv_SHD_IR_HOA3};
for i = 1:length(SHD_HRIRs)
    IR = SHD_HRIRs{i};
    [~, binaural_convbands, num_channels, binaural_ntaps] = size(IR.IR);
    
    % write header for this chunk
    fwrite(f_id, IR.header.renderer_type, 'int32');
    fwrite(f_id, IR.header.in_fmt, 'int32');
    fwrite(f_id, IR.header.fs, 'int32');
    fwrite(f_id, IR.header.chunksize, 'uint32');
    
    fwrite(f_id, IR.latency_s, 'float32');
    fwrite(f_id, binaural_convbands, 'uint16');
    fwrite(f_id, num_channels, 'uint16');
    fwrite(f_id, binaural_ntaps, 'uint16');

    for band = 1:binaural_convbands
        for ch = 1:num_channels
            fwrite(f_id, real(squeeze(IR.IR(1, band, ch, :))), 'float32');
        end
    end
    for band = 1:binaural_convbands
        for ch = 1:num_channels
            fwrite(f_id, imag(squeeze(IR.IR(1, band, ch, :))), 'float32');
        end
    end
    for band = 1:binaural_convbands
        for ch = 1:num_channels
            fwrite(f_id, real(squeeze(IR.IR(2, band, ch, :))), 'float32');
        end
    end
    for band = 1:binaural_convbands
        for ch = 1:num_channels
            fwrite(f_id, imag(squeeze(IR.IR(2, band, ch, :))), 'float32');
        end
    end
end

%   SD HRIRs
IR = FastConv_SD_IR;
[~, binaural_convbands, num_channels, binaural_ntaps] = size(IR.IR);

% write header for this chunk
fwrite(f_id, IR.header.renderer_type, 'int32');
fwrite(f_id, IR.header.in_fmt, 'int32');
fwrite(f_id, IR.header.fs, 'int32');
fwrite(f_id, IR.header.chunksize, 'uint32');
    
fwrite(f_id, IR.latency_s, 'float32');
fwrite(f_id, binaural_convbands, 'uint16');
fwrite(f_id, num_channels, 'uint16');
fwrite(f_id, binaural_ntaps, 'uint16');
for band = 1:binaural_convbands
    for ch = 1:num_channels
        fwrite(f_id, real(squeeze(IR.IR(1, band, ch, :))), 'float32');
    end
end
for band = 1:binaural_convbands
    for ch = 1:num_channels
        fwrite(f_id, imag(squeeze(IR.IR(1, band, ch, :))), 'float32');
    end
end
for band = 1:binaural_convbands
    for ch = 1:num_channels
        fwrite(f_id, real(squeeze(IR.IR(2, band, ch, :))), 'float32');
    end
end
for band = 1:binaural_convbands
    for ch = 1:num_channels
        fwrite(f_id, imag(squeeze(IR.IR(2, band, ch, :))), 'float32');
    end
end


%   SD BRIRs
IR = FastConv_SD_BRIR;
[~, binaural_convbands, num_channels, ~] = size(IR.IR);
cldfb_no_channels_max = IR.rev_param.kAna;

% write header for this chunk
fwrite(f_id, IR.header.renderer_type, 'int32');
fwrite(f_id, IR.header.in_fmt, 'int32');
fwrite(f_id, IR.header.fs, 'int32');
fwrite(f_id, IR.header.chunksize, 'uint32');
    
fwrite(f_id, IR.rev_param.latency_s, 'float32');
fwrite(f_id, binaural_convbands, 'uint16');
fwrite(f_id, num_channels, 'uint16');
fwrite(f_id, IR.rev_param.NFilter, 'uint16');
for band = 1:binaural_convbands
    for ch = 1:num_channels
        fwrite(f_id, real(squeeze(IR.IR(1, band, ch, 1:IR.rev_param.NFilter))), 'float32' );
    end
end
for band = 1:binaural_convbands
    for ch = 1:num_channels
        fwrite(f_id, imag(squeeze(IR.IR(1, band, ch, 1:IR.rev_param.NFilter))), 'float32' );
    end
end
for band = 1:binaural_convbands
    for ch = 1:num_channels
        fwrite(f_id, real(squeeze(IR.IR(2, band, ch, 1:IR.rev_param.NFilter))), 'float32' );
    end
end
for band = 1:binaural_convbands
    for ch = 1:num_channels
        fwrite(f_id, imag(squeeze(IR.IR(2, band, ch, 1:IR.rev_param.NFilter))), 'float32' );
    end
end

fwrite(f_id, cldfb_no_channels_max, 'uint16');
fwrite(f_id, IR.rev_param.rt60, 'float32');
fwrite(f_id, IR.rev_param.nrgLr, 'float32');

fclose(f_id);

end
 No newline at end of file
+100 −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.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function write_fastconv_rom_table_flt(output_file, FastConv_SHD_IR_FOA, FastConv_SHD_IR_HOA2, FastConv_SHD_IR_HOA3, FastConv_SD_IR, FastConv_SD_BRIR)
    %% Open file and write header
    if ismac
        username = getenv('USER');
    else
        username = getenv('username');
    end
    fid = fopen(output_file, 'at');
    fprintf(fid, '#ifdef DEBUGGING\n');
    fprintf(fid, '/* Generated on %s with Matlab version %s by %s on %s */\n', datetime("today"), version, username, computer);
    fprintf(fid, '#endif\n\n\n');
    
    %% HRIRs (SHD)
    % HOA3
    fprintf(fid, ['const float FASTCONV_' FastConv_SHD_IR_HOA3.order '_latency_s = %s;\n'], flt2hex(FastConv_SHD_IR_HOA3.latency_s));
    writeData3L(fid, ['const float leftHRIRReal_' FastConv_SHD_IR_HOA3.order '[BINAURAL_CONVBANDS][' FastConv_SHD_IR_HOA3.order '_CHANNELS][BINAURAL_NTAPS_SBA]'],'%a', real(squeeze(FastConv_SHD_IR_HOA3.IR(1,:,:,:))));
    writeData3L(fid, ['const float leftHRIRImag_' FastConv_SHD_IR_HOA3.order '[BINAURAL_CONVBANDS][' FastConv_SHD_IR_HOA3.order '_CHANNELS][BINAURAL_NTAPS_SBA]'], '%a',imag(squeeze(FastConv_SHD_IR_HOA3.IR(1,:,:,:))));
    writeData3L(fid, ['const float rightHRIRReal_' FastConv_SHD_IR_HOA3.order '[BINAURAL_CONVBANDS][' FastConv_SHD_IR_HOA3.order '_CHANNELS][BINAURAL_NTAPS_SBA]'],'%a', real(squeeze(FastConv_SHD_IR_HOA3.IR(2,:,:,:))));
    writeData3L(fid, ['const float rightHRIRImag_' FastConv_SHD_IR_HOA3.order '[BINAURAL_CONVBANDS][' FastConv_SHD_IR_HOA3.order '_CHANNELS][BINAURAL_NTAPS_SBA]'],'%a', imag(squeeze(FastConv_SHD_IR_HOA3.IR(2,:,:,:))));
    % HOA2
    fprintf(fid, ['const float FASTCONV_' FastConv_SHD_IR_HOA2.order '_latency_s = %s;\n'], flt2hex(FastConv_SHD_IR_HOA2.latency_s));
    writeData3L(fid, ['const float leftHRIRReal_' FastConv_SHD_IR_HOA2.order '[BINAURAL_CONVBANDS][' FastConv_SHD_IR_HOA2.order '_CHANNELS][BINAURAL_NTAPS_SBA]'],'%a', real(squeeze(FastConv_SHD_IR_HOA2.IR(1,:,:,:))));
    writeData3L(fid, ['const float leftHRIRImag_' FastConv_SHD_IR_HOA2.order '[BINAURAL_CONVBANDS][' FastConv_SHD_IR_HOA2.order '_CHANNELS][BINAURAL_NTAPS_SBA]'],'%a', imag(squeeze(FastConv_SHD_IR_HOA2.IR(1,:,:,:))));
    writeData3L(fid, ['const float rightHRIRReal_' FastConv_SHD_IR_HOA2.order '[BINAURAL_CONVBANDS][' FastConv_SHD_IR_HOA2.order '_CHANNELS][BINAURAL_NTAPS_SBA]'],'%a', real(squeeze(FastConv_SHD_IR_HOA2.IR(2,:,:,:))));
    writeData3L(fid, ['const float rightHRIRImag_' FastConv_SHD_IR_HOA2.order '[BINAURAL_CONVBANDS][' FastConv_SHD_IR_HOA2.order '_CHANNELS][BINAURAL_NTAPS_SBA]'],'%a', imag(squeeze(FastConv_SHD_IR_HOA2.IR(2,:,:,:))));
    % FOA
    fprintf(fid, ['const float FASTCONV_' FastConv_SHD_IR_FOA.order '_latency_s = %s;\n'], flt2hex(FastConv_SHD_IR_FOA.latency_s));
    writeData3L(fid, ['const float leftHRIRReal_' FastConv_SHD_IR_FOA.order '[BINAURAL_CONVBANDS][' FastConv_SHD_IR_FOA.order '_CHANNELS][BINAURAL_NTAPS_SBA]'],'%a', real(squeeze(FastConv_SHD_IR_FOA.IR(1,:,:,:))));
    writeData3L(fid, ['const float leftHRIRImag_' FastConv_SHD_IR_FOA.order '[BINAURAL_CONVBANDS][' FastConv_SHD_IR_FOA.order '_CHANNELS][BINAURAL_NTAPS_SBA]'],'%a', imag(squeeze(FastConv_SHD_IR_FOA.IR(1,:,:,:))));
    writeData3L(fid, ['const float rightHRIRReal_' FastConv_SHD_IR_FOA.order '[BINAURAL_CONVBANDS][' FastConv_SHD_IR_FOA.order '_CHANNELS][BINAURAL_NTAPS_SBA]'], '%a',real(squeeze(FastConv_SHD_IR_FOA.IR(2,:,:,:))));
    writeData3L(fid, ['const float rightHRIRImag_' FastConv_SHD_IR_FOA.order '[BINAURAL_CONVBANDS][' FastConv_SHD_IR_FOA.order '_CHANNELS][BINAURAL_NTAPS_SBA]'], '%a',imag(squeeze(FastConv_SHD_IR_FOA.IR(2,:,:,:))));

    %% HRIRs (SD)
    fprintf(fid, 'const float FASTCONV_HRIR_latency_s = %s;\n', flt2hex(FastConv_SD_IR.latency_s));
    writeData3L(fid, 'const float leftHRIRReal[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NTAPS]','%a', real(squeeze(FastConv_SD_IR.IR(1,:,:,:))));
    writeData3L(fid, 'const float leftHRIRImag[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NTAPS]','%a', imag(squeeze(FastConv_SD_IR.IR(1,:,:,:))));
    writeData3L(fid, 'const float rightHRIRReal[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NTAPS]', '%a',real(squeeze(FastConv_SD_IR.IR(2,:,:,:))));
    writeData3L(fid, 'const float rightHRIRImag[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NTAPS]','%a', imag(squeeze(FastConv_SD_IR.IR(2,:,:,:))));
    
    %% BRIRs (SD)
    fprintf(fid, '/* Binaural rendering data set based on BRIRs \n');
    fprintf(fid, ' * Tables derived from Mozart IIS BRIRs.*/\n');
    fprintf(fid, 'const float FASTCONV_BRIR_latency_s = %s;\n', flt2hex(FastConv_SD_BRIR.rev_param.latency_s));
    writeData3L(fid, 'const float leftBRIRReal[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NTAPS_MAX]','%a', real(squeeze(FastConv_SD_BRIR.IR(1,:,:,1:FastConv_SD_BRIR.rev_param.NFilter))));
    writeData3L(fid, 'const float leftBRIRImag[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NTAPS_MAX]', '%a',imag(squeeze(FastConv_SD_BRIR.IR(1,:,:,1:FastConv_SD_BRIR.rev_param.NFilter))));
    writeData3L(fid, 'const float rightBRIRReal[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NTAPS_MAX]', '%a',real(squeeze(FastConv_SD_BRIR.IR(2,:,:,1:FastConv_SD_BRIR.rev_param.NFilter))));
    writeData3L(fid, 'const float rightBRIRImag[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NTAPS_MAX]','%a', imag(squeeze(FastConv_SD_BRIR.IR(2,:,:,1:FastConv_SD_BRIR.rev_param.NFilter))));

    % RT60
    fprintf(fid,'const float fastconvReverberationTimes[CLDFB_NO_CHANNELS_MAX] = \n{');
    fprintf(fid,'\n    ');
    for bandIdx = 1:FastConv_SD_BRIR.rev_param.kAna
        fprintf(fid,'%s,    ', flt2hex(FastConv_SD_BRIR.rev_param.rt60(bandIdx)));
    end
    fprintf(fid,'\n};\n');
    fprintf(fid,'\n\n');

    % energyReverb
    fprintf(fid,'const float fastconvReverberationEneCorrections[CLDFB_NO_CHANNELS_MAX] = \n{');
    fprintf(fid,'\n    ');
    for bandIdx = 1:FastConv_SD_BRIR.rev_param.kAna
        fprintf(fid,'%s,    ', flt2hex(FastConv_SD_BRIR.rev_param.nrgLr(bandIdx)));
    end
    fprintf(fid,'\n};\n');
    fprintf(fid,'\n\n');

    fclose(fid);

end
+119 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading