Skip to content
Snippets Groups Projects

SNR in observation filter calculation feature and repository version update

Merged Imported Achilles Kappis requested to merge ObsFiltUpdate into main
5 files
+ 100
11
Compare changes
  • Side-by-side
  • Inline
Files
5
@@ -3,7 +3,7 @@
% Author: Achilles Kappis
% e-mail: axilleaz@protonmail.com
%
% Date: 15/08/2024 (DD/MM/YYYY)
% Date: 01/09/2024 (DD/MM/YYYY)
%
% Copyright: MIT
% --------------------------------------------------
@@ -36,6 +36,17 @@
% regularisation factor for all microphones.
% [Default: 0]
%
% snrVal [numeric] (Optional): This is the Root-Mean-Square (RMS)
% Signal-to-Noise Ratio (SNR) in the
% monitoring microphone signals. This must
% be either a scalar indicating the common
% SNR value of the microphone signals, or a
% vector of dimensions Kx1, containing the SNR
% values of each microphone. The values must
% be real or Inf for the noiseless case. See
% the Notes below for references on how this
% value is calculated. [Default: Inf]
%
% --------------------------------------------------
% Output
%
@@ -59,12 +70,16 @@
% --------------------------------------------------
% Notes
%
% - The SNR at the monitoring microphones calculation is based on the
% paper: "Combining the remote microphone technique with head-tracking
% for local active sound control" by W. Jung, S. J. Elliott and J. Cheer.
%
% --------------------------------------------------
function [oOpt, Sme, Smm, condNum] = obsFilt(Pe, Pm, srcCsd, regFacs)
function [oOpt, Sme, Smm, condNum] = obsFilt(Pe, Pm, srcCsd, regFacs, snrVal)
% ====================================================
% Check for number of arguments
% ====================================================
narginchk(2, 4);
narginchk(2, 5);
nargoutchk(0, 4);
% ====================================================
@@ -92,6 +107,21 @@ function [oOpt, Sme, Smm, condNum] = obsFilt(Pe, Pm, srcCsd, regFacs)
regFacs = 0;
end
if nargin > 4 && ~isempty(snrVal)
validateattributes(snrVal, "numeric", {'vector', 'real', 'nonnan', 'nonempty'}, mfilename, "Normalised Root-Mean-Square Singal-to-Noise Ratio of the monitoring microphones", 5);
% Make sure snrVal has correct dimensions
if ~isscalar(snrVal) && numel(snrVal) ~= size(Pm, 1)
error("SNR must be either a scalar or its length must match the number of monitoring microphones.");
end
if sum(snrVal == -Inf) > 0
error("SNR value cannot be equal to -Inf");
end
else
snrVal = Inf;
end
% ====================================================
% Calculate optimal filters
@@ -102,14 +132,24 @@ function [oOpt, Sme, Smm, condNum] = obsFilt(Pe, Pm, srcCsd, regFacs)
Sme = Pe * tmpVal; % Virtual-Monitor mics cross-spectra
Smm = Pm * tmpVal; % Monitor-Monitor mics cross-spectra
% Regularisation matrix
if isscalar(regFacs)
regMat = eye(size(Smm)) .* regFacs; % Regularisation matrix
regMat = eye(size(Smm)) .* regFacs;
else
regMat = diag(regFacs);
end
% Signal-to-Noise Ratio at the monitoring microphones
if ~isinf(snrVal)
snrVal = 10^(-snrVal/10); % Convert deciBel to linear
snrMtx = (snrVal.^2) .* norm(Smm, 'fro')/(size(Pm, 1)^2); % Calculate the appropriate SNR amplitude values
else
snrMtx = 1;
end
snrMtx = snrMtx .* eye(size(Pm, 1));
% Calcualte observation filters
invQty = Smm + regMat;
invQty = Smm + snrMtx + regMat;
oOpt = Sme/invQty;
% Condition number of auto-correlation (power spectrum) matrix
Loading