Commit 5f64c1c9 authored by Marek Szczerba's avatar Marek Szczerba
Browse files

Added scripts for computing reverb parameters from spatial impulse response recordings

parent e499d545
Loading
Loading
Loading
Loading
Loading
+742 −0

File added.

Preview size limit exceeded, changes collapsed.

+51 −0
Original line number Diff line number Diff line
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% (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.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function srcNormEnergyWideband = calculateNormalizedSourceEnergy(source)

% Surface integral of sphere around omnidirectional source at refDistance
% results in the surface area of a sphere with r = refDistance. Normalize
% to surface area associated to PCM signal (human ear), to get scaling
% factor.
dirEnergyScale = 4 * pi * source.refDistance^2 ./ (0.05 * 0.04 / 2);


% Include effect of pregain.
srcNormEnergyWideband = dirEnergyScale .* 10^(source.dBPreGain / 10);


+64 −0
Original line number Diff line number Diff line
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% (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.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


function filtered = filterFiles(file_dir, file_filters)
% filter out files from git repo based on specific keywords

files = dir(file_dir);
% filter out only desired files..
filtered = {};
nfiles = 0;
for jj=1:length(files)
    
    fname = files(jj).name;
    res = 1;
    for kk=1:length(file_filters)
        if isempty(strfind(fname, file_filters{kk}))
            res = 0;
        end
    end
    
    if res == 1
        filtered{nfiles+1} = strcat(file_dir, fname);
        nfiles = nfiles+1; 
    end
end

% =========================================================================

+73 −0
Original line number Diff line number Diff line
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% (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.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function rirSet = loadRIRs(files, sim_delay, fs)

nCh = 0;
maxLength = 0;
for fileIdx = 1:length(files)
    [~, fname, ext] = fileparts(files{fileIdx});
    if (strcmpi(ext, '.wav'))
        info = audioinfo(files{fileIdx});
        maxLength = max(maxLength, info.TotalSamples);
        nCh = nCh + info.NumChannels;
    else
        error('Unsupported file format: %s', ext);
    end
end

rirSet = zeros(maxLength, nCh);
chIdx = 1;  % Channel index initialization
for fileIdx = 1:length(files)
    [~, fname, ext] = fileparts(files{fileIdx});
  
    fprintf(1, 'RIR index: %2d -- File %2d / %2d -- %s\n', fileIdx, fileIdx, length(files), [fname ext]);
    [rir, fs_file] = audioread(files{fileIdx});
    
    if (fs ~= fs_file)
      error('Samplerate in wav file differs from configured sample rate.');
    end

    % Remove known delay
    rir = rir(sim_delay + 1:end, :);

    % Extract the channels
    for n = 1:size(rir, 2)
        rirSet(1:length(rir), chIdx) = rir(:, n);
        chIdx = chIdx + 1;
    end
end
 No newline at end of file
+77 −0
Original line number Diff line number Diff line

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% (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.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Contact: Jeroen Koppens (jeroen.koppens@philips.com)
%          Marek Szczerba (marek.szczerba@philips.com)
% 
% function [B, A] = octaveBandFilter(fc, width, fs, [N])
%
% Returns the coefficients of a bandfilter, based on a 2Nth Butterworth
% filter [1].
%
% fc    : Center frequency (Hz)
% width : Filter width (octaves), for example 1/3 = one-third-octave
% fs    : Sampling frequency (Hz)
% N     : Filter order (default: 3)
%
% REFERENCES:
%
% [1] Couvreur, C. (1997?), "Implementation of a one-third-octave filter
%     bank in MATLAB", Applied Acoustics

function [B, A] = octaveBandFilter(fc, width, fs, N)

% Check arguments

if nargin < 3
    error('Too few arguments')
end

% Default order?
% 
if nargin < 4
     N = 3;
 end
 
half_width = width/2;

f1 = fc / (2^half_width);
f2 = fc * (2^half_width);

Wn = 2*[f1 f2]/fs;
[B,A] = butter(N,Wn);
Loading